Adding Traces
You can add custom traces using tracer
. Here’s an example of adding traces to a call from OpenAI API.
import { tracer } from "@palico-ai/app";
const tracer = getTracer("ChatbotAgent");
const newConversation = async (message: string) => {
return tracer.trace("OpenAIConversation", async (span) => {
span.setAttribute("message", message);
const response = await openaiClient.chat.completions.create({
model: "gpt-3.5-turbo",
messages: [
],
});
const responseMessage = response.choices[0].message.content;
span.setAttribute("LLM reply", responseMessage);
return response;
});
};
Adding Logs
You can add logs using the logger
object from Palico. Here’s an example of adding logs to a call from OpenAI API.
import { logger } from "@palico-ai/app";
const newConversation = async (message: string) => {
logger.info("Starting new conversation", { message });
const response = await openaiClient.chat.completions.create({
model: "gpt-3.5-turbo",
messages: [
],
});
const responseMessage = response.choices[0].message.content;
logger.info("LLM reply", { responseMessage });
return response;
};
View Logs and Traces
You can view logs and traces in Palico Studio’s Trace View.