|
| 1 | +using OpenAI.ClientShared.Internal; |
1 | 2 | using System; |
2 | | -using System.ClientModel; |
3 | | -using System.ClientModel.Internal; |
4 | | - |
5 | 3 | using System.ClientModel; |
6 | 4 | using System.ClientModel.Primitives; |
7 | 5 | using System.Collections.Generic; |
8 | | -using System.Threading; |
9 | 6 | using System.Threading.Tasks; |
10 | | -using OpenAI.Internal; |
11 | | -using System.Text.Json; |
12 | | -using OpenAI.ClientShared.Internal; |
13 | 7 |
|
14 | 8 | namespace OpenAI.Assistants; |
15 | 9 |
|
@@ -530,13 +524,13 @@ Internal.Models.CreateThreadAndRunRequest request |
530 | 524 | return ClientResult.FromValue(new ThreadRun(internalResult.Value), internalResult.GetRawResponse()); |
531 | 525 | } |
532 | 526 |
|
533 | | - public virtual ClientResult<ThreadRun> GetRun(string threadId, string runId) |
| 527 | + public virtual ClientResult<ThreadRun> GetRun(string threadId, string runId) |
534 | 528 | { |
535 | 529 | ClientResult<Internal.Models.RunObject> internalResult = RunShim.GetRun(threadId, runId); |
536 | 530 | return ClientResult.FromValue(new ThreadRun(internalResult.Value), internalResult.GetRawResponse()); |
537 | 531 | } |
538 | 532 |
|
539 | | - public virtual async Task<ClientResult<ThreadRun>> GetRunAsync(string threadId, string runId) |
| 533 | + public virtual async Task<ClientResult<ThreadRun>> GetRunAsync(string threadId, string runId) |
540 | 534 | { |
541 | 535 | ClientResult<Internal.Models.RunObject> internalResult |
542 | 536 | = await RunShim.GetRunAsync(threadId, runId).ConfigureAwait(false); |
@@ -575,60 +569,60 @@ public virtual Task<ClientResult<ListQueryPage<ThreadRun>>> GetRunsAsync( |
575 | 569 | return GetListQueryPageAsync<ThreadRun, Internal.Models.ListRunsResponse>(internalFunc); |
576 | 570 | } |
577 | 571 |
|
578 | | - public virtual ClientResult<ThreadRun> ModifyRun(string threadId, string runId, RunModificationOptions options) |
| 572 | + public virtual ClientResult<ThreadRun> ModifyRun(string threadId, string runId, RunModificationOptions options) |
579 | 573 | { |
580 | 574 | Internal.Models.ModifyRunRequest request = new(options.Metadata, serializedAdditionalRawData: null); |
581 | 575 | ClientResult<Internal.Models.RunObject> internalResult = RunShim.ModifyRun(threadId, runId, request); |
582 | 576 | return ClientResult.FromValue(new ThreadRun(internalResult.Value), internalResult.GetRawResponse()); |
583 | 577 | } |
584 | 578 |
|
585 | | - public virtual async Task<ClientResult<ThreadRun>> ModifyRunAsync(string threadId, string runId, RunModificationOptions options) |
| 579 | + public virtual async Task<ClientResult<ThreadRun>> ModifyRunAsync(string threadId, string runId, RunModificationOptions options) |
586 | 580 | { |
587 | 581 | Internal.Models.ModifyRunRequest request = new(options.Metadata, serializedAdditionalRawData: null); |
588 | 582 | ClientResult<Internal.Models.RunObject> internalResult |
589 | 583 | = await RunShim.ModifyRunAsync(threadId, runId, request).ConfigureAwait(false); |
590 | 584 | return ClientResult.FromValue(new ThreadRun(internalResult.Value), internalResult.GetRawResponse()); |
591 | 585 | } |
592 | 586 |
|
593 | | - public virtual ClientResult<bool> CancelRun(string threadId, string runId) |
| 587 | + public virtual ClientResult<bool> CancelRun(string threadId, string runId) |
594 | 588 | { |
595 | 589 | ClientResult<Internal.Models.RunObject> internalResult = RunShim.CancelRun(threadId, runId); |
596 | 590 | return ClientResult.FromValue(true, internalResult.GetRawResponse()); |
597 | 591 | } |
598 | 592 |
|
599 | | - public virtual async Task<ClientResult<bool>> CancelRunAsync(string threadId, string runId) |
| 593 | + public virtual async Task<ClientResult<bool>> CancelRunAsync(string threadId, string runId) |
600 | 594 | { |
601 | 595 | ClientResult<Internal.Models.RunObject> internalResult |
602 | 596 | = await RunShim.CancelRunAsync(threadId, runId); |
603 | 597 | return ClientResult.FromValue(true, internalResult.GetRawResponse()); |
604 | 598 | } |
605 | 599 |
|
606 | | - public virtual ClientResult<bool> SubmitToolOutputs(string threadId, string runId, IEnumerable<ToolOutput> toolOutputs) |
| 600 | + public virtual ClientResult<ThreadRun> SubmitToolOutputs(string threadId, string runId, IEnumerable<ToolOutput> toolOutputs) |
607 | 601 | { |
608 | | - BinaryContent content = BinaryContent.Create(BinaryData.FromObjectAsJson(new |
609 | | - { |
610 | | - tool_outputs = toolOutputs |
611 | | - }, |
612 | | - new JsonSerializerOptions() |
613 | | - { |
614 | | - PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower |
615 | | - })); |
616 | | - ClientResult internalResult = RunShim.SubmitToolOuputsToRun(threadId, runId, content, default); |
617 | | - return ClientResult.FromValue(true, internalResult.GetRawResponse()); |
| 602 | + List<Internal.Models.SubmitToolOutputsRunRequestToolOutput> requestToolOutputs = []; |
| 603 | + |
| 604 | + foreach (ToolOutput toolOutput in toolOutputs) |
| 605 | + { |
| 606 | + requestToolOutputs.Add(new(toolOutput.Id, toolOutput.Output, null)); |
| 607 | + } |
| 608 | + |
| 609 | + Internal.Models.SubmitToolOutputsRunRequest request = new(requestToolOutputs, null); |
| 610 | + ClientResult<Internal.Models.RunObject> internalResult = RunShim.SubmitToolOuputsToRun(threadId, runId, request); |
| 611 | + return ClientResult.FromValue(new ThreadRun(internalResult.Value), internalResult.GetRawResponse()); |
618 | 612 | } |
619 | 613 |
|
620 | | - public virtual async Task<ClientResult<bool>> SubmitToolOutputsAsync(string threadId, string runId, IEnumerable<ToolOutput> toolOutputs) |
| 614 | + public virtual async Task<ClientResult<bool>> SubmitToolOutputsAsync(string threadId, string runId, IEnumerable<ToolOutput> toolOutputs) |
621 | 615 | { |
622 | | - BinaryContent content = BinaryContent.Create(BinaryData.FromObjectAsJson(new |
623 | | - { |
624 | | - tool_outputs = toolOutputs |
625 | | - }, |
626 | | - new JsonSerializerOptions() |
627 | | - { |
628 | | - PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower |
629 | | - })); |
630 | | - ClientResult internalResult |
631 | | - = await RunShim.SubmitToolOuputsToRunAsync(threadId, runId, content, default).ConfigureAwait(false); |
| 616 | + List<Internal.Models.SubmitToolOutputsRunRequestToolOutput> requestToolOutputs = []; |
| 617 | + |
| 618 | + foreach (ToolOutput toolOutput in toolOutputs) |
| 619 | + { |
| 620 | + requestToolOutputs.Add(new(toolOutput.Id, toolOutput.Output, null)); |
| 621 | + } |
| 622 | + |
| 623 | + Internal.Models.SubmitToolOutputsRunRequest request = new(requestToolOutputs, null); |
| 624 | + ClientResult<Internal.Models.RunObject> internalResult |
| 625 | + = await RunShim.SubmitToolOuputsToRunAsync(threadId, runId, request).ConfigureAwait(false); |
632 | 626 | return ClientResult.FromValue(true, internalResult.GetRawResponse()); |
633 | 627 | } |
634 | 628 |
|
|
0 commit comments