Skip to content
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

[Type Conflict] The ChatCompletionOutputToolCall and the ChatCompletionStreamOutputDeltaToolCall incapable #827

Open
whats2000 opened this issue Jul 31, 2024 · 0 comments · May be fixed by #828

Comments

@whats2000
Copy link

Here I found an issue when creating an inference tool from the JS API.

Version

"@huggingface/inference": "^2.8.0" with npm installation

Description

  1. The issue is that the delta of the tool call (ChatCompletionStreamOutputDeltaToolCall ) is a type of "number", but the full result (ChatCompletionStreamOutputDeltaToolCall) is identified by "string"
// At @huggingface\tasks\src\tasks\chat-completion
export interface ChatCompletionOutputToolCall {
	function: ChatCompletionOutputFunctionDefinition;
	id: number;
	type: string;
	[property: string]: unknown;
}
// At @huggingface\tasks\src\tasks\chat-completion
export interface ChatCompletionStreamOutputDeltaToolCall {
	function: ChatCompletionStreamOutputFunction;
	id: string;
	index: number;
	type: string;
	[property: string]: unknown;
}
  1. The ChatCompletionStreamOutputDelta.tool_calls type is ChatCompletionStreamOutputDeltaToolCall but might be a mistake as that should be the ChatCompletionStreamOutputDeltaToolCall[] (Array of calls instead of a single object, this one needs some help of explanation.
  • Is the current API endpoint with stream only support a single tool result?
  • But the full one is an Array ChatCompletionOutputMessage.tool_calls: ChatCompletionOutputToolCall[]
// At @huggingface\tasks\src\tasks\chat-completion
export interface ChatCompletionStreamOutputDelta {
	content?: string;
	role: string;
	tool_calls?: ChatCompletionStreamOutputDeltaToolCall;
	[property: string]: unknown;
}
// At @huggingface\tasks\src\tasks\chat-completion
export interface ChatCompletionOutputMessage {
	content?: string;
	name?: string;
	role: string;
	tool_calls?: ChatCompletionOutputToolCall[];
	[property: string]: unknown;
}

ScreenShot

image
image
image

Reference Link

If you want to check it out, here is the link can compare to almost the same code for OpenAI and HuggingFace. And the HuggingFace one have the above issue (OpenAI one is correctly work, hope can help to debug)
OpenAI Tool Use Inference
HuggingFace Tool Use Inference

@coyotte508 coyotte508 linked a pull request Jul 31, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant