-
Notifications
You must be signed in to change notification settings - Fork 147
Open
Description
The sample provided on this page: https://learn.microsoft.com/en-us/agent-framework/user-guide/agents/agent-types/azure-ai-foundry-agent?pivots=programming-language-python#basic-agent-creation shows the following code:
AzureCliCredential() as credential,
AzureAIAgentClient(async_credential=credential).as_agent(
name="HelperAgent",
instructions="You are a helpful assistant."
) as agent,
):When trying this code in my FastAPI endpoint I get an error stating:
Azure credential is required when agents_client is not provided.
I had to change my code to the following to get the code working: AzureAIAgentClient(credential=credential).as_agent(
Full sample:
class calculator:
async def run(self, question: str):
answer = "I don't know"
async with AzureCliCredential() as credential:
async with AzureAIAgentClient(credential=credential).as_agent(
name="HelperAgent",
instructions="You are a helpful assistant."
) as agent:
answer = await agent.run(question)
return answerI'm not sure if the behavior is different between a console app & FastAPI endpoint (which is also marked as async, but the error is confusing at least. It looks like the code sample needs updating, but might need some more testing.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels