使用Python调用coze
coze官方只提供了curl调用范例,未提供python调用接口。
一个有毅力的吃货花了些时间利用requests库进行了实现,封装成了coze这个python库。
支持流式输出,支持多轮对话。
一,安装coze库
pip install coze
二,使用范例
import os
from coze import Coze
os.environ['COZE_API_TOKEN'] = 'pat_xxx'
os.environ['COZE_BOT_ID'] = "7362845197946257419"
chat = Coze(api_token= os.environ['COZE_API_TOKEN'],
bot_id = os.environ['COZE_BOT_ID'],
max_chat_rounds=20,
stream=True)
你好!有什么可以帮助你的?
register magic %%chat sucessed ...
可以使用__call__方法调用
response = chat('北京最新的高级产品经理岗位有推荐吗')
call function: liepin-job_recommendation; args ={'address': '北京', 'jobName': '高级产品经理'}
北京近期推荐的高级产品经理岗位有以下几个,提供给对这一职业领域感兴趣的求职者:
1. 获客多 Hokdo公司提供产品经理和高级产品经理岗位,位于北京万泉河地区,产业属于计算机软件并且公司处于A轮融资阶段。提供的薪资为20-30k或25-35k,15个月薪资。招聘负责人是许先生。
2. 北京微云众网络科技有限公司招募的Futures Operations Director 职位涉及Web3 分布式产品运营,位于北京东四地区,公司规模100-499人,被标记具有较大的发展空间和国际化优势。
3. 美团是一个大规模的互联网生活服务公司,已上市,招聘的岗位是“企平-产品专家(工单平台方向)”和“财务科技-税务产品经理(海外税务方向)”,位于北京南法信,提出的薪资在30-60k和25-35k之间,均为15个月薪资。
以上职位都可以通过相应的跳转链接获取更详细的职位描述和申请方式。
在notebook中推荐使用jupyter魔法命令进行调用。
三,详细教程
参考 本项目下的 coze_tutorial.ipynb 文件
Metadata
Release files for coze 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| coze-0.0.1.tar.gz | 4.4 kB | Without provenance | Details for coze-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| coze-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for coze-0.0.1-py3-none-any.whl |
Total release size: 8.8 kB
Release files / coze-0.0.1.tar.gz
| Download URL | coze-0.0.1.tar.gz |
|---|---|
| Size | 4.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e8f00d761797902341c900ca0d6ef76323f56ce4f721cddb99b5993d10725629
|
|
BLAKE2b-256 checksum How to use checksums |
7fe212e353a50e6450c56b0f5ebfd458de10ed94a0115612a53c81d7d0282c35
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.6
|
Release files / coze-0.0.1-py3-none-any.whl
| Download URL | coze-0.0.1-py3-none-any.whl |
|---|---|
| Size | 4.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e8878d0881b0191535867e3cc3e99fe1b193cf1308c5e3790552525b8e116bd2
|
|
BLAKE2b-256 checksum How to use checksums |
162dc879118ff8c4020d398f04d3ad997d11b8de37fa805e982f3b763c888564
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.6
|
Security for coze 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.