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

Implement support for concatSupported = false for OpenAI models #7299

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

NoahCristino
Copy link

When streaming structured output with the ChatOpenAI model the event on_chain_end is incorrect. All of the variables within data.output are a concatenation of all the intermediary streamed output messages instead of just the final result.

This happens since when combining the streamed chunks in RunnableSequence._streamIterator() we check if concatenation is supported by checking concatSupported, but this variable is hardcoded to true and the false branch of the if statement is not implemented so for every model it assumes that concatenation is supported which is not the case for the ChatOpenAI model.

To solve this issue we have implemented the false branch which takes the last streamed chunk as the final output, instead of concatenating them all together to support models which don’t support concatenation.

Fixes #7114

Copy link

vercel bot commented Nov 30, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchainjs-docs ✅ Ready (Inspect) Visit Preview Nov 30, 2024 4:10pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchainjs-api-refs ⬜️ Ignored (Inspect) Nov 30, 2024 4:10pm

@NoahCristino
Copy link
Author

Currently we are trying to figure out where to override concatSupported to false for the OpenAI module

@jacoblee93
Copy link
Collaborator

Thanks for this - will think through how best to fix this

@Stadly
Copy link
Contributor

Stadly commented Dec 9, 2024

Is there any way to help this forward, @jacoblee93?

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.

End event contains wrong data when streaming structured output
3 participants