Skip to main content

use coze api in python

Project description

使用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 文件

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

coze-0.0.1.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

coze-0.0.1-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file coze-0.0.1.tar.gz.

File metadata

  • Download URL: coze-0.0.1.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.6

File hashes

Hashes for coze-0.0.1.tar.gz
Algorithm Hash digest
SHA256 e8f00d761797902341c900ca0d6ef76323f56ce4f721cddb99b5993d10725629
MD5 6521df5763588a2962fee8f47ee21e0b
BLAKE2b-256 7fe212e353a50e6450c56b0f5ebfd458de10ed94a0115612a53c81d7d0282c35

See more details on using hashes here.

File details

Details for the file coze-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: coze-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.6

File hashes

Hashes for coze-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e8878d0881b0191535867e3cc3e99fe1b193cf1308c5e3790552525b8e116bd2
MD5 2db46c9f9fc377d472e0edfa2c945bd0
BLAKE2b-256 162dc879118ff8c4020d398f04d3ad997d11b8de37fa805e982f3b763c888564

See more details on using hashes here.

Supported by

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