-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodeSample.py
More file actions
25 lines (19 loc) · 758 Bytes
/
codeSample.py
File metadata and controls
25 lines (19 loc) · 758 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from azure.ai.projects import AIProjectClient
from azure.identity import DefaultAzureCredential
project_client = AIProjectClient.from_connection_string(
credential=DefaultAzureCredential(),
conn_str="<%= connectionString %>")
agent = project_client.agents.get_agent("<%= agentId %>")
thread = project_client.agents.create_thread()
print(f"Created thread, ID: {thread.id}")
message = project_client.agents.create_message(
thread_id=thread.id,
role="user",
content="<%= userMessage %>"
)
run = project_client.agents.create_and_process_run(
thread_id=thread.id,
agent_id=agent.id)
messages = project_client.agents.list_messages(thread_id=thread.id)
for text_message in messages.text_messages:
print(text_message.as_dict())