Skip to content

Commit

Permalink
Merge branch 'dargilco/ai-model-inference' into trangevi/structured-o…
Browse files Browse the repository at this point in the history
…utputs-java
  • Loading branch information
trangevi committed Jan 10, 2025
2 parents cba2d23 + 3409632 commit daf385d
Show file tree
Hide file tree
Showing 19 changed files with 335 additions and 229 deletions.
55 changes: 29 additions & 26 deletions specification/ai/ModelClient/client.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,23 @@ 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);

// Since we made all operator methods internal, we need to expliclty
// say we still want the models they use to be public.
// 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.getModelInfo, Access.internal, "python");

// Since we made all operator methods internal, we need to explicity
// say we still want the models they use to be public, since they will be used by hand-written operator methods.
@@access(AI.Model.ChatChoice, Access.public);
@@access(AI.Model.ChatCompletions, Access.public);
@@access(AI.Model.ChatCompletionsToolCall, Access.public);
@@access(AI.Model.ChatCompletionsToolDefinition, Access.public);
@@access(AI.Model.ChatCompletionsNamedToolSelection, Access.public);
@@access(AI.Model.ChatCompletionsFunctionToolSelection, Access.public);
@@access(AI.Model.ChatCompletionsResponseFormat, Access.public);
@@access(AI.Model.ChatCompletionsResponseFormatJSON, Access.public);
@@access(AI.Model.ChatCompletionsResponseFormatText, Access.public);
@@access(AI.Model.ChatCompletionsNamedToolChoice, Access.public);
@@access(AI.Model.ChatCompletionsNamedToolChoiceFunction, Access.public);
@@access(AI.Model.ChatCompletionsToolCall, Access.public);
@@access(AI.Model.ChatCompletionsToolDefinition, Access.public);
@@access(AI.Model.ChatCompletionsToolSelectionPreset, Access.public);
@@access(AI.Model.ChatCompletionsToolChoicePreset, Access.public);
@@access(AI.Model.ChatRequestAssistantMessage, Access.public);
@@access(AI.Model.ChatRequestMessage, Access.public);
@@access(AI.Model.ChatRequestSystemMessage, 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);
@@access(AI.Model.EmbeddingInput, Access.public);
@@access(AI.Model.EmbeddingInputType, Access.public);
@@access(AI.Model.EmbeddingItem, Access.public);
@@access(AI.Model.EmbeddingsResult, Access.public);
@@access(AI.Model.EmbeddingsUsage, Access.public);
@@access(AI.Model.EmbeddingEncodingFormat, Access.public, "python");
@@access(AI.Model.ImageEmbeddingInput, 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.ExtraParameters, Access.public, "java");
@@access(AI.Model.FunctionCall, Access.public);
@@access(AI.Model.FunctionDefinition, Access.public);
Expand All @@ -55,19 +58,19 @@ 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);
@@access(AI.Model.StreamingChatChoiceUpdate, Access.public);
@@access(AI.Model.StreamingChatResponseMessageUpdate, Access.public);
@@access(AI.Model.StreamingChatResponseToolCallUpdate, 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.ChatCompletionsResponseFormatJsonSchemaDefinition,
Access.public,
"python"
);

// The operators need to be hidden, since we hand-write the public versions of those to
// 1. Add chat completions streaming (to getChatCompletions operator)
// 2. Add hyper-params (to getChatCompletions/Embeddings/ImageEmbeddings, all clients)
// 3. Cache model info (to getModelInfo, all clients, Python only)
@@access(AI.Model.getChatCompletions, Access.internal);
@@access(AI.Model.getEmbeddings, Access.internal);
@@access(AI.Model.getImageEmbeddings, Access.internal);
@@access(AI.Model.getModelInfo, Access.internal);
@@clientName(AI.Model.ChatCompletionsResponseFormatJsonSchemaDefinition,
"JsonSchemaFormat",
"python"
);
@@clientName(AI.Model.ChatCompletionsResponseFormatJSON, "ChatCompletionsResponseFormatJson", "java");

