Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Introduce AI dialog model "Kimi" #19

Merged
merged 1 commit into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions app/lib/enum.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/**
* Copyright (c) 2023 - present TinyEngine Authors.
* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
*
* Use of this source code is governed by an MIT-style license.
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/
* Copyright (c) 2023 - present TinyEngine Authors.
* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
*
* Use of this source code is governed by an MIT-style license.
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/
// 请求method
export enum E_Method {
Get = 'GET',
Expand Down Expand Up @@ -289,5 +289,6 @@ export enum E_Public {
export enum E_FOUNDATION_MODEL {
GPT_35_TURBO = 'gpt-3.5-turbo', // openai
Local_GPT = 'loacl-compatible-gpt-3.5', //本地兼容opanai-api接口的 大语言模型,如chatGLM6b,通义千问 等。
ERNIE_BOT_TURBO = 'ERNIE-Bot-turbo' // 文心一言
ERNIE_BOT_TURBO = 'ERNIE-Bot-turbo', // 文心一言
MOONSHOT_V1_8K = 'moonshot-v1-8k' // kimi
}
2 changes: 0 additions & 2 deletions app/service/app-center/aiChat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,8 @@ export default class AiChat extends Service {
const { httpRequestUrl, httpRequestOption } = aiChatConfig[chatConfig.model];
this.ctx.logger.debug(httpRequestOption);
res = await ctx.curl(httpRequestUrl, httpRequestOption);

} catch (e: any) {
this.ctx.logger.debug(`调用AI大模型接口失败: ${(e as Error).message}`);

return this.ctx.helper.getResponseData(`调用AI大模型接口失败: ${(e as Error).message}`);
}

Expand Down
18 changes: 16 additions & 2 deletions config/config.default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ export default (appInfo) => {
};

//ai大模型相关配置,请自行替换服务配置
config.aiChat = (messages = [], accessToken: string) => {
config.aiChat = (messages = [], token: string) => {
return {
[E_FOUNDATION_MODEL.GPT_35_TURBO]: {
httpRequestUrl: (process.env.OPENAI_API_URL || 'https://api.openai.com') + '/v1/chat/completions',
Expand Down Expand Up @@ -278,7 +278,7 @@ export default (appInfo) => {
manufacturer: '!openai'
},
[E_FOUNDATION_MODEL.ERNIE_BOT_TURBO]: {
httpRequestUrl: `https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/eb-instant?access_token=${accessToken || process.env.WENXIN_ACCESS_TOKEN}`,
httpRequestUrl: `https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/eb-instant?access_token=${token || process.env.WENXIN_ACCESS_TOKEN}`,
httpRequestOption: {
...commonRequestOption,
data: {
Expand All @@ -287,6 +287,20 @@ export default (appInfo) => {
}
},
manufacturer: 'baidu'
},
[E_FOUNDATION_MODEL.MOONSHOT_V1_8K]: {
httpRequestUrl: `https://api.moonshot.cn/v1/chat/completions`,
httpRequestOption: {
...commonRequestOption,
data: {
model: E_FOUNDATION_MODEL.MOONSHOT_V1_8K,
messages
},
headers: {
Authorization: `Bearer ${token}`
}
},
manufacturer: 'kimi'
}
};
};
Expand Down
Loading