refactor: Simplify agent input text content construction (#5344)

* refactor: Simplify agent input text content construction

* Change HUMAN to Input

---------

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
This commit is contained in:
anovazzi1 2024-12-20 10:28:54 -03:00 committed by GitHub
commit 243055e1cd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -25,16 +25,8 @@ class InputDict(TypedDict):
def _build_agent_input_text_content(agent_input_dict: InputDict) -> str:
chat_history = agent_input_dict.get("chat_history", [])
messages = [
f"**{message.type.upper()}**: {message.content}"
for message in chat_history
if isinstance(message, BaseMessage) and message.content
]
final_input = agent_input_dict.get("input", "")
if messages and final_input not in messages[-1]:
messages.append(f"**HUMAN**: {final_input}")
return " \n".join(messages)
return f"**Input**: {final_input}"
def _calculate_duration(start_time: float) -> int: