mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-12 06:29:03 +08:00
feat:add deepseek r1 think display for ollama provider (#13272)
This commit is contained in:
parent
49b4144ffd
commit
0d13aee15c
@ -314,6 +314,7 @@ class OllamaLargeLanguageModel(LargeLanguageModel):
|
|||||||
"""
|
"""
|
||||||
full_text = ""
|
full_text = ""
|
||||||
chunk_index = 0
|
chunk_index = 0
|
||||||
|
is_reasoning_started = False
|
||||||
|
|
||||||
def create_final_llm_result_chunk(
|
def create_final_llm_result_chunk(
|
||||||
index: int, message: AssistantPromptMessage, finish_reason: str
|
index: int, message: AssistantPromptMessage, finish_reason: str
|
||||||
@ -367,6 +368,14 @@ class OllamaLargeLanguageModel(LargeLanguageModel):
|
|||||||
|
|
||||||
# transform assistant message to prompt message
|
# transform assistant message to prompt message
|
||||||
text = chunk_json["response"]
|
text = chunk_json["response"]
|
||||||
|
if "<think>" in text:
|
||||||
|
is_reasoning_started = True
|
||||||
|
text = text.replace("<think>", "> 💭 ")
|
||||||
|
elif "</think>" in text:
|
||||||
|
is_reasoning_started = False
|
||||||
|
text = text.replace("</think>", "") + "\n\n"
|
||||||
|
elif is_reasoning_started:
|
||||||
|
text = text.replace("\n", "\n> ")
|
||||||
|
|
||||||
assistant_prompt_message = AssistantPromptMessage(content=text)
|
assistant_prompt_message = AssistantPromptMessage(content=text)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user