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

feat (provider/openai): set stream_options/include_usage to true when streaming #1578

Merged
merged 7 commits into from
May 14, 2024

Conversation

lgrammel
Copy link
Collaborator

No description provided.

@lgrammel lgrammel self-assigned this May 14, 2024
@lgrammel lgrammel changed the title feat (provider/openai): add stream_options flag feat (provider/openai): set stream_options/include_usage to true when streaming May 14, 2024
@lgrammel lgrammel marked this pull request as ready for review May 14, 2024 11:18
@lgrammel lgrammel merged commit 1009594 into main May 14, 2024
6 checks passed
@lgrammel lgrammel deleted the openai_include_usage_flag branch May 14, 2024 14:50
@minkiha
Copy link

minkiha commented May 15, 2024

Putting 'stream_options' in the request body breaks completions for at least Groq.

property 'stream_options' is unsupported, did you mean 'stream'?

Raw response:
{ url: 'https://api.groq.com/openai/v1/chat/completions', requestBodyValues: { model: 'llama3-70b-8192', logit_bias: undefined, logprobs: false, top_logprobs: undefined, user: undefined, max_tokens: undefined, temperature: 0, top_p: undefined, frequency_penalty: undefined, presence_penalty: undefined, seed: undefined, messages: [ [Object] ], tools: undefined, stream: true, stream_options: { include_usage: true } }, statusCode: 400, responseHeaders: { 'alt-svc': 'h3=":443"; ma=86400', 'cache-control': 'private, max-age=0, no-store, no-ca che, must-revalidate', 'cf-cache-status': 'DYNAMIC', connection: 'keep-alive', 'content-length': '120', 'content-type': 'application/json', date: 'Wed, 15 May 2024 11:32:42 GMT', server: 'cloudflare', vary: 'Origin', via: '1.1 google', }, responseBody: {"error":{"message":"property 'stream_op
tions' is unsupported, did you mean 'stream'?","type":"in
valid_request_error"}}\n, cause: undefined, isRetryable: false, data: undefined }

@lgrammel
Copy link
Collaborator Author

Putting 'stream_options' in the request body breaks completions for at least Groq.

property 'stream_options' is unsupported, did you mean 'stream'?

Raw response: { url: 'https://api.groq.com/openai/v1/chat/completions', requestBodyValues: { model: 'llama3-70b-8192', logit_bias: undefined, logprobs: false, top_logprobs: undefined, user: undefined, max_tokens: undefined, temperature: 0, top_p: undefined, frequency_penalty: undefined, presence_penalty: undefined, seed: undefined, messages: [ [Object] ], tools: undefined, stream: true, stream_options: { include_usage: true } }, statusCode: 400, responseHeaders: { 'alt-svc': 'h3=":443"; ma=86400', 'cache-control': 'private, max-age=0, no-store, no-ca che, must-revalidate', 'cf-cache-status': 'DYNAMIC', connection: 'keep-alive', 'content-length': '120', 'content-type': 'application/json', date: 'Wed, 15 May 2024 11:32:42 GMT', server: 'cloudflare', vary: 'Origin', via: '1.1 google', }, responseBody: {"error":{"message":"property 'stream_op tions' is unsupported, did you mean 'stream'?","type":"in valid_request_error"}}\n, cause: undefined, isRetryable: false, data: undefined }

Can you use @ai-sdk/openai v0.0.11 for now?

We need streamOptions for OpenAI, which should work correctly out of the box. I'm torn between introducing a compatibilityMode flag and a dedicated provider for groq.

@lgrammel
Copy link
Collaborator Author

@minkiha fixed with @ai-sdk/openai@0.0.13

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 this pull request may close these issues.

3 participants