Add reusable LLM parser profiles with multi-event extract.
Support kind=llm profiles (instruction/schema), optional multi-event posts via #eN URLs, and recover stale running/queued parse jobs after worker crashes. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { ADMIN_BASE, request } from "./client";
|
||||
import type {
|
||||
HeuristicProfile,
|
||||
LlmProfile,
|
||||
ParseChannel,
|
||||
ParseChannelCreate,
|
||||
ParseChannelUpdate,
|
||||
@@ -10,7 +11,7 @@ import type {
|
||||
TargetField,
|
||||
} from "../types/admin";
|
||||
|
||||
export type { HeuristicProfile, TargetField } from "../types/admin";
|
||||
export type { HeuristicProfile, LlmProfile, TargetField } from "../types/admin";
|
||||
|
||||
export function fetchChannels(): Promise<ParseChannel[]> {
|
||||
return request<ParseChannel[]>("/parse-channels", undefined, ADMIN_BASE);
|
||||
@@ -64,6 +65,10 @@ export function fetchTargetFields(): Promise<{ fields: TargetField[] }> {
|
||||
return request<{ fields: TargetField[] }>("/parser-profiles/target-fields", undefined, ADMIN_BASE);
|
||||
}
|
||||
|
||||
export function fetchLlmDefaults(): Promise<LlmProfile> {
|
||||
return request<LlmProfile>("/parser-profiles/llm-defaults", undefined, ADMIN_BASE);
|
||||
}
|
||||
|
||||
export function generateParserProfile(payload: {
|
||||
sample_post: string;
|
||||
hint?: string;
|
||||
@@ -94,10 +99,35 @@ export function generateParserProfile(payload: {
|
||||
export function previewParserProfile(
|
||||
sample_post: string,
|
||||
heuristic_profile: HeuristicProfile | Record<string, unknown>,
|
||||
): Promise<{ fields: Record<string, string> }> {
|
||||
return request<{ fields: Record<string, string> }>(
|
||||
): Promise<{ fields: Record<string, string>; matched: boolean; missing_required: string[] }> {
|
||||
return request<{ fields: Record<string, string>; matched: boolean; missing_required: string[] }>(
|
||||
"/parser-profiles/preview",
|
||||
{ method: "POST", body: JSON.stringify({ sample_post, heuristic_profile }) },
|
||||
ADMIN_BASE,
|
||||
);
|
||||
}
|
||||
|
||||
export function previewLlmProfile(
|
||||
sample_post: string,
|
||||
llm_profile: LlmProfile | Record<string, unknown>,
|
||||
): Promise<{
|
||||
fields: Record<string, string>;
|
||||
events: Record<string, string>[];
|
||||
matched: boolean;
|
||||
missing_required: string[];
|
||||
is_event: boolean;
|
||||
matched_count: number;
|
||||
}> {
|
||||
return request<{
|
||||
fields: Record<string, string>;
|
||||
events: Record<string, string>[];
|
||||
matched: boolean;
|
||||
missing_required: string[];
|
||||
is_event: boolean;
|
||||
matched_count: number;
|
||||
}>(
|
||||
"/parser-profiles/preview-llm",
|
||||
{ method: "POST", body: JSON.stringify({ sample_post, llm_profile }) },
|
||||
ADMIN_BASE,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user