Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge C# feature branch into main Azure.AI.Inference branch #31869

Draft
wants to merge 65 commits into
base: dargilco/ai-model-inference
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
51fb73b
Update ImageEmbeddingsClient to change embed to embedImage
trangevi May 31, 2024
fd54bf9
Add typespec-csharp to the tspconfig
trangevi May 31, 2024
c53ca69
Merge remote-tracking branch 'upstream/dargilco/ai-model-inference' i…
trangevi Jun 4, 2024
08c7c64
Move csharp client property renames
trangevi Jun 5, 2024
ab6c309
Missing semicolons
trangevi Jun 5, 2024
4f8a7ea
Wrong namespace
trangevi Jun 5, 2024
be84fda
Incorrect namespaces
trangevi Jun 5, 2024
4f56fb3
Aliases need to have things referenced differently, apparently
trangevi Jun 5, 2024
db6580b
Need to specify parameters?
trangevi Jun 5, 2024
a5b3fbc
Move alias renames to the individual file for now
trangevi Jun 5, 2024
234a992
Merge branch 'dargilco/ai-model-inference' into trangevi/ai-model-inf…
trangevi Jun 12, 2024
1c552f3
Change ChatCompletionsOptions to a model
trangevi Jun 20, 2024
8e420b9
syntax
trangevi Jun 20, 2024
420cdf6
Merge branch 'dargilco/ai-model-inference' into trangevi/ai-model-inf…
trangevi Jun 21, 2024
8c122c5
Leave the model property
trangevi Jun 21, 2024
e6e24a1
Add additional properties for ChatCompletionsOptions
trangevi Jun 27, 2024
c33085f
3 dots, not 2
trangevi Jun 27, 2024
bc2ead4
Can't add docstring to generic spread property
trangevi Jun 27, 2024
cea8c46
Change unknown parameters to extra parameters
trangevi Jul 2, 2024
e5f72fe
Merge branch 'dargilco/ai-model-inference' into trangevi/ai-model-inf…
trangevi Jul 9, 2024
69c429f
Remove unnecessary rename
trangevi Jul 9, 2024
9353cd8
Removing api-key change for python, for now
trangevi Jul 11, 2024
404726c
Merge branch 'main' into trangevi/ai-model-inference
trangevi Jul 12, 2024
440f104
Merge branch 'dargilco/ai-model-inference' into trangevi/ai-model-inf…
trangevi Jul 23, 2024
acd2c9a
Make operator method internal
trangevi Jul 23, 2024
7e90c46
Fix pass-through header
trangevi Jul 25, 2024
6525a08
Re-enable protocol methods for csharp
trangevi Jul 26, 2024
c625ccb
Remove "spread" for ChatCompletionsOptions
trangevi Jul 26, 2024
b3ff7cf
Remove spread for additionalRequestHeaders
trangevi Jul 26, 2024
3cad35a
needed commas
trangevi Jul 26, 2024
4d8fe2c
another formatting attempt
trangevi Jul 26, 2024
442e62e
okay, figured out how the formatting works
trangevi Jul 26, 2024
eba14da
Alias breaks the generator
trangevi Jul 26, 2024
4a3dfd2
A model won't give us the interaction pattern that we want. Trying this.
trangevi Jul 26, 2024
392243f
Forgot semicolon
trangevi Jul 26, 2024
156d4e0
Merge branch 'dargilco/ai-model-inference' into trangevi/ai-model-inf…
trangevi Jul 29, 2024
72ff5d0
Does swapping the order of parameters matter?
trangevi Jul 29, 2024
063b051
Make extraParams optional?
trangevi Jul 29, 2024
dd47e68
Try and get rid of anonymous model
trangevi Jul 29, 2024
1f62242
Try adding RequestHeadersTrait
trangevi Jul 29, 2024
7254471
Maybe needs to be an object?
trangevi Jul 29, 2024
d752df6
Add using
trangevi Jul 29, 2024
4039eb1
Revert to "good" state
trangevi Jul 30, 2024
33fb66c
Merge branch 'dargilco/ai-model-inference' into trangevi/ai-model-inf…
trangevi Aug 5, 2024
d2d069e
Merge branch 'dargilco/ai-model-inference' into trangevi/ai-model-inf…
trangevi Aug 8, 2024
7b1e6e1
Try moving extra parameters. Change Parameters back to unknown
trangevi Aug 13, 2024
65239b3
Skip the alias
trangevi Aug 13, 2024
323366c
Is it the header which is causing issues?
trangevi Aug 13, 2024
1562993
Headers in the options object seems to not work
trangevi Aug 13, 2024
bd9d308
Remove commented operation
trangevi Aug 13, 2024
7e3d4fd
Unnecessary using
trangevi Aug 13, 2024
9b2fbf0
Merge branch 'dargilco/ai-model-inference' into trangevi/ai-model-inf…
trangevi Aug 23, 2024
376a388
Add embeddings for csharp
trangevi Aug 23, 2024
b2d19d3
Merge branch 'dargilco/ai-model-inference' into trangevi/ai-model-inf…
trangevi Aug 23, 2024
56e81a8
Client changes for C#
trangevi Aug 26, 2024
b1d22e9
Need the options objects to be models
trangevi Aug 26, 2024
fb263d7
Make the embedding methods public for now, for intial testing
trangevi Aug 28, 2024
2ef0546
Remove image embedding for now until it can be tested
trangevi Aug 29, 2024
aa97e50
Add new streaming classes for C#
trangevi Sep 27, 2024
96219f2
Merge branch 'dargilco/ai-model-inference' into trangevi/ai-model-inf…
trangevi Dec 10, 2024
331fcb3
Revert to Darren's branch to test
trangevi Dec 12, 2024
3e5944b
Explicitly set the completions options object to be an input
trangevi Dec 12, 2024
8592ffc
Other clients with spread parameters
trangevi Dec 12, 2024
844519f
No image embedding client yet, so leave this out for now
trangevi Dec 12, 2024
19827a6
Operations need to be internal for all languages
trangevi Dec 12, 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
27 changes: 15 additions & 12 deletions specification/ai/ModelClient/client.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ namespace Customizations; // The actual name here doesn't matter and is here for
@@usage(AI.Model.StreamingChatResponseMessageUpdate, Usage.output);
@@usage(AI.Model.StreamingChatResponseToolCallUpdate, Usage.output);

