Skip to content

Python: .Net: AzureAIAgent (ImportError: cannot import name 'Agent' from 'azure.ai.projects.models') #12140

Closed
@SaivigneshSkysecure

Description

@SaivigneshSkysecure

#Error#

Image

AzureAIAgent using that only i am getting these error, below is the code i have used. Can you please help me to sort this out? Is there any change or update within this AzureAIAgent that i need to know?

#code#
import asyncio
import os
from azure.identity.aio import DefaultAzureCredential
from semantic_kernel.agents import AzureAIAgent, ConcurrentOrchestration
from semantic_kernel.agents.runtime import InProcessRuntime

Your Azure Foundry project connection string (make sure it's in env or hardcode carefully)
PROJECT_CONN_STR = ""

categoriser_agent_id = "<assitant_id>"
data_agent_id = "<assitant_id>"

async def get_azure_agents():
credential = DefaultAzureCredential()
async with credential, AzureAIAgent.create_client(
credential=credential, conn_str=PROJECT_CONN_STR
) as client:

    categoriser_def = await client.agents.get_agent(assistant_id=categoriser_agent_id)
    data_def = await client.agents.get_agent(assistant_id=data_agent_id)

    categoriser_agent = AzureAIAgent(client=client, definition=categoriser_def)
    data_agent = AzureAIAgent(client=client, definition=data_def)

    return [categoriser_agent, data_agent]

async def main():
agents = await get_azure_agents()

# Create concurrent orchestration from AzureAIAgents
concurrent_orchestration = ConcurrentOrchestration(members=agents)

runtime = InProcessRuntime()
runtime.start()

task_text = (
    "<task text>"
)

orchestration_result = await concurrent_orchestration.invoke(task=task_text, runtime=runtime)

try:
    value = await orchestration_result.get(timeout=30)
    for item in value:
        print(f"# {item.name}: {item.content}")
except asyncio.TimeoutError:
    print("⚠️ Orchestration timed out")

await runtime.stop_when_idle()

if name == "main":
asyncio.run(main())

Metadata

Metadata

Assignees

Labels

agentsbugSomething isn't workingpythonPull requests for the Python Semantic Kernel

Type

No type

Projects

Status

Bug

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions