Skip to content

Commit

Permalink
refactor: Simplify agent input text content construction (#5344)
Browse files Browse the repository at this point in the history
* refactor: Simplify agent input text content construction

* Change HUMAN to Input

---------

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
  • Loading branch information
anovazzi1 and ogabrielluiz authored Dec 20, 2024
1 parent 68c36c4 commit 243055e
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions src/backend/base/langflow/base/agents/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 243055e

Please sign in to comment.