From 0933d5aec9c2c7a2f9b21c856e5bed448b7c3e09 Mon Sep 17 00:00:00 2001 From: jacoblee93 Date: Wed, 18 Sep 2024 11:32:30 -0700 Subject: [PATCH] Simplify --- langgraph.json | 2 +- src/agent/configuration.ts | 23 ----------------------- src/agent/graph.ts | 12 ++++-------- src/agent/index.ts | 1 - 4 files changed, 5 insertions(+), 33 deletions(-) delete mode 100644 src/agent/configuration.ts delete mode 100644 src/agent/index.ts diff --git a/langgraph.json b/langgraph.json index be56c16..25fca68 100644 --- a/langgraph.json +++ b/langgraph.json @@ -1,7 +1,7 @@ { "node_version": "20", "graphs": { - "agent": "./src/agent/index.ts:graph" + "agent": "./src/agent/graph.ts:graph" }, "env": ".env" } diff --git a/src/agent/configuration.ts b/src/agent/configuration.ts deleted file mode 100644 index 7a0567d..0000000 --- a/src/agent/configuration.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Define the configurable parameters for the agent. - */ - -import { RunnableConfig } from "@langchain/core/runnables"; - -export interface Configuration { - /** - * Placeholder: you can define custom configuration to change the behavior of - * your graph! - */ - model: string; -} - -export function ensureConfiguration(config: RunnableConfig): Configuration { - /** - * Pull a default `configurable` field from a RunnableConfig object. - */ - const configurable = config.configurable ?? {}; - return { - model: configurable.model ?? "my-model", - }; -} diff --git a/src/agent/graph.ts b/src/agent/graph.ts index 84399ed..244f88e 100644 --- a/src/agent/graph.ts +++ b/src/agent/graph.ts @@ -1,13 +1,10 @@ /** - * Empty LangGraph Template - * + * Starter LangGraph.js Template * Make this code your own! */ - import { StateGraph } from "@langchain/langgraph"; -import { StateAnnotation } from "./state.js"; -import { ensureConfiguration } from "./configuration.js"; import { RunnableConfig } from "@langchain/core/runnables"; +import { StateAnnotation } from "./state.js"; /** * Define a node, these do the work of the graph and should have most of the logic. @@ -19,9 +16,8 @@ import { RunnableConfig } from "@langchain/core/runnables"; */ const callModel = async ( state: typeof StateAnnotation.State, - config: RunnableConfig, + _config: RunnableConfig, ): Promise => { - const configuration = ensureConfiguration(config); /** * Do some work... (e.g. call an LLM) * For example, with LangChain you could do something like: @@ -65,7 +61,7 @@ const callModel = async ( messages: [ { role: "assistant", - content: `Hi, there! This is ${configuration.model}`, + content: `Hi there! How are you?`, }, ], }; diff --git a/src/agent/index.ts b/src/agent/index.ts deleted file mode 100644 index e46db80..0000000 --- a/src/agent/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { graph } from "./graph.js";