feat: support ark bot & fix function call type

This commit is contained in:
quemingyi.wudong 2025-04-28 19:32:59 +08:00
parent f028bea0c5
commit 6ec1ca54e1
3 changed files with 50 additions and 11 deletions

View File

@ -87,7 +87,7 @@ export enum AI_MODEL {
DOUBAO_PRO_32K = 'Doubao-pro-32k',
DOUBAO_PRO_128K = 'Doubao-pro-128k',
VISION = 'Vision',
// VISION2 = 'ArkVLM',
ARK_BOT = 'ArkBot',
}
/**
@ -107,26 +107,30 @@ export const AI_MODE_MAP: Partial<Record<AI_MODEL, AI_MODEL_MODE>> = {
[AI_MODEL.DOUBAO_PRO_32K]: AI_MODEL_MODE.ARK_V3,
[AI_MODEL.DOUBAO_PRO_128K]: AI_MODEL_MODE.ARK_V3,
[AI_MODEL.VISION]: AI_MODEL_MODE.ARK_V3,
[AI_MODEL.ARK_BOT]: AI_MODEL_MODE.ARK_V3,
};
/**
* @brief ID
* @brief ID
* @note ID https://console.volcengine.com/ark/region:ark+cn-beijing/endpoint?config=%7B%7D&s=g 参看/创建
* ID ID, "接入点名称" , "ep-2024xxxxxx-xxx" ID
*/
export const ARK_V3_MODEL_ID: Partial<Record<AI_MODEL, string>> = {
[AI_MODEL.DOUBAO_LITE_4K]: '************** 此处填充方舟上的模型 ID *************',
[AI_MODEL.DOUBAO_PRO_4K]: '************** 此处填充方舟上的模型 ID *************',
[AI_MODEL.DOUBAO_PRO_32K]: '************** 此处填充方舟上的模型 ID *************',
[AI_MODEL.DOUBAO_PRO_128K]: '************** 此处填充方舟上的模型 ID *************',
[AI_MODEL.VISION]: '************** 此处填充方舟上的模型 ID *************',
[AI_MODEL.DOUBAO_LITE_4K]: '************** 此处填充方舟上的模型 ID *************',
[AI_MODEL.DOUBAO_PRO_4K]: '************** 此处填充方舟上的模型 ID *************',
[AI_MODEL.DOUBAO_PRO_32K]: '************** 此处填充方舟上的模型 ID *************',
[AI_MODEL.DOUBAO_PRO_128K]: '************** 此处填充方舟上的模型 ID *************',
[AI_MODEL.VISION]: '************** 此处填充方舟上的模型 ID *************',
// ... 可根据所开通的模型进行扩充
};
/**
* @brief BotID
* @brief BotID
* @note ID https://console.volcengine.com/ark/region:ark+cn-beijing/assistant?s=g 参看/创建
* Bot ID ID, "bot-2025xxxxxx-xxx" ID
*/
export const LLM_BOT_ID: Partial<Record<AI_MODEL, string>> = {
[AI_MODEL.ARK_BOT]: '************** 此处填充方舟上的 Bot ID *************',
// ... 可根据所开通的模型进行扩充
};

View File

@ -16,6 +16,7 @@ import {
AI_MODEL,
AI_MODE_MAP,
AI_MODEL_MODE,
LLM_BOT_ID,
isVisionMode,
} from '.';
@ -137,7 +138,12 @@ export class ConfigFactory {
get LLMConfig() {
const params: Record<string, unknown> = {
Mode: AI_MODE_MAP[this.Model || ''] || AI_MODEL_MODE.CUSTOM,
/**
* @note EndPointId BotId EndPointId
*
*/
EndPointId: ARK_V3_MODEL_ID[this.Model],
BotId: LLM_BOT_ID[this.Model],
MaxTokens: 1024,
Temperature: 0.1,
TopP: 0.3,
@ -150,6 +156,37 @@ export class ConfigFactory {
Url: this.Url,
Feature: JSON.stringify({ Http: true }),
};
if (LLM_BOT_ID[this.Model]) {
/**
* @note , Function Call , Tools ,
* https://www.volcengine.com/docs/6348/1404673?s=g#llmconfig%EF%BC%88%E7%81%AB%E5%B1%B1%E6%96%B9%E8%88%9F%E5%B9%B3%E5%8F%B0%EF%BC%89
* src/utils/handler.ts ,
*/
params.Tools = [
{
type: 'function',
function: {
name: 'get_current_weather',
description: '获取给定地点的天气',
parameters: {
type: 'object',
properties: {
location: {
type: 'string',
description: '地理位置,比如北京市',
},
unit: {
type: 'string',
description: '',
enum: ['摄氏度', '华氏度'],
},
},
required: ['location'],
},
},
},
];
}
if (isVisionMode(this.Model)) {
params.VisionConfig = {
Enable: true,

View File

@ -19,7 +19,7 @@ export type AnyRecord = Record<string, any>;
export enum MESSAGE_TYPE {
BRIEF = 'conv',
SUBTITLE = 'subv',
FUNCTION_CALL = 'func',
FUNCTION_CALL = 'tool',
}
export enum AGENT_BRIEF {
@ -134,8 +134,6 @@ export const useMessageHandler = () => {
console.log('[Function Call] - Called by sendUserBinaryMessage');
const map: Record<string, string> = {
getcurrentweather: '今天下雪, 最低气温零下10度',
musicplayer: '查询到李四的歌曲, 名称是千里之内',
sendmessage: '发送成功',
};
RtcClient.engine.sendUserBinaryMessage(