DB-backed workspace + LangGraph agent
This commit is contained in:
@@ -4,6 +4,7 @@ import type { ChatRole, Prisma } from "@prisma/client";
|
||||
import { prisma } from "../utils/prisma";
|
||||
import { datasetRoot } from "../dataset/paths";
|
||||
import { ensureDataset } from "../dataset/exporter";
|
||||
import { runLangGraphCrmAgentFor } from "./langgraphCrmAgent";
|
||||
|
||||
type ContactIndexRow = {
|
||||
id: string;
|
||||
@@ -74,6 +75,11 @@ export async function runCrmAgent(userText: string): Promise<AgentReply> {
|
||||
export async function runCrmAgentFor(
|
||||
input: { teamId: string; userId: string; userText: string },
|
||||
): Promise<AgentReply> {
|
||||
const mode = (process.env.CF_AGENT_MODE ?? "langgraph").toLowerCase();
|
||||
if (mode !== "rule" && process.env.OPENAI_API_KEY) {
|
||||
return runLangGraphCrmAgentFor(input);
|
||||
}
|
||||
|
||||
await ensureDataset({ teamId: input.teamId, userId: input.userId });
|
||||
const q = normalize(input.userText);
|
||||
const root = datasetRoot({ teamId: input.teamId, userId: input.userId });
|
||||
|
||||
Reference in New Issue
Block a user