You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{OpenAssistantAgent,LangGraphProvider}from'@openassistant/agent';import{createSupervisor}from'@langchain/langgraph-supervisor';import{createReactAgent}from'@langchain/langgraph/prebuilt';import{ChatOpenAI}from'@langchain/openai';import{MemorySaver,InMemoryStore}from"@langchain/langgraph";import{v4asuuidv4}from"uuid";consttoolset=newOpenAssistantAgent({provider: newLangGraphProvider()});constllm=newChatOpenAI({model: 'gpt-4.1',temperature: 0.0});constsiteSelectionAgent=createReactAgent({
llm,name: 'site_selection_agent',tools: awaittoolset.getTools([{toolName: 'places'context: {getFSQToken: ()=>return '';
}},{
toolName: 'h3hub'
context: {
getFSQToken: ()=>return'';}},]),prompt: `You are an AI agent specialized in site selection using the H3-hub, Places and Measurement APIs based on given geographical location or address`});constreportAgent=createReactAgent({
llm,name: 'report_agent',tools: awaittoolset.getTools([{toolName: 'keplergl'context: {getMapboxToken: ()=>return '';
}},{
toolName: 'vegalite'
context: {
getDBConnection: ()=>return'';}},]),prompt: `You are an AI agent specialized in creating report using keplergl map and vegalite plots based on the results from other agents.`});constcheckpointer=newMemorySaver();conststore=newInMemoryStore();// Create supervisor that orchestrates agentsconstworkflow=createSupervisor({agents: [siteSelectionAgent,reportAgent],
llm,prompt: `You're the supervisor that routes tasks and updates memory. You have two agents that you should supervise:- site selection agent. Assign site selection, business location selection etc tasks to this agent.- report agent. If site selection has a result, call this agent to generate a report using maps and plots.Assign work to one agent at a time, do not call agents in parallel. Do NOT do any work yourself.`});// Compile the graph with both memory layersconstapp=workflow.compile({
checkpointer,
store
});consteventStream=app.streamEvents({ messages });// for Vercel AI SDK stream// Adapt the LangChain stream to Vercel AI SDK StreamreturnLangChainAdapter.toDataStreamResponse(transformedStream);
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Support multiple providers:
Support multiple languages:
Simplify Usage:
Support Agent
LangGraph
Beta Was this translation helpful? Give feedback.
All reactions