@@usage(AI.Model.ChatCompletionsOptions, Usage.input);
@@usage(AI.Model.EmbeddingsOptions, Usage.input);

// Since we made all operator methods internal, we need to expliclty
// say we still want the models they use to be public.
@@access(AI.Model.ChatChoice, Access.public);
Expand All @@ -39,12 +42,12 @@ namespace Customizations; // The actual name here doesn't matter and is here for
@@access(AI.Model.ChatRole, Access.public);
@@access(AI.Model.CompletionsFinishReason, Access.public);
@@access(AI.Model.CompletionsUsage, Access.public);
@@access(AI.Model.EmbeddingEncodingFormat, Access.public, "python");
@@access(AI.Model.EmbeddingInput, Access.public, "python");
@@access(AI.Model.EmbeddingInputType, Access.public, "python");
@@access(AI.Model.EmbeddingItem, Access.public, "python");
@@access(AI.Model.EmbeddingsResult, Access.public, "python");
@@access(AI.Model.EmbeddingsUsage, Access.public, "python");
@@access(AI.Model.EmbeddingEncodingFormat, Access.public, "python,csharp");
@@access(AI.Model.EmbeddingInput, Access.public, "python,csharp");
@@access(AI.Model.EmbeddingInputType, Access.public, "python,csharp");
@@access(AI.Model.EmbeddingItem, Access.public, "python,csharp");
@@access(AI.Model.EmbeddingsResult, Access.public, "python,csharp");
@@access(AI.Model.EmbeddingsUsage, Access.public, "python,csharp");
@@access(AI.Model.FunctionCall, Access.public);
@@access(AI.Model.FunctionDefinition, Access.public);
@@access(AI.Model.ModelInfo, Access.public);
Expand All @@ -54,15 +57,15 @@ namespace Customizations; // The actual name here doesn't matter and is here for
@@access(AI.Model.ChatMessageImageContentItem, Access.public);
@@access(AI.Model.ChatMessageImageUrl, Access.public);
@@access(AI.Model.ChatMessageImageDetailLevel, Access.public);
@@access(AI.Model.StreamingChatCompletionsUpdate, Access.public, "python");
@@access(AI.Model.StreamingChatChoiceUpdate, Access.public, "python");
@@access(AI.Model.StreamingChatResponseMessageUpdate, Access.public, "python");
@@access(AI.Model.StreamingChatResponseToolCallUpdate, Access.public, "python");
@@access(AI.Model.StreamingChatCompletionsUpdate, Access.public, "python,csharp");
@@access(AI.Model.StreamingChatChoiceUpdate, Access.public, "python,csharp");
@@access(AI.Model.StreamingChatResponseMessageUpdate, Access.public, "python,csharp");
@@access(AI.Model.StreamingChatResponseToolCallUpdate, Access.public, "python,csharp");

