Skip to content

Commit c8ae2d1

Browse files
committed
FEAT: greeting for openai
1 parent 059e65f commit c8ae2d1

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

modules/api/openai.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from config import config
77
from modules.logs import get_logger, log_gui_general_message, log_gui_model_message
88
from modules.servers.tf2 import send_say_command_to_tf2
9-
from modules.typing import MessageHistory
9+
from modules.typing import MessageHistory, Message
1010
from modules.utils.text import add_prompts_by_flags, remove_hashtags
1111

1212
main_logger = get_logger("main")
@@ -64,6 +64,9 @@ def handle_cgpt_request(
6464
gui_logger.error(f"Request '{user_prompt}' violates OPENAI TOS. Skipping...")
6565
return conversation_history
6666

67+
if not conversation_history:
68+
conversation_history.append(Message(role="assistant", content=config.GREETING))
69+
6770
conversation_history.append({"role": "user", "content": message})
6871

6972
response = get_response(conversation_history, username, model)
@@ -94,7 +97,10 @@ def handle_gpt_request(
9497
)
9598
return
9699

97-
response = get_response([{"role": "user", "content": message}], username, model)
100+
response = get_response([
101+
Message(role="assistant", content=config.GREETING),
102+
Message(role="user", content=message)
103+
], username, model)
98104

99105
if response:
100106
main_logger.info(

0 commit comments

Comments
 (0)