Backend: - Enterprise Agent refactored from single-round to ReAct multi-turn loop - New agent.ts (LLM decision node) + tool-executor.ts (tool execution + Gen-UI) - tool-defs.ts extracted for shared tool schemas - MAX_ITERATIONS=6 safeguard against infinite loops Frontend: - MessageBubble: Markdown + code highlighting + LaTeX + tables - ThemeToggle: light/dark/system theme cycling - chart-result Gen-UI card: recharts bar/line/pie/area charts Infrastructure: - Docker Compose (lightweight): only LangGraph + Frontend, Azure cloud for PG/Redis/Blob - Dockerfiles for dev (hot reload) and prod - Makefile with dev/prod/down/logs commands - Updated CLAUDE.md and agent definitions for LangGraph.js architecture Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
30 lines
661 B
TypeScript
30 lines
661 B
TypeScript
import {
|
|
Annotation,
|
|
MessagesAnnotation,
|
|
START,
|
|
StateGraph,
|
|
} from "@langchain/langgraph";
|
|
import { createLlm } from "@/agent/utils/create-llm";
|
|
|
|
const ChatAgentAnnotation = Annotation.Root({
|
|
messages: MessagesAnnotation.spec["messages"],
|
|
});
|
|
|
|
const graph = new StateGraph(ChatAgentAnnotation)
|
|
.addNode("chat", async (state) => {
|
|
const model = createLlm();
|
|
|
|
const response = await model.invoke([
|
|
{ role: "system", content: "You are a helpful assistant." },
|
|
...state.messages,
|
|
]);
|
|
|
|
return {
|
|
messages: response,
|
|
};
|
|
})
|
|
.addEdge(START, "chat");
|
|
|
|
export const agent = graph.compile();
|
|
agent.name = "Chat Agent";
|