Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/atorber/cozer
coze API非官方API
https://github.com/atorber/cozer
Last synced: about 1 month ago
JSON representation
coze API非官方API
- Host: GitHub
- URL: https://github.com/atorber/cozer
- Owner: atorber
- License: apache-2.0
- Created: 2024-05-27T03:02:49.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-05-27T13:32:04.000Z (7 months ago)
- Last Synced: 2024-10-19T22:29:33.452Z (3 months ago)
- Language: TypeScript
- Size: 49.8 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Cozer
> 即将发布
## 概述
Cozer非官方coze SDK,基于coze API快速接入自己的业务系统
- 获取bot列表
- 获取bot详情
- 启停bot
- 添加bot
- 对话bot
- 查询bot对话列表
- 查询bot对话历史
- ...## 快速入门
### 安装依赖
```shell
npm i cozer
```### 配置环境变量
在根目录创建一个名称为.env的配置文件
```yaml
COZE_ENDPOINT=https://api.coze.cn/open_api/v2/chat
COZE_TOKEN='coze的API token'
BOT_ID='coze的bot id'
```### 示例代码
```typescript
#!/usr/bin/env -S node --no-warnings --loader ts-node/esm
/* eslint-disable camelcase */
/* eslint-disable sort-keys */
import 'dotenv/config.js'
import { CozeBot, ChatV2Req } from '../src/coze.js'const coze_token = process.env['COZE_TOKEN'] || ''
const bot_id = process.env['BOT_ID'] || ''
const cozeBot = new CozeBot({
api_key: coze_token,
bot_id,
})const data: ChatV2Req = {
conversation_id: '1234567890',
user: '张三',
query: '你好,你是谁?',
history_count: 5,
stream: false,
}const chatResp = await cozeBot.chat(data)
const urls = chatResp.extractImageUrls()
const answers = chatResp.extractAnswer()console.info('urls:', urls)
console.info('answers:', answers)
```