Logging and Tracing
Palico provides tracing with OpenTelemetry. We provide traces out-of-the-box, but you can also add your own custom traces. You can view all your traces in Palico Studio
Adding Custom Traces
You can add custom traces using OpenTelemetry. Here's an example of adding traces to a call from OpenAI API.
import { tracer } from "@palico-ai/app";
// 1. Create a new tracer
const tracer = getTracer('ChatbotAgent');
const newConversation = async (message: string) => {
// 2. Start a new span
return tracer.trace("OpenAIConversation", async (span) => {
// 3. Add attributes to the span
span.setAttribute("message", message);
const response = await openaiClient.chat.completions.create({
model: "gpt-3.5-turbo",
messages: [
// ... your prompts
],
});;
const responseMessage = response.choices[0].message.content
// additonal attributes
span.setAttribute("LLM reply", responseMessage)
return response;
});
};
Viewing Traces
You can view logs and traces in Palico studio