File size: 1,648 Bytes
51f2dc1 dbbd5e7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
from pydantic import BaseModel, Field
# ============================================= Entity + Relations extraction
class ExtractEntitiesRequest(BaseModel):
content: str
class ExtractEntitiesResponse(BaseModel):
entities: list[str] = Field(..., description="A list of entities")
class ExtractedRelation(BaseModel):
start: str = Field(..., description="The first entity in the relationship")
to: str = Field(..., description="The second entity of the relationship")
tag: str = Field(..., description="A tag describing the relationship", examples=[
"related_to", "born_in", "made", "created"])
description: str = Field(...,
description="A detailled description of the relationship")
class ExtractedRelationsResponse(BaseModel):
relations: list[ExtractedRelation]
# ======================================================== Create search plan ==================
class CreateSearchPlanRequest(BaseModel):
query: str
class CreateSearchPlanResponse(BaseModel):
sub_queries: list[str] = Field(...,
description="A list of subqueries formulated as questions")
# ======================================================= Determine intent =========================
class Intent(BaseModel):
target_entity: str = Field(
..., description="One of the entities required to fulfil the user intent")
target_relations: list[str] = Field(
..., description="A list of one or multiple types of relations required to fulfil the user intent")
class ExtractedIntentReponse(BaseModel):
intents: list[Intent]
|