mirror of
https://github.com/livekit/agents.git
synced 2026-12-06 03:18:30 +00:00
820 B
820 B
LangChain plugin for LiveKit Agents
This plugin integrates capabilites from LangChain within LiveKit Agents
Installation
pip install livekit-plugins-langchain
Usage
Using LangGraph workflows
You can bring over any existing workflow in LangGraph as an Agents LLM with langchain.LLMAdapter. For example:
from langgraph.graph import StateGraph
from livekit.agents import Agent, AgentServer, JobContext, VoiceSession
from livekit.plugins import langchain
server = AgentServer()
@server.rtc_session()
async def entrypoint(ctx: JobContext):
graph = StateGraph(...).compile()
session = VoiceSession(
vad=...,
stt=...,
tts=...,
)
await session.start(
agent=Agent(instructions="", llm=langchain.LLMAdapter(graph)),
)
...