Skip to content

Commit

Permalink
Merge pull request #2103 from solliancenet/cp-message-history
Browse files Browse the repository at this point in the history
Fix message history for LangGraphReactAgent and ExternalWorkflow path
  • Loading branch information
ciprianjichici authored Dec 22, 2024
2 parents e1ed2a2 + fed6556 commit 789bb4b
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,11 @@ async def invoke_async(self, request: KnowledgeManagementCompletionRequest) -> C

# Define the graph
graph = create_react_agent(llm, tools=tools, state_modifier=self.prompt.prefix)
messages = self._build_conversation_history_message_list(request.message_history, agent.conversation_history_settings.max_history)
if agent.conversation_history_settings.enabled:
messages = self._build_conversation_history_message_list(request.message_history, agent.conversation_history_settings.max_history)
else:
messages = []

messages.append(HumanMessage(content=parsed_user_prompt))

response = await graph.ainvoke(
Expand Down Expand Up @@ -526,8 +530,11 @@ async def invoke_async(self, request: KnowledgeManagementCompletionRequest) -> C
self.user_identity,
self.config)

# Get message history
messages = self._build_conversation_history_message_list(request.message_history, agent.conversation_history_settings.max_history)
# Get message history
if agent.conversation_history_settings.enabled:
messages = self._build_conversation_history_message_list(request.message_history, agent.conversation_history_settings.max_history)
else:
messages = []

response = await workflow.invoke_async(
operation_id=request.operation_id,
Expand Down

0 comments on commit 789bb4b

Please sign in to comment.