55from pydantic import BaseModel , model_validator , field_validator , Field
66from llama_stack_client .types .agents .turn_create_params import Document
77
8+ from log import get_logger
89from utils import suid
910
11+ logger = get_logger (__name__ )
12+
1013
1114class Attachment (BaseModel ):
1215 """Model representing an attachment that can be send from UI as part of query.
@@ -55,8 +58,6 @@ class Attachment(BaseModel):
5558 }
5659
5760
58- # TODO(lucasagomes): add media_type when needed, current implementation
59- # does not support streaming response, so this is not used
6061class QueryRequest (BaseModel ):
6162 """Model representing a request for the LLM (Language Model).
6263
@@ -80,6 +81,9 @@ class QueryRequest(BaseModel):
8081 model : Optional [str ] = None
8182 system_prompt : Optional [str ] = None
8283 attachments : Optional [list [Attachment ]] = None
84+ # media_type is not used in 'lightspeed-stack' that only supports application/json.
85+ # the field is kept here to enable compatibility with 'road-core' clients.
86+ media_type : Optional [str ] = None
8387
8488 # provides examples for /docs endpoint
8589 model_config = {
@@ -132,6 +136,15 @@ def validate_provider_and_model(self) -> Self:
132136 raise ValueError ("Model must be specified if provider is specified" )
133137 return self
134138
139+ @model_validator (mode = "after" )
140+ def validate_media_type (self ) -> Self :
141+ """Log use of media_type that is unsupported but kept for backwards compatibility."""
142+ if self .media_type :
143+ logger .warning (
144+ "media_type was set in the request but is not supported. The value will be ignored."
145+ )
146+ return self
147+
135148
136149class FeedbackRequest (BaseModel ):
137150 """Model representing a feedback request.
0 commit comments