UpdateRoot in the callback handler seems not work #2830
-
|
Hi. I'm using the stack (Langchain, langfuse, and as model OpenAI). Here is my code: The prompt is working fine, and the result is the expected result. Thank you in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
@joaoCrulhas Olá! Sou um bot que pode te ajudar a resolver bugs, responder perguntas e se tornar um colaborador. Estou aqui para te ajudar enquanto aguardamos um mantenedor humano. The issue you're facing with the To achieve your goal of updating the trace name to make it more descriptive and easier to filter, you can manually update the trace after its creation. Here is an example of how you can do this: const lf = new Langfuse();
const trace = lf.trace({
metadata: {
type: 'DocumentType',
},
name: 'Task_One',
userId: 'userId',
});
const langfuseHandlerTrace = new CallbackHandler({ root: trace, updateRoot: false });
const prompt = await this.langfuse.getPrompt('prompt1');
const parsers = StructuredOutputParser.fromZodSchema(
z.object({
// my Parser
}),
);
const promptTemplate = await PromptTemplate.fromTemplate(prompt.getLangchainPrompt()).partial({
schema: parsers.getFormatInstructions(),
});
const extractJsonLambda = new RunnableLambda({
func: extractJson<ConsumptionRecord>,
});
const postProcessing = new RunnableLambda({
func: postProcessingConsumptionInvoice,
});
const chain = RunnableSequence.from(
[promptTemplate, model, extractJsonLambda, postProcessing],
'TaskOne',
);
await chain.invoke(
{
query: UserInput,
},
{
callbacks: [langfuseHandlerTrace],
},
);
// Update the trace name after invocation
trace.update({
name: 'Updated_Task_One',
});
await lf.flushAsync();In this example, the |
Beta Was this translation helpful? Give feedback.

Just one notice, doing this, the input and output will be null, to fix it should add