Skip to content

Commit

Permalink
添加混元助手文档
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengxs2018 committed Dec 10, 2023
1 parent 969c78b commit 3eb3c83
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 4 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ main();
- [文心一言](./doc/ernie.md)
- [通义千问](./doc/qwen.md)
- [讯飞星火](./doc/spark.md)
- [混元助手](./doc/hunyuan.md)
- [Minimax](./doc/minimax.md)
- [ImagineArt](./doc/vyro.md)

Expand All @@ -77,7 +78,7 @@ main();

## 待办

- [x] 百度文心一言大模型 [百度飞桨分发](https://aistudio.baidu.com/cooperate/yiyan)
- [x] [百度文心一言大模型](https://aistudio.baidu.com/cooperate/yiyan) (飞桨平台分发)
- [x] Chat
- [x] Embeddings
- [ ] ~~Images~~ 飞浆平台不支持
Expand All @@ -91,7 +92,7 @@ main();
- [x] Chat
- [ ] ~~Embeddings~~ 未获得资格
- [ ] ~~Images~~ 未获得资格
- [x] [腾讯混元大模型](https://hunyuan.tencent.com/)
- [x] [腾讯混元助手大模型](https://hunyuan.tencent.com/)
- [x] Chat
- [x] [Minimax](https://api.minimax.chat/)
- [x] Chat
Expand Down
48 changes: 48 additions & 0 deletions doc/hunyuan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# 混元助手

在这里获取你的 [API密钥](https://console.cloud.tencent.com/cam/capi)

## 通用对话

当前支持 `hunyuan` 模型。

```ts
import { HunYuanAI } from '@zhengxs/ai';

const client = new HunYuanAI({
appId: 'My APP ID', // defaults to process.env["HUNYUAN_APP_ID"]
secretId: 'My Secret ID', // defaults to process.env["HUNYUAN_SECRET_ID"]
secretKey: 'My Secret Key', // defaults to process.env["HUNYUAN_SECRET_KEY"]
});

async function main() {
const chatCompletion = await client.chat.completions.create({
model: 'hunyuan',
messages: [{ role: 'user', content: 'Say this is a test' }],
});
}

main();
```

### 支持流式

```ts
import { HunYuanAI } from '@zhengxs/ai';

const client = new HunYuanAI();

async function main() {
const stream = await client.chat.completions.create({
model: 'hunyuan',
messages: [{ role: 'user', content: 'Say this is a test' }],
stream: true,
});

for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content || '');
}
}

main();
```
4 changes: 2 additions & 2 deletions doc/qwen.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

## 通用对话

当前支持 `qwen-turbo | qwen-plus | qwen-max | qwen-max-1201 | qwen-max-longcontext | baichuan2-7b-chat-v1` 模型
当前支持大部分千问,以及其他系列的同类模型

```ts
import { QWenAI } from '@zhengxs/ai';
Expand Down Expand Up @@ -134,7 +134,7 @@ console.log(embedding.data);

## 文生图

目前支持 `wanx-v1`, `stable-diffusion-v1.5``stable-diffusion-xl` 模型;
支持 `wanx-v1`, `stable-diffusion-v1.5``stable-diffusion-xl` 模型;

```js
import path from 'node:path';
Expand Down

0 comments on commit 3eb3c83

Please sign in to comment.