Skip to main content

coze loop sdk

Project description

CozeLoop Python SDK

English | 简体中文

Overview

The CozeLoop SDK is a Python client for interacting with CozeLoop platform. Key features:

  • Report trace
  • Get and format prompt
  • Execute Prompt as a Service (PTaaS)

Requirements

  • Python 3.8 or higher

Installation

pip install CozeLoop

Usage

Initialize

To get started, visit https://www.coze.cn/open/oauth/apps and create an OAuth app. Then you can get your owner appid, public key and private key.

Set your environment variables:

export COZELOOP_WORKSPACE_ID=your workspace id
export COZELOOP_JWT_OAUTH_CLIENT_ID=your client id
export COZELOOP_JWT_OAUTH_PRIVATE_KEY=your private key
export COZELOOP_JWT_OAUTH_PUBLIC_KEY_ID=your public key id

Report Trace

def main():
    span = cozeloop.start_span("root", "custom")

    span.set_input("Hello") 
    span.set_output("World") 
	
    span.finish()
	
    cozeloop.close()

Get Prompt

def main():
    prompt = cozeloop.get_prompt(prompt_key="your_prompt_key")
    messages = cozeloop.prompt_format(
        prompt,
        {"var1": "your content"},
    )

You can see more examples here.

Contribution

Please check Contributing for more details.

Security

If you discover a potential security issue in this project, or think you may have discovered a security issue, we ask that you notify Bytedance Security via our security center or vulnerability reporting email.

Please do not create a public GitHub issue.

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gaotu_cozeloop-0.1.26.tar.gz (64.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gaotu_cozeloop-0.1.26-py3-none-any.whl (91.9 kB view details)

Uploaded Python 3

File details

Details for the file gaotu_cozeloop-0.1.26.tar.gz.

File metadata

  • Download URL: gaotu_cozeloop-0.1.26.tar.gz
  • Upload date:
  • Size: 64.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.12

File hashes

Hashes for gaotu_cozeloop-0.1.26.tar.gz
Algorithm Hash digest
SHA256 2adf0629ad56abbb35ff181ad6ac95e1cd2e289a27c3c22a19cc436b0bd4f6fd
MD5 6dd6f05c8ebdbd755ac248653a08ffc6
BLAKE2b-256 c3456392693776ccce4daf0a9129a139f08f9b0f80c499502798315828ebde76

See more details on using hashes here.

File details

Details for the file gaotu_cozeloop-0.1.26-py3-none-any.whl.

File metadata

File hashes

Hashes for gaotu_cozeloop-0.1.26-py3-none-any.whl
Algorithm Hash digest
SHA256 d459577497e3b6d810d1b6ada403921747c32d7e1ea5d6622bbca4cc0a2ccee1
MD5 3887f1fe5f30bd9dd6de8097dd9714f9
BLAKE2b-256 aa5b0584bdcea92eff1c4ba19be1fac7be0454921ec42a661a177b2e5243b0ad

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page