apps/opik-documentation/documentation/fern/docs-v2/evaluation/advanced/annotation_queues.mdx
Involving subject matter experts in AI projects is essential because they provide the domain knowledge and contextual judgment that ensures model outputs are accurate, relevant, and aligned with real-world expectations. Annotation Queues in Opik make it simple for subject matter experts (SMEs) to review and annotate agent outputs. This feature streamlines the human-in-the-loop process by providing easy queue management, simple invitation flows, and a distraction-free annotation experience designed for non-technical users.
Annotation Queues are collections of traces or threads that need human review and feedback. They enable you to organize content for review, share with SMEs easily, collect structured feedback, and track progress across all your evaluation workflows.
Each annotation queue is defined by a collection of traces or threads, evaluation instructions, and feedback definitions:
Navigate to the Annotation Queues page in your project and click Create Queue.
<Frame> </Frame>Configure your queue with:
You can add items to your queue in several ways:
From Traces/Threads Lists:
From Individual Trace/Thread Details:
Once your queue is set up, you can share it with SMEs:
Copy Queue Link:
<Tip> **SME Access Required**: Subject matter experts must be invited to your workspace before they can access annotation queues. Make sure to invite them to your project first, then share the queue link. </Tip>When SMEs access a queue, they experience a streamlined, distraction-free interface designed for efficient review.
<Frame> </Frame>The annotation workflow begins with clear instructions and context, allowing SMEs to understand what they're evaluating and how to provide meaningful feedback.
<Frame> </Frame>The SME interface provides:
You can create and manage annotation queues programmatically using the Python or TypeScript SDK. This is useful for automating the process of adding items to queues based on specific criteria.
import opik
client = opik.Opik()
# Create a traces annotation queue
queue = client.create_traces_annotation_queue(
name="High Priority Traces",
description="Traces that need review",
instructions="Check for accuracy and completeness",
feedback_definition_names=["relevance", "accuracy"]
)
print(f"Created queue: {queue.name} (ID: {queue.id})")
</Tab>
<Tab value="TypeScript" title="TypeScript">
import { Opik } from "opik";
const client = new Opik();
// Create a trace annotation queue
const queue = await client.createTracesAnnotationQueue({
name: "High Priority Traces",
description: "Traces that need review",
instructions: "Check for accuracy and completeness",
feedbackDefinitionNames: ["relevance", "accuracy"],
});
console.log(`Created queue: ${queue.name} (ID: ${queue.id})`);
</Tab>
import opik
client = opik.Opik()
# Get an existing traces queue
queue = client.get_traces_annotation_queue("queue-id")
# Search for traces and add them to the queue
traces = client.search_traces(
project_name="my-project",
filter_string='feedback_scores.user_frustration > 0.5'
)
queue.add_traces(traces)
# For a single trace, wrap it in a list
single_trace = client.get_trace_content("trace-id")
queue.add_traces([single_trace])
</Tab>
<Tab value="TypeScript" title="TypeScript">
import { Opik } from "opik";
const client = new Opik();
// Get an existing traces queue
const queue = await client.getTracesAnnotationQueue("queue-id");
// Search for traces and add them to the queue
const traces = await client.searchTraces({
projectName: "my-project",
filterString: 'feedback_scores.user_frustration > 0.5',
});
await queue.addTraces(traces);
// For a single trace, wrap it in an array
const singleTraceResponse = await client.api.traces.getTraceById("trace-id");
await queue.addTraces([singleTraceResponse.data]);
</Tab>
import opik
client = opik.Opik()
# Create a threads annotation queue
thread_queue = client.create_threads_annotation_queue(
name="Thread Review Queue",
description="Threads needing review"
)
# Get threads and add them to the queue
threads_client = client.get_threads_client()
important_threads = threads_client.search_threads(
project_name="my-project",
filter_string='tags contains "important"'
)
thread_queue.add_threads(important_threads)
</Tab>
<Tab value="TypeScript" title="TypeScript">
import { Opik } from "opik";
const client = new Opik();
// Create a thread annotation queue
const threadQueue = await client.createThreadsAnnotationQueue({
name: "Thread Review Queue",
description: "Threads needing review",
});
// Search for threads and add them to the queue
const threads = await client.searchThreads({
projectName: "my-project",
filterString: 'tags contains "important"',
});
await threadQueue.addThreads(threads);
</Tab>
import opik
client = opik.Opik()
# Get an existing traces queue
queue = client.get_traces_annotation_queue("queue-id")
# Update queue properties
queue.update(
description="Traces that need a thorough review",
instructions="Check the conversation tone"
)
# Remove traces from the queue
short_traces = client.search_traces(
project_name="my-project",
filter_string='duration < 10'
)
queue.remove_traces(short_traces)
# Delete the queue
queue.delete()
import opik
client = opik.Opik()
# Get all traces annotation queues for a project
traces_queues = client.get_traces_annotation_queues(project_name="my-project")
for queue in traces_queues:
print(f"Traces Queue: {queue.name}, Items: {queue.items_count}")
# Get all threads annotation queues for a project
threads_queues = client.get_threads_annotation_queues(project_name="my-project")
for queue in threads_queues:
print(f"Threads Queue: {queue.name}, Items: {queue.items_count}")
</Tab>
<Tab value="TypeScript" title="TypeScript">
import { Opik } from "opik";
const client = new Opik();
// Get an existing traces queue
const queue = await client.getTracesAnnotationQueue("queue-id");
// Update queue properties
await queue.update({
description: "Traces that need a thorough review",
instructions: "Check the conversation tone",
});
// Remove traces from the queue
const shortTraces = await client.searchTraces({
projectName: "my-project",
filterString: "duration < 10",
});
await queue.removeTraces(shortTraces);
// Delete the queue
await queue.delete();
</Tab>
import opik
client = opik.Opik()
# Get all traces annotation queues for a project
traces_queues = client.get_traces_annotation_queues(project_name="my-project")
for queue in traces_queues:
print(f"Traces Queue: {queue.name}, Items: {queue.items_count}")
# Get all threads annotation queues for a project
threads_queues = client.get_threads_annotation_queues(project_name="my-project")
for queue in threads_queues:
print(f"Threads Queue: {queue.name}, Items: {queue.items_count}")
</Tab>
<Tab value="TypeScript" title="TypeScript">
import { Opik } from "opik";
const client = new Opik();
// Get all traces annotation queues for a project
const tracesQueues = await client.getTracesAnnotationQueues({
projectName: "my-project",
});
for (const queue of tracesQueues) {
const itemsCount = await queue.getItemsCount();
console.log(
`Queue: ${queue.name}, Scope: ${queue.scope}, Items: ${itemsCount}`
);
}
// Get all threads annotation queues for a project
const threadsQueues = await client.getThreadsAnnotationQueues({
projectName: "my-project",
});
for (const queue of threadsQueues) {
const itemsCount = await queue.getItemsCount();
console.log(
`Queue: ${queue.name}, Scope: ${queue.scope}, Items: ${itemsCount}`
);
}
</Tab>
You can learn more about Opik's annotation and evaluation features in: