Oharra
Baimena behar duzu orria atzitzeko. Direktorioetan saioa has dezakezu edo haiek alda ditzakezu.
Baimena behar duzu orria atzitzeko. Direktorioak alda ditzakezu.
La integración de Copilot Studio permite usar agentes de Copilot Studio en Agent Framework.
En el ejemplo siguiente se muestra cómo crear un agente mediante Copilot Studio:
using System;
using Azure.Identity;
using Microsoft.Agents.AI;
using Microsoft.Agents.AI.CopilotStudio;
// Create a Copilot Studio agent using the IChatClient pattern
// Requires: dotnet add package Microsoft.Agents.AI.CopilotStudio --prerelease
var copilotClient = new CopilotStudioChatClient(
environmentId: "<your-environment-id>",
agentIdentifier: "<your-agent-id>",
credential: new AzureCliCredential());
AIAgent agent = copilotClient.AsAIAgent(
instructions: "You are a helpful enterprise assistant.");
Console.WriteLine(await agent.RunAsync("What are our company policies on remote work?"));
Nota:
La compatibilidad de Python con agentes de Copilot Studio está disponible a través del agent-framework-copilotstudio paquete.
Instalación
pip install agent-framework-copilotstudio --pre
Configuración
Establezca las siguientes variables de entorno para la configuración automática:
COPILOTSTUDIOAGENT__ENVIRONMENTID="<your-environment-id>"
COPILOTSTUDIOAGENT__SCHEMANAME="<your-agent-schema-name>"
COPILOTSTUDIOAGENT__AGENTAPPID="<your-client-id>"
COPILOTSTUDIOAGENT__TENANTID="<your-tenant-id>"
Creación de un agente de Copilot Studio
CopilotStudioAgent lee automáticamente la configuración de conexión de las variables de entorno:
import asyncio
from agent_framework.microsoft import CopilotStudioAgent
async def main():
agent = CopilotStudioAgent()
result = await agent.run("What are our company policies on remote work?")
print(result)
asyncio.run(main())
Transmisión en línea
async def streaming_example():
agent = CopilotStudioAgent()
print("Agent: ", end="", flush=True)
async for chunk in agent.run("What is the largest city in France?", stream=True):
if chunk.text:
print(chunk.text, end="", flush=True)
print()