Skip to content

Commit 6ae7989

Browse files
committed
name the openai message roles
1 parent ede3ffe commit 6ae7989

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

app/prompt.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from app import settings
2222
from app.const import MISSING, ToolChoice
2323
from app.logging_config import get_logger, setup_logging
24-
from app.settings import TOOL_CHOICE
24+
from app.settings import ASSISTANT_NAME, TOOL_CHOICE
2525
from app.stackademy import stackademy_app
2626
from app.utils import dump_json_colored
2727

@@ -50,10 +50,12 @@
5050
You should respond in a concise and clear manner, providing accurate information based on the user's request.
5151
If you ask a follow up question, then place it at the bottom of the response and precede it with "QUESTION:".
5252
""",
53+
name=ASSISTANT_NAME,
5354
),
5455
ChatCompletionAssistantMessageParam(
5556
role="assistant",
5657
content="How can I assist you with Stackademy today?",
58+
name=ASSISTANT_NAME,
5759
),
5860
]
5961

@@ -109,7 +111,7 @@ def process_tool_calls(message: ChatCompletionMessage) -> list[str]:
109111
assistant_content = message.content if message.content else "Accessing tool..."
110112
messages.append(
111113
ChatCompletionAssistantMessageParam(
112-
role="assistant", content=assistant_content, tool_calls=tool_calls_param
114+
role="assistant", content=assistant_content, tool_calls=tool_calls_param, name=ASSISTANT_NAME
113115
)
114116
)
115117
logger.info("Function call detected: %s with args %s", function_name, function_args)

app/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
# General settings
1717
LOGGING_LEVEL = int(os.getenv("LOGGING_LEVEL", str(logging.INFO)))
1818
TOOL_CHOICE = os.getenv("TOOL_CHOICE", ToolChoice.REQUIRED)
19+
ASSISTANT_NAME = "StackademyAssistant"
1920

2021

2122
# OpenAI API settings

0 commit comments

Comments
 (0)