Skip to content

Commit 2b35ee4

Browse files
committed
init repo
0 parents  commit 2b35ee4

90 files changed

Lines changed: 9574 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# shell
7+
license.sh
8+
9+
# C extensions
10+
*.so
11+
12+
# Unit test / coverage reports
13+
htmlcov/
14+
.tox/
15+
.nox/
16+
.coverage
17+
.coverage.*
18+
.cache
19+
nosetests.xml
20+
coverage.xml
21+
*.cover
22+
.hypothesis/
23+
.pytest_cache/
24+
25+
# Environments
26+
.env
27+
.venv
28+
env/
29+
venv/
30+
ENV/
31+
env.bak/
32+
venv.bak/
33+
34+
/.idea
35+
/.vscode
36+
/output

CHANGLOG.md

Whitespace-only changes.

CONTRIBUTING.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# How to contribute
2+
3+
## Set Up Environment
4+
Make sure you have Python installed (version 3.8 or higher).
5+
6+
## Dependencies Management
7+
We use poetry for dependency management.
8+
Intall dependencies:
9+
```bash
10+
poetry install
11+
```

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 ByteDance and/or its affiliates.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Loop Go SDK
2+
English | [简体中文](README.zh_CN.md)
3+
4+
## Overview
5+
6+
The Loop SDK is a Python client for interacting with [CozeLoop platform](https://loop.coze.cn).
7+
Key features:
8+
- Report trace
9+
- Get and format prompt
10+
11+
## Requirements
12+
- Python 3.8 or higher
13+
14+
## Installation
15+
16+
`pip install CozeLoop`
17+
18+
## Usage
19+
20+
### Initialize
21+
22+
To get started, visit https://www.coze.cn/open/oauth/apps and create an OAuth app.
23+
Then you can get your owner appid, public key and private key.
24+
25+
Set your environment variables:
26+
```bash
27+
export COZELOOP_WORKSPACE_ID=your workspace id
28+
export COZELOOP_JWT_OAUTH_CLIENT_ID=your client id
29+
export COZELOOP_JWT_OAUTH_PRIVATE_KEY=your private key
30+
export COZELOOP_JWT_OAUTH_PUBLIC_KEY_ID=your public key id
31+
```
32+
33+
### Report Trace
34+
35+
```python
36+
def main():
37+
span = cozeloop.start_span("root", "custom")
38+
39+
span.set_input("Hello")
40+
span.set_output("World")
41+
42+
span.finish()
43+
44+
cozeloop.close()
45+
```
46+
47+
### Get Prompt
48+
```python
49+
def main():
50+
prompt = cozeloop.get_prompt(prompt_key="your_prompt_key")
51+
messages = cozeloop.prompt_format(
52+
prompt,
53+
{"var1": "your content"},
54+
)
55+
```
56+
57+
You can see more examples [here](examples).
58+
59+
## Contribution
60+
61+
Please check [Contributing](CONTRIBUTING.md) for more details.
62+
63+
## Security
64+
65+
If you discover a potential security issue in this project, or think you may
66+
have discovered a security issue, we ask that you notify Bytedance Security via our [security center](https://security.bytedance.com/src) or [vulnerability reporting email](sec@bytedance.com).
67+
68+
Please do **not** create a public GitHub issue.
69+
70+
## License
71+
72+
This project is licensed under the [MIT License](LICENSE).

README.zh_CN.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
2+
# Loop Go SDK
3+
[English](README.md) | 简体中文
4+
5+
## 概述
6+
7+
Loop SDK 是一个用于与 [CozeLoop 平台](https://loop.coze.cn) 进行交互的 Python 客户端。
8+
主要功能:
9+
- Trace上报
10+
- Prompt拉取
11+
12+
## 要求
13+
- Python 3.8 或更高版本
14+
15+
## 安装
16+
17+
`go get github.com/coze-dev/loop-go`
18+
19+
## 用法
20+
21+
### 初始化
22+
23+
首先,访问 https://www.coze.cn/open/oauth/apps 并创建一个 OAuth 应用,
24+
获取应用所有者的 AppID、公钥和私钥。
25+
26+
设置环境变量
27+
```bash
28+
export COZELOOP_WORKSPACE_ID=your workspace id
29+
export COZELOOP_JWT_OAUTH_CLIENT_ID=your client id
30+
export COZELOOP_JWT_OAUTH_PRIVATE_KEY=your private key
31+
export COZELOOP_JWT_OAUTH_PUBLIC_KEY_ID=your public key id
32+
```
33+
34+
### Trace上报
35+
```python
36+
def main():
37+
span = cozeloop.start_span("root", "custom")
38+
39+
span.set_input("Hello")
40+
span.set_output("World")
41+
42+
span.finish()
43+
44+
cozeloop.close()
45+
```
46+
47+
### Prompt拉取
48+
```python
49+
def main():
50+
prompt = cozeloop.get_prompt(prompt_key="your_prompt_key")
51+
messages = cozeloop.prompt_format(
52+
prompt,
53+
{"var1": "your content"},
54+
)
55+
```
56+
57+
你可以在 [这里](examples) 查看更多示例。
58+
59+
## 贡献
60+
61+
如需了解更多详细信息,请查看 [Contributing](CONTRIBUTING.md)
62+
63+
## 安全
64+
65+
如果你发现本项目中存在潜在的安全问题,或者认为自己可能发现了安全问题,请通过我们的 [安全中心](https://security.bytedance.com/src)[漏洞报告邮箱](sec@bytedance.com) 通知字节跳动安全团队。
66+
**不要**创建公开的 GitHub 问题。
67+
68+
## License
69+
70+
本项目采用 [MIT License](LICENSE)

__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
2+
# SPDX-License-Identifier: MIT
3+

cozeloop/__init__.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
2+
# SPDX-License-Identifier: MIT
3+
4+
from .entities.prompt import Prompt, Message
5+
import cozeloop.entities
6+
from .logger import set_log_level, add_log_handler
7+
8+
from .internal import __version__
9+
from .internal.consts import (
10+
CN_BASE_URL,
11+
)
12+
from .internal.consts.error import *
13+
14+
from .client import Client
15+
from ._client import (
16+
new_client,
17+
workspace_id,
18+
close,
19+
get_prompt,
20+
prompt_format,
21+
start_span,
22+
get_span_from_context,
23+
get_span_from_header,
24+
flush,
25+
ENV_API_BASE_URL,
26+
ENV_WORKSPACE_ID,
27+
ENV_API_TOKEN,
28+
ENV_JWT_OAUTH_CLIENT_ID,
29+
ENV_JWT_OAUTH_PRIVATE_KEY,
30+
ENV_JWT_OAUTH_PUBLIC_KEY_ID
31+
)
32+
33+
from .span import SpanContext, Span

0 commit comments

Comments
 (0)