Skip to content

[Bot] Update tasks specs #1030

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

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
25 changes: 19 additions & 6 deletions packages/tasks/src/tasks/chat-completion/inference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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
Expand Down Expand Up @@ -154,10 +154,23 @@ export interface ChatCompletionInputStreamOptions {
[property: string]: unknown;
}

export type ChatCompletionInputTool = ChatCompletionInputToolType | string;
/**
*
* <https://platform.openai.com/docs/guides/function-calling/configuring-function-calling-behavior-using-the-tool_choice-parameter>
*/
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;
}

Expand All @@ -166,7 +179,7 @@ export interface ChatCompletionInputFunctionName {
[property: string]: unknown;
}

export interface ToolElement {
export interface ChatCompletionInputTool {
function: ChatCompletionInputFunctionDefinition;
type: string;
[property: string]: unknown;
Expand Down
33 changes: 14 additions & 19 deletions packages/tasks/src/tasks/chat-completion/spec/input.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
"$ref": "#/$defs/ChatCompletionInputToolChoice"
}
],
"default": "auto",
"nullable": true
},
"tool_prompt": {
Expand Down Expand Up @@ -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",
Expand All @@ -298,14 +297,10 @@
"$ref": "#/$defs/ChatCompletionInputFunctionName"
}
}
},
{
"type": "object",
"default": null,
"nullable": true
}
],
"title": "ChatCompletionInputToolType"
"description": "<https://platform.openai.com/docs/guides/function-calling/configuring-function-calling-behavior-using-the-tool_choice-parameter>",
"title": "ChatCompletionInputToolChoice"
},
"ChatCompletionInputFunctionName": {
"type": "object",
Expand Down
2 changes: 1 addition & 1 deletion packages/tasks/src/tasks/feature-extraction/inference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: ",
* ...},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading