51 lines
1.3 KiB
Python
51 lines
1.3 KiB
Python
from __future__ import annotations
|
|
|
|
from typing import Literal
|
|
from uuid import UUID
|
|
|
|
from pydantic import Field
|
|
|
|
from .common import ApiEnvelope, JsonObject, JsonValue, RouteContract, SchemaModel
|
|
|
|
HTTP_METHOD = 'POST'
|
|
ROUTE_PATH = '/api/rag/chat/'
|
|
|
|
|
|
class RagChatRequest(SchemaModel):
|
|
farm_uuid: UUID
|
|
query: str | None = None
|
|
message: str | None = None
|
|
history: list[JsonObject] | str | None = None
|
|
image_urls: list[str] = Field(default_factory=list)
|
|
image: str | None = None
|
|
images: list[str] = Field(default_factory=list)
|
|
|
|
|
|
class RagChatSection(SchemaModel):
|
|
type: Literal['recommendation', 'list', 'warning', 'info', 'summary']
|
|
title: str
|
|
icon: str | None = None
|
|
content: str | None = None
|
|
items: list[str] = Field(default_factory=list)
|
|
primaryAction: str | None = None
|
|
timing: str | None = None
|
|
validityPeriod: str | None = None
|
|
expandableExplanation: str | None = None
|
|
metadata: JsonValue | None = None
|
|
|
|
|
|
class RagChatResponseData(SchemaModel):
|
|
sections: list[RagChatSection] = Field(default_factory=list)
|
|
|
|
|
|
class RagChatResponse(ApiEnvelope[RagChatResponseData]):
|
|
pass
|
|
|
|
|
|
CONTRACT = RouteContract(
|
|
method=HTTP_METHOD,
|
|
path=ROUTE_PATH,
|
|
request_model=RagChatRequest.__name__,
|
|
response_model=RagChatResponse.__name__,
|
|
)
|