style(ai): 格式化 AI API 错误消息和调整 AI 视图布局
- 格式化 Ollama 和 OpenAI API 的错误消息字符串以提高可读性 - 移除 AI 视图中的 BaseURL 输入字段并硬编码为固定端点 - 简化 AI 视图中 API 调用的基础 URL 配置逻辑 - 修复多个组件中的代码格式和空格缩进问题 - 清理经销商订单视图中的多余注释和代码结构 - 调整表单组件的标签和布局格式以提升用户体验
This commit is contained in:
@@ -48,7 +48,9 @@ export async function listOllamaModels(opts?: { baseURL?: string }) {
|
||||
if (!res.ok) {
|
||||
const text = await res.text().catch(() => '');
|
||||
throw new Error(
|
||||
`listOllamaModels failed: ${res.status} ${res.statusText}${text ? ` - ${text}` : ''}`
|
||||
`listOllamaModels failed: ${res.status} ${res.statusText}${
|
||||
text ? ` - ${text}` : ''
|
||||
}`
|
||||
);
|
||||
}
|
||||
return (await res.json()) as OllamaTagsResponse;
|
||||
@@ -68,7 +70,9 @@ export async function ollamaChat(
|
||||
if (!res.ok) {
|
||||
const text = await res.text().catch(() => '');
|
||||
throw new Error(
|
||||
`ollamaChat failed: ${res.status} ${res.statusText}${text ? ` - ${text}` : ''}`
|
||||
`ollamaChat failed: ${res.status} ${res.statusText}${
|
||||
text ? ` - ${text}` : ''
|
||||
}`
|
||||
);
|
||||
}
|
||||
return (await res.json()) as OllamaChatResponseChunk;
|
||||
@@ -97,7 +101,9 @@ export async function ollamaChatStream(
|
||||
if (!res.ok || !res.body) {
|
||||
const text = await res.text().catch(() => '');
|
||||
throw new Error(
|
||||
`ollamaChatStream failed: ${res.status} ${res.statusText}${text ? ` - ${text}` : ''}`
|
||||
`ollamaChatStream failed: ${res.status} ${res.statusText}${
|
||||
text ? ` - ${text}` : ''
|
||||
}`
|
||||
);
|
||||
}
|
||||
|
||||
@@ -143,4 +149,3 @@ export async function ollamaChatStream(
|
||||
|
||||
opts.onDone?.();
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,9 @@ export async function listModels(opts?: { apiKey?: string; baseURL?: string }) {
|
||||
if (!res.ok) {
|
||||
const text = await res.text().catch(() => '');
|
||||
throw new Error(
|
||||
`listModels failed: ${res.status} ${res.statusText}${text ? ` - ${text}` : ''}`
|
||||
`listModels failed: ${res.status} ${res.statusText}${
|
||||
text ? ` - ${text}` : ''
|
||||
}`
|
||||
);
|
||||
}
|
||||
return (await res.json()) as OpenAIListModelsResponse;
|
||||
@@ -91,7 +93,9 @@ export async function chatCompletions(
|
||||
if (!res.ok) {
|
||||
const text = await res.text().catch(() => '');
|
||||
throw new Error(
|
||||
`chatCompletions failed: ${res.status} ${res.statusText}${text ? ` - ${text}` : ''}`
|
||||
`chatCompletions failed: ${res.status} ${res.statusText}${
|
||||
text ? ` - ${text}` : ''
|
||||
}`
|
||||
);
|
||||
}
|
||||
return (await res.json()) as OpenAIChatCompletionResponse;
|
||||
@@ -124,7 +128,9 @@ export async function chatCompletionsStream(
|
||||
if (!res.ok || !res.body) {
|
||||
const text = await res.text().catch(() => '');
|
||||
throw new Error(
|
||||
`chatCompletionsStream failed: ${res.status} ${res.statusText}${text ? ` - ${text}` : ''}`
|
||||
`chatCompletionsStream failed: ${res.status} ${res.statusText}${
|
||||
text ? ` - ${text}` : ''
|
||||
}`
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user