added conditions
This commit is contained in:
@@ -638,33 +638,35 @@ class QueryRequest(BaseModel):
|
|||||||
only_need_prompt: Optional[bool] = Field(default=None)
|
only_need_prompt: Optional[bool] = Field(default=None)
|
||||||
|
|
||||||
"""Defines the response format. Examples: 'Multiple Paragraphs', 'Single Paragraph', 'Bullet Points'."""
|
"""Defines the response format. Examples: 'Multiple Paragraphs', 'Single Paragraph', 'Bullet Points'."""
|
||||||
response_type: Optional[str] = Field(default=None)
|
response_type: Optional[str] = Field(min_length=1, default=None)
|
||||||
|
|
||||||
"""Number of top items to retrieve. Represents entities in 'local' mode and relationships in 'global' mode."""
|
"""Number of top items to retrieve. Represents entities in 'local' mode and relationships in 'global' mode."""
|
||||||
top_k: Optional[int] = Field(default=None)
|
top_k: Optional[int] = Field(gt=1, default=None)
|
||||||
|
|
||||||
"""Maximum number of tokens allowed for each retrieved text chunk."""
|
"""Maximum number of tokens allowed for each retrieved text chunk."""
|
||||||
max_token_for_text_unit: Optional[int] = Field(default=None)
|
max_token_for_text_unit: Optional[int] = Field(gt=1, default=None)
|
||||||
|
|
||||||
"""Maximum number of tokens allocated for relationship descriptions in global retrieval."""
|
"""Maximum number of tokens allocated for relationship descriptions in global retrieval."""
|
||||||
max_token_for_global_context: Optional[int] = Field(default=None)
|
max_token_for_global_context: Optional[int] = Field(gt=1, default=None)
|
||||||
|
|
||||||
"""Maximum number of tokens allocated for entity descriptions in local retrieval."""
|
"""Maximum number of tokens allocated for entity descriptions in local retrieval."""
|
||||||
max_token_for_local_context: Optional[int] = Field(default=None)
|
max_token_for_local_context: Optional[int] = Field(gt=1, default=None)
|
||||||
|
|
||||||
"""List of high-level keywords to prioritize in retrieval."""
|
"""List of high-level keywords to prioritize in retrieval."""
|
||||||
hl_keywords: Optional[List[str]] = Field(default=None)
|
hl_keywords: Optional[List[str]] = Field(min_length=1, default=None)
|
||||||
|
|
||||||
"""List of low-level keywords to refine retrieval focus."""
|
"""List of low-level keywords to refine retrieval focus."""
|
||||||
ll_keywords: Optional[List[str]] = Field(default=None)
|
ll_keywords: Optional[List[str]] = Field(min_length=1, default=None)
|
||||||
|
|
||||||
"""Stores past conversation history to maintain context.
|
"""Stores past conversation history to maintain context.
|
||||||
Format: [{"role": "user/assistant", "content": "message"}].
|
Format: [{"role": "user/assistant", "content": "message"}].
|
||||||
"""
|
"""
|
||||||
conversation_history: Optional[List[dict[str, Any]]] = Field(default=None)
|
conversation_history: Optional[List[dict[str, Any]]] = Field(
|
||||||
|
min_length=1, default=None
|
||||||
|
)
|
||||||
|
|
||||||
"""Number of complete conversation turns (user-assistant pairs) to consider in the response context."""
|
"""Number of complete conversation turns (user-assistant pairs) to consider in the response context."""
|
||||||
history_turns: Optional[int] = Field(default=None)
|
history_turns: Optional[int] = Field(gt=1, default=None)
|
||||||
|
|
||||||
|
|
||||||
class QueryResponse(BaseModel):
|
class QueryResponse(BaseModel):
|
||||||
@@ -672,24 +674,21 @@ class QueryResponse(BaseModel):
|
|||||||
|
|
||||||
|
|
||||||
class InsertTextRequest(BaseModel):
|
class InsertTextRequest(BaseModel):
|
||||||
text: str
|
text: str = Field(min_length=1)
|
||||||
|
|
||||||
@field_validator('text', mode='after')
|
@field_validator("text", mode="after")
|
||||||
@classmethod
|
@classmethod
|
||||||
def check_not_empty(cls, text: str) -> str:
|
def strip_after(cls, text: str) -> str:
|
||||||
if not text:
|
return text.strip()
|
||||||
raise ValueError("Text cannot be empty")
|
|
||||||
return text
|
|
||||||
|
|
||||||
class InsertTextsRequest(BaseModel):
|
class InsertTextsRequest(BaseModel):
|
||||||
texts: list[str] = Field(default_factory=list)
|
texts: list[str] = Field(min_length=1)
|
||||||
|
|
||||||
@field_validator('texts', mode='after')
|
@field_validator("texts", mode="after")
|
||||||
@classmethod
|
@classmethod
|
||||||
def check_not_empty(cls, texts: list[str]) -> list[str]:
|
def strip_after(cls, texts: list[str]) -> list[str]:
|
||||||
if not texts:
|
return [text.strip() for text in texts]
|
||||||
raise ValueError("Texts cannot be empty")
|
|
||||||
return texts
|
|
||||||
|
|
||||||
|
|
||||||
class InsertResponse(BaseModel):
|
class InsertResponse(BaseModel):
|
||||||
|
Reference in New Issue
Block a user