| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- import type { DebugExecuteRequest } from '../types';
- const BASE_URL = '/debug/api';
- export interface PromptVersionInfo {
- name: string;
- version: string;
- time: string;
- chain: string;
- isCurrent: boolean;
- systemPrompt?: string;
- userPrompt?: string;
- }
- export async function executeReview(
- params: DebugExecuteRequest,
- signal?: AbortSignal,
- ): Promise<{ task_id: string }> {
- const res = await fetch(`${BASE_URL}/review/execute`, {
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify(params),
- signal,
- });
- if (!res.ok) {
- let message = `请求失败 (${res.status})`;
- try {
- const body = await res.json();
- message = body.message || body.detail || message;
- } catch {
- // ignore parse error
- }
- throw new Error(message);
- }
- return res.json();
- }
- export async function fetchPromptVersions(): Promise<PromptVersionInfo[]> {
- const res = await fetch(`${BASE_URL}/prompts`);
- if (!res.ok) throw new Error('获取提示词版本失败');
- const data = await res.json();
- return data.items ?? [];
- }
|