Skip to content

Commit

Permalink
deduplicat in name OutputOutputMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
Wauplin committed Sep 20, 2024
1 parent 761ff3e commit 67c30c3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
6 changes: 4 additions & 2 deletions packages/tasks/scripts/inference-tgi-import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async function _extractAndAdapt(task: string, mainComponentName: string, type: "
// e.g. TextGeneration
const camelName = toCamelCase(task);
// e.g. TextGenerationInput
const camelFullName = camelName + toCamelCase(type);
let camelFullName = camelName + toCamelCase(type);
const mainComponent = components[mainComponentName];
const filteredComponents: Record<string, JsonObject> = {};

Expand All @@ -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
4 changes: 2 additions & 2 deletions packages/tasks/src/tasks/chat-completion/inference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export interface ChatCompletionOutputComplete {
finish_reason: string;
index: number;
logprobs?: ChatCompletionOutputLogprobs;
message: ChatCompletionOutputOutputMessage;
message: ChatCompletionOutputMessage;
[property: string]: unknown;
}

Expand All @@ -222,7 +222,7 @@ export interface ChatCompletionOutputTopLogprob {
[property: string]: unknown;
}

export interface ChatCompletionOutputOutputMessage {
export interface ChatCompletionOutputMessage {
content?: string;
role: string;
tool_calls?: ChatCompletionOutputToolCall[];
Expand Down
6 changes: 3 additions & 3 deletions packages/tasks/src/tasks/chat-completion/spec/output.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"nullable": true
},
"message": {
"$ref": "#/$defs/ChatCompletionOutputOutputMessage"
"$ref": "#/$defs/ChatCompletionOutputMessage"
}
},
"title": "ChatCompletionOutputComplete"
Expand Down Expand Up @@ -106,7 +106,7 @@
},
"title": "ChatCompletionOutputTopLogprob"
},
"ChatCompletionOutputOutputMessage": {
"ChatCompletionOutputMessage": {
"oneOf": [
{
"$ref": "#/$defs/ChatCompletionOutputTextMessage"
Expand All @@ -115,7 +115,7 @@
"$ref": "#/$defs/ChatCompletionOutputToolCallMessage"
}
],
"title": "ChatCompletionOutputOutputMessage"
"title": "ChatCompletionOutputMessage"
},
"ChatCompletionOutputTextMessage": {
"type": "object",
Expand Down
2 changes: 1 addition & 1 deletion packages/tasks/src/tasks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export type {
ChatCompletionInputMessage,
ChatCompletionOutput,
ChatCompletionOutputComplete,
ChatCompletionOutputOutputMessage,
ChatCompletionOutputMessage,
ChatCompletionStreamOutput,
ChatCompletionStreamOutputChoice,
ChatCompletionStreamOutputDelta,
Expand Down

0 comments on commit 67c30c3

Please sign in to comment.