Skip to content

Commit

Permalink
another test
Browse files Browse the repository at this point in the history
  • Loading branch information
vbarda committed Jan 23, 2025
1 parent c8fd224 commit 97a2ce9
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions libs/langgraph/tests/test_prebuilt.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,23 @@ def prompt(state):
assert response == expected_response


async def test_callable_prompt_async():
async def prompt(state):
modified_message = f"Bar {state['messages'][-1].content}"
return [HumanMessage(content=modified_message)]

for agent in (
create_react_agent(FakeToolCallingModel(), [], prompt=prompt),
create_react_agent(FakeToolCallingModel(), [], state_modifier=prompt),
):
inputs = [HumanMessage("hi?")]
response = await agent.ainvoke({"messages": inputs})
expected_response = {
"messages": inputs + [AIMessage(content="Bar hi?", id="0")]
}
assert response == expected_response


def test_runnable_prompt():
messages_modifier = RunnableLambda(
lambda messages: [HumanMessage(content=f"Baz {messages[-1].content}")]
Expand Down

0 comments on commit 97a2ce9

Please sign in to comment.