From 592029f3cebcbf8b187873a9876303798efa9e75 Mon Sep 17 00:00:00 2001 From: Wauplin <11801849+Wauplin@users.noreply.github.com> Date: Fri, 22 Nov 2024 03:17:19 +0000 Subject: [PATCH] Update tasks specs (automated commit) --- .../src/tasks/chat-completion/inference.ts | 25 ++++++++++---- .../src/tasks/chat-completion/spec/input.json | 33 ++++++++----------- .../src/tasks/feature-extraction/inference.ts | 2 +- .../tasks/feature-extraction/spec/input.json | 2 +- 4 files changed, 35 insertions(+), 27 deletions(-) diff --git a/packages/tasks/src/tasks/chat-completion/inference.ts b/packages/tasks/src/tasks/chat-completion/inference.ts index febaffc8f1..4c4449a733 100644 --- a/packages/tasks/src/tasks/chat-completion/inference.ts +++ b/packages/tasks/src/tasks/chat-completion/inference.ts @@ -79,7 +79,7 @@ export interface ChatCompletionInput { * We generally recommend altering this or `top_p` but not both. */ temperature?: number; - tool_choice?: ChatCompletionInputTool; + tool_choice?: ChatCompletionInputToolChoice; /** * A prompt to be appended before the tools */ @@ -89,7 +89,7 @@ export interface ChatCompletionInput { * Use this to provide a list of * functions the model may generate JSON inputs for. */ - tools?: ToolElement[]; + tools?: ChatCompletionInputTool[]; /** * An integer between 0 and 5 specifying the number of most likely tokens to return at each * token position, each with @@ -154,10 +154,23 @@ export interface ChatCompletionInputStreamOptions { [property: string]: unknown; } -export type ChatCompletionInputTool = ChatCompletionInputToolType | string; +/** + * + * + */ +export type ChatCompletionInputToolChoice = ChatCompletionInputToolChoiceEnum | ChatCompletionInputToolChoiceObject; + +/** + * Means the model can pick between generating a message or calling one or more tools. + * + * Means the model will not call any tool and instead generates a message. + * + * Means the model must call one or more tools. + */ +export type ChatCompletionInputToolChoiceEnum = "auto" | "none" | "required"; -export interface ChatCompletionInputToolType { - function?: ChatCompletionInputFunctionName; +export interface ChatCompletionInputToolChoiceObject { + function: ChatCompletionInputFunctionName; [property: string]: unknown; } @@ -166,7 +179,7 @@ export interface ChatCompletionInputFunctionName { [property: string]: unknown; } -export interface ToolElement { +export interface ChatCompletionInputTool { function: ChatCompletionInputFunctionDefinition; type: string; [property: string]: unknown; diff --git a/packages/tasks/src/tasks/chat-completion/spec/input.json b/packages/tasks/src/tasks/chat-completion/spec/input.json index 86ca23c82c..b34de9953c 100644 --- a/packages/tasks/src/tasks/chat-completion/spec/input.json +++ b/packages/tasks/src/tasks/chat-completion/spec/input.json @@ -114,6 +114,7 @@ "$ref": "#/$defs/ChatCompletionInputToolChoice" } ], + "default": "auto", "nullable": true }, "tool_prompt": { @@ -272,23 +273,21 @@ "title": "ChatCompletionInputStreamOptions" }, "ChatCompletionInputToolChoice": { - "allOf": [ - { - "$ref": "#/$defs/ChatCompletionInputToolType" - } - ], - "nullable": true, - "title": "ChatCompletionInputToolChoice" - }, - "ChatCompletionInputToolType": { "oneOf": [ { - "type": "object", - "default": null, - "nullable": true + "type": "string", + "description": "Means the model can pick between generating a message or calling one or more tools.", + "enum": ["auto"] }, { - "type": "string" + "type": "string", + "description": "Means the model will not call any tool and instead generates a message.", + "enum": ["none"] + }, + { + "type": "string", + "description": "Means the model must call one or more tools.", + "enum": ["required"] }, { "type": "object", @@ -298,14 +297,10 @@ "$ref": "#/$defs/ChatCompletionInputFunctionName" } } - }, - { - "type": "object", - "default": null, - "nullable": true } ], - "title": "ChatCompletionInputToolType" + "description": "", + "title": "ChatCompletionInputToolChoice" }, "ChatCompletionInputFunctionName": { "type": "object", diff --git a/packages/tasks/src/tasks/feature-extraction/inference.ts b/packages/tasks/src/tasks/feature-extraction/inference.ts index 96194d7e9b..404b103089 100644 --- a/packages/tasks/src/tasks/feature-extraction/inference.ts +++ b/packages/tasks/src/tasks/feature-extraction/inference.ts @@ -23,7 +23,7 @@ export interface FeatureExtractionInput { * The name of the prompt that should be used by for encoding. If not set, no prompt * will be applied. * - * Must be a key in the `Sentence Transformers` configuration `prompts` dictionary. + * Must be a key in the `sentence-transformers` configuration `prompts` dictionary. * * For example if ``prompt_name`` is "query" and the ``prompts`` is {"query": "query: ", * ...}, diff --git a/packages/tasks/src/tasks/feature-extraction/spec/input.json b/packages/tasks/src/tasks/feature-extraction/spec/input.json index 94e8d7a0b2..a4fec711a4 100644 --- a/packages/tasks/src/tasks/feature-extraction/spec/input.json +++ b/packages/tasks/src/tasks/feature-extraction/spec/input.json @@ -17,7 +17,7 @@ }, "prompt_name": { "type": "string", - "description": "The name of the prompt that should be used by for encoding. If not set, no prompt\nwill be applied.\n\nMust be a key in the `Sentence Transformers` configuration `prompts` dictionary.\n\nFor example if ``prompt_name`` is \"query\" and the ``prompts`` is {\"query\": \"query: \", ...},\nthen the sentence \"What is the capital of France?\" will be encoded as\n\"query: What is the capital of France?\" because the prompt text will be prepended before\nany text to encode.", + "description": "The name of the prompt that should be used by for encoding. If not set, no prompt\nwill be applied.\n\nMust be a key in the `sentence-transformers` configuration `prompts` dictionary.\n\nFor example if ``prompt_name`` is \"query\" and the ``prompts`` is {\"query\": \"query: \", ...},\nthen the sentence \"What is the capital of France?\" will be encoded as\n\"query: What is the capital of France?\" because the prompt text will be prepended before\nany text to encode.", "default": "null", "example": "null", "nullable": true