You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/ai-services/agents/how-to/tools/code-interpreter-samples.md
+67-67Lines changed: 67 additions & 67 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -150,98 +150,98 @@ This ensures proper resource management and prevents unnecessary resource consum
150
150
First, set up the configuration using `appsettings.json`, create a `PersistentAgentsClient`, and then create a `PersistentAgent` with the Code Interpreter tool enabled.
"Hi, Agent! Draw a graph for a line with a slope of 4 and y-intercept of 9.");
188
188
```
189
189
190
190
## Create and monitor a run
191
191
192
192
Then, create a `ThreadRun` for the thread and agent. Poll the run's status until it completes or requires action.
193
193
194
194
```csharp
195
-
ThreadRunrun=client.Runs.CreateRun(
196
-
thread.Id,
197
-
agent.Id,
198
-
additionalInstructions: "Please address the user as Jane Doe. The user has a premium account.");
199
-
200
-
do
201
-
{
202
-
Thread.Sleep(TimeSpan.FromMilliseconds(500));
203
-
run=client.Runs.GetRun(thread.Id, run.Id);
204
-
}
205
-
while (run.Status==RunStatus.Queued
206
-
||run.Status==RunStatus.InProgress
207
-
||run.Status==RunStatus.RequiresAction);
195
+
ThreadRunrun=client.Runs.CreateRun(
196
+
thread.Id,
197
+
agent.Id,
198
+
additionalInstructions: "Please address the user as Jane Doe. The user has a premium account.");
199
+
200
+
do
201
+
{
202
+
Thread.Sleep(TimeSpan.FromMilliseconds(500));
203
+
run=client.Runs.GetRun(thread.Id, run.Id);
204
+
}
205
+
while (run.Status==RunStatus.Queued
206
+
||run.Status==RunStatus.InProgress
207
+
||run.Status==RunStatus.RequiresAction);
208
208
```
209
209
210
210
## Process the results and handle files
211
211
212
212
Once the run is finished, retrieve all messages from the thread. Iterate through the messages to display text content and handle any generated image files by saving them locally and opening them.
0 commit comments