-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
63 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,28 @@ | ||
/** | ||
* 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. | ||
* | ||
*/ | ||
import { Controller } from 'egg'; | ||
import { E_FOUNDATION_MODEL } from '../../lib/enum'; | ||
|
||
export default class AiChatController extends Controller { | ||
|
||
|
||
/** | ||
* @router post /api/ai/chat 路径 | ||
* @summary AI大模型聊天 | ||
* @description 根据角色和提问信息返回AI答复 | ||
*/ | ||
public async aiChat() { | ||
const { ctx } = this; | ||
const { foundationModel, messages, accessToken } = ctx.request.body; | ||
const { foundationModel, messages } = ctx.request.body; | ||
this.ctx.logger.info('ai接口请求参参数 model选型:', foundationModel); | ||
if (!messages || !Array.isArray(messages)) { | ||
return this.ctx.helper.getResponseData('Not passing the correct message parameter'); | ||
} | ||
const model = foundationModel?.model ?? E_FOUNDATION_MODEL.GPT_35_TURBO; | ||
ctx.body = await ctx.service.appCenter.aiChat.getAnswerFromAi(messages, { model }, accessToken); | ||
const token = foundationModel.token; | ||
ctx.body = await ctx.service.appCenter.aiChat.getAnswerFromAi(messages, { model, token }); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters