Skip to content

Commit a007c52

Browse files
committed
Callback handler の設定見直し
1 parent ea43ba5 commit a007c52

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

rag/cdk/lambda/handler.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ export async function handle(
3232
'あなたは文書からコンテキストを取得する専門家です。ツールを使用してユーザーの質問に答える手助けをしてください。必ずユーザーの質問と同じ言語で答えてください。';
3333

3434
const { platform, model, modelName } = selectLlm(modelType);
35-
36-
const agent = createAgent({ model, tools: [tool], systemPrompt });
37-
3835
// Initialize Langfuse callback handler
3936
const langfuseHandler = langfuse.publicKey && langfuse.secretKey ? new CallbackHandler({
4037
sessionId,
@@ -43,6 +40,12 @@ export async function handle(
4340
tags: [modelName],
4441
}) : undefined;
4542

43+
const agent = createAgent({
44+
model,
45+
tools: [tool],
46+
systemPrompt,
47+
});
48+
4649
logger.debug(`Langfuse: ${langfuseHandler ? 'enable' : 'disable'}`);
4750

4851
const threadId = uuidv7();
@@ -54,8 +57,8 @@ export async function handle(
5457
configurable: {
5558
sessionId,
5659
thread_id: threadId,
57-
callbacks: langfuseHandler ? [langfuseHandler] : [],
5860
},
61+
callbacks: langfuseHandler ? [langfuseHandler] : [],
5962
},
6063
);
6164
for await (const sEvent of stream) {

0 commit comments

Comments
 (0)