Skip to content

Commit

Permalink
fix: AI dialogue context removes form data (#2257)
Browse files Browse the repository at this point in the history
  • Loading branch information
shaohuzhang1 authored Feb 12, 2025
1 parent 6a5ec86 commit 4874c0e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
@date:2024/6/4 14:30
@desc:
"""
import re
import time
from functools import reduce
from typing import List, Dict
Expand All @@ -14,7 +15,6 @@
from langchain.schema import HumanMessage, SystemMessage
from langchain_core.messages import BaseMessage, AIMessage

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

def generate_prompt_question(self, prompt):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
@date:2024/6/4 14:30
@desc:
"""
import re
import time
from functools import reduce
from typing import List, Dict
Expand Down Expand Up @@ -114,6 +115,9 @@ def get_history_message(history_chat_record, dialogue_number):
[history_chat_record[index].get_human_message(), history_chat_record[index].get_ai_message()]
for index in
range(start_index if start_index > 0 else 0, len(history_chat_record))], [])
for message in history_message:
if isinstance(message.content, str):
message.content = re.sub('<form_rander>[\d\D]*?<\/form_rander>', '', message.content)
return history_message

def generate_prompt_question(self, prompt):
Expand Down

0 comments on commit 4874c0e

Please sign in to comment.