Skip to content

Conversation

@dhvll
Copy link
Contributor

@dhvll dhvll commented Oct 16, 2025

Resolves: #523

@vercel
Copy link
Contributor

vercel bot commented Oct 16, 2025

@dhvll is attempting to deploy a commit to the Merit Systems Team on Vercel.

A member of the Team first needs to authorize it.

@dhvll dhvll marked this pull request as draft October 16, 2025 15:54
const chunks = parseSSEGPTFormat(data);

for (const chunk of chunks) {
if (chunk.usage !== null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (chunk.usage !== null) {
if (chunk.usage && chunk.usage !== null) {

The code checks if (chunk.usage !== null) but chunk.usage could be undefined, which would cause a TypeError at runtime.

View Details

Analysis

TypeError in GroqProvider.handleBody() when accessing undefined usage properties

What fails: GroqProvider.handleBody() checks if (chunk.usage !== null) but crashes when chunk.usage is undefined, attempting to access chunk.usage.prompt_tokens

How to reproduce:

// When streaming chunk has missing usage property (undefined)
const chunk = { id: "test", choices: [] }; // usage property omitted
if (chunk.usage !== null) { // undefined !== null is true 
  chunk.usage.prompt_tokens; // TypeError: Cannot read properties of undefined
}

Result: TypeError: Cannot read properties of undefined (reading 'prompt_tokens')

Expected: Should safely skip undefined usage like OpenRouterProvider.ts does with if (chunk.usage && chunk.usage !== null)

@dhvll dhvll marked this pull request as ready for review October 16, 2025 21:39
@dhvll dhvll marked this pull request as draft October 16, 2025 21:45
@dhvll dhvll requested a review from rsproule October 16, 2025 21:48
@rsproule
Copy link
Contributor

Thanks for making this PR!

This server side support looks good, so you are pretty much done.

We also need support for this in the typescript SDK so that people can actually use it.

You will just need to add the groq provider. You can look how this is done for openai here

then quickly add to next sdk:

openai: createEchoOpenAI(config),
anthropic: createEchoAnthropic(config),
google: createEchoGoogle(config),

Dont worry about bumping the sdk versions, our CI will do that

@dhvll dhvll marked this pull request as ready for review October 16, 2025 22:19
@rsproule rsproule changed the base branch from master to rfs/groq-takeover October 17, 2025 18:07
@rsproule rsproule merged commit 21cd217 into Merit-Systems:rfs/groq-takeover Oct 17, 2025
1 of 13 checks passed
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.

Model Support: Groq

2 participants