feat: 增强智能体模型调用兼容能力
- 增加模型流式开关和 HTTP 传输策略配置 - 使用 AgentScope 执行基础连接、流式与 VLM 双阶段验证 - 固定多模态校验图片并统一验证状态展示
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
import type { ModelVerificationData } from '#/api/ai/llm';
|
||||
|
||||
export type VerifyButtonStatus =
|
||||
| 'error'
|
||||
| 'idle'
|
||||
| 'loading'
|
||||
| 'success'
|
||||
| 'warning';
|
||||
|
||||
export interface ModelVerificationFeedback {
|
||||
dimension?: number;
|
||||
message: string;
|
||||
status: 'error' | 'success' | 'warning';
|
||||
}
|
||||
|
||||
interface ModelVerificationResponse {
|
||||
data?: ModelVerificationData;
|
||||
errorCode: number;
|
||||
message?: string;
|
||||
}
|
||||
|
||||
const STREAMING_UNAVAILABLE_MESSAGE =
|
||||
'连接成功,流式响应不可用,可关闭智能体的模型流式响应。';
|
||||
|
||||
export function resolveModelVerificationFeedback(
|
||||
response: ModelVerificationResponse,
|
||||
modelType: string,
|
||||
): ModelVerificationFeedback {
|
||||
if (response.errorCode !== 0) {
|
||||
return {
|
||||
message: response.message || '验证失败',
|
||||
status: 'error',
|
||||
};
|
||||
}
|
||||
|
||||
if (response.data?.status === 'PARTIAL') {
|
||||
return {
|
||||
message: response.data.message || STREAMING_UNAVAILABLE_MESSAGE,
|
||||
status: 'warning',
|
||||
};
|
||||
}
|
||||
|
||||
if (response.data?.status === 'FAILED') {
|
||||
return {
|
||||
message: response.data.message || '验证失败',
|
||||
status: 'error',
|
||||
};
|
||||
}
|
||||
|
||||
const dimension = response.data?.dimension;
|
||||
return {
|
||||
dimension,
|
||||
message:
|
||||
modelType === 'embeddingModel' && dimension
|
||||
? `验证成功,向量维度:${dimension}`
|
||||
: response.data?.message || '验证成功',
|
||||
status: 'success',
|
||||
};
|
||||
}
|
||||
|
||||
export function getVerifyButtonText(status: VerifyButtonStatus): string {
|
||||
if (status === 'loading') {
|
||||
return '验证中';
|
||||
}
|
||||
if (status === 'success') {
|
||||
return '验证成功';
|
||||
}
|
||||
if (status === 'warning') {
|
||||
return '流式不可用';
|
||||
}
|
||||
if (status === 'error') {
|
||||
return '验证失败';
|
||||
}
|
||||
return '验证配置';
|
||||
}
|
||||
Reference in New Issue
Block a user