// We use shorter names in the Python client library
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,57 +10,56 @@
"role": "ChatRequestMessage"
}
],
"frequency_penalty": 1,
"frequency_penalty": -2,
"stream": true,
"presence_penalty": -2,
"presence_penalty": -1,
"temperature": 0,
"top_p": 0,
"max_tokens": 0,
"response_format": {
"type": "ChatCompletionsResponseFormat"
},
"stop": [
"lwlqenszpaurxntgit"
"dcfnxrdeumnoytdaooqkbl"
],
"tools": [
{
"type": "function",
"function": {
"name": "velupowkmhiyypklqmgzzlmcjokcs",
"description": "dngfctkfjoypnjfikiowvpuvisga",
"parameters": {}
"name": "ikvkykzp",
"description": "gofxoftbpdi"
}
}
],
"seed": 10,
"model": "bcxpoxjhymqvjo"
"seed": 21,
"model": "askiizcjob"
}
},
"responses": {
"200": {
"body": {
"id": "qdjwxvfotmorpdevwdmhbqnsgi",
"created": 16,
"model": "wr",
"id": "kgousajxgzyhugvqekuswuqbk",
"created": 18,
"model": "zjxvtpxhzhvgjrhit",
"usage": {
"completion_tokens": 9,
"prompt_tokens": 15,
"total_tokens": 1
"completion_tokens": 19,
"prompt_tokens": 28,
"total_tokens": 16
},
"choices": [
{
"index": 29,
"index": 7,
"finish_reason": "stop",
"message": {
"role": "system",
"content": "wynvtftvlenfzzzrfmg",
"content": "jnsnrwblpuokzbkrzdcwubpfz",
"tool_calls": [
{
"id": "zlmfpvg",
"id": "yrobmilsrugmbwukmzo",
"type": "function",
"function": {
"name": "velupowkmhiyypklqmgzzlmcjokcs",
"arguments": "zocluceldmcazefk"
"name": "ikvkykzp",
"arguments": "oqxvktuduomvckic"
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@
"responses": {
"200": {
"body": {
"id": "qdjwxvfotmorpdevwdmhbqnsgi",
"created": 16,
"model": "wr",
"id": "kgousajxgzyhugvqekuswuqbk",
"created": 18,
"model": "zjxvtpxhzhvgjrhit",
"usage": {
"completion_tokens": 9,
"prompt_tokens": 15,
"total_tokens": 1
"completion_tokens": 19,
"prompt_tokens": 28,
"total_tokens": 16
},
"choices": [
{
"index": 29,
"index": 7,
"finish_reason": "stop",
"message": {
"role": "system",
"content": "wynvtftvlenfzzzrfmg"
"content": "jnsnrwblpuokzbkrzdcwubpfz"
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,28 @@
"extra-parameters": "error",
"body": {
"input": [
"wditkfkcn"
"p"
],
"dimensions": 14,
"dimensions": 11,
"encoding_format": "base64",
"input_type": "text",
"model": "esgcnvlwfzgrstu"
"model": "kwkpluujwiabfquhkaugttxut"
}
},
"responses": {
"200": {
"body": {
"id": "cknxthfa",
"data": [
{
"index": 4
"index": 21
}
],
"usage": {
"prompt_tokens": 30,
"total_tokens": 29
"prompt_tokens": 4,
"total_tokens": 22
},
"model": "rbnjxkkdrp"
"model": "uvrmctbnze"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,30 @@
"body": {
"input": [
{
"image": "hxkwvrx",
"text": "qpoyljvucirvkzjhhnhpdeqkl"
"image": "puqkvvlvgcjyzughesnkena",
"text": "azrzyjsmnuefqpowpvfmyobeehqsni"
}
],
"dimensions": 17,
"dimensions": 26,
"encoding_format": "base64",
"input_type": "text",
"model": "wssoguntnhwg"
"model": "jyb"
}
},
"responses": {
"200": {
"body": {
"id": "cknxthfa",
"data": [
{
"index": 4
"index": 21
}
],
"usage": {
"prompt_tokens": 30,
"total_tokens": 29
"prompt_tokens": 4,
"total_tokens": 22
},
"model": "rbnjxkkdrp"
"model": "uvrmctbnze"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"responses": {
"200": {
"body": {
"model_name": "wzkm",
"model_name": "jno",
"model_type": "embeddings",
"model_provider_name": "jkxwuyloxsmuhsevvytzp"
"model_provider_name": "ulyaphtaszwdkefpbkklnjtrhzh"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"responses": {
"200": {
"body": {
"model_name": "wzkm",
"model_name": "jno",
"model_type": "embeddings",
"model_provider_name": "jkxwuyloxsmuhsevvytzp"
"model_provider_name": "ulyaphtaszwdkefpbkklnjtrhzh"
}
}
}
Expand Down
Loading

0 comments on commit daf385d

Please sign in to comment.