Condividi tramite


Panoramica degli strumenti

Agent Framework supporta molti tipi diversi di strumenti che estendono le funzionalità dell'agente. Gli strumenti consentono agli agenti di interagire con sistemi esterni, eseguire codice, cercare dati e altro ancora.

Tipi di strumenti

Tipo di strumento Descrzione
Strumenti per le funzioni Codice personalizzato che gli agenti possono chiamare durante le conversazioni
Approvazione degli strumenti Approvazione umana nel ciclo per le chiamate agli strumenti
Interprete di codice Eseguire codice in un ambiente in modalità sandbox
Ricerca file Eseguire ricerche nei file caricati
Ricerca Web Cercare informazioni sul Web
Strumenti MCP ospitati Strumenti MCP ospitati da Azure AI Foundry
Strumenti MCP locali Strumenti MCP in esecuzione in locale o in server personalizzati

Matrice di supporto del provider

I provider OpenAI e Azure OpenAI offrono ognuno più tipi di client con diverse funzionalità degli strumenti. I client OpenAI di Azure rispecchiano gli equivalenti OpenAI.

Tipo di strumento Completamento chat Risposte Assistenti Azure IA Foundry Anthropic Ollama GitHub Copilot Copilot Studio
Strumenti per le funzioni
Approvazione degli strumenti
Interprete di codice
Ricerca file
Ricerca Web
Strumenti MCP ospitati
Strumenti MCP locali

Annotazioni

Le colonne Completamento chat, Risposte e Assistenti si applicano sia a OpenAI che ad Azure OpenAI. Le varianti di Azure rispecchiano lo stesso supporto degli strumenti delle controparti OpenAI.

Matrice di supporto del provider

I provider OpenAI e Azure OpenAI offrono ognuno più tipi di client con diverse funzionalità degli strumenti. I client OpenAI di Azure rispecchiano gli equivalenti OpenAI.

Tipo di strumento Completamento chat Risposte Assistenti Azure IA Foundry Anthropic Claude Agent Ollama GitHub Copilot
Strumenti per le funzioni
Approvazione degli strumenti
Interprete di codice
Ricerca file
Ricerca Web
Generazione di immagini
Strumenti MCP ospitati
Strumenti MCP locali

Annotazioni

Le colonne Completamento chat, Risposte e Assistenti si applicano sia a OpenAI che ad Azure OpenAI. Le varianti di Azure rispecchiano lo stesso supporto degli strumenti delle controparti OpenAI. Gli strumenti MCP locali funzionano con qualsiasi provider che supporta gli strumenti per le funzioni.

Uso di un agente come strumento per le funzioni

È possibile usare un agente come strumento funzione per un altro agente, abilitando la composizione degli agenti e flussi di lavoro più avanzati. L'agente interno viene convertito in uno strumento di funzione e fornito all'agente esterno, che può quindi chiamarlo in base alle esigenze.

Chiamare .AsAIFunction() su un AIAgent oggetto per convertirlo in uno strumento funzione che può essere fornito a un altro agente:

// Create the inner agent with its own tools
AIAgent weatherAgent = new AzureOpenAIClient(
    new Uri("https://<myresource>.openai.azure.com"),
    new AzureCliCredential())
     .GetChatClient("gpt-4o-mini")
     .AsAIAgent(
        instructions: "You answer questions about the weather.",
        name: "WeatherAgent",
        description: "An agent that answers questions about the weather.",
        tools: [AIFunctionFactory.Create(GetWeather)]);

// Create the main agent and provide the inner agent as a function tool
AIAgent agent = new AzureOpenAIClient(
    new Uri("https://<myresource>.openai.azure.com"),
    new AzureCliCredential())
     .GetChatClient("gpt-4o-mini")
     .AsAIAgent(instructions: "You are a helpful assistant.", tools: [weatherAgent.AsAIFunction()]);

// The main agent can now call the weather agent as a tool
Console.WriteLine(await agent.RunAsync("What is the weather like in Amsterdam?"));

Chiamare .as_tool() un agente per convertirlo in uno strumento funzione che può essere fornito a un altro agente:

from agent_framework.azure import AzureOpenAIChatClient
from azure.identity import AzureCliCredential

# Create the inner agent with its own tools
weather_agent = AzureOpenAIChatClient(credential=AzureCliCredential()).as_agent(
    name="WeatherAgent",
    description="An agent that answers questions about the weather.",
    instructions="You answer questions about the weather.",
    tools=get_weather
)

# Create the main agent and provide the inner agent as a function tool
main_agent = AzureOpenAIChatClient(credential=AzureCliCredential()).as_agent(
    instructions="You are a helpful assistant.",
    tools=weather_agent.as_tool()
)

# The main agent can now call the weather agent as a tool
result = await main_agent.run("What is the weather like in Amsterdam?")
print(result.text)

È anche possibile personalizzare il nome, la descrizione e il nome dell'argomento dello strumento:

weather_tool = weather_agent.as_tool(
    name="WeatherLookup",
    description="Look up weather information for any location",
    arg_name="query",
    arg_description="The weather query or location"
)

Passaggi successivi