Replies: 1 comment
-
🤖 To stream a response from a language model to Google Chat using the LangChain Javascript framework, you would need to use the Here's an example of how you can do this: import { PromptTemplate } from "langchain/prompts";
import { ChatCloudflareWorkersAI } from "langchain/chat_models/cloudflare_workersai";
const model = new ChatCloudflareWorkersAI({});
const promptTemplate = PromptTemplate.fromTemplate(
"Translate '{text}' from English to German"
);
const chain = promptTemplate.pipe(model);
const stream = await chain.stream({ text: "I love programming" });
let response = '';
for await (const chunk of stream) {
response += chunk?.content;
}
// Now you can send the response to Google Chat
sendToGoogleChat(response); In this example, Please note that the You can find more information about the
I hope this helps! If you have any other questions, feel free to ask. 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.
Uh oh!
There was an error while loading. Please reload this page.
-
i implemented a Chat Bot using a http-endpoint like described here https://developers.google.com/chat/quickstart/gcf-app
With this, you can return a message as response:
Anyone knows how to stream the response from the chain using this approach?
i already asked this question on stack overflow, since it seems to be completly unknown to the internet ;-)
https://stackoverflow.com/questions/77473078/how-can-i-stream-a-response-from-a-language-model-to-google-chat
Beta Was this translation helpful? Give feedback.
All reactions