Skip to content

Commit

Permalink
Refactor tool calling agent component: update prompt handling and inp…
Browse files Browse the repository at this point in the history
…ut naming conventions
  • Loading branch information
ogabrielluiz committed Oct 25, 2024
1 parent b28a4ec commit f7f940a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/backend/base/langflow/components/agents/tool_calling.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from langchain.agents import create_tool_calling_agent
from langchain_core.prompts import ChatPromptTemplate, HumanMessagePromptTemplate, PromptTemplate
from langchain_core.prompts import ChatPromptTemplate

from langflow.base.agents.agent import LCToolsAgentComponent
from langflow.inputs import MessageTextInput
Expand All @@ -25,10 +25,10 @@ class ToolCallingAgentComponent(LCToolsAgentComponent):
),
MessageTextInput(
name="input_value",
display_name="User Input",
display_name="Input",
info="The input provided by the user for the agent to process.",
),
DataInput(name="chat_history", display_name="Conversation History", is_list=True, advanced=True),
DataInput(name="chat_history", display_name="Chat Memory", is_list=True, advanced=True),
]

def get_chat_history_data(self) -> list[Data] | None:
Expand All @@ -41,7 +41,7 @@ def create_agent_runnable(self):
messages = [
("system", self.system_prompt),
("placeholder", "{chat_history}"),
HumanMessagePromptTemplate(prompt=PromptTemplate(input_variables=["input"], template=self.user_prompt)),
("human", self.input_value),
("placeholder", "{agent_scratchpad}"),
]
prompt = ChatPromptTemplate.from_messages(messages)
Expand Down

0 comments on commit f7f940a

Please sign in to comment.