// The operators need to be hidden, since we hand-write the public versions of those
@@access(AI.Model.getChatCompletions, Access.internal);
@@access(AI.Model.getEmbeddings, Access.internal);
@@access(AI.Model.getImageEmbeddings, Access.internal);
@@access(AI.Model.getImageEmbeddings, Access.internal, "python");
@@access(AI.Model.getModelInfo, Access.internal, "python");

// We use shorter names in the Python client library
Expand Down Expand Up @@ -99,7 +102,7 @@ interface Client1 {
name: "EmbeddingsClient",
service: AI.Model,
},
"python"
"python,csharp"
)
interface Client2 {
embed is AI.Model.getEmbeddings;
Expand Down
2 changes: 1 addition & 1 deletion specification/ai/ModelClient/main.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ using Azure.Core;

#suppress "@azure-tools/typespec-autorest/unsupported-http-auth-scheme"
@useAuth(
BearerAuth | ApiKeyAuth<ApiKeyLocation.header, "api-key"> | OAuth2Auth<[
BearerAuth | OAuth2Auth<[
{
type: OAuth2FlowType.implicit,
authorizationUrl: "https://login.microsoftonline.com/common/oauth2/v2.0/authorize",
Expand Down
9 changes: 7 additions & 2 deletions specification/ai/ModelClient/models/chat_completions.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ using Azure.ClientGenerator.Core;

namespace AI.Model;

alias ChatCompletionsOptions = {
@doc("""
The configuration information for a chat completions request.
Completions support a wide variety of tasks and generate text that continues from or "completes"
provided prompt data.
""")
model ChatCompletionsOptions {
@doc("""
The collection of context messages associated with this chat completions request.
Typical usage begins with a chat message for the System role that provides instructions for
Expand Down Expand Up @@ -116,7 +121,7 @@ alias ChatCompletionsOptions = {
`model`?: string;

...Record<unknown>;
};
}

alias ChatCompletionsCommon = {
@doc("A unique identifier associated with this chat completions response.")
Expand Down
5 changes: 4 additions & 1 deletion specification/ai/ModelClient/models/embeddings.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ using TypeSpec.Http;

namespace AI.Model;

alias EmbeddingsOptions = {
@doc("""
The configuration information for an embeddings request.
""")
model EmbeddingsOptions {
@doc("""
Input text to embed, encoded as a string or array of tokens.
To embed multiple inputs in a single request, pass an array
Expand Down
5 changes: 4 additions & 1 deletion specification/ai/ModelClient/models/image_embeddings.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ using TypeSpec.Http;

namespace AI.Model;

alias ImageEmbeddingsOptions = {
@doc("""
The configuration information for an image embeddings request.
""")
model ImageEmbeddingsOptions {
@doc("""
Input image to embed. To embed multiple inputs in a single request, pass an array.
The input must not exceed the max input tokens for the model.
Expand Down
2 changes: 1 addition & 1 deletion specification/ai/ModelClient/routes.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace AI.Model;
@doc("""
Gets chat completions for the provided chat messages.
Completions support a wide variety of tasks and generate text that continues from or "completes"
provided prompt data. The method makes a REST API call to the `/chat/completions` route
provided prompt data. The method makes a REST API call to the `/chat/completions` route
on the given endpoint.
""")
@actionSeparator("/")
Expand Down
2 changes: 1 addition & 1 deletion specification/ai/ModelClient/tspconfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ options:
namespace: "Azure.AI.Inference"
clear-output-folder: true
model-namespace: false
flavor: azure
flavor: azure
Loading