1804 lines
45 KiB
YAML
1804 lines
45 KiB
YAML
openapi: 3.1.0
|
|
info:
|
|
title: Yuqei AI Platform API
|
|
version: 0.1.0
|
|
description: V2 AI platform contract for model routing, legal QA, legal review, knowledge bases, and AI audit.
|
|
servers:
|
|
- url: http://localhost:8101
|
|
description: Local AI platform
|
|
paths:
|
|
/health:
|
|
get:
|
|
operationId: getHealth
|
|
summary: Health check
|
|
responses:
|
|
"200":
|
|
description: Service health
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: "#/components/schemas/HealthResponse"
|
|
/api/v1/legal/qa:
|
|
post:
|
|
operationId: runLegalQa
|
|
summary: Answer a legal question with citations
|
|
parameters:
|
|
- $ref: "#/components/parameters/TraceIdHeader"
|
|
- $ref: "#/components/parameters/TenantIdHeader"
|
|
- $ref: "#/components/parameters/UserIdHeader"
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: "#/components/schemas/LegalQaRequest"
|
|
responses:
|
|
"200":
|
|
description: Legal QA answer
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: "#/components/schemas/LegalQaResponse"
|
|
/api/v1/legal/review:
|
|
post:
|
|
operationId: runLegalReview
|
|
summary: Review contract text and return structured risks
|
|
parameters:
|
|
- $ref: "#/components/parameters/TraceIdHeader"
|
|
- $ref: "#/components/parameters/TenantIdHeader"
|
|
- $ref: "#/components/parameters/UserIdHeader"
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: "#/components/schemas/LegalReviewRequest"
|
|
responses:
|
|
"200":
|
|
description: Legal review result
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: "#/components/schemas/LegalReviewResponse"
|
|
/api/v1/ai/chat/stream:
|
|
post:
|
|
operationId: streamChat
|
|
summary: Stream AI chat events
|
|
parameters:
|
|
- $ref: "#/components/parameters/TraceIdHeader"
|
|
- $ref: "#/components/parameters/TenantIdHeader"
|
|
- $ref: "#/components/parameters/UserIdHeader"
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: "#/components/schemas/ChatStreamRequest"
|
|
responses:
|
|
"200":
|
|
description: Server-sent events stream
|
|
content:
|
|
text/event-stream:
|
|
schema:
|
|
type: string
|
|
/api/v1/model-configs:
|
|
get:
|
|
operationId: listModelConfigs
|
|
summary: List model provider configs
|
|
responses:
|
|
"200":
|
|
description: Model provider configs
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: array
|
|
items:
|
|
$ref: "#/components/schemas/ProviderConfig"
|
|
post:
|
|
operationId: upsertModelConfig
|
|
summary: Create or update a model provider config
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: "#/components/schemas/ProviderConfigCreate"
|
|
responses:
|
|
"200":
|
|
description: Model provider config
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: "#/components/schemas/ProviderConfig"
|
|
/api/v1/prompt-templates:
|
|
get:
|
|
operationId: listPromptTemplates
|
|
summary: List prompt templates
|
|
responses:
|
|
"200":
|
|
description: Prompt templates
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: array
|
|
items:
|
|
$ref: "#/components/schemas/PromptTemplate"
|
|
post:
|
|
operationId: upsertPromptTemplate
|
|
summary: Create or update a prompt template
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: "#/components/schemas/PromptTemplateCreate"
|
|
responses:
|
|
"200":
|
|
description: Prompt template
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: "#/components/schemas/PromptTemplate"
|
|
/api/v1/knowledge-bases:
|
|
get:
|
|
operationId: listKnowledgeBases
|
|
summary: List knowledge bases
|
|
parameters:
|
|
- $ref: "#/components/parameters/TenantIdHeader"
|
|
- $ref: "#/components/parameters/Page"
|
|
- $ref: "#/components/parameters/PageSize"
|
|
responses:
|
|
"200":
|
|
description: Knowledge base page
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: "#/components/schemas/KnowledgeBasePage"
|
|
post:
|
|
operationId: createKnowledgeBase
|
|
summary: Create a knowledge base
|
|
parameters:
|
|
- $ref: "#/components/parameters/TenantIdHeader"
|
|
- $ref: "#/components/parameters/UserIdHeader"
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: "#/components/schemas/CreateKnowledgeBaseRequest"
|
|
responses:
|
|
"200":
|
|
description: Created knowledge base
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: "#/components/schemas/KnowledgeBase"
|
|
/api/v1/knowledge-bases/{knowledge_base_id}/documents:
|
|
post:
|
|
operationId: uploadKnowledgeDocument
|
|
summary: Upload a knowledge document
|
|
parameters:
|
|
- $ref: "#/components/parameters/TenantIdHeader"
|
|
- $ref: "#/components/parameters/UserIdHeader"
|
|
- name: knowledge_base_id
|
|
in: path
|
|
required: true
|
|
schema:
|
|
type: string
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
multipart/form-data:
|
|
schema:
|
|
type: object
|
|
required:
|
|
- file
|
|
properties:
|
|
file:
|
|
type: string
|
|
format: binary
|
|
responses:
|
|
"200":
|
|
description: Uploaded document
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: "#/components/schemas/KnowledgeDocument"
|
|
/api/v1/knowledge-documents:
|
|
post:
|
|
operationId: addKnowledgeDocument
|
|
summary: Add a text knowledge document
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: "#/components/schemas/KnowledgeDocumentCreate"
|
|
responses:
|
|
"200":
|
|
description: Knowledge document
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: "#/components/schemas/KnowledgeDocument"
|
|
/api/v1/knowledge-documents/reindex:
|
|
post:
|
|
operationId: reindexKnowledgeDocuments
|
|
summary: Rebuild knowledge document chunks with the current embedding provider
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: "#/components/schemas/KnowledgeReindexRequest"
|
|
responses:
|
|
"200":
|
|
description: Reindex result
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: "#/components/schemas/KnowledgeReindexResult"
|
|
/api/v1/knowledge-import-batches:
|
|
get:
|
|
operationId: listKnowledgeImportBatches
|
|
summary: List knowledge import batches
|
|
parameters:
|
|
- name: knowledge_base_id
|
|
in: query
|
|
required: false
|
|
schema:
|
|
type: string
|
|
- name: limit
|
|
in: query
|
|
required: false
|
|
schema:
|
|
type: integer
|
|
default: 20
|
|
minimum: 1
|
|
maximum: 100
|
|
responses:
|
|
"200":
|
|
description: Knowledge import batches
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: array
|
|
items:
|
|
$ref: "#/components/schemas/KnowledgeImportBatch"
|
|
post:
|
|
operationId: createKnowledgeImportBatch
|
|
summary: Create a knowledge import batch
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: "#/components/schemas/KnowledgeImportBatchCreate"
|
|
responses:
|
|
"200":
|
|
description: Knowledge import batch
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: "#/components/schemas/KnowledgeImportBatch"
|
|
/api/v1/knowledge-documents/{document_id}/chunks:
|
|
get:
|
|
operationId: listKnowledgeChunks
|
|
summary: List chunks for a knowledge document
|
|
parameters:
|
|
- name: document_id
|
|
in: path
|
|
required: true
|
|
schema:
|
|
type: string
|
|
responses:
|
|
"200":
|
|
description: Knowledge chunks
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: array
|
|
items:
|
|
$ref: "#/components/schemas/KnowledgeChunk"
|
|
/api/v1/knowledge-documents/search:
|
|
get:
|
|
operationId: searchKnowledgeDocuments
|
|
summary: Search knowledge documents
|
|
parameters:
|
|
- name: keyword
|
|
in: query
|
|
required: false
|
|
schema:
|
|
type: string
|
|
default: ""
|
|
- name: limit
|
|
in: query
|
|
required: false
|
|
schema:
|
|
type: integer
|
|
default: 5
|
|
minimum: 1
|
|
maximum: 20
|
|
- name: knowledge_base_id
|
|
in: query
|
|
required: false
|
|
schema:
|
|
type: string
|
|
responses:
|
|
"200":
|
|
description: Knowledge document matches
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: array
|
|
items:
|
|
$ref: "#/components/schemas/KnowledgeDocument"
|
|
/api/v1/knowledge-chunks/search:
|
|
get:
|
|
operationId: searchKnowledgeChunks
|
|
summary: Search knowledge chunks with relevance score and locator
|
|
parameters:
|
|
- name: keyword
|
|
in: query
|
|
required: false
|
|
schema:
|
|
type: string
|
|
default: ""
|
|
- name: knowledge_base_id
|
|
in: query
|
|
required: false
|
|
schema:
|
|
type: string
|
|
- name: limit
|
|
in: query
|
|
required: false
|
|
schema:
|
|
type: integer
|
|
default: 5
|
|
minimum: 1
|
|
maximum: 20
|
|
- name: strategy
|
|
in: query
|
|
required: false
|
|
schema:
|
|
type: string
|
|
enum: [keyword, vector, hybrid]
|
|
default: hybrid
|
|
responses:
|
|
"200":
|
|
description: Knowledge chunk matches
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: array
|
|
items:
|
|
$ref: "#/components/schemas/KnowledgeSearchResult"
|
|
/api/v1/knowledge-chunks/search/explain:
|
|
get:
|
|
operationId: explainKnowledgeSearch
|
|
summary: Explain knowledge chunk retrieval scoring and filtering
|
|
parameters:
|
|
- name: keyword
|
|
in: query
|
|
required: false
|
|
schema:
|
|
type: string
|
|
default: ""
|
|
- name: knowledge_base_id
|
|
in: query
|
|
required: false
|
|
schema:
|
|
type: string
|
|
- name: limit
|
|
in: query
|
|
required: false
|
|
schema:
|
|
type: integer
|
|
default: 5
|
|
minimum: 1
|
|
maximum: 20
|
|
- name: candidate_limit
|
|
in: query
|
|
required: false
|
|
schema:
|
|
type: integer
|
|
default: 20
|
|
minimum: 1
|
|
maximum: 100
|
|
- name: strategy
|
|
in: query
|
|
required: false
|
|
schema:
|
|
type: string
|
|
enum: [keyword, vector, hybrid]
|
|
default: hybrid
|
|
responses:
|
|
"200":
|
|
description: Retrieval explain result
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: "#/components/schemas/KnowledgeSearchExplain"
|
|
/api/v1/audit/ai-runs:
|
|
get:
|
|
operationId: listAiRuns
|
|
summary: List AI audit runs
|
|
parameters:
|
|
- name: limit
|
|
in: query
|
|
required: false
|
|
schema:
|
|
type: integer
|
|
default: 20
|
|
minimum: 1
|
|
maximum: 100
|
|
responses:
|
|
"200":
|
|
description: AI run audit list
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: array
|
|
items:
|
|
$ref: "#/components/schemas/AiRun"
|
|
/api/v1/audit/quality-dashboard:
|
|
get:
|
|
operationId: getQualityDashboard
|
|
summary: Get AI quality operation dashboard
|
|
parameters:
|
|
- name: days
|
|
in: query
|
|
required: false
|
|
schema:
|
|
type: integer
|
|
default: 14
|
|
minimum: 1
|
|
maximum: 90
|
|
- name: pending_limit
|
|
in: query
|
|
required: false
|
|
schema:
|
|
type: integer
|
|
default: 20
|
|
minimum: 1
|
|
maximum: 100
|
|
responses:
|
|
"200":
|
|
description: AI quality dashboard
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: "#/components/schemas/AiQualityDashboard"
|
|
/api/v1/audit/quality-improvement-actions:
|
|
get:
|
|
operationId: listQualityImprovementActions
|
|
summary: List AI quality improvement actions
|
|
parameters:
|
|
- name: status
|
|
in: query
|
|
required: false
|
|
schema:
|
|
type: string
|
|
enum: [open, in_progress, resolved, false_positive, closed]
|
|
- name: owner
|
|
in: query
|
|
required: false
|
|
schema:
|
|
type: string
|
|
minLength: 1
|
|
maxLength: 128
|
|
- name: priority
|
|
in: query
|
|
required: false
|
|
schema:
|
|
type: string
|
|
enum: [low, medium, high, critical]
|
|
- name: action_type
|
|
in: query
|
|
required: false
|
|
schema:
|
|
type: string
|
|
enum: [investigate, tune_prompt, improve_knowledge, tune_model, mark_false_positive]
|
|
- name: dimension
|
|
in: query
|
|
required: false
|
|
schema:
|
|
type: string
|
|
enum: [model, prompt_template, knowledge_base, label_code]
|
|
- name: limit
|
|
in: query
|
|
required: false
|
|
schema:
|
|
type: integer
|
|
default: 20
|
|
minimum: 1
|
|
maximum: 100
|
|
responses:
|
|
"200":
|
|
description: AI quality improvement actions
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: array
|
|
items:
|
|
$ref: "#/components/schemas/AiQualityImprovementAction"
|
|
post:
|
|
operationId: createQualityImprovementAction
|
|
summary: Create an AI quality improvement action from attribution
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: "#/components/schemas/AiQualityImprovementActionCreate"
|
|
responses:
|
|
"200":
|
|
description: Created AI quality improvement action
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: "#/components/schemas/AiQualityImprovementAction"
|
|
/api/v1/audit/quality-improvement-actions/{action_id}:
|
|
patch:
|
|
operationId: updateQualityImprovementAction
|
|
summary: Update an AI quality improvement action status
|
|
parameters:
|
|
- name: action_id
|
|
in: path
|
|
required: true
|
|
schema:
|
|
type: string
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: "#/components/schemas/AiQualityImprovementActionUpdate"
|
|
responses:
|
|
"200":
|
|
description: Updated AI quality improvement action
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: "#/components/schemas/AiQualityImprovementAction"
|
|
/api/v1/audit/ai-runs/{run_id}/quality-labels/{label_code}:
|
|
patch:
|
|
operationId: updateAiRunQualityLabel
|
|
summary: Update AI run quality label review status
|
|
parameters:
|
|
- name: run_id
|
|
in: path
|
|
required: true
|
|
schema:
|
|
type: string
|
|
- name: label_code
|
|
in: path
|
|
required: true
|
|
schema:
|
|
type: string
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: "#/components/schemas/AiQualityLabelReviewUpdate"
|
|
responses:
|
|
"200":
|
|
description: Updated AI run audit
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: "#/components/schemas/AiRun"
|
|
/api/v1/quality-rules/default:
|
|
get:
|
|
operationId: getQualityRuleConfig
|
|
summary: Get default AI quality rule config
|
|
responses:
|
|
"200":
|
|
description: AI quality rule config
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: "#/components/schemas/AiQualityRuleConfig"
|
|
put:
|
|
operationId: upsertQualityRuleConfig
|
|
summary: Update default AI quality rule config
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: "#/components/schemas/AiQualityRuleConfigUpdate"
|
|
responses:
|
|
"200":
|
|
description: AI quality rule config
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: "#/components/schemas/AiQualityRuleConfig"
|
|
components:
|
|
parameters:
|
|
TraceIdHeader:
|
|
name: X-Trace-Id
|
|
in: header
|
|
required: false
|
|
schema:
|
|
type: string
|
|
TenantIdHeader:
|
|
name: X-Tenant-Id
|
|
in: header
|
|
required: true
|
|
schema:
|
|
type: string
|
|
UserIdHeader:
|
|
name: X-User-Id
|
|
in: header
|
|
required: true
|
|
schema:
|
|
type: string
|
|
Page:
|
|
name: page
|
|
in: query
|
|
required: false
|
|
schema:
|
|
type: integer
|
|
minimum: 1
|
|
default: 1
|
|
PageSize:
|
|
name: page_size
|
|
in: query
|
|
required: false
|
|
schema:
|
|
type: integer
|
|
minimum: 1
|
|
maximum: 100
|
|
default: 20
|
|
schemas:
|
|
HealthResponse:
|
|
type: object
|
|
required:
|
|
- status
|
|
- service
|
|
- version
|
|
- environment
|
|
- provider_config_source
|
|
properties:
|
|
status:
|
|
type: string
|
|
enum: [ok]
|
|
service:
|
|
type: string
|
|
version:
|
|
type: string
|
|
environment:
|
|
type: string
|
|
provider_config_source:
|
|
type: string
|
|
LegalCitation:
|
|
type: object
|
|
required:
|
|
- source_type
|
|
- title
|
|
- reference
|
|
- quote
|
|
properties:
|
|
source_type:
|
|
type: string
|
|
enum: [law, regulation, judicial_interpretation, internal_policy, contract_clause, knowledge_document]
|
|
title:
|
|
type: string
|
|
reference:
|
|
type: string
|
|
description: Article, clause, section, or document locator.
|
|
quote:
|
|
type: string
|
|
url:
|
|
type: string
|
|
nullable: true
|
|
score:
|
|
type: number
|
|
format: float
|
|
nullable: true
|
|
locator:
|
|
type: string
|
|
nullable: true
|
|
document_id:
|
|
type: string
|
|
nullable: true
|
|
chunk_id:
|
|
type: string
|
|
nullable: true
|
|
knowledge_base_id:
|
|
type: string
|
|
nullable: true
|
|
keyword_score:
|
|
type: number
|
|
format: float
|
|
nullable: true
|
|
vector_score:
|
|
type: number
|
|
format: float
|
|
nullable: true
|
|
hybrid_score:
|
|
type: number
|
|
format: float
|
|
nullable: true
|
|
retrieval_strategy:
|
|
type: string
|
|
nullable: true
|
|
matched_terms:
|
|
type: array
|
|
items:
|
|
type: string
|
|
LegalQaRequest:
|
|
type: object
|
|
required:
|
|
- question
|
|
properties:
|
|
question:
|
|
type: string
|
|
matter_context:
|
|
type: string
|
|
nullable: true
|
|
knowledge_base_ids:
|
|
type: array
|
|
items:
|
|
type: string
|
|
retrieval_strategy:
|
|
type: string
|
|
enum: [keyword, vector, hybrid]
|
|
default: hybrid
|
|
LegalQaResponse:
|
|
type: object
|
|
required:
|
|
- answer
|
|
- citations
|
|
properties:
|
|
answer:
|
|
type: string
|
|
citations:
|
|
type: array
|
|
items:
|
|
$ref: "#/components/schemas/LegalCitation"
|
|
primary_sources:
|
|
type: array
|
|
items:
|
|
$ref: "#/components/schemas/LegalCitation"
|
|
confidence:
|
|
type: number
|
|
format: float
|
|
nullable: true
|
|
LegalReviewRequest:
|
|
type: object
|
|
required:
|
|
- text
|
|
properties:
|
|
title:
|
|
type: string
|
|
nullable: true
|
|
text:
|
|
type: string
|
|
contract_type:
|
|
type: string
|
|
nullable: true
|
|
review_perspective:
|
|
type: string
|
|
enum: [party_a, party_b, neutral]
|
|
default: neutral
|
|
knowledge_base_ids:
|
|
type: array
|
|
items:
|
|
type: string
|
|
RiskItem:
|
|
type: object
|
|
required:
|
|
- id
|
|
- severity
|
|
- title
|
|
- description
|
|
properties:
|
|
id:
|
|
type: string
|
|
severity:
|
|
type: string
|
|
enum: [high, medium, low]
|
|
title:
|
|
type: string
|
|
description:
|
|
type: string
|
|
suggestion:
|
|
type: string
|
|
nullable: true
|
|
citations:
|
|
type: array
|
|
items:
|
|
$ref: "#/components/schemas/LegalCitation"
|
|
LegalReviewResponse:
|
|
type: object
|
|
required:
|
|
- risk_summary
|
|
- risk_items
|
|
- review_opinion
|
|
properties:
|
|
risk_summary:
|
|
type: object
|
|
required:
|
|
- high
|
|
- medium
|
|
- low
|
|
- overall
|
|
properties:
|
|
high:
|
|
type: integer
|
|
medium:
|
|
type: integer
|
|
low:
|
|
type: integer
|
|
overall:
|
|
type: string
|
|
enum: [high, medium, low, none]
|
|
risk_items:
|
|
type: array
|
|
items:
|
|
$ref: "#/components/schemas/RiskItem"
|
|
review_opinion:
|
|
type: string
|
|
recommendation:
|
|
type: string
|
|
nullable: true
|
|
ChatStreamRequest:
|
|
type: object
|
|
required:
|
|
- message
|
|
properties:
|
|
message:
|
|
type: string
|
|
conversation_id:
|
|
type: string
|
|
nullable: true
|
|
context:
|
|
type: object
|
|
additionalProperties: true
|
|
ProviderConfigCreate:
|
|
type: object
|
|
required:
|
|
- provider
|
|
- model
|
|
- display_name
|
|
properties:
|
|
provider:
|
|
type: string
|
|
model:
|
|
type: string
|
|
display_name:
|
|
type: string
|
|
base_url:
|
|
type: string
|
|
nullable: true
|
|
temperature:
|
|
type: number
|
|
format: float
|
|
default: 0.2
|
|
max_tokens:
|
|
type: integer
|
|
default: 4096
|
|
enabled:
|
|
type: boolean
|
|
default: true
|
|
is_default:
|
|
type: boolean
|
|
default: false
|
|
ProviderConfig:
|
|
allOf:
|
|
- $ref: "#/components/schemas/ProviderConfigCreate"
|
|
- type: object
|
|
required:
|
|
- id
|
|
- updated_at
|
|
properties:
|
|
id:
|
|
type: string
|
|
updated_at:
|
|
type: string
|
|
format: date-time
|
|
PromptTemplateCreate:
|
|
type: object
|
|
required:
|
|
- name
|
|
- content
|
|
properties:
|
|
name:
|
|
type: string
|
|
version:
|
|
type: string
|
|
default: draft
|
|
content:
|
|
type: string
|
|
enabled:
|
|
type: boolean
|
|
default: true
|
|
PromptTemplate:
|
|
allOf:
|
|
- $ref: "#/components/schemas/PromptTemplateCreate"
|
|
- type: object
|
|
required:
|
|
- id
|
|
- updated_at
|
|
properties:
|
|
id:
|
|
type: string
|
|
updated_at:
|
|
type: string
|
|
format: date-time
|
|
KnowledgeBase:
|
|
type: object
|
|
required:
|
|
- id
|
|
- name
|
|
- status
|
|
properties:
|
|
id:
|
|
type: string
|
|
name:
|
|
type: string
|
|
description:
|
|
type: string
|
|
nullable: true
|
|
status:
|
|
type: string
|
|
enum: [draft, indexing, active, archived]
|
|
KnowledgeBasePage:
|
|
type: object
|
|
required:
|
|
- items
|
|
- page
|
|
- page_size
|
|
- total
|
|
properties:
|
|
items:
|
|
type: array
|
|
items:
|
|
$ref: "#/components/schemas/KnowledgeBase"
|
|
page:
|
|
type: integer
|
|
page_size:
|
|
type: integer
|
|
total:
|
|
type: integer
|
|
CreateKnowledgeBaseRequest:
|
|
type: object
|
|
required:
|
|
- name
|
|
properties:
|
|
name:
|
|
type: string
|
|
description:
|
|
type: string
|
|
nullable: true
|
|
KnowledgeDocument:
|
|
type: object
|
|
required:
|
|
- id
|
|
- knowledge_base_id
|
|
- title
|
|
- source_type
|
|
- reference
|
|
- content
|
|
- created_at
|
|
properties:
|
|
id:
|
|
type: string
|
|
import_batch_id:
|
|
type: string
|
|
nullable: true
|
|
knowledge_base_id:
|
|
type: string
|
|
title:
|
|
type: string
|
|
source_type:
|
|
type: string
|
|
enum: [law, regulation, judicial_interpretation, internal_policy, contract_clause, knowledge_document]
|
|
reference:
|
|
type: string
|
|
content:
|
|
type: string
|
|
index_status:
|
|
type: string
|
|
enum: [pending, indexing, indexed, failed]
|
|
default: indexed
|
|
created_at:
|
|
type: string
|
|
format: date-time
|
|
KnowledgeDocumentCreate:
|
|
type: object
|
|
required:
|
|
- title
|
|
- content
|
|
properties:
|
|
import_batch_id:
|
|
type: string
|
|
nullable: true
|
|
knowledge_base_id:
|
|
type: string
|
|
default: default
|
|
title:
|
|
type: string
|
|
source_type:
|
|
type: string
|
|
default: knowledge_document
|
|
reference:
|
|
type: string
|
|
default: ""
|
|
content:
|
|
type: string
|
|
index_status:
|
|
type: string
|
|
default: indexed
|
|
KnowledgeReindexRequest:
|
|
type: object
|
|
properties:
|
|
document_id:
|
|
type: string
|
|
nullable: true
|
|
knowledge_base_id:
|
|
type: string
|
|
nullable: true
|
|
import_batch_id:
|
|
type: string
|
|
nullable: true
|
|
limit:
|
|
type: integer
|
|
default: 100
|
|
minimum: 1
|
|
maximum: 1000
|
|
KnowledgeReindexResult:
|
|
type: object
|
|
required:
|
|
- documents_count
|
|
- chunks_count
|
|
- embedding_provider
|
|
- embedding_model
|
|
- embedding_dimension
|
|
- document_ids
|
|
properties:
|
|
documents_count:
|
|
type: integer
|
|
chunks_count:
|
|
type: integer
|
|
embedding_provider:
|
|
type: string
|
|
embedding_model:
|
|
type: string
|
|
embedding_dimension:
|
|
type: integer
|
|
document_ids:
|
|
type: array
|
|
items:
|
|
type: string
|
|
KnowledgeImportBatchCreate:
|
|
type: object
|
|
required:
|
|
- source_name
|
|
properties:
|
|
knowledge_base_id:
|
|
type: string
|
|
default: default
|
|
source_name:
|
|
type: string
|
|
source_type:
|
|
type: string
|
|
default: manual_text
|
|
status:
|
|
type: string
|
|
default: indexed
|
|
KnowledgeImportBatch:
|
|
allOf:
|
|
- $ref: "#/components/schemas/KnowledgeImportBatchCreate"
|
|
- type: object
|
|
required:
|
|
- id
|
|
- documents_count
|
|
- chunks_count
|
|
- created_at
|
|
- updated_at
|
|
properties:
|
|
id:
|
|
type: string
|
|
documents_count:
|
|
type: integer
|
|
chunks_count:
|
|
type: integer
|
|
created_at:
|
|
type: string
|
|
format: date-time
|
|
updated_at:
|
|
type: string
|
|
format: date-time
|
|
KnowledgeChunk:
|
|
type: object
|
|
required:
|
|
- id
|
|
- document_id
|
|
- knowledge_base_id
|
|
- title
|
|
- source_type
|
|
- reference
|
|
- content
|
|
- chunk_index
|
|
- locator
|
|
- embedding_provider
|
|
- created_at
|
|
properties:
|
|
id:
|
|
type: string
|
|
document_id:
|
|
type: string
|
|
import_batch_id:
|
|
type: string
|
|
nullable: true
|
|
knowledge_base_id:
|
|
type: string
|
|
title:
|
|
type: string
|
|
source_type:
|
|
type: string
|
|
reference:
|
|
type: string
|
|
content:
|
|
type: string
|
|
chunk_index:
|
|
type: integer
|
|
locator:
|
|
type: string
|
|
embedding_provider:
|
|
type: string
|
|
default: local-hash
|
|
embedding_model:
|
|
type: string
|
|
default: local-hash-v1
|
|
embedding_dimension:
|
|
type: integer
|
|
default: 64
|
|
created_at:
|
|
type: string
|
|
format: date-time
|
|
KnowledgeSearchResult:
|
|
type: object
|
|
required:
|
|
- chunk
|
|
- score
|
|
- matched_terms
|
|
properties:
|
|
chunk:
|
|
$ref: "#/components/schemas/KnowledgeChunk"
|
|
score:
|
|
type: number
|
|
format: float
|
|
keyword_score:
|
|
type: number
|
|
format: float
|
|
vector_score:
|
|
type: number
|
|
format: float
|
|
hybrid_score:
|
|
type: number
|
|
format: float
|
|
retrieval_strategy:
|
|
type: string
|
|
enum: [keyword, vector, hybrid]
|
|
matched_terms:
|
|
type: array
|
|
items:
|
|
type: string
|
|
KnowledgeSearchExplainItem:
|
|
type: object
|
|
required:
|
|
- chunk
|
|
- included
|
|
properties:
|
|
chunk:
|
|
$ref: "#/components/schemas/KnowledgeChunk"
|
|
score:
|
|
type: number
|
|
format: float
|
|
keyword_score:
|
|
type: number
|
|
format: float
|
|
vector_score:
|
|
type: number
|
|
format: float
|
|
hybrid_score:
|
|
type: number
|
|
format: float
|
|
retrieval_strategy:
|
|
type: string
|
|
enum: [keyword, vector, hybrid]
|
|
matched_terms:
|
|
type: array
|
|
items:
|
|
type: string
|
|
included:
|
|
type: boolean
|
|
rank:
|
|
type: integer
|
|
nullable: true
|
|
filter_reason:
|
|
type: string
|
|
nullable: true
|
|
KnowledgeSearchExplain:
|
|
type: object
|
|
required:
|
|
- keyword
|
|
- retrieval_strategy
|
|
- embedding_provider
|
|
- embedding_model
|
|
- results
|
|
properties:
|
|
keyword:
|
|
type: string
|
|
normalized_terms:
|
|
type: array
|
|
items:
|
|
type: string
|
|
retrieval_strategy:
|
|
type: string
|
|
enum: [keyword, vector, hybrid]
|
|
knowledge_base_ids:
|
|
type: array
|
|
items:
|
|
type: string
|
|
limit:
|
|
type: integer
|
|
candidate_limit:
|
|
type: integer
|
|
candidate_count:
|
|
type: integer
|
|
included_count:
|
|
type: integer
|
|
retrieval_backend:
|
|
type: string
|
|
embedding_provider:
|
|
type: string
|
|
embedding_model:
|
|
type: string
|
|
query_embedding_dimension:
|
|
type: integer
|
|
keyword_threshold:
|
|
type: number
|
|
format: float
|
|
vector_threshold:
|
|
type: number
|
|
format: float
|
|
hybrid_keyword_weight:
|
|
type: number
|
|
format: float
|
|
hybrid_vector_weight:
|
|
type: number
|
|
format: float
|
|
results:
|
|
type: array
|
|
items:
|
|
$ref: "#/components/schemas/KnowledgeSearchExplainItem"
|
|
RetrievalSource:
|
|
type: object
|
|
required:
|
|
- title
|
|
- source_type
|
|
- reference
|
|
properties:
|
|
chunk_id:
|
|
type: string
|
|
nullable: true
|
|
document_id:
|
|
type: string
|
|
nullable: true
|
|
knowledge_base_id:
|
|
type: string
|
|
nullable: true
|
|
title:
|
|
type: string
|
|
source_type:
|
|
type: string
|
|
reference:
|
|
type: string
|
|
locator:
|
|
type: string
|
|
nullable: true
|
|
score:
|
|
type: number
|
|
format: float
|
|
keyword_score:
|
|
type: number
|
|
format: float
|
|
vector_score:
|
|
type: number
|
|
format: float
|
|
hybrid_score:
|
|
type: number
|
|
format: float
|
|
retrieval_strategy:
|
|
type: string
|
|
enum: [keyword, vector, hybrid]
|
|
matched_terms:
|
|
type: array
|
|
items:
|
|
type: string
|
|
AiQualityLabel:
|
|
type: object
|
|
required:
|
|
- code
|
|
- title
|
|
- detail
|
|
properties:
|
|
code:
|
|
type: string
|
|
severity:
|
|
type: string
|
|
enum: [info, warning, error]
|
|
default: info
|
|
title:
|
|
type: string
|
|
detail:
|
|
type: string
|
|
review_status:
|
|
type: string
|
|
enum: [pending, reviewed, false_positive, resolved]
|
|
default: pending
|
|
review_note:
|
|
type: string
|
|
nullable: true
|
|
reviewed_by:
|
|
type: string
|
|
nullable: true
|
|
reviewed_at:
|
|
type: string
|
|
format: date-time
|
|
nullable: true
|
|
AiQualityLabelReviewUpdate:
|
|
type: object
|
|
required:
|
|
- review_status
|
|
properties:
|
|
review_status:
|
|
type: string
|
|
enum: [pending, reviewed, false_positive, resolved]
|
|
review_note:
|
|
type: string
|
|
nullable: true
|
|
reviewed_by:
|
|
type: string
|
|
nullable: true
|
|
AiQualityRuleConfigUpdate:
|
|
type: object
|
|
properties:
|
|
min_citation_count:
|
|
type: integer
|
|
minimum: 0
|
|
maximum: 10
|
|
default: 1
|
|
min_source_count:
|
|
type: integer
|
|
minimum: 0
|
|
maximum: 10
|
|
default: 2
|
|
high_token_threshold:
|
|
type: integer
|
|
minimum: 1
|
|
maximum: 1000000
|
|
default: 8000
|
|
high_latency_ms:
|
|
type: integer
|
|
minimum: 1
|
|
maximum: 600000
|
|
default: 15000
|
|
critical_latency_ms:
|
|
type: integer
|
|
minimum: 1
|
|
maximum: 600000
|
|
default: 30000
|
|
warning_penalty:
|
|
type: integer
|
|
minimum: 0
|
|
maximum: 100
|
|
default: 10
|
|
error_penalty:
|
|
type: integer
|
|
minimum: 0
|
|
maximum: 100
|
|
default: 30
|
|
AiQualityRuleConfig:
|
|
allOf:
|
|
- $ref: "#/components/schemas/AiQualityRuleConfigUpdate"
|
|
- type: object
|
|
required:
|
|
- id
|
|
- updated_at
|
|
properties:
|
|
id:
|
|
type: string
|
|
updated_at:
|
|
type: string
|
|
format: date-time
|
|
AiQualityDailyMetric:
|
|
type: object
|
|
properties:
|
|
date:
|
|
type: string
|
|
total_runs:
|
|
type: integer
|
|
passed_runs:
|
|
type: integer
|
|
needs_review_runs:
|
|
type: integer
|
|
failed_quality_runs:
|
|
type: integer
|
|
fallback_runs:
|
|
type: integer
|
|
source_issue_runs:
|
|
type: integer
|
|
token_issue_runs:
|
|
type: integer
|
|
latency_issue_runs:
|
|
type: integer
|
|
pending_labels:
|
|
type: integer
|
|
pass_rate:
|
|
type: number
|
|
format: float
|
|
fallback_rate:
|
|
type: number
|
|
format: float
|
|
source_issue_rate:
|
|
type: number
|
|
format: float
|
|
latency_issue_rate:
|
|
type: number
|
|
format: float
|
|
AiQualityPendingLabel:
|
|
type: object
|
|
properties:
|
|
run_id:
|
|
type: string
|
|
label_code:
|
|
type: string
|
|
severity:
|
|
type: string
|
|
title:
|
|
type: string
|
|
detail:
|
|
type: string
|
|
review_status:
|
|
type: string
|
|
enum: [pending, reviewed, false_positive, resolved]
|
|
created_at:
|
|
type: string
|
|
format: date-time
|
|
question:
|
|
type: string
|
|
nullable: true
|
|
provider:
|
|
type: string
|
|
nullable: true
|
|
model:
|
|
type: string
|
|
nullable: true
|
|
quality_status:
|
|
type: string
|
|
quality_score:
|
|
type: integer
|
|
AiQualityDashboardSummary:
|
|
allOf:
|
|
- $ref: "#/components/schemas/AiQualityDailyMetric"
|
|
- type: object
|
|
properties:
|
|
days:
|
|
type: integer
|
|
AiQualityAttributionItem:
|
|
type: object
|
|
properties:
|
|
dimension:
|
|
type: string
|
|
enum: [model, prompt_template, knowledge_base, label_code]
|
|
key:
|
|
type: string
|
|
label:
|
|
type: string
|
|
total_runs:
|
|
type: integer
|
|
affected_runs:
|
|
type: integer
|
|
warning_labels:
|
|
type: integer
|
|
error_labels:
|
|
type: integer
|
|
pending_labels:
|
|
type: integer
|
|
fallback_runs:
|
|
type: integer
|
|
average_quality_score:
|
|
type: number
|
|
format: float
|
|
top_label_codes:
|
|
type: array
|
|
items:
|
|
type: string
|
|
root_cause_hint:
|
|
type: string
|
|
nullable: true
|
|
AiQualityAttribution:
|
|
type: object
|
|
properties:
|
|
by_model:
|
|
type: array
|
|
items:
|
|
$ref: "#/components/schemas/AiQualityAttributionItem"
|
|
by_prompt_template:
|
|
type: array
|
|
items:
|
|
$ref: "#/components/schemas/AiQualityAttributionItem"
|
|
by_knowledge_base:
|
|
type: array
|
|
items:
|
|
$ref: "#/components/schemas/AiQualityAttributionItem"
|
|
by_label_code:
|
|
type: array
|
|
items:
|
|
$ref: "#/components/schemas/AiQualityAttributionItem"
|
|
AiQualityImprovementActionCreate:
|
|
type: object
|
|
required:
|
|
- dimension
|
|
- key
|
|
- label
|
|
properties:
|
|
dimension:
|
|
type: string
|
|
enum: [model, prompt_template, knowledge_base, label_code]
|
|
key:
|
|
type: string
|
|
minLength: 1
|
|
maxLength: 256
|
|
label:
|
|
type: string
|
|
minLength: 1
|
|
maxLength: 256
|
|
action_type:
|
|
type: string
|
|
enum: [investigate, tune_prompt, improve_knowledge, tune_model, mark_false_positive]
|
|
default: investigate
|
|
title:
|
|
type: string
|
|
nullable: true
|
|
maxLength: 256
|
|
description:
|
|
type: string
|
|
nullable: true
|
|
owner:
|
|
type: string
|
|
nullable: true
|
|
maxLength: 128
|
|
priority:
|
|
type: string
|
|
enum: [low, medium, high, critical]
|
|
default: medium
|
|
source_label_codes:
|
|
type: array
|
|
items:
|
|
type: string
|
|
source_run_ids:
|
|
type: array
|
|
items:
|
|
type: string
|
|
root_cause_hint:
|
|
type: string
|
|
nullable: true
|
|
evaluation_days:
|
|
type: integer
|
|
minimum: 1
|
|
maximum: 90
|
|
default: 14
|
|
AiQualityImprovementActionUpdate:
|
|
type: object
|
|
required:
|
|
- status
|
|
properties:
|
|
status:
|
|
type: string
|
|
enum: [open, in_progress, resolved, false_positive, closed]
|
|
owner:
|
|
type: string
|
|
nullable: true
|
|
maxLength: 128
|
|
priority:
|
|
type: string
|
|
enum: [low, medium, high, critical]
|
|
nullable: true
|
|
resolution_note:
|
|
type: string
|
|
nullable: true
|
|
AiQualityImprovementAction:
|
|
allOf:
|
|
- $ref: "#/components/schemas/AiQualityImprovementActionCreate"
|
|
- type: object
|
|
required:
|
|
- id
|
|
- title
|
|
- status
|
|
- created_at
|
|
- updated_at
|
|
properties:
|
|
id:
|
|
type: string
|
|
title:
|
|
type: string
|
|
status:
|
|
type: string
|
|
enum: [open, in_progress, resolved, false_positive, closed]
|
|
default: open
|
|
baseline_total_runs:
|
|
type: integer
|
|
baseline_affected_runs:
|
|
type: integer
|
|
baseline_pending_labels:
|
|
type: integer
|
|
baseline_quality_score:
|
|
type: number
|
|
format: float
|
|
current_total_runs:
|
|
type: integer
|
|
current_affected_runs:
|
|
type: integer
|
|
current_pending_labels:
|
|
type: integer
|
|
current_quality_score:
|
|
type: number
|
|
format: float
|
|
affected_rate_delta:
|
|
type: number
|
|
format: float
|
|
pending_labels_delta:
|
|
type: integer
|
|
quality_score_delta:
|
|
type: number
|
|
format: float
|
|
effect_status:
|
|
type: string
|
|
enum: [pending_data, improved, unchanged, regressed]
|
|
effect_summary:
|
|
type: string
|
|
nullable: true
|
|
resolution_note:
|
|
type: string
|
|
nullable: true
|
|
created_at:
|
|
type: string
|
|
format: date-time
|
|
updated_at:
|
|
type: string
|
|
format: date-time
|
|
resolved_at:
|
|
type: string
|
|
format: date-time
|
|
nullable: true
|
|
AiQualityDashboard:
|
|
type: object
|
|
properties:
|
|
summary:
|
|
$ref: "#/components/schemas/AiQualityDashboardSummary"
|
|
daily_metrics:
|
|
type: array
|
|
items:
|
|
$ref: "#/components/schemas/AiQualityDailyMetric"
|
|
pending_labels:
|
|
type: array
|
|
items:
|
|
$ref: "#/components/schemas/AiQualityPendingLabel"
|
|
attribution:
|
|
$ref: "#/components/schemas/AiQualityAttribution"
|
|
improvement_actions:
|
|
type: array
|
|
items:
|
|
$ref: "#/components/schemas/AiQualityImprovementAction"
|
|
AiRun:
|
|
type: object
|
|
required:
|
|
- id
|
|
- operation
|
|
- status
|
|
- created_at
|
|
properties:
|
|
id:
|
|
type: string
|
|
operation:
|
|
type: string
|
|
provider_config_id:
|
|
type: string
|
|
nullable: true
|
|
prompt_template_id:
|
|
type: string
|
|
nullable: true
|
|
provider:
|
|
type: string
|
|
nullable: true
|
|
model:
|
|
type: string
|
|
nullable: true
|
|
provider_status:
|
|
type: string
|
|
nullable: true
|
|
provider_error:
|
|
type: string
|
|
nullable: true
|
|
prompt_preview:
|
|
type: string
|
|
nullable: true
|
|
question:
|
|
type: string
|
|
nullable: true
|
|
answer:
|
|
type: string
|
|
nullable: true
|
|
citations_count:
|
|
type: integer
|
|
retrieval_query:
|
|
type: string
|
|
nullable: true
|
|
retrieval_strategy:
|
|
type: string
|
|
nullable: true
|
|
retrieved_chunk_ids:
|
|
type: array
|
|
items:
|
|
type: string
|
|
retrieved_sources:
|
|
type: array
|
|
items:
|
|
$ref: "#/components/schemas/RetrievalSource"
|
|
prompt_tokens:
|
|
type: integer
|
|
completion_tokens:
|
|
type: integer
|
|
total_tokens:
|
|
type: integer
|
|
estimated_cost:
|
|
type: number
|
|
format: float
|
|
latency_ms:
|
|
type: integer
|
|
quality_status:
|
|
type: string
|
|
enum: [unknown, passed, needs_review, failed]
|
|
quality_score:
|
|
type: integer
|
|
quality_labels:
|
|
type: array
|
|
items:
|
|
$ref: "#/components/schemas/AiQualityLabel"
|
|
quality_summary:
|
|
type: string
|
|
nullable: true
|
|
status:
|
|
type: string
|
|
enum: [pending, running, succeeded, fallback, skipped, failed, cancelled]
|
|
created_at:
|
|
type: string
|
|
format: date-time
|
|
AiRunPage:
|
|
type: object
|
|
required:
|
|
- items
|
|
- page
|
|
- page_size
|
|
- total
|
|
properties:
|
|
items:
|
|
type: array
|
|
items:
|
|
$ref: "#/components/schemas/AiRun"
|
|
page:
|
|
type: integer
|
|
page_size:
|
|
type: integer
|
|
total:
|
|
type: integer
|