Relax conversation history role validation requirements
• Remove strict role value checking • Allow any non-empty string roles
This commit is contained in:
parent
ba216787c1
commit
df43afc89b
1 changed files with 4 additions and 4 deletions
|
|
@ -111,10 +111,10 @@ class QueryRequest(BaseModel):
|
||||||
if conversation_history is None:
|
if conversation_history is None:
|
||||||
return None
|
return None
|
||||||
for msg in conversation_history:
|
for msg in conversation_history:
|
||||||
if "role" not in msg or msg["role"] not in {"user", "assistant"}:
|
if "role" not in msg:
|
||||||
raise ValueError(
|
raise ValueError("Each message must have a 'role' key.")
|
||||||
"Each message must have a 'role' key with value 'user' or 'assistant'."
|
if not isinstance(msg["role"], str) or not msg["role"].strip():
|
||||||
)
|
raise ValueError("Each message 'role' must be a non-empty string.")
|
||||||
return conversation_history
|
return conversation_history
|
||||||
|
|
||||||
def to_query_params(self, is_stream: bool) -> "QueryParam":
|
def to_query_params(self, is_stream: bool) -> "QueryParam":
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue