@@ -39,6 +39,7 @@ You can add the code interpreter tool to an agent programatically using the code
3939
4040:::zone pivot="python"
4141
42+
4243## Initialization
4344The code begins by setting up the necessary imports and initializing the AI Project client:
4445
@@ -57,7 +58,6 @@ project_endpoint = os.environ["PROJECT_ENDPOINT"] # Ensure the PROJECT_ENDPOINT
5758project_client = AIProjectClient(
5859 endpoint = project_endpoint,
5960 credential = DefaultAzureCredential(), # Use Azure Default Credential for authentication
60- api_version = " latest" ,
6161)
6262```
6363
@@ -96,10 +96,10 @@ agent = project_client.agents.create_agent(
9696The code creates a conversation thread and initial message:
9797
9898``` python
99- thread = project_client.agents.create_thread ()
100- message = project_client.agents.create_message (
99+ thread = project_client.agents.threads.create ()
100+ message = project_client.agents.messages.create (
101101 thread_id = thread.id,
102- role = " user " ,
102+ role = MessageRole. USER ,
103103 content = " Could you please create bar chart in TRANSPORTATION sector for the operating profit from the uploaded csv file and provide file to me?" ,
104104)
105105```
@@ -108,14 +108,14 @@ message = project_client.agents.create_message(
108108A run is created to process the message and execute code:
109109
110110``` python
111- run = project_client.agents.create_and_process_run (thread_id = thread.id, agent_id = agent.id)
111+ run = project_client.agents.runs.create_and_process (thread_id = thread.id, agent_id = agent.id)
112112```
113113
114114## File Handling
115115The code handles the output files and annotations:
116116
117117``` python
118- messages = project_client.agents.list_messages (thread_id = thread.id)
118+ messages = project_client.agents.messages.list (thread_id = thread.id)
119119
120120# Save generated image files
121121for image_content in messages.image_contents:
0 commit comments