mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-02 21:19:12 +00:00
Add list typing to the updated_messages temporary variable
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from typing import Dict
|
from typing import Dict, List
|
||||||
|
|
||||||
import openai
|
import openai
|
||||||
from openai.types.chat.chat_completion import ChatCompletion
|
from openai.types.chat.chat_completion import ChatCompletion
|
||||||
@@ -184,7 +184,7 @@ def llm_thread(
|
|||||||
elif model_name.startswith("deepseek-reasoner"):
|
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.
|
# 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).
|
# The first message should always be a user message (except system message).
|
||||||
updated_messages = []
|
updated_messages: List[dict] = []
|
||||||
for i, message in enumerate(formatted_messages):
|
for i, message in enumerate(formatted_messages):
|
||||||
if i > 0 and message["role"] == formatted_messages[i - 1]["role"]:
|
if i > 0 and message["role"] == formatted_messages[i - 1]["role"]:
|
||||||
updated_messages[-1]["content"] += " " + message["content"]
|
updated_messages[-1]["content"] += " " + message["content"]
|
||||||
|
|||||||
Reference in New Issue
Block a user