Skip to content

Commit 5a8707a

Browse files
committed
Correct functions
1 parent 0de9f79 commit 5a8707a

File tree

1 file changed

+9
-9
lines changed
  • samples/microsoft/python/getting-started-agents/3p-tools/legalfly

1 file changed

+9
-9
lines changed

samples/microsoft/python/getting-started-agents/3p-tools/legalfly/legalfly.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141

4242

4343
# Initialize the project client using the endpoint and default credentials
44-
with AIProjectClient(
45-
endpoint=endpoint,
44+
with AIProjectClient.from_connection_string(
45+
conn_str=endpoint,
4646
credential=DefaultAzureCredential(exclude_interactive_browser_credential=False),
4747
) as project_client:
4848
# </initialization>
@@ -51,7 +51,7 @@
5151
with open("./legalfly.json", "r") as f:
5252
openapi_spec = jsonref.loads(f.read())
5353

54-
conn_id = project_client.connections.get(name=connection_name).id
54+
conn_id = project_client.connections.get(connection_name=connection_name).id
5555
# Create Auth object for the OpenApiTool (note that connection or managed identity auth setup requires additional setup in Azure)
5656
auth = OpenApiConnectionAuthDetails(security_scheme=OpenApiConnectionSecurityScheme(connection_id=conn_id))
5757

@@ -79,11 +79,11 @@
7979
# <thread_management>
8080
# --- Thread Management ---
8181
# Create a new conversation thread for the interaction
82-
thread = project_client.agents.threads.create()
82+
thread = project_client.agents.create_thread()
8383
print(f"Created thread, ID: {thread.id}")
8484

8585
# Create the initial user message in the thread
86-
message = project_client.agents.messages.create(
86+
message = project_client.agents.create_message(
8787
thread_id=thread.id,
8888
role="user",
8989
# give an example of a user message that the agent can respond to
@@ -96,7 +96,7 @@
9696
# --- Message Processing (Run Creation and Auto-processing) ---
9797
# Create and automatically process the run, handling tool calls internally
9898
# Note: This differs from the function_tool example where tool calls are handled manually
99-
run = project_client.agents.runs.create_and_process(thread_id=thread.id, agent_id=agent.id)
99+
run = project_client.agents.create_and_process_run(thread_id=thread.id, agent_id=agent.id)
100100
print(f"Run finished with status: {run.status}")
101101
# </message_processing>
102102

@@ -106,7 +106,7 @@
106106
print(f"Run failed: {run.last_error}")
107107

108108
# Retrieve the steps taken during the run for analysis
109-
run_steps = project_client.agents.run_steps.list(thread_id=thread.id, run_id=run.id)
109+
run_steps = project_client.agents.list_run_steps(thread_id=thread.id, run_id=run.id)
110110

111111
# Loop through each step to display information
112112
for step in run_steps.data:
@@ -135,12 +135,12 @@
135135
print("Deleted agent")
136136

137137
# Fetch and log all messages exchanged during the conversation thread
138-
messages = project_client.agents.messages.list(thread_id=thread.id)
138+
messages = project_client.agents.list_messages(thread_id=thread.id)
139139
print(f"Messages: {messages}")
140140
messages_array = messages.data
141141
for m in messages_array:
142142
content = m.get("content", [])
143143
if content and content[0].get("type") == "text":
144144
text_value = content[0].get("text", {}).get("value", "")
145145
print(f"Text: {text_value}")
146-
# </cleanup>
146+
# </cleanup>

0 commit comments

Comments
 (0)