Refine CRM chat UX and add DB-backed pin toggle

This commit is contained in:
Ruslan Bakiev
2026-02-19 13:51:18 +07:00
parent 626d4ddd76
commit 23a4deba37
10 changed files with 173 additions and 45 deletions

View File

@@ -7,6 +7,7 @@ import { ChatOpenAI } from "@langchain/openai";
import { tool } from "@langchain/core/tools";
import { z } from "zod";
import { getLangfuseClient } from "../utils/langfuse";
import { Prisma } from "@prisma/client";
function iso(d: Date) {
return d.toISOString();
@@ -570,7 +571,7 @@ export async function runLangGraphCrmAgentFor(input: {
channel: toChannel(change.channel),
content: change.text,
durationSec: change.durationSec,
transcriptJson: Array.isArray(change.transcript) ? change.transcript : null,
transcriptJson: Array.isArray(change.transcript) ? change.transcript : Prisma.JsonNull,
occurredAt: new Date(change.at),
},
});
@@ -598,7 +599,8 @@ export async function runLangGraphCrmAgentFor(input: {
};
const crmTool = tool(
async (raw: z.infer<typeof CrmToolSchema>) => {
async (rawInput: unknown) => {
const raw = CrmToolSchema.parse(rawInput);
const toolName = `crm:${raw.action}`;
const startedAt = new Date().toISOString();
toolsUsed.push(toolName);