Merge pull request #4342 from michaelpoluektov/fix-non-streaming-function-text

fix: function returning "str"
This commit is contained in:
Timothy Jaeryang Baek 2024-08-04 14:09:12 +02:00 committed by GitHub
commit 05977bd1c7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -97,18 +97,19 @@ def openai_chat_message_template(model: str):
} }
def openai_chat_chunk_message_template(model: str, message: str): def openai_chat_chunk_message_template(model: str, message: str) -> dict:
template = openai_chat_message_template(model) template = openai_chat_message_template(model)
template["object"] = "chat.completion.chunk" template["object"] = "chat.completion.chunk"
template["choices"][0]["delta"] = {"content": message} template["choices"][0]["delta"] = {"content": message}
return template return template
def openai_chat_completion_message_template(model: str, message: str): def openai_chat_completion_message_template(model: str, message: str) -> dict:
template = openai_chat_message_template(model) template = openai_chat_message_template(model)
template["object"] = "chat.completion" template["object"] = "chat.completion"
template["choices"][0]["message"] = {"content": message, "role": "assistant"} template["choices"][0]["message"] = {"content": message, "role": "assistant"}
template["choices"][0]["finish_reason"] = "stop" template["choices"][0]["finish_reason"] = "stop"
return template
def get_gravatar_url(email): def get_gravatar_url(email):