Gracefully handle null content in Duo Chat history
What I see:
Requests to /v1/chat/agent where there is content: null
anywhere in the history will return a 422.
What I expect to see:
Requests to /v1/chat/agent where there is content: null
anywhere in the history will return a helpful response.
More context
If Duo Chat ever returns null
for an assistant message in the Chat history, sending that history with a new Duo Chat request (which is what we do unless /clear
is run) will result in a 422.
The AI Gateway should handle this more gracefully and not return a 422. We want to keep validations in place for user messages, but maybe we can relax this requirement for assistant
responses?
Example request body for AI Gateway API request that returns a 422 (tested at http://127.0.0.1:5052/docs#/chat/chat_v1_chat__chat_invokable__post
):
{
"prompt_components": [
{
"type": "string",
"metadata": {
"source": "string",
"version": "string"
},
"payload": {
"content": [{"role":"user","content":"How do I change my password in GitLab?"},{"role":"assistant","content":null},{"role":"user","content":"hi!"}],
"provider": "anthropic",
"model": "claude-2.0",
"params": {
"stop_sequences": [
"\n\nHuman",
"Observation:"
],
"temperature": 0.2,
"max_tokens_to_sample": 2048
},
"model_endpoint": "string",
"model_api_key": "string"
}
}
],
"stream": false
}