note
This content is from the README file of https://github.com/flux0-ai/flux0/tree/develop/examples/langchain_simple. The source code for this example can be found here
Flux0 LangChain Simple Example
This example demonstrates a minimal agent runner integration using Flux0 with the LangChain framework to stream a translation from English to Italian using OpenAI model.
Overview
The agent:
- Extracts user input from the session event stream.
- Sends the input to a LangChain chat model initialized with a translation prompt.
- Streams the output events back to the client in real time.
Key Components
LangChainAgentRunner
A simple agent runner that does the following:
- Retrieves the latest user message from the session.
- Initializes a LangChain chat model.
- Sends a translation prompt along with the user's input.
- Streams model events to the client.
Requirements
- Dependencies:
langchain
andlangchain[openai]
. OPENAPI_KEY
env var set.
Usage
Ensure the agent is defined by:
flux0 agents create --name langchain --type langchain_simple