-
Notifications
You must be signed in to change notification settings - Fork 64
LCORE-390: description for all QueryRequest fields #352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -85,16 +85,70 @@ class QueryRequest(BaseModel): | |||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| query: str | ||||||||||||||||||||||||||||||||||||||||
| conversation_id: Optional[str] = None | ||||||||||||||||||||||||||||||||||||||||
| provider: Optional[str] = None | ||||||||||||||||||||||||||||||||||||||||
| model: Optional[str] = None | ||||||||||||||||||||||||||||||||||||||||
| system_prompt: Optional[str] = None | ||||||||||||||||||||||||||||||||||||||||
| attachments: Optional[list[Attachment]] = None | ||||||||||||||||||||||||||||||||||||||||
| no_tools: Optional[bool] = False | ||||||||||||||||||||||||||||||||||||||||
| query: str = Field( | ||||||||||||||||||||||||||||||||||||||||
| description="The query string", | ||||||||||||||||||||||||||||||||||||||||
| examples=["What is Kubernetes?"], | ||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| conversation_id: Optional[str] = Field( | ||||||||||||||||||||||||||||||||||||||||
| None, | ||||||||||||||||||||||||||||||||||||||||
| description="The optional conversation ID (UUID)", | ||||||||||||||||||||||||||||||||||||||||
| examples=["c5260aec-4d82-4370-9fdf-05cf908b3f16"], | ||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+93
to
+98
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Validate You already have @@
conversation_id: Optional[str] = Field(
None,
description="The optional conversation ID (UUID)",
examples=["c5260aec-4d82-4370-9fdf-05cf908b3f16"],
)
+
+ @field_validator("conversation_id")
+ @classmethod
+ def _validate_conversation_id(cls, v: Optional[str]) -> Optional[str]:
+ if v is None:
+ return v
+ if not suid.check_suid(v):
+ raise ValueError(f"Improper conversation ID {v}")
+ return v📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||
| provider: Optional[str] = Field( | ||||||||||||||||||||||||||||||||||||||||
| None, | ||||||||||||||||||||||||||||||||||||||||
| description="The optional provider", | ||||||||||||||||||||||||||||||||||||||||
| examples=["openai", "watsonx"], | ||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| model: Optional[str] = Field( | ||||||||||||||||||||||||||||||||||||||||
| None, | ||||||||||||||||||||||||||||||||||||||||
| description="The optional model", | ||||||||||||||||||||||||||||||||||||||||
| examples=["gpt4mini"], | ||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| system_prompt: Optional[str] = Field( | ||||||||||||||||||||||||||||||||||||||||
| None, | ||||||||||||||||||||||||||||||||||||||||
| description="The optional system prompt.", | ||||||||||||||||||||||||||||||||||||||||
| examples=["You are OpenShift assistant.", "You are Ansible assistant."], | ||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+111
to
+116
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add reasonable length cap to
- system_prompt: Optional[str] = Field(
- None,
- description="The optional system prompt.",
- examples=["You are OpenShift assistant.", "You are Ansible assistant."],
- )
+ system_prompt: Optional[str] = Field(
+ None,
+ max_length=4096,
+ description="The optional system prompt.",
+ examples=["You are OpenShift assistant.", "You are Ansible assistant."],
+ )📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||
| attachments: Optional[list[Attachment]] = Field( | ||||||||||||||||||||||||||||||||||||||||
| None, | ||||||||||||||||||||||||||||||||||||||||
| description="The optional list of attachments.", | ||||||||||||||||||||||||||||||||||||||||
| examples=[ | ||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||
| "attachment_type": "log", | ||||||||||||||||||||||||||||||||||||||||
| "content_type": "text/plain", | ||||||||||||||||||||||||||||||||||||||||
| "content": "this is attachment", | ||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||
| "attachment_type": "configuration", | ||||||||||||||||||||||||||||||||||||||||
| "content_type": "application/yaml", | ||||||||||||||||||||||||||||||||||||||||
| "content": "kind: Pod\n metadata:\n name: private-reg", | ||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||
| "attachment_type": "configuration", | ||||||||||||||||||||||||||||||||||||||||
| "content_type": "application/yaml", | ||||||||||||||||||||||||||||||||||||||||
| "content": "foo: bar", | ||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| no_tools: Optional[bool] = Field( | ||||||||||||||||||||||||||||||||||||||||
| False, | ||||||||||||||||||||||||||||||||||||||||
| description="Whether to bypass all tools and MCP servers", | ||||||||||||||||||||||||||||||||||||||||
| examples=[True, False], | ||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| # media_type is not used in 'lightspeed-stack' that only supports application/json. | ||||||||||||||||||||||||||||||||||||||||
| # the field is kept here to enable compatibility with 'road-core' clients. | ||||||||||||||||||||||||||||||||||||||||
| media_type: Optional[str] = None | ||||||||||||||||||||||||||||||||||||||||
| media_type: Optional[str] = Field( | ||||||||||||||||||||||||||||||||||||||||
| None, | ||||||||||||||||||||||||||||||||||||||||
| description="Media type (used just to enable compatibility)", | ||||||||||||||||||||||||||||||||||||||||
| examples=["application/json"], | ||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| # provides examples for /docs endpoint | ||||||||||||||||||||||||||||||||||||||||
| model_config = { | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Enforce non-empty
queryand document the requirementqueryis the only mandatory input, yet an empty string would pass validation and yield undefined behaviour downstream.Add a minimal length (or
strip_whitespace=True) to guard against accidental empty submissions:📝 Committable suggestion
🤖 Prompt for AI Agents