feat: support ark bot & fix function call type
This commit is contained in:
parent
f028bea0c5
commit
6ec1ca54e1
@ -87,7 +87,7 @@ export enum AI_MODEL {
|
|||||||
DOUBAO_PRO_32K = 'Doubao-pro-32k',
|
DOUBAO_PRO_32K = 'Doubao-pro-32k',
|
||||||
DOUBAO_PRO_128K = 'Doubao-pro-128k',
|
DOUBAO_PRO_128K = 'Doubao-pro-128k',
|
||||||
VISION = 'Vision',
|
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_32K]: AI_MODEL_MODE.ARK_V3,
|
||||||
[AI_MODEL.DOUBAO_PRO_128K]: 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.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 参看/创建
|
* @note 具体的模型 ID 请至 https://console.volcengine.com/ark/region:ark+cn-beijing/endpoint?config=%7B%7D&s=g 参看/创建
|
||||||
* 模型 ID 即接入点 ID, 在上述链接中表格内 "接入点名称" 列中, 类似于 "ep-2024xxxxxx-xxx" 格式即是模型 ID。
|
* 模型 ID 即接入点 ID, 在上述链接中表格内 "接入点名称" 列中, 类似于 "ep-2024xxxxxx-xxx" 格式即是模型 ID。
|
||||||
*/
|
*/
|
||||||
export const ARK_V3_MODEL_ID: Partial<Record<AI_MODEL, string>> = {
|
export const ARK_V3_MODEL_ID: Partial<Record<AI_MODEL, string>> = {
|
||||||
[AI_MODEL.DOUBAO_LITE_4K]: '************** 此处填充方舟上的模型 ID *************',
|
[AI_MODEL.DOUBAO_LITE_4K]: '************** 此处填充方舟上的模型 ID *************',
|
||||||
[AI_MODEL.DOUBAO_PRO_4K]: '************** 此处填充方舟上的模型 ID *************',
|
[AI_MODEL.DOUBAO_PRO_4K]: '************** 此处填充方舟上的模型 ID *************',
|
||||||
[AI_MODEL.DOUBAO_PRO_32K]: '************** 此处填充方舟上的模型 ID *************',
|
[AI_MODEL.DOUBAO_PRO_32K]: '************** 此处填充方舟上的模型 ID *************',
|
||||||
[AI_MODEL.DOUBAO_PRO_128K]: '************** 此处填充方舟上的模型 ID *************',
|
[AI_MODEL.DOUBAO_PRO_128K]: '************** 此处填充方舟上的模型 ID *************',
|
||||||
[AI_MODEL.VISION]: '************** 此处填充方舟上的模型 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>> = {
|
export const LLM_BOT_ID: Partial<Record<AI_MODEL, string>> = {
|
||||||
|
[AI_MODEL.ARK_BOT]: '************** 此处填充方舟上的 Bot ID *************',
|
||||||
// ... 可根据所开通的模型进行扩充
|
// ... 可根据所开通的模型进行扩充
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -16,6 +16,7 @@ import {
|
|||||||
AI_MODEL,
|
AI_MODEL,
|
||||||
AI_MODE_MAP,
|
AI_MODE_MAP,
|
||||||
AI_MODEL_MODE,
|
AI_MODEL_MODE,
|
||||||
|
LLM_BOT_ID,
|
||||||
isVisionMode,
|
isVisionMode,
|
||||||
} from '.';
|
} from '.';
|
||||||
|
|
||||||
@ -137,7 +138,12 @@ export class ConfigFactory {
|
|||||||
get LLMConfig() {
|
get LLMConfig() {
|
||||||
const params: Record<string, unknown> = {
|
const params: Record<string, unknown> = {
|
||||||
Mode: AI_MODE_MAP[this.Model || ''] || AI_MODEL_MODE.CUSTOM,
|
Mode: AI_MODE_MAP[this.Model || ''] || AI_MODEL_MODE.CUSTOM,
|
||||||
|
/**
|
||||||
|
* @note EndPointId 与 BotId 不可同时填写,若同时填写,则 EndPointId 生效。
|
||||||
|
* 当前仅支持自定义推理接入点,不支持预置推理接入点。
|
||||||
|
*/
|
||||||
EndPointId: ARK_V3_MODEL_ID[this.Model],
|
EndPointId: ARK_V3_MODEL_ID[this.Model],
|
||||||
|
BotId: LLM_BOT_ID[this.Model],
|
||||||
MaxTokens: 1024,
|
MaxTokens: 1024,
|
||||||
Temperature: 0.1,
|
Temperature: 0.1,
|
||||||
TopP: 0.3,
|
TopP: 0.3,
|
||||||
@ -150,6 +156,37 @@ export class ConfigFactory {
|
|||||||
Url: this.Url,
|
Url: this.Url,
|
||||||
Feature: JSON.stringify({ Http: true }),
|
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)) {
|
if (isVisionMode(this.Model)) {
|
||||||
params.VisionConfig = {
|
params.VisionConfig = {
|
||||||
Enable: true,
|
Enable: true,
|
||||||
|
|||||||
@ -19,7 +19,7 @@ export type AnyRecord = Record<string, any>;
|
|||||||
export enum MESSAGE_TYPE {
|
export enum MESSAGE_TYPE {
|
||||||
BRIEF = 'conv',
|
BRIEF = 'conv',
|
||||||
SUBTITLE = 'subv',
|
SUBTITLE = 'subv',
|
||||||
FUNCTION_CALL = 'func',
|
FUNCTION_CALL = 'tool',
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum AGENT_BRIEF {
|
export enum AGENT_BRIEF {
|
||||||
@ -134,8 +134,6 @@ export const useMessageHandler = () => {
|
|||||||
console.log('[Function Call] - Called by sendUserBinaryMessage');
|
console.log('[Function Call] - Called by sendUserBinaryMessage');
|
||||||
const map: Record<string, string> = {
|
const map: Record<string, string> = {
|
||||||
getcurrentweather: '今天下雪, 最低气温零下10度',
|
getcurrentweather: '今天下雪, 最低气温零下10度',
|
||||||
musicplayer: '查询到李四的歌曲, 名称是千里之内',
|
|
||||||
sendmessage: '发送成功',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
RtcClient.engine.sendUserBinaryMessage(
|
RtcClient.engine.sendUserBinaryMessage(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user