Skip to content

Commit 7814bb2

Browse files
committed
fix: update langchain tests for v1
1 parent 8fd1ea3 commit 7814bb2

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

test-langchain2/main_tool.py

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,39 +27,36 @@ def calculate_tip(bill_amount: float, tip_percentage: float) -> float:
2727
def my_pipeline(llm, tools):
2828
with sentry_sdk.start_transaction(name="langchain-sync-tool"):
2929
# Create agent with tools
30-
# prompt = ChatPromptTemplate.from_messages([
31-
# ("system", "You are a helpful assistant that can use tools to help answer questions."),
32-
# ("placeholder", "{chat_history}"),
33-
# ("human", "{input}"),
34-
# ("placeholder", "{agent_scratchpad}"),
35-
# ])
36-
37-
agent = create_agent(model=llm, tools=tools, system_prompt="You are a helpful assistant that can use tools to help answer questions")#.with_config(config={"run_name": "MyAgent1"})
38-
# agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)
30+
agent = create_agent(
31+
model=llm,
32+
tools=tools,
33+
system_prompt="You are a helpful assistant that can use tools to help answer questions",
34+
).with_config(config={"run_name": "MyAgent1"})
3935

4036
# Test with weather tool
4137
result1 = agent.invoke(
4238
{
4339
"messages": [
44-
{"role": "user", "content": "What's the weather like in San Francisco, CA?"}
40+
{
41+
"role": "user",
42+
"content": "What's the weather like in San Francisco, CA?",
43+
}
4544
]
4645
}
4746
)
4847
print("Weather Result:")
4948
print(result1)
5049

5150
# Test with calculation tool
52-
result2 = agent.invoke({
53-
"input": "Calculate a 18% tip on a $45.50 bill"
54-
})
51+
result2 = agent.invoke({"input": "Calculate a 18% tip on a $45.50 bill"})
5552
print("Tip Calculation Result:")
5653
print(result2)
5754

5855
# Test streaming with agent
5956
print("Streaming Result:")
60-
for chunk in agent.stream({
61-
"input": "What's the weather in New York and calculate a 20% tip on $30?"
62-
}):
57+
for chunk in agent.stream(
58+
{"input": "What's the weather in New York and calculate a 20% tip on $30?"}
59+
):
6360
print(chunk)
6461

6562

0 commit comments

Comments
 (0)