mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-08-21 15:12:26 +02:00
This PR introduces the `--build-command` and `--install-command` arguments to `langgraph build`. `--install-command` is a custom install command. If passed, it will be run from wherever the `langgraph build` call was made, i.e. NOT where the langgraph.json file lives (except if these are the same place). This will override the detected install command that we previously used. `--build-command` is a custom build command. This will run from wherever the langgraph.json file lives, and will be done after the install has been run. You don't need to provide both. Just providing one will make the install (detected or supplied) run in the directory from where `langgraph build was called` and then have the build command (if one exists) run in the directory where langgraph.json exists. I think we should probably allow configuring the directories from which these commands get run, but I don't think this needs to be part of the MVP. --------- Co-authored-by: William FH <13333726+hinthornw@users.noreply.github.com>
48 lines
1.1 KiB
TypeScript
48 lines
1.1 KiB
TypeScript
/**
|
|
* Simple LangGraph.js example for monorepo testing
|
|
*/
|
|
import { StateGraph } from "@langchain/langgraph";
|
|
import { RunnableConfig } from "@langchain/core/runnables";
|
|
import { StateAnnotation } from "./state.js";
|
|
import { getGreeting } from "@js-monorepo-example/shared";
|
|
|
|
/**
|
|
* Simple node that uses the shared library
|
|
*/
|
|
const callModel = async (
|
|
state: typeof StateAnnotation.State,
|
|
_config: RunnableConfig,
|
|
): Promise<typeof StateAnnotation.Update> => {
|
|
// Use functions from the shared library
|
|
const greeting = getGreeting();
|
|
|
|
return {
|
|
messages: [
|
|
{
|
|
role: "assistant",
|
|
content: `${greeting}`,
|
|
},
|
|
],
|
|
};
|
|
};
|
|
|
|
/**
|
|
* Simple routing function
|
|
*/
|
|
export const route = (
|
|
state: typeof StateAnnotation.State,
|
|
): "__end__" | "callModel" => {
|
|
if (state.messages.length > 0) {
|
|
return "__end__";
|
|
}
|
|
return "callModel";
|
|
};
|
|
|
|
// Create the graph
|
|
const builder = new StateGraph(StateAnnotation)
|
|
.addNode("callModel", callModel)
|
|
.addEdge("__start__", "callModel")
|
|
.addConditionalEdges("callModel", route);
|
|
|
|
export const graph = builder.compile();
|