Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion scenarios/Agents/samples/bing-search/bing-python.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
BING_CONNECTION_NAME - the name of the connection of Grounding with Bing Search

"""

# <create a project client>
import os
from azure.ai.projects import AIProjectClient
from azure.identity import DefaultAzureCredential
Expand All @@ -38,7 +38,9 @@
credential=DefaultAzureCredential(),
conn_str=os.environ["PROJECT_CONNECTION_STRING"],
)
# </create a project client>

# <create agent>
bing_connection = project_client.connections.get(connection_name=os.environ["CONNECTION_NAME"])
conn_id = bing_connection.id

Expand All @@ -57,7 +59,9 @@
headers={"x-ms-enable-preview": "true"},
)
print(f"Created agent, ID: {agent.id}")
# </create agent>

# <create thread>
# Create thread for communication
thread = project_client.agents.create_thread()
print(f"Created thread, ID: {thread.id}")
Expand All @@ -69,7 +73,9 @@
content="How is the weather in Seattle today?",
)
print(f"Created message, ID: {message.id}")
# </create thread>

# <create run>
# Create and process agent run in thread with tools
run = project_client.agents.create_and_process_run(thread_id=thread.id, agent_id=agent.id)
print(f"Run finished with status: {run.status}")
Expand All @@ -84,3 +90,4 @@
# Fetch and log all messages
messages = project_client.agents.list_messages(thread_id=thread.id)
print(f"Messages: {messages}")
# </create run>
Loading