Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
e3b8093
Update to use new pageable APIs and patterns
annelo-msft May 29, 2024
5ce3907
start adding back client-driven paging parameters for paging POC
annelo-msft May 29, 2024
45c7106
updates to APIs to move client-paging parameters into service methods
annelo-msft May 30, 2024
e41e18b
prove paged collection 'rehydration' concept and fix bugs in pageable…
annelo-msft May 30, 2024
4ac7cb2
WIP + tests
annelo-msft May 30, 2024
bff1887
use only LastId for continuationToken per what TypeSpec allows
annelo-msft May 30, 2024
ba89320
updates from renaming continuationToken to pageToken
annelo-msft May 31, 2024
351a358
backup of WIP; investigating feasibility of using PreviousPageToken p…
annelo-msft May 31, 2024
02fa33b
backup of WIP; investigating feasibility of using PreviousPageToken p…
annelo-msft Jun 1, 2024
aa38364
backup of WIP; refactored for debugging - still proving concept of Pr…
annelo-msft Jun 1, 2024
40b658e
Merge remote-tracking branch 'joseharriaga/main' into oai-scm-paging-…
annelo-msft Jun 3, 2024
05586fc
backup
annelo-msft Jun 3, 2024
a472b97
correction
annelo-msft Jun 3, 2024
da44e91
more debugging and exploration of paging
annelo-msft Jun 3, 2024
f72e696
updates
annelo-msft Jun 6, 2024
7d1056d
updates from changes to SCM pageable types
annelo-msft Jun 7, 2024
a82f1ea
remove prev page experiment
annelo-msft Jun 7, 2024
b11b390
WIP: Update with proof of concept of pageable API where GetPage is th…
annelo-msft Jun 10, 2024
318b8c3
look at subtype implementation
annelo-msft Jun 10, 2024
c2338de
updates from last round of SCM renames
annelo-msft Jun 10, 2024
c3ef5ab
backup of me being confused
annelo-msft Jun 11, 2024
23f9eec
updates from SCM renames
annelo-msft Jun 12, 2024
a297ad5
more tries and ideas
annelo-msft Jun 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 10 additions & 24 deletions .dotnet/OpenAI.sln
Original file line number Diff line number Diff line change
@@ -1,37 +1,19 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29709.97
# Visual Studio Version 17
VisualStudioVersion = 17.9.34902.65
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenAI", "src\OpenAI.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenAI", "src\OpenAI.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenAI.Tests", "tests\OpenAI.Tests.csproj", "{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenAI.Tests", "tests\OpenAI.Tests.csproj", "{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.ClientModel", "..\..\azure-sdk-for-net\sdk\core\System.ClientModel\src\System.ClientModel.csproj", "{174AF64C-C129-454D-BFE7-0D05018EC531}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.Build.0 = Release|Any CPU
{8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.Build.0 = Release|Any CPU
{A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.Build.0 = Release|Any CPU
{FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.Build.0 = Release|Any CPU
{85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.Build.0 = Release|Any CPU
{28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU
{28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -40,6 +22,10 @@ Global
{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.Build.0 = Release|Any CPU
{174AF64C-C129-454D-BFE7-0D05018EC531}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{174AF64C-C129-454D-BFE7-0D05018EC531}.Debug|Any CPU.Build.0 = Debug|Any CPU
{174AF64C-C129-454D-BFE7-0D05018EC531}.Release|Any CPU.ActiveCfg = Release|Any CPU
{174AF64C-C129-454D-BFE7-0D05018EC531}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
5 changes: 5 additions & 0 deletions .dotnet/src/Custom/Assistants/Assistant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@ public partial class Assistant
/// </summary>
[CodeGenMember("TopP")]
public float? NucleusSamplingFactor { get; }

public override string ToString()
{
return Id;
}
}
238 changes: 127 additions & 111 deletions .dotnet/src/Custom/Assistants/AssistantClient.Convenience.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,41 +121,45 @@ public virtual ClientResult<ThreadMessage> CreateMessage(
MessageCreationOptions options = null)
=> CreateMessage(thread?.Id, content, options);

/// <summary>
/// Returns a collection of <see cref="ThreadMessage"/> instances from an existing <see cref="AssistantThread"/>.
/// </summary>
/// <param name="thread"> The thread to list messages from. </param>
/// <param name="resultOrder">
/// The <c>order</c> that results should appear in the list according to their <c>created_at</c>
/// timestamp.
/// </param>
/// <returns> A collection of messages that can be enumerated using <c>await foreach</c>. </returns>
public virtual AsyncPageableCollection<ThreadMessage> GetMessagesAsync(
AssistantThread thread,
ListOrder? resultOrder = default)
{
Argument.AssertNotNull(thread, nameof(thread));

return GetMessagesAsync(thread.Id, resultOrder);
}

/// <summary>
/// Returns a collection of <see cref="ThreadMessage"/> instances from an existing <see cref="AssistantThread"/>.
/// </summary>
/// <param name="thread"> The thread to list messages from. </param>
/// <param name="resultOrder">
/// The <c>order</c> that results should appear in the list according to their <c>created_at</c>
/// timestamp.
/// </param>
/// <returns> A collection of messages that can be enumerated using <c>foreach</c>. </returns>
public virtual PageableCollection<ThreadMessage> GetMessages(
AssistantThread thread,
ListOrder? resultOrder = default)
{
Argument.AssertNotNull(thread, nameof(thread));

return GetMessages(thread.Id, resultOrder);
}
///// <summary>
///// Returns a collection of <see cref="ThreadMessage"/> instances from an existing <see cref="AssistantThread"/>.
///// </summary>
///// <param name="thread"> The thread to list messages from. </param>
///// <param name="itemOrder">
///// The <c>order</c> that results should appear in the list according to their <c>created_at</c>
///// timestamp.
///// </param>
///// <returns> A collection of messages that can be enumerated using <c>await foreach</c>. </returns>
//public virtual AsyncClientPageable<ThreadMessage> GetMessagesAsync(
// AssistantThread thread,
// int? pageSize = null,
// ListOrder? itemOrder = default)
//{
// Argument.AssertNotNull(thread, nameof(thread));

// return GetMessagesAsync(thread.Id, pageSize, itemOrder);
//}

///// <summary>
///// Returns a collection of <see cref="ThreadMessage"/> instances from an existing <see cref="AssistantThread"/>.
///// </summary>
///// <param name="thread"> The thread to list messages from. </param>
///// <param name="itemOrder">
///// The <c>order</c> that results should appear in the list according to their <c>created_at</c>
///// timestamp.
///// </param>
///// <returns> A collection of messages that can be enumerated using <c>foreach</c>. </returns>
//public virtual ClientPageable<ThreadMessage> GetMessages(
// AssistantThread thread,
// ListOrder? itemOrder = null,
// string itemsAfter = default,
// string itemsBefore = default,
// int? pageSize = null)
//{
// Argument.AssertNotNull(thread, nameof(thread));

// return GetMessages(thread.Id, itemOrder, itemsAfter, itemsBefore, pageSize);
//}

/// <summary>
/// Gets an updated instance of an existing <see cref="ThreadMessage"/>.
Expand Down Expand Up @@ -236,7 +240,7 @@ public virtual ClientResult<ThreadRun> CreateRun(AssistantThread thread, Assista
/// <param name="thread"> The thread that the run should evaluate. </param>
/// <param name="assistant"> The assistant that should be used when evaluating the thread. </param>
/// <param name="options"> Additional options for the run. </param>
public virtual AsyncResultCollection<StreamingUpdate> CreateRunStreamingAsync(
public virtual AsyncClientCollection<StreamingUpdate> CreateRunStreamingAsync(
AssistantThread thread,
Assistant assistant,
RunCreationOptions options = null)
Expand All @@ -249,7 +253,7 @@ public virtual AsyncResultCollection<StreamingUpdate> CreateRunStreamingAsync(
/// <param name="thread"> The thread that the run should evaluate. </param>
/// <param name="assistant"> The assistant that should be used when evaluating the thread. </param>
/// <param name="options"> Additional options for the run. </param>
public virtual ResultCollection<StreamingUpdate> CreateRunStreaming(
public virtual ClientCollection<StreamingUpdate> CreateRunStreaming(
AssistantThread thread,
Assistant assistant,
RunCreationOptions options = null)
Expand Down Expand Up @@ -287,7 +291,7 @@ public virtual ClientResult<ThreadRun> CreateThreadAndRun(
/// <param name="assistant"> The assistant that the new run should use. </param>
/// <param name="threadOptions"> Options for the new thread that will be created. </param>
/// <param name="runOptions"> Additional options to apply to the run that will begin. </param>
public virtual AsyncResultCollection<StreamingUpdate> CreateThreadAndRunStreamingAsync(
public virtual AsyncClientCollection<StreamingUpdate> CreateThreadAndRunStreamingAsync(
Assistant assistant,
ThreadCreationOptions threadOptions = null,
RunCreationOptions runOptions = null)
Expand All @@ -299,47 +303,53 @@ public virtual AsyncResultCollection<StreamingUpdate> CreateThreadAndRunStreamin
/// <param name="assistant"> The assistant that the new run should use. </param>
/// <param name="threadOptions"> Options for the new thread that will be created. </param>
/// <param name="runOptions"> Additional options to apply to the run that will begin. </param>
public virtual ResultCollection<StreamingUpdate> CreateThreadAndRunStreaming(
public virtual ClientCollection<StreamingUpdate> CreateThreadAndRunStreaming(
Assistant assistant,
ThreadCreationOptions threadOptions = null,
RunCreationOptions runOptions = null)
=> CreateThreadAndRunStreaming(assistant?.Id, threadOptions, runOptions);

/// <summary>
/// Returns a collection of <see cref="ThreadRun"/> instances associated with an existing <see cref="AssistantThread"/>.
/// </summary>
/// <param name="thread"> The thread that runs in the list should be associated with. </param>
/// <param name="resultOrder">
/// The <c>order</c> that results should appear in the list according to their <c>created_at</c>
/// timestamp.
/// </param>
/// <returns> A collection of runs that can be enumerated using <c>await foreach</c>. </returns>
public virtual AsyncPageableCollection<ThreadRun> GetRunsAsync(
AssistantThread thread,
ListOrder? resultOrder = default)
{
Argument.AssertNotNull(thread, nameof(thread));

return GetRunsAsync(thread.Id, resultOrder);
}

/// <summary>
/// Returns a collection of <see cref="ThreadRun"/> instances associated with an existing <see cref="AssistantThread"/>.
/// </summary>
/// <param name="thread"> The thread that runs in the list should be associated with. </param>
/// <param name="resultOrder">
/// The <c>order</c> that results should appear in the list according to their <c>created_at</c>
/// timestamp.
/// </param>
/// <returns> A collection of runs that can be enumerated using <c>foreach</c>. </returns>
public virtual PageableCollection<ThreadRun> GetRuns(
AssistantThread thread,
ListOrder? resultOrder = default)
{
Argument.AssertNotNull(thread, nameof(thread));

return GetRuns(thread.Id, resultOrder);
}
///// <summary>
///// Returns a collection of <see cref="ThreadRun"/> instances associated with an existing <see cref="AssistantThread"/>.
///// </summary>
///// <param name="thread"> The thread that runs in the list should be associated with. </param>
///// <param name="itemOrder">
///// The <c>order</c> that results should appear in the list according to their <c>created_at</c>
///// timestamp.
///// </param>
///// <returns> A collection of runs that can be enumerated using <c>await foreach</c>. </returns>
//public virtual AsyncClientPageable<ThreadRun> GetRunsAsync(
// AssistantThread thread,
// ListOrder? itemOrder = null,
// string itemsAfter = default,
// string itemsBefore = default,
// int? pageSize = null)
//{
// Argument.AssertNotNull(thread, nameof(thread));

// return GetRunsAsync(thread.Id, itemOrder, itemsAfter, itemsBefore, pageSize);
//}

///// <summary>
///// Returns a collection of <see cref="ThreadRun"/> instances associated with an existing <see cref="AssistantThread"/>.
///// </summary>
///// <param name="thread"> The thread that runs in the list should be associated with. </param>
///// <param name="itemOrder">
///// The <c>order</c> that results should appear in the list according to their <c>created_at</c>
///// timestamp.
///// </param>
///// <returns> A collection of runs that can be enumerated using <c>foreach</c>. </returns>
//public virtual ClientPageable<ThreadRun> GetRuns(
// AssistantThread thread,
// ListOrder? itemOrder = null,
// string itemsAfter = default,
// string itemsBefore = default,
// int? pageSize = null)
//{
// Argument.AssertNotNull(thread, nameof(thread));

// return GetRuns(thread.Id, itemOrder, itemsAfter, itemsBefore, pageSize);
//}

/// <summary>
/// Gets a refreshed instance of an existing <see cref="ThreadRun"/>.
Expand Down Expand Up @@ -390,7 +400,7 @@ public virtual ClientResult<ThreadRun> SubmitToolOutputsToRun(
/// <param name="toolOutputs">
/// The tool outputs, corresponding to <see cref="InternalRequiredToolCall"/> instances from the run.
/// </param>
public virtual AsyncResultCollection<StreamingUpdate> SubmitToolOutputsToRunStreamingAsync(
public virtual AsyncClientCollection<StreamingUpdate> SubmitToolOutputsToRunStreamingAsync(
ThreadRun run,
IEnumerable<ToolOutput> toolOutputs)
=> SubmitToolOutputsToRunStreamingAsync(run?.ThreadId, run?.Id, toolOutputs);
Expand All @@ -402,7 +412,7 @@ public virtual AsyncResultCollection<StreamingUpdate> SubmitToolOutputsToRunStre
/// <param name="toolOutputs">
/// The tool outputs, corresponding to <see cref="InternalRequiredToolCall"/> instances from the run.
/// </param>
public virtual ResultCollection<StreamingUpdate> SubmitToolOutputsToRunStreaming(
public virtual ClientCollection<StreamingUpdate> SubmitToolOutputsToRunStreaming(
ThreadRun run,
IEnumerable<ToolOutput> toolOutputs)
=> SubmitToolOutputsToRunStreaming(run?.ThreadId, run?.Id, toolOutputs);
Expand All @@ -423,39 +433,45 @@ public virtual Task<ClientResult<ThreadRun>> CancelRunAsync(ThreadRun run)
public virtual ClientResult<ThreadRun> CancelRun(ThreadRun run)
=> CancelRun(run?.ThreadId, run?.Id);

/// <summary>
/// Gets a collection of <see cref="RunStep"/> instances associated with a <see cref="ThreadRun"/>.
/// </summary>
/// <param name="run"> The run to list run steps from. </param>
/// <param name="resultOrder">
/// The <c>order</c> that results should appear in the list according to their <c>created_at</c>
/// timestamp.
/// </param>
/// <returns> A collection of run steps that can be enumerated using <c>await foreach</c>. </returns>
public virtual PageableCollection<RunStep> GetRunSteps(
ThreadRun run,
ListOrder? resultOrder = default)
{
Argument.AssertNotNull(run, nameof(run));

return GetRunSteps(run.ThreadId, run.Id, resultOrder);
}

/// <summary>
/// Gets a collection of <see cref="RunStep"/> instances associated with a <see cref="ThreadRun"/>.
/// </summary>
/// <param name="run"> The run to list run steps from. </param>
/// <param name="resultOrder">
/// The <c>order</c> that results should appear in the list according to their <c>created_at</c>
/// timestamp.
/// </param>
/// <returns> A collection of run steps that can be enumerated using <c>foreach</c>. </returns>
public virtual AsyncPageableCollection<RunStep> GetRunStepsAsync(
ThreadRun run,
ListOrder? resultOrder = default)
{
Argument.AssertNotNull(run, nameof(run));

return GetRunStepsAsync(run.ThreadId, run.Id, resultOrder);
}
///// <summary>
///// Gets a collection of <see cref="RunStep"/> instances associated with a <see cref="ThreadRun"/>.
///// </summary>
///// <param name="run"> The run to list run steps from. </param>
///// <param name="itemOrder">
///// The <c>order</c> that results should appear in the list according to their <c>created_at</c>
///// timestamp.
///// </param>
///// <returns> A collection of run steps that can be enumerated using <c>await foreach</c>. </returns>
//public virtual ClientPageable<RunStep> GetRunSteps(
// ThreadRun run,
// ListOrder? itemOrder = null,
// string itemsAfter = default,
// string itemsBefore = default,
// int? pageSize = null)
//{
// Argument.AssertNotNull(run, nameof(run));

// return GetRunSteps(run.ThreadId, run.Id, itemOrder, itemsAfter, itemsBefore, pageSize);
//}

///// <summary>
///// Gets a collection of <see cref="RunStep"/> instances associated with a <see cref="ThreadRun"/>.
///// </summary>
///// <param name="run"> The run to list run steps from. </param>
///// <param name="itemOrder">
///// The <c>order</c> that results should appear in the list according to their <c>created_at</c>
///// timestamp.
///// </param>
///// <returns> A collection of run steps that can be enumerated using <c>foreach</c>. </returns>
//public virtual AsyncClientPageable<RunStep> GetRunStepsAsync(
// ThreadRun run,
// ListOrder? itemOrder = null,
// string itemsAfter = default,
// string itemsBefore = default,
// int? pageSize = null)
//{
// Argument.AssertNotNull(run, nameof(run));

// return GetRunStepsAsync(run.ThreadId, run.Id, itemOrder, itemsAfter, itemsBefore, pageSize);
//}
}
Loading