Skip to content

streaming response #28925

Answered by dosubot bot
navaneethstabilix asked this question in Ask Dosu
Discussion options

You must be logged in to vote

I found two similar unsolved discussions that might be relevant to your question:

  1. How to return streamed response in a function [1].
  2. How return LLMChain.run() stream data?? it did not store stream text in variable rather it just print?? [2].

To integrate your stream_to_websocket function with FastAPI WebSockets, you can use FastAPI's WebSocket support. Here's a basic example of how you might set this up:

from fastapi import FastAPI, WebSocket
from langchain import LLM  # Assuming LLM is the class you're using

app = FastAPI()

@app.websocket("/ws")
async def websocket_endpoint(websocket: WebSocket):
    await websocket.accept()
    prompt = "Your prompt here"  # You can modify this to …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by navaneethstabilix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant