Open eyurtsev opened 7 months ago
š¤
It's great to see your interest in improving the streaming functionality in LangChain for chat models and language models. Your proposed goal and acceptance criteria for the PR are clear and well-defined. If you have a solution in mind and are planning to work on a fix, we encourage you to go ahead and create a pull request. Your contribution will be valuable in enhancing the LangChain platform. Thank you for your willingness to improve the codebase!
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a š if this is helpful and š if it is irrelevant.
If you want to continue the conversation, start your reply with @dosu-bot.
Working on this, can I get it assigned?
@samjove feel free to start working on it for a specific model and reference this issue!
Privileged issue
Issue Content
Goal
Improve streaming in LangChain for chat models / language models.
Background
Many chat and language models implement a streaming mode in which they stream tokens one at a time.
LangChain has a callback system that is useful for logging and important APIs like "stream", "stream_log" and "stream_events".
Currently many models incorrectly yield the token (chat generation) before invoking the callback.
Acceptance criteria
For a PR to be accepted and merged, the PR should:
Example PR
Here is an example PR that shows the fix for the OpenAI chat model:
https://github.com/langchain-ai/langchain/pull/16909
Find models that need to be fixed
The easiest way to find places in the code that may need to be fixed is using git grep
Examine the output to determine whether the callback is called before the token is yielded (correct) or after (needs to be fixed).