Skip to content

Commit 9bb88ea

Browse files
committed
feat: 修改common py
1 parent 2de50c3 commit 9bb88ea

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

01_base/练习/langchain/common.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import requests
2+
3+
def get_exchange_rate(base: str, target: str) -> str:
4+
url = f"https://api.exchangerate-api.com/v4/latest/{base}"
5+
response = requests.get(url)
6+
data = response.json()
7+
rate = data['rates'].get(target)
8+
return f"1 {base} = {rate} {target}"
9+
print(get_exchange_rate("USD", "EUR"), get_exchange_rate("USD", "JPY"), get_exchange_rate("CNY", "JPY"))

01_base/练习/langchain/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def exchange_rate(input: str) -> str:
2020

2121
llm = ChatOpenAI(model="deepseek-chat",api_key=os.getenv("DEEPSEEK_API_KEY"), base_url="https://api.deepseek.com", temperature=0)
2222

23-
agent = create_agent(model=llm, tools=tools,)
23+
agent = create_agent(model=llm, tools=tools, system_prompt="You are a helpful assistant.when the user asks about currency conversion or exchange rate, use the exchange_rate tool. when the user asks about weather, use the weather tool.")
2424

2525
while True:
2626
query = input("Enter your query (or 'exit' to quit): ")

0 commit comments

Comments
 (0)