OAI: Relax role requirement for chat completion message lists

Make it so any message role can be parsed from a list. Not really
sure why this is the case because system and assistant shouldn't be
sending data other than text, but it also doesn't make much sense
to be extremely strict with roles either.

Signed-off-by: kingbri <bdashore3@proton.me>
This commit is contained in:
kingbri 2024-09-22 22:42:06 -04:00
parent 2cda890deb
commit fb903ecddf

View file

@ -217,7 +217,7 @@ async def format_prompt_with_template(
# Deal with list in messages.content
# Just replace the content list with the very first text message
for message in data.messages:
if message["role"] == "user" and isinstance(message["content"], list):
if isinstance(message["content"], list):
message["content"] = next(
(
content["text"]