Skip to content

Commit 3cecde9

Browse files
authored
Update code-interpreter-samples.md
update code samples with 1rp python sdk
1 parent 6557233 commit 3cecde9

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

articles/ai-services/agents/how-to/tools/code-interpreter-samples.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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
4344
The 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
5758
project_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(
9696
The 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(
108108
A 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
115115
The 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
121121
for image_content in messages.image_contents:

0 commit comments

Comments
 (0)