Replies: 2 comments
-
🤖 Hello, Thank you for your interest in the LangChain project and for your detailed question. Based on the current functionality of the To answer your questions:
Please note that while I've done my best to provide accurate information based on the current state of the LangChain codebase, there may be plans to add such functionality in the future or there may be aspects of the codebase that I've overlooked. I would recommend keeping an eye on the repository for updates and potentially opening a feature request if real-time streaming is a functionality you'd like to see in LangChain. I hope this helps, and please don't hesitate to ask if you have any further questions. Best regards, Sources
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. |
Beta Was this translation helpful? Give feedback.
-
I'm new to langchain, just experimenting. Having similar requirements: want a stream data from the "chat-conversational-react-description" agent. I sketched that: const regex = /"action"\: \"Final Answer\".+\n\s*\"action_input\"\: \"(.+?)\"?$/g;
let buf = '', lastResult = '';
const res = await executor.call({ input: line }, [
{
handleLLMNewToken(token: string) {
buf += token;
const match = regex.exec(buf);
const finalResultMaybe = match?.[1];
let resultToken = '';
if (finalResultMaybe) {
resultToken = finalResultMaybe.substring(lastResult.length);
lastResult = finalResultMaybe;
}
process.stdout.write(resultToken);
},
},
]); The idea is to continuously parse the output string and try to find the "Final Answer" pattern. As soon it is found, the resulting token can be retrieved as a diff between the last and the current state. WDYT? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, Langchain community and maintainers,
I'm currently exploring the StructuredOutputParser class and its capabilities. I have a specific use case in my React application where I'm handling real-time JSON streaming data.
Current Implementation:
In my React application, I've developed a custom hook (useJsonStreamParser) that listens to a stream of JSON-like strings. It uses React's useEffect and useRef hooks to maintain a buffer and state.
The hook does the following:
Questions:
Does StructuredOutputParser have capabilities for real-time streaming? Could it be used to process a stream of JSON strings in real time?
If it does support streaming, how would one go about implementing this feature?
Could StructuredOutputParser potentially be a drop-in replacement for my custom function?
I would love to hear your thoughts and insights on this. This discussion could be beneficial for anyone looking to leverage Langchain for real-time data streaming and parsing.
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions