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
@@ -145,98 +145,98 @@ This ensures proper resource management and prevents unnecessary resource consum
145
145
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.");
183
183
```
184
184
185
185
## Create and monitor a run
186
186
187
187
Then, create a `ThreadRun` for the thread and agent. Poll the run's status until it completes or requires action.
188
188
189
189
```csharp
190
-
ThreadRunrun=client.Runs.CreateRun(
191
-
thread.Id,
192
-
agent.Id,
193
-
additionalInstructions: "Please address the user as Jane Doe. The user has a premium account.");
194
-
195
-
do
196
-
{
197
-
Thread.Sleep(TimeSpan.FromMilliseconds(500));
198
-
run=client.Runs.GetRun(thread.Id, run.Id);
199
-
}
200
-
while (run.Status==RunStatus.Queued
201
-
||run.Status==RunStatus.InProgress
202
-
||run.Status==RunStatus.RequiresAction);
190
+
ThreadRunrun=client.Runs.CreateRun(
191
+
thread.Id,
192
+
agent.Id,
193
+
additionalInstructions: "Please address the user as Jane Doe. The user has a premium account.");
194
+
195
+
do
196
+
{
197
+
Thread.Sleep(TimeSpan.FromMilliseconds(500));
198
+
run=client.Runs.GetRun(thread.Id, run.Id);
199
+
}
200
+
while (run.Status==RunStatus.Queued
201
+
||run.Status==RunStatus.InProgress
202
+
||run.Status==RunStatus.RequiresAction);
203
203
```
204
204
205
205
## Process the results and handle files
206
206
207
207
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