Skip to content

Commit 0b40377

Browse files
authored
Merge pull request #25 from Azure-Samples/langchainv1
Update examples
2 parents 07761b3 + 5075351 commit 0b40377

File tree

3 files changed

+15
-35
lines changed

3 files changed

+15
-35
lines changed
8.18 KB
Loading

examples/langchainv1_supervisor.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def get_current_date() -> str:
8282
return datetime.now().strftime("%Y-%m-%d")
8383

8484

85-
activity_agent = create_agent(
85+
weekend_agent = create_agent(
8686
model=base_model,
8787
prompt=(
8888
"You help users plan their weekends and choose the best activities for the given weather."
@@ -94,10 +94,10 @@ def get_current_date() -> str:
9494

9595

9696
@tool
97-
def activity_agent_tool(query: str) -> str:
97+
def weekend_agent_tool(query: str) -> str:
9898
"""Invoke the activity planning agent and return its final response as plain text."""
99-
logger.info("Tool:activity_agent invoked")
100-
response = activity_agent.invoke({"messages": [HumanMessage(content=query)]})
99+
logger.info("Tool:weekend_agent invoked")
100+
response = weekend_agent.invoke({"messages": [HumanMessage(content=query)]})
101101
final = response["messages"][-1].content
102102
return final
103103

@@ -147,7 +147,7 @@ def check_fridge() -> list[str]:
147147
return ["tofu", "soy sauce", "broccoli", "carrots"]
148148

149149

150-
recipe_agent = create_agent(
150+
meal_agent = create_agent(
151151
model=base_model,
152152
prompt=(
153153
"You help users plan meals and choose the best recipes."
@@ -159,10 +159,10 @@ def check_fridge() -> list[str]:
159159

160160

161161
@tool
162-
def recipe_agent_tool(query: str) -> str:
162+
def meal_agent_tool(query: str) -> str:
163163
"""Invoke the recipe planning agent and return its final response as plain text."""
164-
logger.info("Tool:recipe_agent invoked")
165-
response = recipe_agent.invoke({"messages": [HumanMessage(content=query)]})
164+
logger.info("Tool:meal_agent invoked")
165+
response = meal_agent.invoke({"messages": [HumanMessage(content=query)]})
166166
final = response["messages"][-1].content
167167
return final
168168

@@ -176,7 +176,7 @@ def recipe_agent_tool(query: str) -> str:
176176
"You are a supervisor, managing an activity planning agent and recipe planning agent."
177177
"Assign work to them as needed in order to answer user's question."
178178
),
179-
tools=[activity_agent_tool, recipe_agent_tool],
179+
tools=[weekend_agent_tool, meal_agent_tool],
180180
)
181181

182182

examples/openai_functioncalling.py

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
client = openai.OpenAI(base_url="https://models.inference.ai.azure.com", api_key=os.environ["GITHUB_TOKEN"])
1313
MODEL_NAME = os.getenv("GITHUB_MODEL", "gpt-4o")
1414
elif API_HOST == "azure":
15-
token_provider = azure.identity.get_bearer_token_provider(azure.identity.DefaultAzureCredential(), "https://cognitiveservices.azure.com/.default")
15+
token_provider = azure.identity.get_bearer_token_provider(
16+
azure.identity.DefaultAzureCredential(), "https://cognitiveservices.azure.com/.default"
17+
)
1618
client = openai.AzureOpenAI(
1719
api_version=os.environ["AZURE_OPENAI_VERSION"],
1820
azure_endpoint=os.environ["AZURE_OPENAI_ENDPOINT"],
@@ -41,38 +43,16 @@
4143
"additionalProperties": False,
4244
},
4345
},
44-
},
45-
{
46-
"type": "function",
47-
"function": {
48-
"name": "lookup_movies",
49-
"description": "Lookup movies playing in a given city name or zip code.",
50-
"parameters": {
51-
"type": "object",
52-
"properties": {
53-
"city_name": {
54-
"type": "string",
55-
"description": "The city name",
56-
},
57-
"zip_code": {
58-
"type": "string",
59-
"description": "The zip code",
60-
},
61-
},
62-
"additionalProperties": False,
63-
},
64-
},
65-
},
46+
}
6647
]
6748

6849
response = client.chat.completions.create(
6950
model=MODEL_NAME,
7051
messages=[
71-
{"role": "system", "content": "You are a tourism chatbot."},
72-
{"role": "user", "content": "is it rainy enough in sydney to watch movies and which ones are on?"},
52+
{"role": "system", "content": "You're a weather chatbot"},
53+
{"role": "user", "content": "whats the weather in NYC?"},
7354
],
7455
tools=tools,
75-
tool_choice="auto",
7656
)
7757

7858
print(f"Response from {MODEL_NAME} on {API_HOST}: \n")

0 commit comments

Comments
 (0)