mirror of
https://github.com/langchain-ai/new-langgraphjs-project.git
synced 2026-07-01 20:54:02 -04:00
Simplify
This commit is contained in:
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"node_version": "20",
|
||||
"graphs": {
|
||||
"agent": "./src/agent/index.ts:graph"
|
||||
"agent": "./src/agent/graph.ts:graph"
|
||||
},
|
||||
"env": ".env"
|
||||
}
|
||||
|
||||
@@ -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
@@ -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 +0,0 @@
|
||||
export { graph } from "./graph.js";
|
||||
Reference in New Issue
Block a user