Closed waptik closed 1 year ago
Hm, you're right. Would you be willing to open a PR?
I’d love to but Unfortunately I don’t know how go about making the streaming wok properly
On 7 Oct 2023, at 19:56, Lino Le Van @.***> wrote:
Hm, you're right. Would you be willing to open a PR?
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.
Should just be a type definition change. The streaming should work the same.
export interface ChatCompletionStream {
id: string;
object: "chat.completion.chunk";
created: number;
choices: {
index: number;
delta: {
name?: string;
role?: "system" | "assistant" | "user";
content?: string;
};
finish_reason: string;
}[];
}
export interface ChatCompletionStream {
id: string;
object: "chat.completion.chunk";
created: number;
choices: {
index: number;
delta: {
name?: string;
role?: "system" | "assistant" | "user";
content?: string | null; // sometimes null
function_call?: {
name?: string;
arguments: string;
};
};
finish_reason: string | null; // mostly null
}[];
}
But I'd actually prefer if we could use FunctionAwareAssistantCompletionMessage
or ChatCompletionMessage
directly.
Some data from OpenAI GPT 3.5 in case you want to test it:
{"id":"chatcmpl-redacted","object":"chat.completion.chunk","created":1697649987,"model":"gpt-3.5-turbo-0613","choices":{"0":{"index":0,"delta":{"role":"assistant","content":null,"function_call":{"name":"user_choice","arguments":""}},"finish_reason":null}}}
{"id":"chatcmpl-redacted","object":"chat.completion.chunk","created":1697649987,"model":"gpt-3.5-turbo-0613","choices":{"0":{"index":0,"delta":{"function_call":{"arguments":"{"}},"finish_reason":null}}}
{"id":"chatcmpl-redacted","object":"chat.completion.chunk","created":1697649987,"model":"gpt-3.5-turbo-0613","choices":{"0":{"index":0,"delta":{"function_call":{"arguments":" "}},"finish_reason":null}}}
{"id":"chatcmpl-redacted","object":"chat.completion.chunk","created":1697649987,"model":"gpt-3.5-turbo-0613","choices":{"0":{"index":0,"delta":{"function_call":{"arguments":" ""}},"finish_reason":null}}}
{"id":"chatcmpl-redacted","object":"chat.completion.chunk","created":1697649987,"model":"gpt-3.5-turbo-0613","choices":{"0":{"index":0,"delta":{"function_call":{"arguments":"}"}},"finish_reason":null}}}
{"id":"chatcmpl-redacted","object":"chat.completion.chunk","created":1697649987,"model":"gpt-3.5-turbo-0613","choices":{"0":{"index":0,"delta":{},"finish_reason":"stop"}}}
@userpixel Are you willing to make a PR? This looks good to me.
I noticed that the type defintion for
createChatCompletionStream
options doesn't acceptfunction_call
andfunctions
unlikecreateChatCompletion
that accepts them as options