@tonyclaw/llm-inspector 1.14.7 → 1.14.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.output/nitro.json +1 -1
- package/.output/public/assets/index-CdnotuLh.js +105 -0
- package/.output/public/assets/index-vP91146S.css +1 -0
- package/.output/public/assets/{main-BV7uNIIz.js → main-CJ4MreBr.js} +1 -1
- package/.output/server/_libs/lucide-react.mjs +87 -79
- package/.output/server/_libs/radix-ui__react-id.mjs +1 -1
- package/.output/server/_ssr/{index-BvHLASu8.mjs → index-9uTJ4xYR.mjs} +744 -581
- package/.output/server/_ssr/index.mjs +2 -2
- package/.output/server/_ssr/{router-lUOA8pi6.mjs → router-BKnjB_zi.mjs} +2 -2
- package/.output/server/{_tanstack-start-manifest_v-XNH7fVPN.mjs → _tanstack-start-manifest_v-IsglLVKy.mjs} +1 -1
- package/.output/server/index.mjs +28 -28
- package/package.json +1 -1
- package/src/components/ProxyViewer.tsx +114 -146
- package/src/components/providers/ProviderCard.tsx +79 -26
- package/src/components/providers/ProviderForm.tsx +37 -22
- package/src/components/providers/ProvidersPanel.tsx +79 -47
- package/src/components/providers/SettingsDialog.tsx +25 -15
- package/src/components/proxy-viewer/ConversationGroup.tsx +50 -10
- package/src/components/proxy-viewer/ConversationHeader.tsx +48 -2
- package/src/components/proxy-viewer/LogEntry.tsx +116 -45
- package/src/components/proxy-viewer/LogEntryHeader.tsx +89 -71
- package/src/components/proxy-viewer/ReplayDialog.tsx +16 -6
- package/src/components/proxy-viewer/StreamingChunkSequence.tsx +24 -16
- package/src/components/proxy-viewer/ThreadConnector.tsx +104 -0
- package/src/components/proxy-viewer/index.ts +2 -1
- package/src/lib/stopReason.ts +57 -0
- package/.output/public/assets/index-Cmi8TfeU.js +0 -105
- package/.output/public/assets/index-DXUNTCVh.css +0 -1
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { CapturedLog } from "../proxy/schemas";
|
|
2
|
+
|
|
3
|
+
export type StopReason = "end_turn" | "tool_use" | "stop" | null;
|
|
4
|
+
|
|
5
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
6
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Extracts the stop/finish reason from a captured log's response text.
|
|
11
|
+
* Returns the raw stop_reason value for Anthropic, the finish_reason for
|
|
12
|
+
* OpenAI, or null if the response is pending, malformed, or unrecognized.
|
|
13
|
+
*/
|
|
14
|
+
export function extractStopReason(log: CapturedLog): StopReason {
|
|
15
|
+
if (log.responseText === null) return null;
|
|
16
|
+
|
|
17
|
+
try {
|
|
18
|
+
let json: unknown = JSON.parse(log.responseText);
|
|
19
|
+
// Handle double-encoded JSON
|
|
20
|
+
if (typeof json === "string") {
|
|
21
|
+
json = JSON.parse(json);
|
|
22
|
+
}
|
|
23
|
+
if (!isRecord(json)) return null;
|
|
24
|
+
|
|
25
|
+
// Anthropic: { stop_reason: "end_turn" | "tool_use" | ... }
|
|
26
|
+
if (log.apiFormat === "anthropic" && typeof json.stop_reason === "string") {
|
|
27
|
+
if (json.stop_reason === "end_turn" || json.stop_reason === "tool_use") {
|
|
28
|
+
return json.stop_reason;
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// OpenAI: { choices: [{ finish_reason: "stop" | ... }] }
|
|
34
|
+
if (
|
|
35
|
+
log.apiFormat === "openai" &&
|
|
36
|
+
Array.isArray(json.choices) &&
|
|
37
|
+
json.choices.length > 0 &&
|
|
38
|
+
isRecord(json.choices[0]) &&
|
|
39
|
+
typeof json.choices[0].finish_reason === "string" &&
|
|
40
|
+
json.choices[0].finish_reason === "stop"
|
|
41
|
+
) {
|
|
42
|
+
return "stop";
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return null;
|
|
46
|
+
} catch {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Returns true when the stop reason indicates the assistant completed its
|
|
53
|
+
* turn naturally (Anthropic end_turn or OpenAI stop).
|
|
54
|
+
*/
|
|
55
|
+
export function isTurnBoundary(stopReason: StopReason): boolean {
|
|
56
|
+
return stopReason === "end_turn" || stopReason === "stop";
|
|
57
|
+
}
|