Log & Detect
Logs
Learn how to log inputs and outputs to Quotient.
You can use Quotient’s SDK to log inputs and outputs from your retrieval or search-augmented AI applications.
Initialize the Logger
Initialize the Quotient logger with configuration settings for your application:
Parameters:
app_name
(string): Name of your application. Core parameter used to identify the source of logs in the Quotient dashboard.environment
(string): Environment where your application is running (e.g., “dev”, “staging”, “prod”). Core parameter used to help segregate logs by deployment environment.tags
(object): Key-value pairs for categorizing and filtering logs. Useful for slicing analytics by dimensions like customer, feature, model version, etc. Example:{"model": "gpt-4", "feature": "customer-support"}
sample_rate
(float): Value that determines what percent of logs to persist. Valid range of 0.0 to 1.0. Defaults to 1.0.detections
(array): List of detection types to run. Available options:DetectionType.HALLUCINATION
- Detects potential hallucinations in model outputsDetectionType.DOCUMENT_RELEVANCY
- Evaluates how relevant retrieved documents are to the user query
detection_sample_rate
(float): Value that determines what percent of logs to run detections on. Valid range of 0.0 to 1.0. Defaults to 0.0.
Send Logs
Log model interactions with context and metadata for analysis.
Parameters:
user_query
(string): The input query or prompt sent to the model. 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): List of document contents used as context for the model. Can be strings or dictionaries withpage_content
and optionalmetadata
. Used in hallucination detection and attribution analysis. Required when document relevancy detection is enabled. If a dictionary is passed, it must have the keypage_content
, containing the document text, and optionallymetadata
, containing any document metadata you want to capture about the document. Example:NOTE: One ofdocuments
,message_history
, orinstructions
is required when hallucination detection is enabled.message_history
(array): Previous messages in the conversation, following the OpenAI message format withrole
andcontent
keys. Used in hallucination detection and attribution analysis. Example:NOTE: One ofdocuments
,message_history
, orinstructions
is required when hallucination detection is enabled.instructions
(array): List of instructions provided to the model. Used in hallucination detection and attribution analysis. Example:NOTE: One ofdocuments
,message_history
, orinstructions
is required.tags
(object): Additional tags to associate with each log entry. Example:{"model": "gpt-4", "feature": "customer-support"}
Returns:
log_id
(string): A UUID representing the unique identifier for the logged event.
Retrieve Logs
Retrieve logs sent to Quotient using the client.
Returns:
logs
(array): An array ofLog
objects containing the following fields:id
(string): Unique identifier for the log entry.app_name
(string): Name of the application that generated the log.environment
(string): Environment where the log was generated (e.g., “dev”, “prod”).hallucination_detection
(boolean): Whether hallucination detection was enabled for this log.user_query
(string): The original user query or prompt that was logged.model_output
(string): The model’s response that was logged.documents
(array): List of documents used as context for the model. Can be strings or LogDocument objects.message_history
(array): Previous messages in the conversation, following the OpenAI message format.instructions
(array): List of instructions provided to the model.tags
(object): Dictionary of tags associated with the log entry.created_at
(datetime): Timestamp when the log was created.status
(string): Current status of the log entry.updated_at
(datetime): Timestamp when the log was last updated.has_hallucination
(boolean): Whether the model output was detected to contain hallucinations.hallucination_detection_sample_rate
(float): Sample rate used for hallucination detection.evaluations
(array): List of evaluation results for the log entry.
Asynchronous Python client
You can also use the asynchronous Python client to log data and retrieve logs.