@@ -39,6 +39,7 @@ You can add the code interpreter tool to an agent programatically using the code
39
39
40
40
:::zone pivot="python"
41
41
42
+
42
43
## Initialization
43
44
The code begins by setting up the necessary imports and initializing the AI Project client:
44
45
@@ -57,7 +58,6 @@ project_endpoint = os.environ["PROJECT_ENDPOINT"] # Ensure the PROJECT_ENDPOINT
57
58
project_client = AIProjectClient(
58
59
endpoint = project_endpoint,
59
60
credential = DefaultAzureCredential(), # Use Azure Default Credential for authentication
60
- api_version = " latest" ,
61
61
)
62
62
```
63
63
@@ -96,10 +96,10 @@ agent = project_client.agents.create_agent(
96
96
The code creates a conversation thread and initial message:
97
97
98
98
``` 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 (
101
101
thread_id = thread.id,
102
- role = " user " ,
102
+ role = MessageRole. USER ,
103
103
content = " Could you please create bar chart in TRANSPORTATION sector for the operating profit from the uploaded csv file and provide file to me?" ,
104
104
)
105
105
```
@@ -108,14 +108,14 @@ message = project_client.agents.create_message(
108
108
A run is created to process the message and execute code:
109
109
110
110
``` 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)
112
112
```
113
113
114
114
## File Handling
115
115
The code handles the output files and annotations:
116
116
117
117
``` python
118
- messages = project_client.agents.list_messages (thread_id = thread.id)
118
+ messages = project_client.agents.messages.list (thread_id = thread.id)
119
119
120
120
# Save generated image files
121
121
for image_content in messages.image_contents:
0 commit comments