Once the logger is initialized, you can start sending logs to Quotient. Each log represents a single interaction between a user and your model. Include the query, the model’s output, and the evidence you relied on (documents, history, or instructions). Providing evidence is critical when using hallucination or document relevance detection. At least one of documents, message_history, or instructions is required.

Example

# Assumes quotient client is already initialized (see Initialize the Logger)
log_id = quotient.log(
    user_query="How do I cook a goose?",
    model_output="The capital of France is Paris",
    documents=[
        "Sample Document 1 without metadata",
        {"page_content": "Sample Document 2 with metadata", "metadata": {"source": "google.com"}},
        {"page_content": "Sample Document 3 without metadata"}
    ],
    message_history=[
        {"role": "system", "content": "You are an expert on cooking."},
        {"role": "user", "content": "How do I cook a goose?"}
    ],
    instructions=[
        "Answer concisely.",
        "If you are not sure, say 'I don't know'."
    ],
    tags={"model": "gpt-4", "feature": "recipes"}
)

print("Log created with ID:", log_id)

Parameters

  • user_query (string): Input query or prompt. Required when hallucination or document relevancy detection is enabled.
  • model_output (string): The response generated by the model. Required when hallucination detection is enabled.
  • documents (array<string|object>): Evidence documents. If objects are provided, they must have a page_content key and may include metadata. Example:
    [
      "Plain string document",
      { "page_content": "Document with metadata", "metadata": { "source": "kb.pdf" } }
    ]
    
  • message_history (array): Previous messages following OpenAI format { role, content }. Required if used for hallucination detection.
  • instructions (array): Instruction strings given to the model. Used in hallucination detection.
  • tags (object): Custom metadata to attach to the log. Example: { "model": "gpt-4", "customer": "enterprise-A" }.

Notes

  • When hallucination detection is enabled, one of documents, message_history, or instructions is required.
  • Log only the documents actually retrieved, not the entire corpus.
  • Metadata tags make reports far more useful (e.g., breakdown by retriever or model version).

Best Practices

  • Keep evidence minimal but sufficient for attribution (avoid dumping full corpora).
  • Standardize tag keys (model, retriever, customer) for consistent filtering.
  • Include the returned log_id in your own telemetry to cross-reference with Quotient reports.

Next: Retrieve Logs