Skip to content

Instantly share code, notes, and snippets.

View ninely's full-sized avatar

Ninely ninely

View GitHub Profile
@ninely
ninely / main.py
Last active June 5, 2024 07:35
Langchain with fastapi stream example
"""This is an example of how to use async langchain with fastapi and return a streaming response.
The latest version of Langchain has improved its compatibility with asynchronous FastAPI,
making it easier to implement streaming functionality in your applications.
"""
import asyncio
import os
from typing import AsyncIterable, Awaitable
import uvicorn
from dotenv import load_dotenv