-
Notifications
You must be signed in to change notification settings - Fork 1k
Labels
pythonsamplesIssue relates to the samplesIssue relates to the samplesv1.0Features being tracked for the version 1.0 GAFeatures being tracked for the version 1.0 GA
Description
I need my agent to call tools that require access_token for authentication. My initial approach was to add access_token as a parameter to the tool function (e.g., get_weather). However, agent.run(...) only accepts a single text string as input, so I can't pass additional arguments (e.g., access_token).
from typing import Annotated
from pydantic import Field
def get_weather(
location: Annotated[str, Field(description="The location to get the weather for.")],
access_token: Annotated[str, Field(description="Access token for authentication.")],
) -> str:
"""Get the weather for a given location."""
data = auth(access_token) # Authenticate using the token
return f"The weather in {data['location']} is cloudy with a high of 15°C."
# Problem: How do I pass access_token when calling the agent?
result = await agent.run("What is the weather like in Amsterdam?")I am just wondering if it is possible to provide authentication credentials or metadata to tools when the agent's run method only accepts a text query?
I expect something like this:
def get_weather(
location: Annotated[str, Field(description="The location to get the weather for.")],
access_token: Annotated[str, Field(description="Access token for authentication.")],
) -> str:
"""Get the weather for a given location."""
data = auth(access_token) # Authenticate using the token
return f"The weather in {data['location']} is cloudy with a high of 15°C."
# Problem: How do I pass access_token when calling the agent?
result = await agent.run("What is the weather like in Amsterdam?", access_token="abc")Metadata
Metadata
Assignees
Labels
pythonsamplesIssue relates to the samplesIssue relates to the samplesv1.0Features being tracked for the version 1.0 GAFeatures being tracked for the version 1.0 GA
Type
Projects
Status
Done