mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Python: [Breaking] Simplified Content types to a single class with classmethod constructors. (#3252)
* ported Content to a new model * fixed linting * fixes * fixed data format handling * fix for 3.10 mypy * fix * fix int test
This commit is contained in:
committed by
GitHub
Unverified
parent
73761aa4a3
commit
83e6229c11
+3
-5
@@ -3,7 +3,7 @@
|
||||
import asyncio
|
||||
import os
|
||||
|
||||
from agent_framework import CitationAnnotation
|
||||
from agent_framework import Annotation
|
||||
from agent_framework.azure import AzureAIAgentsProvider
|
||||
from azure.ai.agents.aio import AgentsClient
|
||||
from azure.ai.projects.aio import AIProjectClient
|
||||
@@ -85,13 +85,11 @@ async def main() -> None:
|
||||
)
|
||||
print(f"User: {user_input}")
|
||||
print("Agent: ", end="", flush=True)
|
||||
|
||||
# Stream the response and collect citations
|
||||
citations: list[CitationAnnotation] = []
|
||||
citations: list[Annotation] = []
|
||||
async for chunk in agent.run_stream(user_input):
|
||||
if chunk.text:
|
||||
print(chunk.text, end="", flush=True)
|
||||
|
||||
# Collect citations from Azure AI Search responses
|
||||
for content in getattr(chunk, "contents", []):
|
||||
annotations = getattr(content, "annotations", [])
|
||||
@@ -104,7 +102,7 @@ async def main() -> None:
|
||||
if citations:
|
||||
print("\n\nCitation:")
|
||||
for i, citation in enumerate(citations, 1):
|
||||
print(f"[{i}] {citation.url}")
|
||||
print(f"[{i}] {citation.get('url')}")
|
||||
|
||||
print("\n" + "=" * 50 + "\n")
|
||||
print("Hotel search conversation completed!")
|
||||
|
||||
+5
-5
@@ -2,7 +2,7 @@
|
||||
|
||||
import asyncio
|
||||
|
||||
from agent_framework import CitationAnnotation, HostedWebSearchTool
|
||||
from agent_framework import Annotation, HostedWebSearchTool
|
||||
from agent_framework.azure import AzureAIAgentsProvider
|
||||
from azure.identity.aio import AzureCliCredential
|
||||
|
||||
@@ -57,7 +57,7 @@ async def main() -> None:
|
||||
print("Agent: ", end="", flush=True)
|
||||
|
||||
# Stream the response and collect citations
|
||||
citations: list[CitationAnnotation] = []
|
||||
citations: list[Annotation] = []
|
||||
async for chunk in agent.run_stream(user_input):
|
||||
if chunk.text:
|
||||
print(chunk.text, end="", flush=True)
|
||||
@@ -74,9 +74,9 @@ async def main() -> None:
|
||||
if citations:
|
||||
print("\n\nCitations:")
|
||||
for i, citation in enumerate(citations, 1):
|
||||
print(f"[{i}] {citation.title}: {citation.url}")
|
||||
if citation.snippet:
|
||||
print(f" Snippet: {citation.snippet}")
|
||||
print(f"[{i}] {citation['title']}: {citation.get('url')}")
|
||||
if "snippet" in citation:
|
||||
print(f" Snippet: {citation.get('snippet')}")
|
||||
else:
|
||||
print("\nNo citations found in the response.")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user