arcade-mcp/examples/langgraph-ts/src/configuration.ts
Sergio Serrano 3a45d5fec0
Add LangGraph-TS example (#356)
This PR adds a new example showcasing how to integrate Arcade tools with
LangGraph.js to create a ReAct agent. The example is based on the
[LangChain React Agent
JS](https://github.com/langchain-ai/react-agent-js/tree/main)
repository.
2025-04-09 21:08:18 -03:00

32 lines
838 B
TypeScript

import type { RunnableConfig } from "@langchain/core/runnables";
/**
* Define the configurable parameters for the agent.
*/
import { Annotation } from "@langchain/langgraph";
import { SYSTEM_PROMPT_TEMPLATE } from "./prompts.js";
export const ConfigurationSchema = Annotation.Root({
/**
* The system prompt to be used by the agent.
*/
systemPromptTemplate: Annotation<string>,
/**
* The name of the language model to be used by the agent.
*/
model: Annotation<string>,
});
export function ensureConfiguration(
config: RunnableConfig,
): typeof ConfigurationSchema.State {
/**
* Ensure the defaults are populated.
*/
const configurable = config.configurable ?? {};
return {
systemPromptTemplate:
configurable.systemPromptTemplate ?? SYSTEM_PROMPT_TEMPLATE,
model: configurable.model ?? "gpt-4o-mini",
};
}