feat(tracing): Integrate Langfuse for LLM call tracing and add documentation

This commit is contained in:
Willie Zutz 2025-08-10 10:05:42 -06:00
parent 9670003970
commit 7b4a7a531e
17 changed files with 183 additions and 36 deletions

View file

@ -17,6 +17,7 @@ import { ChatOpenAI } from '@langchain/openai';
import { ChatOllama } from '@langchain/ollama';
import { z } from 'zod';
import { withStructuredOutput } from '@/lib/utils/structuredOutput';
import { getLangfuseCallbacks } from '@/lib/tracing/langfuse';
interface FileRes {
fileName: string;
@ -71,7 +72,9 @@ Generate topics that describe what this document is about, its domain, and key s
name: 'generate_topics',
});
const result = await structuredLlm.invoke(prompt);
const result = await structuredLlm.invoke(prompt, {
...getLangfuseCallbacks(),
});
console.log('Generated topics:', result.topics);
// Filename is included for context
return filename + ', ' + result.topics.join(', ');