Tags

Tags allow you to label queries and completions.

This is useful to further segment your data. For example, you can label all the queries that are related to a specific feature or a specific company.

Later on, this can also be useful for creating fine-tune datasets.

2

Simplest: Identify OpenAI calls

The easiest way to get started adding tags is to send them when doing your OpenAI API calls.

const res = await openai.chat.completions.create({
model: "gpt-3.5-turbo",
messages: [{ role: "user", content: "Hello" }],
tags: ["some-tag"]
})
chat_completion = client.chat.completions.create(
messages=[{"role": "user", "content": "Say this is a test"}],
model="gpt-3.5-turbo",
tags=["some-tag"],
)

If you're using LangChain, you can similarly pass the tags on any LangChain object.

const chat = new ChatOpenAI({
callbacks: [new LunaryHandler()],
});
const res = await chat.call([new HumanMessage("Hello!")], {
tags: ["some-tag"],
});
handler = LunaryCallbackHandler()
chat = ChatOpenAI(
callbacks=[handler],
tags=["some-tag"],
)
3

Advanced: Inject tag into context

You can also inject tags into the context of your code. This is useful if you want to tag all the queries that are related to a specific feature or a specific company.

Coming soon
import lunary
# Method 2: everything inside the with statement will have tags2 and tags3
with lunary.tags(["tag2", "tag3"]):
my_agent()

Questions? We're here to help.