chore: sync upstream v0.3.6 changes
This commit is contained in:
1 parent
9da521ee4e
commit
22132a4d21
34 files changed
+897
-127
No files matched your search
+13
-1
@@ -74,6 +74,7 @@ import type {
|
||||
TokenTotal,
|
||||
TokenUsage,
|
||||
Tool,
|
||||
ToolStat,
|
||||
TrafficDetail,
|
||||
TrafficHost,
|
||||
TrafficResp,
|
||||
@@ -677,8 +678,10 @@ export const api = {
|
||||
thinking_type = "",
|
||||
reasoning_effort = "",
|
||||
profile_id?: number,
|
||||
streaming = true, // 用该配置真实的收发模式来测,别让"流式能通、非流式不通"漏到会话里
|
||||
) =>
|
||||
post<{ ok: boolean; error?: string; latency_ms?: number; model?: string }>("/llm/test", {
|
||||
// reply = 模型实际回复(已截断);一个字都不回的配置后端直接判失败
|
||||
post<{ ok: boolean; error?: string; latency_ms?: number; model?: string; reply?: string }>("/llm/test", {
|
||||
provider,
|
||||
model,
|
||||
base_url,
|
||||
@@ -687,6 +690,7 @@ export const api = {
|
||||
thinking_type,
|
||||
reasoning_effort,
|
||||
profile_id,
|
||||
streaming,
|
||||
}),
|
||||
llmProfiles: () => get<{ profiles: LLMProfile[] }>("/llm/profiles").then((r) => arr(r.profiles)),
|
||||
saveLLMProfile: (p: {
|
||||
@@ -704,6 +708,7 @@ export const api = {
|
||||
reasoning_effort?: string; // ""(不发送)|"low"|"medium"|"high"|"xhigh"|"max"
|
||||
priority?: number; // 轮询顺位,越大越先用
|
||||
pool_exclude?: boolean; // true=不作为故障转移目标
|
||||
streaming?: boolean; // true(默认)=流式 | false=非流式
|
||||
}) => post<{ id: number }>("/llm/profiles", p),
|
||||
deleteLLMProfile: (id: string) => del<{ deleted: number }>(`/llm/profiles/${id}`),
|
||||
activateLLMProfile: (id: string) => post<{ ok: boolean }>("/llm/profiles/active", { id: Number(id) }),
|
||||
@@ -972,6 +977,13 @@ export const api = {
|
||||
sp.set("size", String(params?.size ?? 50));
|
||||
return get<{ commands: CommandRecord[]; total: number }>(`/commands?${sp}`);
|
||||
},
|
||||
// 各工具调用次数;沿用列表的 task/q 筛选,统计的是整个结果集而非当前页。
|
||||
commandStats: (params?: { task?: string; q?: string }) => {
|
||||
const sp = new URLSearchParams();
|
||||
if (params?.task) sp.set("task", params.task);
|
||||
if (params?.q) sp.set("q", params.q);
|
||||
return get<{ stats: ToolStat[] }>(`/commands/stats?${sp}`);
|
||||
},
|
||||
|
||||
// ---- LLM records ----
|
||||
llmRecords: (params?: { model?: string; session?: string; task?: string; page?: number; size?: number }) => {
|
||||
|
||||
@@ -1493,6 +1493,17 @@ function route(m: string, path: string, seg: string[], q: URLSearchParams, b: Re
|
||||
|
||||
// ── 工具执行历史 ──
|
||||
if (path === "/commands" && m === "GET") return { commands: D.commandRecords, total: D.commandRecords.length };
|
||||
if (path === "/commands/stats" && m === "GET") {
|
||||
const tally = new Map<string, { tool: string; total: number; errors: number }>();
|
||||
for (const c of D.commandRecords) {
|
||||
const tool = c.tool || "-";
|
||||
const s = tally.get(tool) ?? { tool, total: 0, errors: 0 };
|
||||
s.total++;
|
||||
if (c.is_error) s.errors++;
|
||||
tally.set(tool, s);
|
||||
}
|
||||
return { stats: [...tally.values()].sort((a, b) => b.total - a.total || a.tool.localeCompare(b.tool)) };
|
||||
}
|
||||
|
||||
// ── LLM ──
|
||||
if (path === "/llm/records" && m === "GET") return { records: mockLLMRecords, total: mockLLMRecords.length };
|
||||
@@ -1509,7 +1520,8 @@ function route(m: string, path: string, seg: string[], q: URLSearchParams, b: Re
|
||||
}
|
||||
if (path === "/llm" && m === "GET") return D.llmConfig;
|
||||
if (path === "/llm" && m === "POST") return { ok: true };
|
||||
if (path === "/llm/test") return { ok: true, latency_ms: 128, model: String(b.model ?? "claude-opus-4-8") };
|
||||
if (path === "/llm/test")
|
||||
return { ok: true, latency_ms: 128, model: String(b.model ?? "claude-opus-4-8"), reply: "OK" };
|
||||
if (path === "/llm/profiles" && m === "GET") return { profiles: D.llmProfiles };
|
||||
if (path === "/llm/profiles" && m === "POST") return { id: Number(b.id) || 3 };
|
||||
if (path === "/llm/profiles/active") return { ok: true };
|
||||
|
||||
@@ -869,6 +869,8 @@ export interface LLMProfile {
|
||||
priority?: number;
|
||||
// true = 不作为故障转移目标(仍可被 agent/任务显式绑定使用)。
|
||||
pool_exclude?: boolean;
|
||||
// true(默认)= 流式(SSE) | false = 真·非流式(stream:false,一次性返回)。
|
||||
streaming?: boolean;
|
||||
}
|
||||
|
||||
// ---- LLM 轮询(故障转移)----
|
||||
@@ -1133,6 +1135,13 @@ export interface CommandRecord {
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
// 单个工具的调用统计(/commands/stats);errors 为其中失败的次数。
|
||||
export interface ToolStat {
|
||||
tool: string;
|
||||
total: number;
|
||||
errors: number;
|
||||
}
|
||||
|
||||
// ---- LLM recording ----
|
||||
export interface LLMRecordItem {
|
||||
id: number;
|
||||
|
||||
Reference in new issue
Block a user