refac: rename message_template

This commit is contained in:
Michael Poluektov 2024-07-31 22:01:22 +01:00
parent 2e0fa1c6a0
commit b9b1fdd1a1

View File

@ -88,7 +88,7 @@ def add_or_update_system_message(content: str, messages: List[dict]):
return messages
def message_template(model: str):
def openai_chat_message_template(model: str):
return {
"id": f"{model}-{str(uuid.uuid4())}",
"created": int(time.time()),
@ -98,14 +98,14 @@ def message_template(model: str):
def openai_chat_chunk_message_template(model: str, message: str):
template = message_template(model)
template = openai_chat_message_template(model)
template["object"] = "chat.completion.chunk"
template["choices"][0]["delta"] = {"content": message}
return template
def openai_chat_completion_message_template(model: str, message: str):
template = message_template(model)
template = openai_chat_message_template(model)
template["object"] = "chat.completion"
template["choices"][0]["message"] = {"content": message, "role": "assistant"}
template["choices"][0]["finish_reason"] = "stop"