Skip to content

Update TGI specs (+ define TextToSpeech independently) #915

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 5 commits into from
Sep 24, 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
4 changes: 3 additions & 1 deletion packages/tasks/scripts/inference-tei-import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ async function _extractAndAdapt(task: string, mainComponentName: string, type: "
}

// Add reference to components to export (and scan it too)
const newRef = camelFullName + ref.replace(camelName, "");
let newRef = camelFullName + ref.replace(camelName, "");
// remove duplicated InputInput or OutputOutput in naming
newRef = newRef.replace("InputInput", "Input").replace("OutputOutput", "Output");
if (!filteredComponents[newRef]) {
components[ref]["title"] = newRef; // Rename title to avoid conflicts
filteredComponents[newRef] = components[ref];
Expand Down
4 changes: 3 additions & 1 deletion packages/tasks/scripts/inference-tgi-import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ async function _extractAndAdapt(task: string, mainComponentName: string, type: "
}

// Add reference to components to export (and scan it too)
const newRef = camelFullName + ref.replace(camelName, "");
let newRef = camelFullName + ref.replace(camelName, "");
// remove duplicated InputInput or OutputOutput in naming
newRef = newRef.replace("InputInput", "Input").replace("OutputOutput", "Output");
if (!filteredComponents[newRef]) {
components[ref]["title"] = newRef; // Rename title to avoid conflicts
filteredComponents[newRef] = components[ref];
Expand Down
87 changes: 66 additions & 21 deletions packages/tasks/src/tasks/chat-completion/inference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export interface ChatCompletionInput {
* [UNUSED] ID of the model to use. See the model endpoint compatibility table for details
* on which models work with the Chat API.
*/
model: string;
model?: string;
/**
* UNUSED
* How many chat completion choices to generate for each input message. Note that you will
Expand All @@ -63,12 +63,14 @@ export interface ChatCompletionInput {
* increasing the model's likelihood to talk about new topics
*/
presence_penalty?: number;
response_format?: ChatCompletionInputGrammarType;
seed?: number;
/**
* Up to 4 sequences where the API will stop generating further tokens.
*/
stop?: string[];
stream?: boolean;
stream_options?: ChatCompletionInputStreamOptions;
/**
* What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the
* output more random, while
Expand All @@ -77,7 +79,7 @@ export interface ChatCompletionInput {
* We generally recommend altering this or `top_p` but not both.
*/
temperature?: number;
tool_choice?: ChatCompletionInputToolType;
tool_choice?: ChatCompletionInputTool;
/**
* A prompt to be appended before the tools
*/
Expand All @@ -87,7 +89,7 @@ export interface ChatCompletionInput {
* Use this to provide a list of
* functions the model may generate JSON inputs for.
*/
tools?: ChatCompletionInputTool[];
tools?: ToolElement[];
/**
* An integer between 0 and 5 specifying the number of most likely tokens to return at each
* token position, each with
Expand All @@ -105,40 +107,78 @@ export interface ChatCompletionInput {
}

export interface ChatCompletionInputMessage {
content?: string;
content: ChatCompletionInputMessageContent;
name?: string;
role: string;
tool_calls?: ChatCompletionInputToolCall[];
[property: string]: unknown;
}

export interface ChatCompletionInputToolCall {
function: ChatCompletionInputFunctionDefinition;
id: number;
type: string;
export type ChatCompletionInputMessageContent = ChatCompletionInputMessageChunk[] | string;

export interface ChatCompletionInputMessageChunk {
image_url?: ChatCompletionInputURL;
text?: string;
type: ChatCompletionInputMessageChunkType;
[property: string]: unknown;
}

export interface ChatCompletionInputFunctionDefinition {
arguments: unknown;
description?: string;
name: string;
export interface ChatCompletionInputURL {
url: string;
[property: string]: unknown;
}

export type ChatCompletionInputToolType = "OneOf" | ChatCompletionInputToolTypeObject;
export type ChatCompletionInputMessageChunkType = "text" | "image_url";

export interface ChatCompletionInputToolTypeObject {
FunctionName: string;
export interface ChatCompletionInputGrammarType {
type: ChatCompletionInputGrammarTypeType;
/**
* A string that represents a [JSON Schema](https://json-schema.org/).
*
* JSON Schema is a declarative language that allows to annotate JSON documents
* with types and descriptions.
*/
value: unknown;
[property: string]: unknown;
}

export type ChatCompletionInputGrammarTypeType = "json" | "regex";

export interface ChatCompletionInputStreamOptions {
/**
* If set, an additional chunk will be streamed before the data: [DONE] message. The usage
* field on this chunk shows the token usage statistics for the entire request, and the
* choices field will always be an empty array. All other chunks will also include a usage
* field, but with a null value.
*/
include_usage: boolean;
[property: string]: unknown;
}

export interface ChatCompletionInputTool {
export type ChatCompletionInputTool = ChatCompletionInputToolType | string;

export interface ChatCompletionInputToolType {
function?: ChatCompletionInputFunctionName;
[property: string]: unknown;
}

export interface ChatCompletionInputFunctionName {
name: string;
[property: string]: unknown;
}

export interface ToolElement {
function: ChatCompletionInputFunctionDefinition;
type: string;
[property: string]: unknown;
}

export interface ChatCompletionInputFunctionDefinition {
arguments: unknown;
description?: string;
name: string;
[property: string]: unknown;
}

/**
* Chat Completion Output.
*
Expand All @@ -151,7 +191,6 @@ export interface ChatCompletionOutput {
created: number;
id: string;
model: string;
object: string;
system_fingerprint: string;
usage: ChatCompletionOutputUsage;
[property: string]: unknown;
Expand Down Expand Up @@ -185,15 +224,14 @@ export interface ChatCompletionOutputTopLogprob {

export interface ChatCompletionOutputMessage {
content?: string;
name?: string;
role: string;
tool_calls?: ChatCompletionOutputToolCall[];
[property: string]: unknown;
}

export interface ChatCompletionOutputToolCall {
function: ChatCompletionOutputFunctionDefinition;
id: number;
id: string;
type: string;
[property: string]: unknown;
}
Expand Down Expand Up @@ -224,8 +262,8 @@ export interface ChatCompletionStreamOutput {
created: number;
id: string;
model: string;
object: string;
system_fingerprint: string;
usage?: ChatCompletionStreamOutputUsage;
[property: string]: unknown;
}

Expand Down Expand Up @@ -275,3 +313,10 @@ export interface ChatCompletionStreamOutputTopLogprob {
token: string;
[property: string]: unknown;
}

export interface ChatCompletionStreamOutputUsage {
completion_tokens: number;
prompt_tokens: number;
total_tokens: number;
[property: string]: unknown;
}
Loading
Loading