mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-02 13:18:18 +00:00
re-enable markdown formatting when chatting with o3
This commit is contained in:
@@ -185,6 +185,17 @@ def llm_thread(
|
||||
model_kwargs.pop("response_format", None)
|
||||
elif model_name.startswith("o3-"):
|
||||
temperature = 1
|
||||
# Get the first system message and add the string `Formatting re-enabled` to it. See https://platform.openai.com/docs/guides/reasoning-best-practices
|
||||
if len(formatted_messages) > 0:
|
||||
system_messages = [
|
||||
(i, message) for i, message in enumerate(formatted_messages) if message["role"] == "system"
|
||||
]
|
||||
if len(system_messages) > 0:
|
||||
first_system_message_index, first_system_message = system_messages[0]
|
||||
formatted_messages[first_system_message_index][
|
||||
"content"
|
||||
] = f"{first_system_message} Formatting re-enabled"
|
||||
|
||||
elif model_name.startswith("deepseek-reasoner"):
|
||||
# Two successive messages cannot be from the same role. Should merge any back-to-back messages from the same role.
|
||||
# The first message should always be a user message (except system message).
|
||||
|
||||
Reference in New Issue
Block a user