Skip to content

Commit 4874c0e

Browse files
authored
fix: AI dialogue context removes form data (#2257)
1 parent 6a5ec86 commit 4874c0e

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

apps/application/flow/step_node/ai_chat_step_node/impl/base_chat_node.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
@date:2024/6/4 14:30
77
@desc:
88
"""
9+
import re
910
import time
1011
from functools import reduce
1112
from typing import List, Dict
@@ -14,7 +15,6 @@
1415
from langchain.schema import HumanMessage, SystemMessage
1516
from langchain_core.messages import BaseMessage, AIMessage
1617

17-
from application.flow.common import Answer
1818
from application.flow.i_step_node import NodeResult, INode
1919
from application.flow.step_node.ai_chat_step_node.i_chat_node import IChatNode
2020
from application.flow.tools import Reasoning
@@ -181,6 +181,9 @@ def get_history_message(history_chat_record, dialogue_number, dialogue_type, run
181181
get_message(history_chat_record[index], dialogue_type, runtime_node_id)
182182
for index in
183183
range(start_index if start_index > 0 else 0, len(history_chat_record))], [])
184+
for message in history_message:
185+
if isinstance(message.content, str):
186+
message.content = re.sub('<form_rander>[\d\D]*?<\/form_rander>', '', message.content)
184187
return history_message
185188

186189
def generate_prompt_question(self, prompt):

apps/application/flow/step_node/question_node/impl/base_question_node.py

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
@date:2024/6/4 14:30
77
@desc:
88
"""
9+
import re
910
import time
1011
from functools import reduce
1112
from typing import List, Dict
@@ -114,6 +115,9 @@ def get_history_message(history_chat_record, dialogue_number):
114115
[history_chat_record[index].get_human_message(), history_chat_record[index].get_ai_message()]
115116
for index in
116117
range(start_index if start_index > 0 else 0, len(history_chat_record))], [])
118+
for message in history_message:
119+
if isinstance(message.content, str):
120+
message.content = re.sub('<form_rander>[\d\D]*?<\/form_rander>', '', message.content)
117121
return history_message
118122

119123
def generate_prompt_question(self, prompt):

0 commit comments

Comments
 (0)