Skip to content

Commit

Permalink
Feature/openai add missing usage (#22337)
Browse files Browse the repository at this point in the history
* add new API version and usage field on completions and embeddings

* typo

* Added docs for Usage classes in completions and embeddings

* Added versioning mark for new usage model

* Added disambiguation for names and removed unnecessary versioning decorator

* Removed unused version bump

* Removed unused version from enum

* Removed wrong annotation

---------

Co-authored-by: Jose Alvarez <[email protected]>
  • Loading branch information
glharper and jpalvarezl authored Jan 28, 2023
1 parent 14f11ca commit a265778
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
7 changes: 6 additions & 1 deletion specification/cognitiveservices/OpenAI.Inference/main.cadl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ https://westus.api.cognitive.microsoft.com).
)
@versioned(ServiceApiVersions)
@versionedDependency(
[[ServiceApiVersions.v2022_06_01_preview, Azure.Core.Versions.v1_0_Preview_1]]
[
[
ServiceApiVersions.v2022_06_01_preview,
Azure.Core.Versions.v1_0_Preview_1
]
]
)
@doc("Azure OpenAI APIs for completions and search")
namespace Azure.OpenAI;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ model Completions {
"model"?: string;
@doc("Array of choices returned containing text completions to prompts sent")
choices?: Choice[];
@doc("Usage counts for tokens input using the completions API")
usage: CompletionsUsage;
}

@doc("Choice model within completion response")
Expand All @@ -163,3 +165,13 @@ model CompletionsLogProbsModel {
@doc("Text offset")
text_offset?: int32[];
}

@doc("Measurment of the amount of tokens used in this request and response")
model CompletionsUsage {
@doc("Number of tokens received in the completion")
completion_token: int32,
@doc("Number of tokens sent in the original request")
prompt_tokens: int32,
@doc("Total number of tokens transacted in this request/response")
total_tokens: int32
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,26 @@ model EmbeddingsOptions {
as we have observed inferior results when newlines are present.
""")
input: string | string[];

@doc("Usage counts for tokens input using the embeddings API")
usage: EmbeddingsUsage;
};

model Embeddings {
object: "list",
data: EmbeddingItem[],
}

model Usage {
prompt_tokens: int32,
total_tokens: int32
}

model EmbeddingItem {
object: "embedding",
embedding: float32[];
index: int32;
}

@doc("Measurment of the amount of tokens used in this request and response")
model EmbeddingsUsage {
@doc("Number of tokens sent in the original request")
prompt_tokens: int32,
@doc("Total number of tokens transacted in this request/response")
total_tokens: int32
}

0 comments on commit a265778

Please sign in to comment.