From c37f792afacd1e10938e397d8e04d87eafa43874 Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Fri, 29 Mar 2024 10:54:01 -0700 Subject: [PATCH] Better way to handle user_bio default in the API (alternative to bdcf31035f06d666f01339c9af2447d6c2b83bcc) --- extensions/openai/completions.py | 2 ++ extensions/openai/typing.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/extensions/openai/completions.py b/extensions/openai/completions.py index 3bc5170a..5925101a 100644 --- a/extensions/openai/completions.py +++ b/extensions/openai/completions.py @@ -261,6 +261,7 @@ def chat_completions_common(body: dict, is_legacy: bool = False, stream=False) - name2 = body['bot_name'] or name2 context = body['context'] or context greeting = body['greeting'] or greeting + user_bio = body['user_bio'] or '' # History user_input, custom_system_message, history = convert_history(messages) @@ -271,6 +272,7 @@ def chat_completions_common(body: dict, is_legacy: bool = False, stream=False) - 'name2': name2, 'context': context, 'greeting': greeting, + 'user_bio': user_bio, 'instruction_template_str': instruction_template_str, 'custom_system_message': custom_system_message, 'chat_template_str': chat_template_str, diff --git a/extensions/openai/typing.py b/extensions/openai/typing.py index dbfa7167..c3ef0404 100644 --- a/extensions/openai/typing.py +++ b/extensions/openai/typing.py @@ -103,7 +103,7 @@ class ChatCompletionRequestParams(BaseModel): context: str | None = Field(default=None, description="Overwrites the value set by character field.") greeting: str | None = Field(default=None, description="Overwrites the value set by character field.") user_name: str | None = Field(default=None, description="Your name (the user). By default, it's \"You\".", alias="name1") - user_bio: str | None = Field(default='', description="The user description/personality.") + user_bio: str | None = Field(default=None, description="The user description/personality.") chat_template_str: str | None = Field(default=None, description="Jinja2 template for chat.") chat_instruct_command: str | None = None