openai/openai-dotnet
Publicmirrored from https://github.com/openai/openai-dotnetAvailable
src/Custom/Assistants/AssistantClient.Convenience.cs
461lines · modecode
| 1 | using System.ClientModel; |
| 2 | using System.Collections.Generic; |
| 3 | using System.Threading.Tasks; |
| 4 | |
| 5 | namespace OpenAI.Assistants; |
| 6 | |
| 7 | public partial class AssistantClient |
| 8 | { |
| 9 | /// <summary> |
| 10 | /// Modifies an existing <see cref="Assistant"/>. |
| 11 | /// </summary> |
| 12 | /// <param name="assistant"> The assistant to modify. </param> |
| 13 | /// <param name="options"> The changes to apply to the assistant. </param> |
| 14 | /// <returns> |
| 15 | /// An updated <see cref="Assistant"/> instance that reflects the requested changes. |
| 16 | /// </returns> |
| 17 | public virtual Task<ClientResult<Assistant>> ModifyAssistantAsync(Assistant assistant, AssistantModificationOptions options) |
| 18 | => ModifyAssistantAsync(assistant?.Id, options); |
| 19 | |
| 20 | /// <summary> |
| 21 | /// Modifies an existing <see cref="Assistant"/>. |
| 22 | /// </summary> |
| 23 | /// <param name="assistant"> The assistant to modify. </param> |
| 24 | /// <param name="options"> The changes to apply to the assistant. </param> |
| 25 | /// <returns> |
| 26 | /// An updated <see cref="Assistant"/> instance that reflects the requested changes. |
| 27 | /// </returns> |
| 28 | public virtual ClientResult<Assistant> ModifyAssistant(Assistant assistant, AssistantModificationOptions options) |
| 29 | => ModifyAssistant(assistant?.Id, options); |
| 30 | |
| 31 | |
| 32 | /// <summary> |
| 33 | /// Deletes an existing <see cref="Assistant"/>. |
| 34 | /// </summary> |
| 35 | /// <param name="assistant"> The assistant to delete. </param> |
| 36 | /// <returns> A value indicating whether the deletion was successful. </returns> |
| 37 | public virtual Task<ClientResult<bool>> DeleteAssistantAsync(Assistant assistant) |
| 38 | => DeleteAssistantAsync(assistant?.Id); |
| 39 | |
| 40 | /// <summary> |
| 41 | /// Deletes an existing <see cref="Assistant"/>. |
| 42 | /// </summary> |
| 43 | /// <param name="assistant"> The assistant to delete. </param> |
| 44 | /// <returns> A value indicating whether the deletion was successful. </returns> |
| 45 | public virtual ClientResult<bool> DeleteAssistant(Assistant assistant) |
| 46 | => DeleteAssistant(assistant?.Id); |
| 47 | |
| 48 | /// <summary> |
| 49 | /// Gets an updated instance of an existing <see cref="AssistantThread"/>. |
| 50 | /// </summary> |
| 51 | /// <param name="thread"> The existing thread to refresh the state of. </param> |
| 52 | /// <returns> An updated instance of the provided <see cref="ThreadMessage"/>. </returns> |
| 53 | public virtual Task<ClientResult<AssistantThread>> GetThreadAsync(AssistantThread thread) |
| 54 | => GetThreadAsync(thread?.Id); |
| 55 | |
| 56 | /// <summary> |
| 57 | /// Gets an updated instance of an existing <see cref="AssistantThread"/>. |
| 58 | /// </summary> |
| 59 | /// <param name="thread"> The existing thread to refresh the state of. </param> |
| 60 | /// <returns> An updated instance of the provided <see cref="ThreadMessage"/>. </returns> |
| 61 | public virtual ClientResult<AssistantThread> GetThread(AssistantThread thread) |
| 62 | => GetThread(thread?.Id); |
| 63 | |
| 64 | /// <summary> |
| 65 | /// Modifies an existing <see cref="AssistantThread"/>. |
| 66 | /// </summary> |
| 67 | /// <param name="thread"> The thread to modify. </param> |
| 68 | /// <param name="options"> The modifications to apply to the thread. </param> |
| 69 | /// <returns> The updated <see cref="AssistantThread"/> instance. </returns> |
| 70 | public virtual Task<ClientResult<AssistantThread>> ModifyThreadAsync(AssistantThread thread, ThreadModificationOptions options) |
| 71 | => ModifyThreadAsync(thread?.Id, options); |
| 72 | |
| 73 | /// <summary> |
| 74 | /// Modifies an existing <see cref="AssistantThread"/>. |
| 75 | /// </summary> |
| 76 | /// <param name="thread"> The thread to modify. </param> |
| 77 | /// <param name="options"> The modifications to apply to the thread. </param> |
| 78 | /// <returns> The updated <see cref="AssistantThread"/> instance. </returns> |
| 79 | public virtual ClientResult<AssistantThread> ModifyThread(AssistantThread thread, ThreadModificationOptions options) |
| 80 | => ModifyThread(thread?.Id, options); |
| 81 | |
| 82 | /// <summary> |
| 83 | /// Deletes an existing <see cref="AssistantThread"/>. |
| 84 | /// </summary> |
| 85 | /// <param name="thread"> The thread to delete. </param> |
| 86 | /// <returns> A value indicating whether the deletion was successful. </returns> |
| 87 | public virtual Task<ClientResult<bool>> DeleteThreadAsync(AssistantThread thread) |
| 88 | => DeleteThreadAsync(thread?.Id); |
| 89 | |
| 90 | /// <summary> |
| 91 | /// Deletes an existing <see cref="AssistantThread"/>. |
| 92 | /// </summary> |
| 93 | /// <param name="thread"> The thread to delete. </param> |
| 94 | /// <returns> A value indicating whether the deletion was successful. </returns> |
| 95 | public virtual ClientResult<bool> DeleteThread(AssistantThread thread) |
| 96 | => DeleteThread(thread?.Id); |
| 97 | |
| 98 | /// <summary> |
| 99 | /// Creates a new <see cref="ThreadMessage"/> on an existing <see cref="AssistantThread"/>. |
| 100 | /// </summary> |
| 101 | /// <param name="thread"> The thread to associate the new message with. </param> |
| 102 | /// <param name="content"> The collection of <see cref="MessageContent"/> items for the message. </param> |
| 103 | /// <param name="options"> Additional options to apply to the new message. </param> |
| 104 | /// <returns> A new <see cref="ThreadMessage"/>. </returns> |
| 105 | public virtual Task<ClientResult<ThreadMessage>> CreateMessageAsync( |
| 106 | AssistantThread thread, |
| 107 | IEnumerable<MessageContent> content, |
| 108 | MessageCreationOptions options = null) |
| 109 | => CreateMessageAsync(thread?.Id, content, options); |
| 110 | |
| 111 | /// <summary> |
| 112 | /// Creates a new <see cref="ThreadMessage"/> on an existing <see cref="AssistantThread"/>. |
| 113 | /// </summary> |
| 114 | /// <param name="thread"> The thread to associate the new message with. </param> |
| 115 | /// <param name="content"> The collection of <see cref="MessageContent"/> items for the message. </param> |
| 116 | /// <param name="options"> Additional options to apply to the new message. </param> |
| 117 | /// <returns> A new <see cref="ThreadMessage"/>. </returns> |
| 118 | public virtual ClientResult<ThreadMessage> CreateMessage( |
| 119 | AssistantThread thread, |
| 120 | IEnumerable<MessageContent> content, |
| 121 | MessageCreationOptions options = null) |
| 122 | => CreateMessage(thread?.Id, content, options); |
| 123 | |
| 124 | /// <summary> |
| 125 | /// Returns a collection of <see cref="ThreadMessage"/> instances from an existing <see cref="AssistantThread"/>. |
| 126 | /// </summary> |
| 127 | /// <param name="thread"> The thread to list messages from. </param> |
| 128 | /// <param name="resultOrder"> |
| 129 | /// The <c>order</c> that results should appear in the list according to their <c>created_at</c> |
| 130 | /// timestamp. |
| 131 | /// </param> |
| 132 | /// <returns> A collection of messages that can be enumerated using <c>await foreach</c>. </returns> |
| 133 | public virtual AsyncPageableCollection<ThreadMessage> GetMessagesAsync( |
| 134 | AssistantThread thread, |
| 135 | ListOrder? resultOrder = default) |
| 136 | { |
| 137 | Argument.AssertNotNull(thread, nameof(thread)); |
| 138 | |
| 139 | return GetMessagesAsync(thread.Id, resultOrder); |
| 140 | } |
| 141 | |
| 142 | /// <summary> |
| 143 | /// Returns a collection of <see cref="ThreadMessage"/> instances from an existing <see cref="AssistantThread"/>. |
| 144 | /// </summary> |
| 145 | /// <param name="thread"> The thread to list messages from. </param> |
| 146 | /// <param name="resultOrder"> |
| 147 | /// The <c>order</c> that results should appear in the list according to their <c>created_at</c> |
| 148 | /// timestamp. |
| 149 | /// </param> |
| 150 | /// <returns> A collection of messages that can be enumerated using <c>foreach</c>. </returns> |
| 151 | public virtual PageableCollection<ThreadMessage> GetMessages( |
| 152 | AssistantThread thread, |
| 153 | ListOrder? resultOrder = default) |
| 154 | { |
| 155 | Argument.AssertNotNull(thread, nameof(thread)); |
| 156 | |
| 157 | return GetMessages(thread.Id, resultOrder); |
| 158 | } |
| 159 | |
| 160 | /// <summary> |
| 161 | /// Gets an updated instance of an existing <see cref="ThreadMessage"/>. |
| 162 | /// </summary> |
| 163 | /// <param name="message"> The existing message to refresh the state of. </param> |
| 164 | /// <returns> An updated instance of the provided <see cref="ThreadMessage"/>. </returns> |
| 165 | public virtual Task<ClientResult<ThreadMessage>> GetMessageAsync(ThreadMessage message) |
| 166 | => GetMessageAsync(message?.ThreadId, message?.Id); |
| 167 | |
| 168 | /// <summary> |
| 169 | /// Gets an updated instance of an existing <see cref="ThreadMessage"/>. |
| 170 | /// </summary> |
| 171 | /// <param name="message"> The existing message to refresh the state of. </param> |
| 172 | /// <returns> An updated instance of the provided <see cref="ThreadMessage"/>. </returns> |
| 173 | public virtual ClientResult<ThreadMessage> GetMessage(ThreadMessage message) |
| 174 | => GetMessage(message?.ThreadId, message?.Id); |
| 175 | |
| 176 | /// <summary> |
| 177 | /// Modifies an existing <see cref="ThreadMessage"/>. |
| 178 | /// </summary> |
| 179 | /// <param name="message"> The message to modify. </param> |
| 180 | /// <param name="options"> The changes to apply to the message. </param> |
| 181 | /// <returns> The updated <see cref="ThreadMessage"/>. </returns> |
| 182 | public virtual Task<ClientResult<ThreadMessage>> ModifyMessageAsync(ThreadMessage message, MessageModificationOptions options) |
| 183 | => ModifyMessageAsync(message?.ThreadId, message?.Id, options); |
| 184 | |
| 185 | /// <summary> |
| 186 | /// Modifies an existing <see cref="ThreadMessage"/>. |
| 187 | /// </summary> |
| 188 | /// <param name="message"> The message to modify. </param> |
| 189 | /// <param name="options"> The changes to apply to the message. </param> |
| 190 | /// <returns> The updated <see cref="ThreadMessage"/>. </returns> |
| 191 | public virtual ClientResult<ThreadMessage> ModifyMessage(ThreadMessage message, MessageModificationOptions options) |
| 192 | => ModifyMessage(message?.ThreadId, message?.Id, options); |
| 193 | |
| 194 | /// <summary> |
| 195 | /// Deletes an existing <see cref="ThreadMessage"/>. |
| 196 | /// </summary> |
| 197 | /// <param name="message"> The message to delete. </param> |
| 198 | /// <returns> A value indicating whether the deletion was successful. </returns> |
| 199 | public virtual Task<ClientResult<bool>> DeleteMessageAsync(ThreadMessage message) |
| 200 | => DeleteMessageAsync(message?.ThreadId, message?.Id); |
| 201 | |
| 202 | /// <summary> |
| 203 | /// Deletes an existing <see cref="ThreadMessage"/>. |
| 204 | /// </summary> |
| 205 | /// <param name="message"> The message to delete. </param> |
| 206 | /// <returns> A value indicating whether the deletion was successful. </returns> |
| 207 | public virtual ClientResult<bool> DeleteMessage(ThreadMessage message) |
| 208 | => DeleteMessage(message?.ThreadId, message?.Id); |
| 209 | |
| 210 | /// <summary> |
| 211 | /// Begins a new <see cref="ThreadRun"/> that evaluates a <see cref="AssistantThread"/> using a specified |
| 212 | /// <see cref="Assistant"/>. |
| 213 | /// </summary> |
| 214 | /// <param name="thread"> The thread that the run should evaluate. </param> |
| 215 | /// <param name="assistant"> The assistant that should be used when evaluating the thread. </param> |
| 216 | /// <param name="options"> Additional options for the run. </param> |
| 217 | /// <returns> A new <see cref="ThreadRun"/> instance. </returns> |
| 218 | public virtual Task<ClientResult<ThreadRun>> CreateRunAsync(AssistantThread thread, Assistant assistant, RunCreationOptions options = null) |
| 219 | => CreateRunAsync(thread?.Id, assistant?.Id, options); |
| 220 | |
| 221 | /// <summary> |
| 222 | /// Begins a new <see cref="ThreadRun"/> that evaluates a <see cref="AssistantThread"/> using a specified |
| 223 | /// <see cref="Assistant"/>. |
| 224 | /// </summary> |
| 225 | /// <param name="thread"> The thread that the run should evaluate. </param> |
| 226 | /// <param name="assistant"> The assistant that should be used when evaluating the thread. </param> |
| 227 | /// <param name="options"> Additional options for the run. </param> |
| 228 | /// <returns> A new <see cref="ThreadRun"/> instance. </returns> |
| 229 | public virtual ClientResult<ThreadRun> CreateRun(AssistantThread thread, Assistant assistant, RunCreationOptions options = null) |
| 230 | => CreateRun(thread?.Id, assistant?.Id, options); |
| 231 | |
| 232 | /// <summary> |
| 233 | /// Begins a new streaming <see cref="ThreadRun"/> that evaluates a <see cref="AssistantThread"/> using a specified |
| 234 | /// <see cref="Assistant"/>. |
| 235 | /// </summary> |
| 236 | /// <param name="thread"> The thread that the run should evaluate. </param> |
| 237 | /// <param name="assistant"> The assistant that should be used when evaluating the thread. </param> |
| 238 | /// <param name="options"> Additional options for the run. </param> |
| 239 | public virtual AsyncResultCollection<StreamingUpdate> CreateRunStreamingAsync( |
| 240 | AssistantThread thread, |
| 241 | Assistant assistant, |
| 242 | RunCreationOptions options = null) |
| 243 | => CreateRunStreamingAsync(thread?.Id, assistant?.Id, options); |
| 244 | |
| 245 | /// <summary> |
| 246 | /// Begins a new streaming <see cref="ThreadRun"/> that evaluates a <see cref="AssistantThread"/> using a specified |
| 247 | /// <see cref="Assistant"/>. |
| 248 | /// </summary> |
| 249 | /// <param name="thread"> The thread that the run should evaluate. </param> |
| 250 | /// <param name="assistant"> The assistant that should be used when evaluating the thread. </param> |
| 251 | /// <param name="options"> Additional options for the run. </param> |
| 252 | public virtual ResultCollection<StreamingUpdate> CreateRunStreaming( |
| 253 | AssistantThread thread, |
| 254 | Assistant assistant, |
| 255 | RunCreationOptions options = null) |
| 256 | => CreateRunStreaming(thread?.Id, assistant?.Id, options); |
| 257 | |
| 258 | /// <summary> |
| 259 | /// Creates a new thread and immediately begins a run against it using the specified <see cref="Assistant"/>. |
| 260 | /// </summary> |
| 261 | /// <param name="assistant"> The assistant that the new run should use. </param> |
| 262 | /// <param name="threadOptions"> Options for the new thread that will be created. </param> |
| 263 | /// <param name="runOptions"> Additional options to apply to the run that will begin. </param> |
| 264 | /// <returns> A new <see cref="ThreadRun"/>. </returns> |
| 265 | public virtual Task<ClientResult<ThreadRun>> CreateThreadAndRunAsync( |
| 266 | Assistant assistant, |
| 267 | ThreadCreationOptions threadOptions = null, |
| 268 | RunCreationOptions runOptions = null) |
| 269 | => CreateThreadAndRunAsync(assistant?.Id, threadOptions, runOptions); |
| 270 | |
| 271 | /// <summary> |
| 272 | /// Creates a new thread and immediately begins a run against it using the specified <see cref="Assistant"/>. |
| 273 | /// </summary> |
| 274 | /// <param name="assistant"> The assistant that the new run should use. </param> |
| 275 | /// <param name="threadOptions"> Options for the new thread that will be created. </param> |
| 276 | /// <param name="runOptions"> Additional options to apply to the run that will begin. </param> |
| 277 | /// <returns> A new <see cref="ThreadRun"/>. </returns> |
| 278 | public virtual ClientResult<ThreadRun> CreateThreadAndRun( |
| 279 | Assistant assistant, |
| 280 | ThreadCreationOptions threadOptions = null, |
| 281 | RunCreationOptions runOptions = null) |
| 282 | => CreateThreadAndRun(assistant?.Id, threadOptions, runOptions); |
| 283 | |
| 284 | /// <summary> |
| 285 | /// Creates a new thread and immediately begins a streaming run against it using the specified <see cref="Assistant"/>. |
| 286 | /// </summary> |
| 287 | /// <param name="assistant"> The assistant that the new run should use. </param> |
| 288 | /// <param name="threadOptions"> Options for the new thread that will be created. </param> |
| 289 | /// <param name="runOptions"> Additional options to apply to the run that will begin. </param> |
| 290 | public virtual AsyncResultCollection<StreamingUpdate> CreateThreadAndRunStreamingAsync( |
| 291 | Assistant assistant, |
| 292 | ThreadCreationOptions threadOptions = null, |
| 293 | RunCreationOptions runOptions = null) |
| 294 | => CreateThreadAndRunStreamingAsync(assistant?.Id, threadOptions, runOptions); |
| 295 | |
| 296 | /// <summary> |
| 297 | /// Creates a new thread and immediately begins a streaming run against it using the specified <see cref="Assistant"/>. |
| 298 | /// </summary> |
| 299 | /// <param name="assistant"> The assistant that the new run should use. </param> |
| 300 | /// <param name="threadOptions"> Options for the new thread that will be created. </param> |
| 301 | /// <param name="runOptions"> Additional options to apply to the run that will begin. </param> |
| 302 | public virtual ResultCollection<StreamingUpdate> CreateThreadAndRunStreaming( |
| 303 | Assistant assistant, |
| 304 | ThreadCreationOptions threadOptions = null, |
| 305 | RunCreationOptions runOptions = null) |
| 306 | => CreateThreadAndRunStreaming(assistant?.Id, threadOptions, runOptions); |
| 307 | |
| 308 | /// <summary> |
| 309 | /// Returns a collection of <see cref="ThreadRun"/> instances associated with an existing <see cref="AssistantThread"/>. |
| 310 | /// </summary> |
| 311 | /// <param name="thread"> The thread that runs in the list should be associated with. </param> |
| 312 | /// <param name="resultOrder"> |
| 313 | /// The <c>order</c> that results should appear in the list according to their <c>created_at</c> |
| 314 | /// timestamp. |
| 315 | /// </param> |
| 316 | /// <returns> A collection of runs that can be enumerated using <c>await foreach</c>. </returns> |
| 317 | public virtual AsyncPageableCollection<ThreadRun> GetRunsAsync( |
| 318 | AssistantThread thread, |
| 319 | ListOrder? resultOrder = default) |
| 320 | { |
| 321 | Argument.AssertNotNull(thread, nameof(thread)); |
| 322 | |
| 323 | return GetRunsAsync(thread.Id, resultOrder); |
| 324 | } |
| 325 | |
| 326 | /// <summary> |
| 327 | /// Returns a collection of <see cref="ThreadRun"/> instances associated with an existing <see cref="AssistantThread"/>. |
| 328 | /// </summary> |
| 329 | /// <param name="thread"> The thread that runs in the list should be associated with. </param> |
| 330 | /// <param name="resultOrder"> |
| 331 | /// The <c>order</c> that results should appear in the list according to their <c>created_at</c> |
| 332 | /// timestamp. |
| 333 | /// </param> |
| 334 | /// <returns> A collection of runs that can be enumerated using <c>foreach</c>. </returns> |
| 335 | public virtual PageableCollection<ThreadRun> GetRuns( |
| 336 | AssistantThread thread, |
| 337 | ListOrder? resultOrder = default) |
| 338 | { |
| 339 | Argument.AssertNotNull(thread, nameof(thread)); |
| 340 | |
| 341 | return GetRuns(thread.Id, resultOrder); |
| 342 | } |
| 343 | |
| 344 | /// <summary> |
| 345 | /// Gets a refreshed instance of an existing <see cref="ThreadRun"/>. |
| 346 | /// </summary> |
| 347 | /// <param name="run"> The run to get a refreshed instance of. </param> |
| 348 | /// <returns> A new <see cref="ThreadRun"/> instance with updated information. </returns> |
| 349 | public virtual Task<ClientResult<ThreadRun>> GetRunAsync(ThreadRun run) |
| 350 | => GetRunAsync(run?.ThreadId, run?.Id); |
| 351 | |
| 352 | /// <summary> |
| 353 | /// Gets a refreshed instance of an existing <see cref="ThreadRun"/>. |
| 354 | /// </summary> |
| 355 | /// <param name="run"> The run to get a refreshed instance of. </param> |
| 356 | /// <returns> A new <see cref="ThreadRun"/> instance with updated information. </returns> |
| 357 | public virtual ClientResult<ThreadRun> GetRun(ThreadRun run) |
| 358 | => GetRun(run?.ThreadId, run?.Id); |
| 359 | |
| 360 | /// <summary> |
| 361 | /// Submits a collection of required tool call outputs to a run and resumes the run. |
| 362 | /// </summary> |
| 363 | /// <param name="run"> The run that reached a <c>requires_action</c> status. </param> |
| 364 | /// <param name="toolOutputs"> |
| 365 | /// The tool outputs, corresponding to <see cref="InternalRequiredToolCall"/> instances from the run. |
| 366 | /// </param> |
| 367 | /// <returns> The <see cref="ThreadRun"/>, updated after the submission was processed. </returns> |
| 368 | public virtual Task<ClientResult<ThreadRun>> SubmitToolOutputsToRunAsync( |
| 369 | ThreadRun run, |
| 370 | IEnumerable<ToolOutput> toolOutputs) |
| 371 | => SubmitToolOutputsToRunAsync(run?.ThreadId, run?.Id, toolOutputs); |
| 372 | |
| 373 | /// <summary> |
| 374 | /// Submits a collection of required tool call outputs to a run and resumes the run. |
| 375 | /// </summary> |
| 376 | /// <param name="run"> The run that reached a <c>requires_action</c> status. </param> |
| 377 | /// <param name="toolOutputs"> |
| 378 | /// The tool outputs, corresponding to <see cref="InternalRequiredToolCall"/> instances from the run. |
| 379 | /// </param> |
| 380 | /// <returns> The <see cref="ThreadRun"/>, updated after the submission was processed. </returns> |
| 381 | public virtual ClientResult<ThreadRun> SubmitToolOutputsToRun( |
| 382 | ThreadRun run, |
| 383 | IEnumerable<ToolOutput> toolOutputs) |
| 384 | => SubmitToolOutputsToRun(run?.ThreadId, run?.Id, toolOutputs); |
| 385 | |
| 386 | /// <summary> |
| 387 | /// Submits a collection of required tool call outputs to a run and resumes the run with streaming enabled. |
| 388 | /// </summary> |
| 389 | /// <param name="run"> The run that reached a <c>requires_action</c> status. </param> |
| 390 | /// <param name="toolOutputs"> |
| 391 | /// The tool outputs, corresponding to <see cref="InternalRequiredToolCall"/> instances from the run. |
| 392 | /// </param> |
| 393 | public virtual AsyncResultCollection<StreamingUpdate> SubmitToolOutputsToRunStreamingAsync( |
| 394 | ThreadRun run, |
| 395 | IEnumerable<ToolOutput> toolOutputs) |
| 396 | => SubmitToolOutputsToRunStreamingAsync(run?.ThreadId, run?.Id, toolOutputs); |
| 397 | |
| 398 | /// <summary> |
| 399 | /// Submits a collection of required tool call outputs to a run and resumes the run with streaming enabled. |
| 400 | /// </summary> |
| 401 | /// <param name="run"> The run that reached a <c>requires_action</c> status. </param> |
| 402 | /// <param name="toolOutputs"> |
| 403 | /// The tool outputs, corresponding to <see cref="InternalRequiredToolCall"/> instances from the run. |
| 404 | /// </param> |
| 405 | public virtual ResultCollection<StreamingUpdate> SubmitToolOutputsToRunStreaming( |
| 406 | ThreadRun run, |
| 407 | IEnumerable<ToolOutput> toolOutputs) |
| 408 | => SubmitToolOutputsToRunStreaming(run?.ThreadId, run?.Id, toolOutputs); |
| 409 | |
| 410 | /// <summary> |
| 411 | /// Cancels an in-progress <see cref="ThreadRun"/>. |
| 412 | /// </summary> |
| 413 | /// <param name="run"> The run to cancel. </param> |
| 414 | /// <returns> An updated <see cref="ThreadRun"/> instance, reflecting the new status of the run. </returns> |
| 415 | public virtual Task<ClientResult<ThreadRun>> CancelRunAsync(ThreadRun run) |
| 416 | => CancelRunAsync(run?.ThreadId, run?.Id); |
| 417 | |
| 418 | /// <summary> |
| 419 | /// Cancels an in-progress <see cref="ThreadRun"/>. |
| 420 | /// </summary> |
| 421 | /// <param name="run"> The run to cancel. </param> |
| 422 | /// <returns> An updated <see cref="ThreadRun"/> instance, reflecting the new status of the run. </returns> |
| 423 | public virtual ClientResult<ThreadRun> CancelRun(ThreadRun run) |
| 424 | => CancelRun(run?.ThreadId, run?.Id); |
| 425 | |
| 426 | /// <summary> |
| 427 | /// Gets a collection of <see cref="RunStep"/> instances associated with a <see cref="ThreadRun"/>. |
| 428 | /// </summary> |
| 429 | /// <param name="run"> The run to list run steps from. </param> |
| 430 | /// <param name="resultOrder"> |
| 431 | /// The <c>order</c> that results should appear in the list according to their <c>created_at</c> |
| 432 | /// timestamp. |
| 433 | /// </param> |
| 434 | /// <returns> A collection of run steps that can be enumerated using <c>await foreach</c>. </returns> |
| 435 | public virtual PageableCollection<RunStep> GetRunSteps( |
| 436 | ThreadRun run, |
| 437 | ListOrder? resultOrder = default) |
| 438 | { |
| 439 | Argument.AssertNotNull(run, nameof(run)); |
| 440 | |
| 441 | return GetRunSteps(run.ThreadId, run.Id, resultOrder); |
| 442 | } |
| 443 | |
| 444 | /// <summary> |
| 445 | /// Gets a collection of <see cref="RunStep"/> instances associated with a <see cref="ThreadRun"/>. |
| 446 | /// </summary> |
| 447 | /// <param name="run"> The run to list run steps from. </param> |
| 448 | /// <param name="resultOrder"> |
| 449 | /// The <c>order</c> that results should appear in the list according to their <c>created_at</c> |
| 450 | /// timestamp. |
| 451 | /// </param> |
| 452 | /// <returns> A collection of run steps that can be enumerated using <c>foreach</c>. </returns> |
| 453 | public virtual AsyncPageableCollection<RunStep> GetRunStepsAsync( |
| 454 | ThreadRun run, |
| 455 | ListOrder? resultOrder = default) |
| 456 | { |
| 457 | Argument.AssertNotNull(run, nameof(run)); |
| 458 | |
| 459 | return GetRunStepsAsync(run.ThreadId, run.Id, resultOrder); |
| 460 | } |
| 461 | } |
| 462 | |