|
|
@@ -1,6 +1,25 @@
|
|
|
import * as api from './api';
|
|
|
import type { CallRecord, ReplayResult } from '../types';
|
|
|
|
|
|
+function mapRecord(raw: Record<string, unknown>): CallRecord {
|
|
|
+ return {
|
|
|
+ id: (raw.id ?? raw.record_id ?? '') as string,
|
|
|
+ time: (raw.time ?? raw.timestamp ?? '') as string,
|
|
|
+ chain: (raw.chain ?? raw.chain_id ?? '') as string,
|
|
|
+ docRef: (raw.doc_ref ?? raw.docRef ?? '') as string,
|
|
|
+ inputSummary: (raw.doc_ref ?? raw.docRef ?? '').toString().slice(0, 30) as string,
|
|
|
+ duration: raw.duration_ms != null ? `${raw.duration_ms}ms` : ((raw.duration ?? '') as string),
|
|
|
+ status: (raw.status ?? '') as CallRecord['status'],
|
|
|
+ model: (raw.model ?? '') as string,
|
|
|
+ promptVer: (raw.prompt_ver ?? raw.promptVer ?? '') as string,
|
|
|
+ tokens: (raw.tokens ?? 0) as number,
|
|
|
+ params: (raw.params ?? {}) as Record<string, string>,
|
|
|
+ steps: (raw.steps ?? []) as CallRecord['steps'],
|
|
|
+ result: (raw.result ?? '') as string,
|
|
|
+ isReplayed: false,
|
|
|
+ };
|
|
|
+}
|
|
|
+
|
|
|
/** 获取调用记录列表 */
|
|
|
export async function fetchCallRecords(params?: {
|
|
|
page?: number;
|
|
|
@@ -8,12 +27,18 @@ export async function fetchCallRecords(params?: {
|
|
|
status?: string;
|
|
|
search?: string;
|
|
|
}): Promise<{ items: CallRecord[]; total: number; page: number; page_size: number }> {
|
|
|
- return (await api.fetchCallRecords(params)) as {
|
|
|
- items: CallRecord[];
|
|
|
+ const raw = await api.fetchCallRecords(params) as {
|
|
|
+ items: Record<string, unknown>[];
|
|
|
total: number;
|
|
|
page: number;
|
|
|
page_size: number;
|
|
|
};
|
|
|
+ return {
|
|
|
+ items: (raw.items ?? []).map(mapRecord),
|
|
|
+ total: raw.total ?? 0,
|
|
|
+ page: raw.page ?? 1,
|
|
|
+ page_size: raw.page_size ?? 20,
|
|
|
+ };
|
|
|
}
|
|
|
|
|
|
/** 获取调用记录详情 */
|