Initial import NDC_1C
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import type { ConnectionState, PromptState, QueryState } from "./types";
|
||||
|
||||
export const DEFAULT_CONNECTION: ConnectionState = {
|
||||
apiKey: "",
|
||||
model: "gpt-4o-mini",
|
||||
baseUrl: "https://api.openai.com/v1",
|
||||
temperature: 0,
|
||||
maxOutputTokens: 700
|
||||
};
|
||||
|
||||
export const DEFAULT_PROMPTS: PromptState = {
|
||||
systemPrompt: "Ты semantic-normalizer для бухгалтерского ассистента NDC. Возвращай только JSON по схеме normalized_query_v2_0_2.",
|
||||
developerPrompt:
|
||||
"Сначала делай decomposition сообщения на task fragments, затем определяй domain scope и route-critical flags. Для каждого fragment заполняй execution_readiness + route_status + no_route_reason. Если fragment routable, не оставляй его в no_route.",
|
||||
domainPrompt:
|
||||
"Контур: данные текущего предприятия в 1С/NDC. In-scope: документы, проводки, взаиморасчеты, остатки, периодное закрытие, аномалии и контрольные проверки. Out-of-scope: общая теория, законы и оффтоп.",
|
||||
schemaNotes: "schema_version: normalized_query_v2_0_2. Строгий JSON без дополнительных полей.",
|
||||
fewShotExamples:
|
||||
"Q: Проверь по поставщикам хвосты и разложи цепочку документов/оплат. => fragment in_scope, flags: multi_entity + chain_explanation. Q: Как вообще по ФСБУ? => out_of_scope/generic_accounting."
|
||||
};
|
||||
|
||||
export const DEFAULT_QUERY: QueryState = {
|
||||
userQuestion: "",
|
||||
batchQuestionsRaw: "",
|
||||
periodHint: "",
|
||||
businessContext: "",
|
||||
expectedRoute: ""
|
||||
};
|
||||
@@ -0,0 +1,172 @@
|
||||
export type TabKey = "normalized" | "fragments" | "scope" | "flags" | "route" | "raw" | "validation" | "logs";
|
||||
|
||||
export interface ConnectionState {
|
||||
apiKey: string;
|
||||
model: string;
|
||||
baseUrl: string;
|
||||
temperature: number;
|
||||
maxOutputTokens: number;
|
||||
}
|
||||
|
||||
export interface PromptState {
|
||||
systemPrompt: string;
|
||||
developerPrompt: string;
|
||||
domainPrompt: string;
|
||||
schemaNotes: string;
|
||||
fewShotExamples: string;
|
||||
}
|
||||
|
||||
export interface QueryState {
|
||||
userQuestion: string;
|
||||
batchQuestionsRaw: string;
|
||||
periodHint: string;
|
||||
businessContext: string;
|
||||
expectedRoute: string;
|
||||
}
|
||||
|
||||
export interface NormalizeResultState {
|
||||
trace_id: string;
|
||||
ok: boolean;
|
||||
normalized: unknown;
|
||||
route_hint_summary: unknown;
|
||||
raw_model_output: unknown;
|
||||
validation: {
|
||||
passed: boolean;
|
||||
errors: string[];
|
||||
};
|
||||
usage: {
|
||||
input_tokens: number;
|
||||
output_tokens: number;
|
||||
total_tokens: number;
|
||||
};
|
||||
latency_ms: number;
|
||||
prompt_version: string;
|
||||
schema_version: string;
|
||||
}
|
||||
|
||||
export interface HistoryItem {
|
||||
trace_id: string;
|
||||
timestamp: string;
|
||||
model: string;
|
||||
question_short: string;
|
||||
confidence: string | null;
|
||||
validation_passed: boolean;
|
||||
route_hint: string | null;
|
||||
save_status: "saved";
|
||||
}
|
||||
|
||||
export interface RuntimeRun {
|
||||
sessionId: string;
|
||||
runId: string;
|
||||
status: string;
|
||||
initiator: string;
|
||||
source: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export type UiMode = "assistant" | "decomposition";
|
||||
|
||||
export type AssistantFallbackType = "none" | "out_of_scope" | "clarification" | "partial" | "unknown";
|
||||
export type AssistantReplyType =
|
||||
| "factual"
|
||||
| "factual_with_explanation"
|
||||
| "partial_coverage"
|
||||
| "clarification_required"
|
||||
| "out_of_scope"
|
||||
| "empty_but_valid"
|
||||
| "no_grounded_answer"
|
||||
| "route_mismatch_blocked"
|
||||
| "backend_error";
|
||||
export type RetrievalResultStatus = "ok" | "empty" | "partial" | "error";
|
||||
export type RetrievalResultType = "list" | "summary" | "object" | "chain" | "ranking";
|
||||
export type RetrievalConfidence = "high" | "medium" | "low";
|
||||
|
||||
export interface AssistantRequirement {
|
||||
requirement_id: string;
|
||||
source_fragment_id: string | null;
|
||||
requirement_text: string;
|
||||
subject_tokens: string[];
|
||||
status: "covered" | "partially_covered" | "uncovered" | "clarification_needed" | "out_of_scope";
|
||||
route: string | null;
|
||||
}
|
||||
|
||||
export interface RequirementCoverageReport {
|
||||
requirements_total: number;
|
||||
requirements_covered: number;
|
||||
requirements_uncovered: string[];
|
||||
requirements_partially_covered: string[];
|
||||
clarification_needed_for: string[];
|
||||
out_of_scope_requirements: string[];
|
||||
}
|
||||
|
||||
export interface AnswerGroundingCheck {
|
||||
status: "grounded" | "partial" | "no_grounded_answer" | "route_mismatch_blocked";
|
||||
route_subject_match: boolean;
|
||||
missing_requirements: string[];
|
||||
reasons: string[];
|
||||
why_included_summary: string[];
|
||||
selection_reason_summary: string[];
|
||||
}
|
||||
|
||||
export interface UnifiedRetrievalResult {
|
||||
fragment_id: string;
|
||||
requirement_ids: string[];
|
||||
route: string;
|
||||
status: RetrievalResultStatus;
|
||||
result_type: RetrievalResultType;
|
||||
items: Array<Record<string, unknown>>;
|
||||
summary: Record<string, unknown>;
|
||||
evidence: Array<Record<string, unknown>>;
|
||||
why_included: string[];
|
||||
selection_reason: string[];
|
||||
risk_factors: string[];
|
||||
business_interpretation: string[];
|
||||
confidence: RetrievalConfidence;
|
||||
limitations: string[];
|
||||
errors: string[];
|
||||
}
|
||||
|
||||
export interface AssistantDebugState {
|
||||
trace_id: string;
|
||||
prompt_version: string;
|
||||
schema_version: string;
|
||||
fallback_type: AssistantFallbackType;
|
||||
route_summary: unknown;
|
||||
fragments: unknown[];
|
||||
requirements_extracted: AssistantRequirement[];
|
||||
coverage_report: RequirementCoverageReport;
|
||||
routes: Array<Record<string, unknown>>;
|
||||
retrieval_status: Array<{
|
||||
fragment_id: string;
|
||||
requirement_ids: string[];
|
||||
route: string;
|
||||
status: RetrievalResultStatus;
|
||||
result_type: RetrievalResultType;
|
||||
}>;
|
||||
retrieval_results: UnifiedRetrievalResult[];
|
||||
answer_grounding_check: AnswerGroundingCheck;
|
||||
dropped_intent_segments: string[];
|
||||
normalized: unknown;
|
||||
}
|
||||
|
||||
export interface AssistantConversationItem {
|
||||
message_id: string;
|
||||
session_id: string;
|
||||
role: "user" | "assistant";
|
||||
text: string;
|
||||
reply_type: AssistantReplyType | null;
|
||||
created_at: string;
|
||||
trace_id: string | null;
|
||||
debug: AssistantDebugState | null;
|
||||
}
|
||||
|
||||
export interface AssistantMessageResultState {
|
||||
ok: boolean;
|
||||
session_id: string;
|
||||
assistant_reply: string;
|
||||
reply_type: AssistantReplyType;
|
||||
conversation_item: AssistantConversationItem;
|
||||
debug: AssistantDebugState;
|
||||
conversation: AssistantConversationItem[];
|
||||
}
|
||||
Reference in New Issue
Block a user