This commit is contained in:
jacoblee93
2024-09-18 11:32:30 -07:00
parent 920d2891ec
commit 0933d5aec9
4 changed files with 5 additions and 33 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
{
"node_version": "20",
"graphs": {
"agent": "./src/agent/index.ts:graph"
"agent": "./src/agent/graph.ts:graph"
},
"env": ".env"
}
-23
View File
@@ -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",
};
}
+4 -8
View File
@@ -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<typeof StateAnnotation.Update> => {
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?`,
},
],
};
-1
View File
@@ -1 +0,0 @@
export { graph } from "./graph.js";