Cool-Admin-Node
后台管理系统开发、Api接口开发
Cool-Admin-Node
后台管理系统开发、Api接口开发
Cool-Admin-Java
后台管理系统开发、Api接口开发
Cool-Admin-Vue
后台管理系统开发前端
Cool Uni
移动端基于 uni-app 的跨端开发框架
Cool Team(即将推出)
Ai多智能体团队协作完成任务
技术指导
提供专业的技术指导服务
定制开发
外包,承接各类软件开发
低价云服务器
特价、低价的云服务器
发布帖子
寻求帮助或分享知识
发布插件
分享您的插件
Cool-Admin-Node
Cool-Admin-Java
Cool-Admin-Vue
Cool Uni
Cool Team(即将推出)
技术指导
定制开发
低价云服务器
发布帖子
发布插件
通义千问
通义千问大模型,是阿里云出品的一款国内领先的大模型问答系统,提供了丰富的 API 接口,可以满足各种场景的需求。
调用插件的时候需要用到标识,标识是唯一的,不能重复,建议使用英文,不要使用中文,对应插件 plugin.json
中的 key
字段
{
"baseUrl": "https://dashscope.aliyuncs.com/api/v1",
"apiKey": "通义的API Key",
"options": {
"model": "qwen-max"
}
}
参数配置可以查看官方文档
下面是插件提供的一些方法
聊天
/**
* 调用模型
* @param messages 消息列表
* @param options 配置,参考官方文档:https://help.aliyun.com/document_detail/2712576.html
* @param callback 当stream为true时,回调函数
* @returns 返回模型结果
*/
async chat(
messages: Message[],
options: any = {
model: "qwen-max",
stream: false,
url: "/services/aigc/text-generation/generation",
},
callback?: (data: any) => void
)
向量化
/**
* 向量化
* @param input 字符串数组
* @param options 配置参数文档:https://help.aliyun.com/document_detail/2712515.html?
*/
async embeddings(
inputs: string[],
options: any = {
model: "text-embedding-v2",
url: "/services/embeddings/text-embedding/text-embedding",
type: "query",
}
)
@Inject()
pluginService: PluginService;
// 获取插件实例
const instance = await this.pluginService.getInstance('test');
const messages: any = [
{ role: "system", content: "你叫小酷" },
{
role: "user",
content: `你好,你是谁`,
},
];
// 普通调用
const res = await instance.chat(messages);
console.log(res);
// 流式调用
instance.chat(messages, { stream: true }, (data) => {
console.log(data);
});
// 向量化
const data = await instance.embeddings(["cool"]);
console.log(data);