import { LangfuseClient } from '@langfuse/client'; import type { PromptFetcher, RawPrompt } from './PromptGateway'; export class LangfusePromptGateway implements PromptFetcher { private readonly client: LangfuseClient; constructor(opts: { publicKey: string; secretKey: string; baseUrl: string }) { this.client = new LangfuseClient({ publicKey: opts.publicKey, secretKey: opts.secretKey, baseUrl: opts.baseUrl, }); } async fetch(promptName: string): Promise { const prompt = await this.client.prompt.get(promptName, { type: 'chat' }); return { name: prompt.name, version: prompt.version, config: (prompt.config ?? {}) as Record, compile: (variables) => prompt.compile(variables as Record) as { role: 'system' | 'user' | 'assistant'; content: string; }[], }; } }