API
ActiveSpan ¶
Represents an active tracing span.
span_id
property
¶
Get the span ID of the current active span.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The span ID. |
trace_id
property
¶
Get the trace ID of the current active span.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The trace ID. |
add_event ¶
Add an event to the active span.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the event. |
required |
attributes
|
Any
|
Optional attributes for the event.
Can be any serializable type or pydantic |
required |
Source code in python/scouter/stubs.pyi
add_queue_item ¶
Helpers to add queue entities into a specified queue associated with the active span. This is an convenience method that abstracts away the details of queue management and leverages tracing's sampling capabilities to control data ingestion. Thus, correlated queue records and spans/traces can be sampled together based on the same sampling decision.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
alias
|
str
|
Alias of the queue to add the item into. |
required |
item
|
Union[Features, Metrics, GenAIEvalRecord]
|
Item to add into the queue. Can be an instance for Features, Metrics, or GenAIEvalRecord. |
required |
Example
Source code in python/scouter/stubs.pyi
set_attribute ¶
Set an attribute on the active span.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The attribute key. |
required |
value
|
SerializedType
|
The attribute value. |
required |
set_input ¶
Set the input for the active span.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input
|
Any
|
The input to set. Can be any serializable primitive type (str, int, float, bool, list, dict),
or a pydantic |
required |
max_length
|
int
|
The maximum length for a given string input. Defaults to 1000. |
1000
|
Source code in python/scouter/stubs.pyi
set_output ¶
Set the output for the active span.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output
|
Any
|
The output to set. Can be any serializable primitive type (str, int, float, bool, list, dict),
or a pydantic |
required |
max_length
|
int
|
The maximum length for a given string output. Defaults to 1000. |
1000
|
Source code in python/scouter/stubs.pyi
set_status ¶
Set the status of the active span.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
status
|
str
|
The status code (e.g., "OK", "ERROR"). |
required |
description
|
Optional[str]
|
Optional description for the status. |
None
|
Source code in python/scouter/stubs.pyi
set_tag ¶
Set a tag on the active span. Tags are similar to attributes except they are often used for indexing and searching spans/traces. All tags are also set as attributes on the span. Before export, tags are extracted and stored in a separate backend table for efficient querying.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The tag key. |
required |
value
|
str
|
The tag value. |
required |
Source code in python/scouter/stubs.pyi
Agent ¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider
|
Provider | str
|
The provider to use for the agent. This can be a Provider enum or a string representing the provider. |
required |
system_instruction
|
Optional[PromptMessage]
|
The system message to use for the agent. This can be a string, a list of strings, a Message object, or a list of Message objects. If None, no system message will be used. This is added to all tasks that the agent executes. If a given task contains it's own system message, the agent's system message will be prepended to the task's system message. |
None
|
Example:
Source code in python/scouter/stubs.pyi
id
property
¶
The ID of the agent. This is a random uuid7 that is generated when the agent is created.
system_instruction
property
¶
The system message to use for the agent. This is a list of Message objects.
execute_prompt ¶
Execute a prompt.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt
|
Prompt
|
The prompt to execute. |
required |
output_type
|
Optional[Any]
|
The output type to use for the task. This can either be a Pydantic |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
AgentResponse |
AgentResponse
|
The response from the agent after executing the task. |
Source code in python/scouter/stubs.pyi
execute_task ¶
Execute a task.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task
|
Task
|
The task to execute. |
required |
output_type
|
Optional[Any]
|
The output type to use for the task. This can either be a Pydantic |
None
|
Returns: AgentResponse: The response from the agent after executing the task.
Source code in python/scouter/stubs.pyi
AgentResponse ¶
log_probs
property
¶
Returns the log probabilities of the agent response if supported. This is primarily used for debugging and analysis purposes.
response
property
¶
The response of the agent. This can be an OpenAIChatResponse, GenerateContentResponse, or AnthropicMessageResponse depending on the provider used.
structured_output
property
¶
Returns the structured output of the agent response if supported.
AlertCondition ¶
baseline_value (float):
The baseline value to compare against for alerting.
alert_threshold (AlertThreshold):
The condition that determines when an alert should be triggered.
Must be one of the AlertThreshold enum members like Below, Above, or Outside.
delta (Optional[float], optional):
Optional delta value that modifies the baseline to create the alert boundary.
The interpretation depends on alert_threshold:
- Above: alert if value > (baseline + delta)
- Below: alert if value < (baseline - delta)
- Outside: alert if value is outside [baseline - delta, baseline + delta]
Example: alert_threshold = AlertCondition(AlertCondition.BELOW, 2.0)
Source code in python/scouter/stubs.pyi
AlertDispatchType ¶
AlertThreshold ¶
Enum representing different alert conditions for monitoring metrics.
Attributes:
| Name | Type | Description |
|---|---|---|
Below |
AlertThreshold
|
Indicates that an alert should be triggered when the metric is below a threshold. |
Above |
AlertThreshold
|
Indicates that an alert should be triggered when the metric is above a threshold. |
Outside |
AlertThreshold
|
Indicates that an alert should be triggered when the metric is outside a specified range. |
from_value
staticmethod
¶
Creates an AlertThreshold enum member from a string value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
The string representation of the alert condition. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
AlertThreshold |
AlertThreshold
|
The corresponding AlertThreshold enum member. |
Source code in python/scouter/stubs.pyi
AlignedEvalResult ¶
Eval Result for a specific evaluation
error_message
property
¶
Get the error message if the evaluation failed
mean_embeddings
property
¶
Get mean embeddings of embedding targets
record_uid
property
¶
Get the unique identifier for the record associated with this result
similarity_scores
property
¶
Get similarity scores of embedding targets
AllowedTools ¶
Configuration for constraining model to specific tools.
This class specifies a list of tools the model is allowed to use, along with the behavior mode.
Examples:
>>> tools = [ToolDefinition("get_weather")]
>>> allowed = AllowedTools(mode=AllowedToolsMode.Auto, tools=tools)
>>>
>>> # Or from function names
>>> allowed = AllowedTools.from_function_names(
... mode=AllowedToolsMode.Required,
... function_names=["get_weather", "get_time"]
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
AllowedToolsMode
|
The mode for tool usage behavior |
required |
tools
|
List[ToolDefinition]
|
List of allowed tools |
required |
Source code in python/scouter/stubs.pyi
from_function_names
staticmethod
¶
Create AllowedTools from function names.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
AllowedToolsMode
|
The mode for tool usage behavior |
required |
function_names
|
List[str]
|
List of function names to allow |
required |
Returns:
| Name | Type | Description |
|---|---|---|
AllowedTools |
AllowedTools
|
Configured allowed tools instance |
Source code in python/scouter/stubs.pyi
AllowedToolsMode ¶
Mode for allowed tools constraint behavior.
This enum defines how the model should behave when constrained to specific tools.
Examples:
Annotations ¶
Annotations attached to OpenAI message content.
This class contains metadata and citations for message content, such as URL citations from web search.
Examples:
AnthropicMessageResponse ¶
Response from Anthropic chat completion API.
Complete response containing generated content and metadata.
Examples:
>>> response = AnthropicMessageResponse(...)
>>> print(response.content[0].text)
>>> print(f"Stop reason: {response.stop_reason}")
>>> print(f"Usage: {response.usage.total_tokens} tokens")
AnthropicSettings ¶
AnthropicSettings(
max_tokens: int = 4096,
metadata: Optional[Metadata] = None,
service_tier: Optional[str] = None,
stop_sequences: Optional[List[str]] = None,
stream: Optional[bool] = None,
system: Optional[str] = None,
temperature: Optional[float] = None,
thinking: Optional[AnthropicThinkingConfig] = None,
top_k: Optional[int] = None,
top_p: Optional[float] = None,
tools: Optional[List[AnthropicTool]] = None,
tool_choice: Optional[AnthropicToolChoice] = None,
extra_body: Optional[Any] = None,
)
Settings for Anthropic chat completion requests.
Comprehensive configuration for chat completion behavior.
Examples:
>>> # Basic settings
>>> settings = AnthropicSettings(
... max_tokens=1024,
... temperature=0.7
... )
>>>
>>> # Advanced settings with tools
>>> tool = AnthropicTool(name="get_weather", ...)
>>> choice = AnthropicToolChoice(type="auto")
>>> settings = AnthropicSettings(
... max_tokens=2048,
... temperature=0.5,
... tools=[tool],
... tool_choice=choice
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_tokens
|
int
|
Maximum tokens to generate |
4096
|
metadata
|
Optional[Metadata]
|
Request metadata |
None
|
service_tier
|
Optional[str]
|
Service tier ("auto" or "standard_only") |
None
|
stop_sequences
|
Optional[List[str]]
|
Stop sequences |
None
|
stream
|
Optional[bool]
|
Enable streaming |
None
|
system
|
Optional[str]
|
System prompt |
None
|
temperature
|
Optional[float]
|
Sampling temperature (0.0-1.0) |
None
|
thinking
|
Optional[AnthropicThinkingConfig]
|
Thinking configuration |
None
|
top_k
|
Optional[int]
|
Top-k sampling parameter |
None
|
top_p
|
Optional[float]
|
Nucleus sampling parameter |
None
|
tools
|
Optional[List[AnthropicTool]]
|
Available tools |
None
|
tool_choice
|
Optional[AnthropicToolChoice]
|
Tool choice configuration |
None
|
extra_body
|
Optional[Any]
|
Additional request parameters |
None
|
Source code in python/scouter/stubs.pyi
AnthropicThinkingConfig ¶
Configuration for extended thinking.
Controls Claude's extended thinking feature.
Examples:
>>> # Enable thinking with budget
>>> config = AnthropicThinkingConfig(type="enabled", budget_tokens=2000)
>>>
>>> # Disable thinking
>>> config = AnthropicThinkingConfig(type="disabled", budget_tokens=None)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type
|
str
|
Configuration type ("enabled" or "disabled") |
required |
budget_tokens
|
Optional[int]
|
Token budget for thinking |
None
|
Source code in python/scouter/stubs.pyi
AnthropicTool ¶
AnthropicTool(
name: str,
description: Optional[str] = None,
input_schema: Any = None,
cache_control: Optional[CacheControl] = None,
)
Tool definition for Anthropic API.
Defines a tool that Claude can use.
Examples:
>>> schema = {
... "type": "object",
... "properties": {
... "location": {"type": "string"}
... },
... "required": ["location"]
... }
>>> tool = AnthropicTool(
... name="get_weather",
... description="Get weather for a location",
... input_schema=schema,
... cache_control=None
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Tool name |
required |
description
|
Optional[str]
|
Tool description |
None
|
input_schema
|
Any
|
JSON schema for tool input |
None
|
cache_control
|
Optional[CacheControl]
|
Cache control settings |
None
|
Source code in python/scouter/stubs.pyi
AnthropicToolChoice ¶
AnthropicToolChoice(
type: str,
disable_parallel_tool_use: Optional[bool] = None,
name: Optional[str] = None,
)
Tool choice configuration.
Controls how Claude uses tools.
Examples:
>>> # Automatic tool choice
>>> choice = AnthropicToolChoice(
... type="auto",
... disable_parallel_tool_use=False,
... name=None
... )
>>>
>>> # Specific tool
>>> choice = AnthropicToolChoice(
... type="tool",
... disable_parallel_tool_use=False,
... name="get_weather"
... )
>>>
>>> # No tools
>>> choice = AnthropicToolChoice(
... type="none",
... disable_parallel_tool_use=None,
... name=None
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type
|
str
|
Choice type ("auto", "any", "tool", "none") |
required |
disable_parallel_tool_use
|
Optional[bool]
|
Whether to disable parallel tool use |
None
|
name
|
Optional[str]
|
Specific tool name (required if type is "tool") |
None
|
Source code in python/scouter/stubs.pyi
AnthropicUsage ¶
Token usage statistics.
Token usage information for the request.
Examples:
>>> usage = response.usage
>>> print(f"Input tokens: {usage.input_tokens}")
>>> print(f"Output tokens: {usage.output_tokens}")
>>> print(f"Total: {usage.input_tokens + usage.output_tokens}")
>>> if usage.cache_read_input_tokens:
... print(f"Cache hits: {usage.cache_read_input_tokens}")
cache_creation_input_tokens
property
¶
Tokens used to create cache.
ApiKeyConfig ¶
ApiKeyConfig(
name: Optional[str] = None,
api_key_secret: Optional[str] = None,
api_key_string: Optional[str] = None,
http_element_location: Optional[
HttpElementLocation
] = None,
)
API key authentication configuration.
Configures API key authentication for external APIs.
Examples:
>>> config = ApiKeyConfig(
... name="X-API-Key",
... api_key_secret="projects/my-project/secrets/api-key",
... http_element_location=HttpElementLocation.HttpInHeader
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
Optional[str]
|
Name of the API key parameter |
None
|
api_key_secret
|
Optional[str]
|
Secret manager resource name |
None
|
api_key_string
|
Optional[str]
|
Direct API key string |
None
|
http_element_location
|
Optional[HttpElementLocation]
|
Where to place the API key |
None
|
Source code in python/scouter/stubs.pyi
http_element_location
property
¶
Where to place the API key.
ApiSpecType ¶
API specification type for external retrieval.
Defines the type of external API used for grounding/retrieval.
Examples:
ApiSpecUnspecified
class-attribute
instance-attribute
¶
Unspecified API spec
AssertionTask ¶
AssertionTask(
id: str,
expected_value: Any,
operator: ComparisonOperator,
field_path: Optional[str] = None,
description: Optional[str] = None,
depends_on: Optional[Sequence[str]] = None,
condition: bool = False,
)
Assertion-based evaluation task for LLM monitoring.
Defines a rule-based assertion that evaluates values extracted from LLM context/responses against expected conditions without requiring additional LLM calls. Assertions are efficient, deterministic evaluations ideal for validating structured outputs, checking thresholds, or verifying data constraints.
Assertions can operate on
- Nested fields via dot-notation paths (e.g., "response.user.age")
- Top-level context values when field_path is None
- String, numeric, boolean, or collection values
Common Use Cases
- Validate response structure ("response.status" == "success")
- Check numeric thresholds ("response.confidence" >= 0.8)
- Verify required fields exist ("response.user.id" is not None)
- Validate string patterns ("response.language" contains "en")
Examples:
Basic numeric comparison:
>>> # Context at runtime: {"response": {"user": {"age": 25}}}
>>> task = AssertionTask(
... id="check_user_age",
... field_path="response.user.age",
... operator=ComparisonOperator.GreaterThan,
... expected_value=18,
... description="Verify user is an adult"
... )
Checking top-level fields:
>>> # Context at runtime: {"user": {"age": 25}}
>>> task = AssertionTask(
... id="check_age",
... field_path="user.age",
... operator=ComparisonOperator.GreaterThanOrEqual,
... expected_value=21,
... description="Check minimum age requirement"
... )
Operating on entire context (no nested path):
>>> # Context at runtime: 25
>>> task = AssertionTask(
... id="age_threshold",
... field_path=None,
... operator=ComparisonOperator.GreaterThan,
... expected_value=18,
... description="Validate age value"
... )
String validation:
>>> # Context: {"response": {"status": "completed"}}
>>> task = AssertionTask(
... id="status_check",
... field_path="response.status",
... operator=ComparisonOperator.Equals,
... expected_value="completed",
... description="Verify completion status"
... )
Collection membership:
>>> # Context: {"response": {"tags": ["valid", "processed"]}}
>>> task = AssertionTask(
... id="tag_validation",
... field_path="response.tags",
... operator=ComparisonOperator.Contains,
... expected_value="valid",
... description="Check for required tag"
... )
With dependencies:
>>> task = AssertionTask(
... id="confidence_check",
... field_path="response.confidence",
... operator=ComparisonOperator.GreaterThan,
... expected_value=0.9,
... description="High confidence validation",
... depends_on=["status_check"]
... )
Note
- Field paths use dot-notation for nested access
- Field paths are case-sensitive
- When field_path is None, the entire context is used as the value
- Type mismatches between actual and expected values will fail the assertion
- Dependencies are executed before this task
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str
|
Unique identifier for the task. Will be converted to lowercase. Used to reference this task in dependencies and results. |
required |
expected_value
|
Any
|
The expected value to compare against. Can be any JSON-serializable type: str, int, float, bool, list, dict, or None. |
required |
operator
|
ComparisonOperator
|
Comparison operator to use for the assertion. Must be a ComparisonOperator enum value. |
required |
field_path
|
Optional[str]
|
Optional dot-notation path to extract value from context (e.g., "response.user.age"). If None, the entire context is used as the comparison value. |
None
|
description
|
Optional[str]
|
Optional human-readable description of what this assertion validates. Useful for understanding evaluation results. |
None
|
depends_on
|
Optional[Sequence[str]]
|
Optional list of task IDs that must complete successfully before this task executes. Empty list if not provided. |
None
|
condition
|
bool
|
If True, this assertion task acts as a condition for subsequent tasks. If the assertion fails, dependent tasks will be skipped and this task will be excluded from final results. |
False
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If expected_value is not JSON-serializable or if operator is not a valid ComparisonOperator. |
Source code in python/scouter/stubs.pyi
description
property
writable
¶
Human-readable description of the assertion.
expected_value
property
¶
Expected value for comparison.
Returns:
| Type | Description |
|---|---|
Any
|
The expected value as a Python object (deserialized from internal |
Any
|
JSON representation). |
field_path
property
writable
¶
Dot-notation path to field in context, or None for entire context.
Attribute ¶
Represents a key-value attribute associated with a span.
Audio ¶
Audio output from OpenAI chat completions.
This class contains audio data generated by the model when audio output is requested.
Examples:
AudioParam ¶
Audio output configuration for OpenAI chat completions.
This class provides configuration for audio output in chat completions, including format and voice selection for text-to-speech capabilities.
Examples:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
format
|
str
|
Audio output format (e.g., "mp3", "opus", "aac", "flac", "wav", "pcm") |
required |
voice
|
str
|
Voice to use for text-to-speech (e.g., "alloy", "echo", "fable", "onyx", "nova", "shimmer") |
required |
Source code in python/scouter/stubs.pyi
model_dump ¶
Convert audio parameters to a dictionary.
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dict[str, Any]: Dictionary representation of audio parameters |
AuthConfig ¶
AuthConfigValue ¶
AuthConfigValue(
api_key_config: Optional[ApiKeyConfig] = None,
http_basic_auth_config: Optional[
HttpBasicAuthConfig
] = None,
google_service_account_config: Optional[
GoogleServiceAccountConfig
] = None,
oauth_config: Optional[OauthConfig] = None,
oidc_config: Optional[OidcConfig] = None,
)
Union type for authentication configuration.
Represents one of several authentication methods.
Examples:
Exactly one configuration type must be provided.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_key_config
|
Optional[ApiKeyConfig]
|
API key authentication |
None
|
http_basic_auth_config
|
Optional[HttpBasicAuthConfig]
|
HTTP Basic authentication |
None
|
google_service_account_config
|
Optional[GoogleServiceAccountConfig]
|
Service account authentication |
None
|
oauth_config
|
Optional[OauthConfig]
|
OAuth authentication |
None
|
oidc_config
|
Optional[OidcConfig]
|
OIDC authentication |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If configuration is invalid |
Source code in python/scouter/stubs.pyi
AuthType ¶
Authentication type for external APIs.
Specifies the authentication method used to access external APIs.
Examples:
AutoRoutingMode ¶
Configuration for automatic model routing.
Controls model selection based on routing preferences when using automatic routing features.
Examples:
>>> # Prioritize quality over cost
>>> mode = AutoRoutingMode(
... model_routing_preference=ModelRoutingPreference.PrioritizeQuality
... )
>>> # Balance quality and cost
>>> mode = AutoRoutingMode(
... model_routing_preference=ModelRoutingPreference.Balanced
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_routing_preference
|
Optional[ModelRoutingPreference]
|
Preference for model selection |
None
|
Source code in python/scouter/stubs.pyi
model_routing_preference
property
¶
The routing preference.
Base64ImageSource ¶
Base64-encoded image source.
Image data encoded in base64 format with media type.
Examples:
>>> source = Base64ImageSource(
... media_type="image/jpeg",
... data="base64_encoded_data_here"
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
media_type
|
str
|
Image media type (e.g., "image/jpeg", "image/png") |
required |
data
|
str
|
Base64-encoded image data |
required |
Source code in python/scouter/stubs.pyi
Base64PDFSource ¶
Base64-encoded PDF source.
PDF document data encoded in base64 format.
Examples:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
str
|
Base64-encoded PDF data |
required |
Source code in python/scouter/stubs.pyi
BaseModel ¶
BaseTracer ¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the service for tracing. |
required |
Source code in python/scouter/stubs.pyi
current_span ¶
Get the current active span.
Returns:
| Name | Type | Description |
|---|---|---|
ActiveSpan |
ActiveSpan
|
The current active span. Raises an error if no active span exists. |
set_scouter_queue ¶
Add a ScouterQueue to the tracer. This allows the tracer to manage and export queue entities in conjunction with span data for correlated monitoring and observability.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
queue
|
ScouterQueue
|
The ScouterQueue instance to add. |
required |
Source code in python/scouter/stubs.pyi
shutdown ¶
start_as_current_span ¶
start_as_current_span(
name: str,
kind: Optional[SpanKind] = SpanKind.Internal,
label: Optional[str] = None,
attributes: Optional[dict[str, str]] = None,
baggage: Optional[dict[str, str]] = None,
tags: Optional[dict[str, str]] = None,
parent_context_id: Optional[str] = None,
trace_id: Optional[str] = None,
span_id: Optional[str] = None,
remote_sampled: Optional[bool] = None,
) -> ActiveSpan
Context manager to start a new span as the current span.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the span. |
required |
kind
|
Optional[SpanKind]
|
The kind of span (e.g., "SERVER", "CLIENT"). |
Internal
|
label
|
Optional[str]
|
An optional label for the span. |
None
|
attributes
|
Optional[dict[str, str]]
|
Optional attributes to set on the span. |
None
|
baggage
|
Optional[dict[str, str]]
|
Optional baggage items to attach to the span. |
None
|
tags
|
Optional[dict[str, str]]
|
Optional tags to set on the span and trace. |
None
|
parent_context_id
|
Optional[str]
|
Optional parent span context ID. |
None
|
trace_id
|
Optional[str]
|
Optional trace ID to associate with the span. This is useful for when linking spans across different services or systems. |
None
|
span_id
|
Optional[str]
|
Optional span ID to associate with the span. This will be the parent span ID. |
None
|
remote_sampled
|
Optional[bool]
|
Optional flag indicating if the span was sampled remotely. |
None
|
Returns: ActiveSpan:
Source code in python/scouter/stubs.pyi
BatchConfig ¶
BatchConfig(
max_queue_size: int = 2048,
scheduled_delay_ms: int = 5000,
max_export_batch_size: int = 512,
)
Configuration for batch exporting of spans.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_queue_size
|
int
|
The maximum queue size for spans. Defaults to 2048. |
2048
|
scheduled_delay_ms
|
int
|
The delay in milliseconds between export attempts. Defaults to 5000. |
5000
|
max_export_batch_size
|
int
|
The maximum batch size for exporting spans. Defaults to 512. |
512
|
Source code in python/scouter/stubs.pyi
Behavior ¶
Bin ¶
Blob ¶
Inline binary data.
Contains raw binary data encoded in base64.
Examples:
>>> import base64
>>> image_data = base64.b64encode(image_bytes).decode('utf-8')
>>> blob = Blob(
... mime_type="image/png",
... data=image_data,
... display_name="Example Image"
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mime_type
|
str
|
IANA MIME type |
required |
data
|
str
|
Base64-encoded binary data |
required |
display_name
|
Optional[str]
|
Optional display name |
None
|
Source code in python/scouter/stubs.pyi
BlockedReason ¶
Reason why content was blocked.
Indicates why a prompt or response was blocked by content filters.
Examples:
BlockedReasonUnspecified
class-attribute
instance-attribute
¶
Unspecified reason
Blocklist
class-attribute
instance-attribute
¶
Blocked due to blocklist match
ImageSafety
class-attribute
instance-attribute
¶
Blocked for image safety
Jailbreak
class-attribute
instance-attribute
¶
Blocked as jailbreak attempt
ProhibitedContent
class-attribute
instance-attribute
¶
Contains prohibited content
CacheControl ¶
Cache control configuration.
Controls prompt caching behavior.
Examples:
>>> # 5 minute cache
>>> cache = CacheControl(cache_type="ephemeral", ttl="5m")
>>>
>>> # 1 hour cache
>>> cache = CacheControl(cache_type="ephemeral", ttl="1h")
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cache_type
|
str
|
Cache type (typically "ephemeral") |
required |
ttl
|
Optional[str]
|
Time-to-live ("5m" or "1h") |
None
|
Source code in python/scouter/stubs.pyi
Candidate ¶
Response candidate from the model.
A single generated response option with content and metadata.
Examples:
>>> candidate = Candidate(
... index=0,
... content=GeminiContent(...),
... finish_reason=FinishReason.Stop,
... safety_ratings=[SafetyRating(...)],
... citation_metadata=CitationMetadata(...)
... )
url_context_metadata
property
¶
URL context metadata.
CharStats ¶
ChatCompletionMessage ¶
Message from OpenAI chat completion response.
This class represents the model's response message, including text content, tool calls, audio, and annotations.
Examples:
>>> # Accessing message from response
>>> choice = response.choices[0]
>>> message = choice.message
>>> print(f"Role: {message.role}")
>>> print(f"Content: {message.content}")
>>>
>>> # Checking for tool calls
>>> if message.tool_calls:
... for call in message.tool_calls:
... print(f"Function: {call.function.name}")
ChatMessage ¶
ChatMessage(
role: str,
content: Union[
str,
List[
Union[
str,
TextContentPart,
ImageContentPart,
InputAudioContentPart,
FileContentPart,
]
],
],
name: Optional[str] = None,
)
Message for OpenAI chat completions.
This class represents a single message in a chat completion conversation, supporting multiple content types including text, images, audio, and files.
Examples:
>>> # Simple text message
>>> msg = ChatMessage(role="user", content="Hello!")
>>>
>>> # Message with image
>>> image = ImageContentPart(url="https://example.com/image.jpg")
>>> msg = ChatMessage(role="user", content=[image])
>>>
>>> # Mixed content message
>>> msg = ChatMessage(
... role="user",
... content=["Describe this image:", image]
... )
>>>
>>> # System message with name
>>> msg = ChatMessage(
... role="system",
... content="You are a helpful assistant.",
... name="assistant_v1"
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
role
|
str
|
Message role ("system", "user", "assistant", "tool", "developer") |
required |
content
|
Union[str, List[...]]
|
Message content - can be: - String: Simple text message - List: Mixed content with strings and content parts - ContentPart: Single structured content part |
required |
name
|
Optional[str]
|
Optional name for the message |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If content format is invalid |
Source code in python/scouter/stubs.pyi
content
property
¶
content: List[
Union[
TextContentPart,
ImageContentPart,
InputAudioContentPart,
FileContentPart,
]
]
The message content parts.
bind ¶
bind(
name: Optional[str] = None,
value: Optional[str | int | float | bool | list] = None,
) -> ChatMessage
Bind variables to the message content. Args: name (Optional[str]): The variable name to bind. value (Optional[Union[str, int, float, bool, list]]): The variable value to bind. Returns: ChatMessage: A new ChatMessage instance with bound variables.
Source code in python/scouter/stubs.pyi
bind_mut ¶
bind_mut(
name: Optional[str] = None,
value: Optional[str | int | float | bool | list] = None,
) -> None
Bind variables to the message content in place. Args: name (Optional[str]): The variable name to bind. value (Optional[Union[str, int, float, bool, list]]): The variable value to bind. Returns: None
Source code in python/scouter/stubs.pyi
model_dump ¶
text ¶
Get the text content of the first part, if available. Returns an empty string if the first part is not text. This is meant for convenience when working with simple text messages.
Choice ¶
Choice from OpenAI chat completion response.
This class represents one possible completion from the model, including the message, finish reason, and optional log probabilities.
Examples:
>>> # Accessing choice from response
>>> choice = response.choices[0]
>>> print(f"Message: {choice.message.content}")
>>> print(f"Finish reason: {choice.finish_reason}")
>>>
>>> # Multiple choices (when n > 1)
>>> for i, choice in enumerate(response.choices):
... print(f"Choice {i}: {choice.message.content}")
Citation ¶
Source citation information.
Citation for a piece of generated content with source details.
Examples:
>>> citation = Citation(
... start_index=10,
... end_index=50,
... uri="https://example.com",
... title="Example Source",
... license="CC-BY-4.0",
... publication_date=GoogleDate(year=2024, month=1, day=1)
... )
CitationCharLocation ¶
CitationCharLocationParam ¶
CitationCharLocationParam(
cited_text: str,
document_index: int,
document_title: str,
end_char_index: int,
start_char_index: int,
)
Citation with character-level location in document.
Specifies a citation reference using character indices within a document.
Examples:
>>> citation = CitationCharLocationParam(
... cited_text="Example text",
... document_index=0,
... document_title="Document Title",
... end_char_index=100,
... start_char_index=50
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cited_text
|
str
|
The text being cited |
required |
document_index
|
int
|
Index of the document in the input |
required |
document_title
|
str
|
Title of the document |
required |
end_char_index
|
int
|
Ending character position |
required |
start_char_index
|
int
|
Starting character position |
required |
Source code in python/scouter/stubs.pyi
CitationContentBlockLocation ¶
CitationContentBlockLocationParam ¶
CitationContentBlockLocationParam(
cited_text: str,
document_index: int,
document_title: str,
end_block_index: int,
start_block_index: int,
)
Citation with content block location in document.
Specifies a citation reference using content block indices within a document.
Examples:
>>> citation = CitationContentBlockLocationParam(
... cited_text="Example text",
... document_index=0,
... document_title="Document Title",
... end_block_index=5,
... start_block_index=2
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cited_text
|
str
|
The text being cited |
required |
document_index
|
int
|
Index of the document in the input |
required |
document_title
|
str
|
Title of the document |
required |
end_block_index
|
int
|
Ending content block index |
required |
start_block_index
|
int
|
Starting content block index |
required |
Source code in python/scouter/stubs.pyi
CitationMetadata ¶
Collection of citations.
Contains all citations for a piece of content.
Examples:
CitationPageLocation ¶
CitationPageLocationParam ¶
CitationPageLocationParam(
cited_text: str,
document_index: int,
document_title: str,
end_page_number: int,
start_page_number: int,
)
Citation with page-level location in document.
Specifies a citation reference using page numbers within a document.
Examples:
>>> citation = CitationPageLocationParam(
... cited_text="Example text",
... document_index=0,
... document_title="Document Title",
... end_page_number=10,
... start_page_number=5
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cited_text
|
str
|
The text being cited |
required |
document_index
|
int
|
Index of the document in the input |
required |
document_title
|
str
|
Title of the document |
required |
end_page_number
|
int
|
Ending page number |
required |
start_page_number
|
int
|
Starting page number |
required |
Source code in python/scouter/stubs.pyi
CitationSearchResultLocationParam ¶
CitationSearchResultLocationParam(
cited_text: str,
end_block_index: int,
search_result_index: int,
source: str,
start_block_index: int,
title: str,
)
Citation from search result.
Specifies a citation reference from a search result with block-level location.
Examples:
>>> citation = CitationSearchResultLocationParam(
... cited_text="Example text",
... end_block_index=5,
... search_result_index=0,
... source="https://example.com",
... start_block_index=2,
... title="Search Result"
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cited_text
|
str
|
The text being cited |
required |
end_block_index
|
int
|
Ending content block index |
required |
search_result_index
|
int
|
Index of the search result |
required |
source
|
str
|
Source URL or identifier |
required |
start_block_index
|
int
|
Starting content block index |
required |
title
|
str
|
Title of the search result |
required |
Source code in python/scouter/stubs.pyi
CitationWebSearchResultLocationParam ¶
CitationWebSearchResultLocationParam(
cited_text: str,
encrypted_index: str,
title: str,
url: str,
)
Citation from web search result.
Specifies a citation reference from a web search result.
Examples:
>>> citation = CitationWebSearchResultLocationParam(
... cited_text="Example text",
... encrypted_index="abc123",
... title="Search Result",
... url="https://example.com"
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cited_text
|
str
|
The text being cited |
required |
encrypted_index
|
str
|
Encrypted search result index |
required |
title
|
str
|
Title of the search result |
required |
url
|
str
|
URL of the search result |
required |
Source code in python/scouter/stubs.pyi
CitationsConfigParams ¶
Configuration for citations.
Controls whether citations are enabled for document content.
Examples:
CitationsSearchResultLocation ¶
CitationsWebSearchResultLocation ¶
Web search result citation location in response.
Citation from a web search result.
Examples:
CodeExecution ¶
CodeExecutionResult ¶
CommonCrons ¶
ComparisonOperator ¶
Comparison operators for assertion-based evaluations.
Defines the available comparison operators that can be used to evaluate assertions against expected values in LLM evaluation workflows.
Examples:
ApproximatelyEquals
instance-attribute
¶
Approximately equals within a tolerance
ContainsAny
instance-attribute
¶
Contains any of the specified elements
ContainsNone
instance-attribute
¶
Contains none of the specified elements
GreaterThanOrEqual
instance-attribute
¶
Greater than or equal comparison (>=)
HasLengthEqual
instance-attribute
¶
Has specified length equal to
HasLengthGreaterThan
instance-attribute
¶
Has specified length greater than
HasLengthGreaterThanOrEqual
instance-attribute
¶
Has specified length greater than or equal to
HasLengthLessThan
instance-attribute
¶
Has specified length less than
HasLengthLessThanOrEqual
instance-attribute
¶
Has specified length less than or equal to
LessThanOrEqual
instance-attribute
¶
Less than or equal comparison (<=)
MatchesRegex
instance-attribute
¶
Matches a regular expression pattern
NotContains
instance-attribute
¶
Does not contain substring or element (not in)
ComparisonResults ¶
Results from comparing two GenAIEvalResults evaluations
baseline_workflow_count
property
¶
Get the number of workflows in the baseline evaluation
comparison_workflow_count
property
¶
Get the number of workflows in the comparison evaluation
has_missing_tasks
property
¶
Check if there are any missing tasks between evaluations
mean_pass_rate_delta
property
¶
Get the mean change in pass rate across all workflows
missing_tasks
property
¶
Get all tasks present in only one evaluation
task_status_changes
property
¶
Get all tasks where pass/fail status changed
unchanged_workflows
property
¶
Get the count of workflows with no significant change
workflow_comparisons
property
¶
Get all workflow-level comparisons
as_table ¶
Print comparison results as formatted tables to the console.
Displays: - Workflow-level summary table - Task status changes table (if any) - Missing tasks list (if any)
print_missing_tasks ¶
print_status_changes_table ¶
print_summary_stats ¶
print_summary_table ¶
CompletionTokenDetails ¶
Detailed token usage for completion output.
This class provides granular information about tokens used in the completion, including reasoning tokens and audio tokens.
Examples:
>>> # Accessing token details
>>> usage = response.usage
>>> details = usage.completion_tokens_details
>>> print(f"Reasoning tokens: {details.reasoning_tokens}")
>>> print(f"Audio tokens: {details.audio_tokens}")
ComputerUse ¶
Computer use tool configuration.
Enables the model to interact with computer interfaces.
Examples:
>>> computer_use = ComputerUse(
... environment=ComputerUseEnvironment.EnvironmentBrowser,
... excluded_predefined_functions=["take_screenshot"]
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
environment
|
ComputerUseEnvironment
|
Operating environment |
required |
excluded_predefined_functions
|
List[str]
|
Functions to exclude from auto-inclusion |
required |
Source code in python/scouter/stubs.pyi
ComputerUseEnvironment ¶
Environment for computer use capabilities.
Specifies the environment in which the model operates when using computer control features.
Examples:
ConsoleDispatchConfig ¶
Content ¶
Content for predicted outputs, supporting text or structured parts.
This class represents the content of a predicted output, which can be either a simple text string or an array of structured content parts.
Examples:
>>> # Text content
>>> content = Content(text="Predicted response")
>>>
>>> # Structured content
>>> parts = [PredictionContentPart(type="text", text="Part 1")]
>>> content = Content(parts=parts)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
Optional[str]
|
Simple text content (mutually exclusive with parts) |
None
|
parts
|
Optional[List[PredictionContentPart]]
|
Structured content parts (mutually exclusive with text) |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If both text and parts are provided or neither is provided |
Source code in python/scouter/stubs.pyi
ContentEmbedding ¶
Content embedding result.
Contains the embedding vector values.
Examples:
CustomChoice ¶
Specification for a custom tool to call.
This class identifies a custom tool by name for tool calling.
Examples:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the custom tool to call |
required |
Source code in python/scouter/stubs.pyi
CustomDefinition ¶
CustomDefinition(
name: str,
description: Optional[str] = None,
format: Optional[CustomToolFormat] = None,
)
Definition of a custom tool for OpenAI chat completions.
This class defines a custom tool with optional format constraints.
Examples:
>>> # Simple custom tool
>>> custom = CustomDefinition(
... name="analyzer",
... description="Analyze data"
... )
>>>
>>> # With format constraints
>>> format = CustomToolFormat(type="text")
>>> custom = CustomDefinition(
... name="analyzer",
... description="Analyze data",
... format=format
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the custom tool |
required |
description
|
Optional[str]
|
Description of what the tool does |
None
|
format
|
Optional[CustomToolFormat]
|
Output format constraints |
None
|
Source code in python/scouter/stubs.pyi
CustomDriftProfile ¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
CustomMetricDriftConfig
|
The configuration for custom metric drift detection. |
required |
metrics
|
list[CustomMetric]
|
A list of CustomMetric objects representing the metrics to be monitored. |
required |
Example
config = CustomMetricDriftConfig(...) metrics = [CustomMetric("accuracy", 0.95), CustomMetric("f1_score", 0.88)] profile = CustomDriftProfile(config, metrics, "1.0.0")
Source code in python/scouter/stubs.pyi
custom_metrics
property
¶
Return custom metric objects that were used to create the drift profile
from_file
staticmethod
¶
Load drift profile from file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Path to the file |
required |
model_dump ¶
model_dump_json ¶
model_validate
staticmethod
¶
Load drift profile from dictionary
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Dict[str, Any]
|
DriftProfile dictionary |
required |
model_validate_json
staticmethod
¶
Load drift profile from json
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_string
|
str
|
JSON string representation of the drift profile |
required |
save_to_json ¶
Save drift profile to json file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Optional[Path]
|
Optional path to save the drift profile. If None, outputs to |
None
|
Returns:
| Type | Description |
|---|---|
Path
|
Path to the saved json file |
Source code in python/scouter/stubs.pyi
update_config_args ¶
update_config_args(
space: Optional[str] = None,
name: Optional[str] = None,
version: Optional[str] = None,
alert_config: Optional[CustomMetricAlertConfig] = None,
) -> None
Inplace operation that updates config args
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
space
|
Optional[str]
|
Model space |
None
|
name
|
Optional[str]
|
Model name |
None
|
version
|
Optional[str]
|
Model version |
None
|
alert_config
|
Optional[CustomMetricAlertConfig]
|
Custom metric alert configuration |
None
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in python/scouter/stubs.pyi
CustomMetric ¶
CustomMetric(
name: str,
baseline_value: float,
alert_threshold: AlertThreshold,
delta: Optional[float] = None,
)
This class represents a custom metric that uses comparison-based alerting. It applies an alert condition to a single metric value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the metric being monitored. This should be a descriptive identifier for the metric. |
required |
baseline_value
|
float
|
The baseline value of the metric. |
required |
alert_threshold
|
AlertThreshold
|
The condition used to determine when an alert should be triggered. |
required |
delta
|
Optional[float]
|
The delta value used in conjunction with the alert_threshold. If supplied, this value will be added or subtracted from the provided metric value to determine if an alert should be triggered. |
None
|
Source code in python/scouter/stubs.pyi
CustomMetricAlertConfig ¶
CustomMetricAlertConfig(
dispatch_config: Optional[
SlackDispatchConfig | OpsGenieDispatchConfig
] = None,
schedule: Optional[str | CommonCrons] = None,
)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dispatch_config
|
Optional[SlackDispatchConfig | OpsGenieDispatchConfig]
|
Alert dispatch config. Defaults to console |
None
|
schedule
|
Optional[str | CommonCrons]
|
Schedule to run monitor. Defaults to daily at midnight |
None
|
Source code in python/scouter/stubs.pyi
alert_conditions
property
writable
¶
Return the alert_condition that were set during metric definition
CustomMetricDriftConfig ¶
CustomMetricDriftConfig(
space: str = "__missing__",
name: str = "__missing__",
version: str = "0.1.0",
sample_size: int = 25,
alert_config: CustomMetricAlertConfig = CustomMetricAlertConfig(),
)
space:
Model space
name:
Model name
version:
Model version. Defaults to 0.1.0
sample_size:
Sample size
alert_config:
Custom metric alert configuration
Source code in python/scouter/stubs.pyi
load_from_json_file
staticmethod
¶
Load config from json file Args: path: Path to json file to load config from.
model_dump_json ¶
update_config_args ¶
update_config_args(
space: Optional[str] = None,
name: Optional[str] = None,
version: Optional[str] = None,
alert_config: Optional[CustomMetricAlertConfig] = None,
) -> None
Inplace operation that updates config args Args: space: Model space name: Model name version: Model version alert_config: Custom metric alert configuration
Source code in python/scouter/stubs.pyi
CustomMetricRecord ¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uid
|
str
|
Unique identifier for the metric record. Must correspond to an existing entity in Scouter. |
required |
metric
|
str
|
Metric name |
required |
value
|
float
|
Metric value |
required |
Source code in python/scouter/stubs.pyi
model_dump_json ¶
CustomTool ¶
Custom tool for OpenAI chat completions.
This class wraps a custom tool definition to create a callable tool for the model.
Examples:
>>> custom = CustomDefinition(name="analyzer")
>>> tool = CustomTool(custom=custom, type="custom")
>>> tool.type
'custom'
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
custom
|
CustomDefinition
|
The custom tool definition |
required |
type
|
str
|
Tool type (typically "custom") |
required |
Source code in python/scouter/stubs.pyi
CustomToolChoice ¶
Tool choice configuration for a custom tool.
This class specifies that the model should call a specific custom tool.
Examples:
>>> custom = CustomChoice(name="custom_tool")
>>> tool_choice = CustomToolChoice(custom=custom)
>>> tool_choice.type
'custom'
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
custom
|
CustomChoice
|
The custom tool to call |
required |
Source code in python/scouter/stubs.pyi
CustomToolFormat ¶
Format specification for custom tool outputs.
This class supports either free-form text or grammar-constrained output formats for custom tools.
Examples:
>>> # Text format
>>> format = CustomToolFormat(type="text")
>>>
>>> # Grammar format
>>> grammar = Grammar(definition="...", syntax="lark")
>>> format = CustomToolFormat(grammar=grammar)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type
|
Optional[str]
|
Format type for text output |
None
|
grammar
|
Optional[Grammar]
|
Grammar definition for structured output |
None
|
Source code in python/scouter/stubs.pyi
DataProfile ¶
Data profile of features
features
property
¶
Returns dictionary of features and their data profiles
model_dump_json ¶
model_validate_json
staticmethod
¶
Load Data profile from json
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_string
|
str
|
JSON string representation of the data profile |
required |
save_to_json ¶
Save data profile to json file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Optional[Path]
|
Optional path to save the data profile. If None, outputs to |
None
|
Returns:
| Type | Description |
|---|---|
Path
|
Path to the saved data profile |
Source code in python/scouter/stubs.pyi
DataProfiler ¶
Source code in python/scouter/stubs.pyi
TraceMetricsRequest ¶
TraceMetricsRequest(
service_name: str,
start_time: datetime,
end_time: datetime,
bucket_interval: str,
)
Request to get trace metrics from the Scouter server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
service_name
|
str
|
The name of the service to query metrics for. |
required |
start_time
|
datetime
|
The start time for the metrics query. |
required |
end_time
|
datetime
|
The end time for the metrics query. |
required |
bucket_interval
|
str
|
Optional interval for aggregating metrics (e.g., "1m", "5m"). |
required |
Source code in python/scouter/stubs.pyi
create_data_profile ¶
create_data_profile(
data: Any,
data_type: Optional[ScouterDataType] = None,
bin_size: int = 20,
compute_correlations: bool = False,
) -> DataProfile
Create a data profile from data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Any
|
Data to create a data profile from. Data can be a numpy array, a polars dataframe or pandas dataframe. Data is expected to not contain any missing values, NaNs or infinities These types are incompatible with computing quantiles, histograms, and correlations. These values must be removed or imputed. |
required |
data_type
|
Optional[ScouterDataType]
|
Optional data type. Inferred from data if not provided. |
None
|
bin_size
|
int
|
Optional bin size for histograms. Defaults to 20 bins. |
20
|
compute_correlations
|
bool
|
Whether to compute correlations or not. |
False
|
Returns:
| Type | Description |
|---|---|
DataProfile
|
DataProfile |
Source code in python/scouter/stubs.pyi
DataStoreSpec ¶
Specification for a Vertex AI Search datastore.
Defines a datastore to search with optional filtering.
Examples:
>>> spec = DataStoreSpec(
... data_store="projects/my-project/locations/us/collections/default/dataStores/my-store",
... filter="category:electronics"
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data_store
|
str
|
Full resource name of the datastore |
required |
filter
|
Optional[str]
|
Optional filter expression |
None
|
Source code in python/scouter/stubs.pyi
Distinct ¶
Doane ¶
DocumentBlockParam ¶
DocumentBlockParam(
source: Any,
cache_control: Optional[CacheControl] = None,
title: Optional[str] = None,
context: Optional[str] = None,
citations: Optional[CitationsConfigParams] = None,
)
Document content block parameter.
Document content with source, optional cache control, title, context, and citations.
Examples:
>>> # PDF document
>>> source = Base64PDFSource(data="...")
>>> block = DocumentBlockParam(
... source=source,
... title="Document Title",
... context="Additional context",
... citations=CitationsConfigParams()
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
Any
|
Document source (Base64PDFSource, UrlPDFSource, or PlainTextSource) |
required |
cache_control
|
Optional[CacheControl]
|
Cache control settings |
None
|
title
|
Optional[str]
|
Document title |
None
|
context
|
Optional[str]
|
Additional context about the document |
None
|
citations
|
Optional[CitationsConfigParams]
|
Citations configuration |
None
|
Source code in python/scouter/stubs.pyi
DriftAlertPaginationRequest ¶
DriftAlertPaginationRequest(
uid: str,
active: bool = False,
limit: Optional[int] = None,
cursor_created_at: Optional[datetime] = None,
cursor_id: Optional[int] = None,
direction: Optional[
Literal["next", "previous"]
] = "previous",
start_datetime: Optional[datetime] = None,
end_datetime: Optional[datetime] = None,
)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uid
|
str
|
Unique identifier tied to drift profile |
required |
active
|
bool
|
Whether to get active alerts only |
False
|
limit
|
Optional[int]
|
Limit for number of alerts to return |
None
|
cursor_created_at
|
Optional[datetime]
|
Pagination cursor: created at timestamp |
None
|
cursor_id
|
Optional[int]
|
Pagination cursor: alert ID |
None
|
direction
|
Optional[Literal['next', 'previous']]
|
Pagination direction: "next" or "previous" |
'previous'
|
start_datetime
|
Optional[datetime]
|
Optional start datetime for alert filtering |
None
|
end_datetime
|
Optional[datetime]
|
Optional end datetime for alert filtering |
None
|
Source code in python/scouter/stubs.pyi
DriftRequest ¶
DriftRequest(
uid: str,
space: str,
time_interval: TimeInterval,
max_data_points: int,
start_datetime: Optional[datetime] = None,
end_datetime: Optional[datetime] = None,
)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uid
|
str
|
Unique identifier tied to drift profile |
required |
space
|
str
|
Space associated with drift profile |
required |
time_interval
|
TimeInterval
|
Time window for drift request |
required |
max_data_points
|
int
|
Maximum data points to return |
required |
start_datetime
|
Optional[datetime]
|
Optional start datetime for drift request |
None
|
end_datetime
|
Optional[datetime]
|
Optional end datetime for drift request |
None
|
Source code in python/scouter/stubs.pyi
Drifter ¶
Source code in python/scouter/stubs.pyi
compute_drift ¶
compute_drift(
data: Any,
drift_profile: SpcDriftProfile,
data_type: Optional[ScouterDataType] = None,
) -> SpcDriftMap
compute_drift(
data: Any,
drift_profile: Union[
SpcDriftProfile, PsiDriftProfile, GenAIEvalProfile
],
data_type: Optional[ScouterDataType] = None,
) -> Union[SpcDriftMap, PsiDriftMap, GenAIEvalResultSet]
Create a drift map from data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Any
|
Data to create a data profile from. Data can be a numpy array, a polars dataframe or a pandas dataframe. |
required |
drift_profile
|
Union[SpcDriftProfile, PsiDriftProfile, GenAIEvalProfile]
|
Drift profile to use to compute drift map |
required |
data_type
|
Optional[ScouterDataType]
|
Optional data type. Inferred from data if not provided. |
None
|
Returns:
| Type | Description |
|---|---|
Union[SpcDriftMap, PsiDriftMap, GenAIEvalResultSet]
|
SpcDriftMap, PsiDriftMap or GenAIEvalResultSet |
Source code in python/scouter/stubs.pyi
create_drift_profile ¶
create_drift_profile(
data: Any,
config: SpcDriftConfig,
data_type: Optional[ScouterDataType] = None,
) -> SpcDriftProfile
create_drift_profile(
data: Any,
config: Optional[
Union[
SpcDriftConfig,
PsiDriftConfig,
CustomMetricDriftConfig,
]
] = None,
data_type: Optional[ScouterDataType] = None,
) -> Union[
SpcDriftProfile, PsiDriftProfile, CustomDriftProfile
]
Create a drift profile from data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Any
|
Data to create a data profile from. Data can be a numpy array, a polars dataframe, pandas dataframe or a list of CustomMetric if creating a custom metric profile. Data is expected to not contain any missing values, NaNs or infinities |
required |
config
|
Optional[Union[SpcDriftConfig, PsiDriftConfig, CustomMetricDriftConfig]]
|
Drift config that will be used for monitoring |
None
|
data_type
|
Optional[ScouterDataType]
|
Optional data type. Inferred from data if not provided. |
None
|
Returns:
| Type | Description |
|---|---|
Union[SpcDriftProfile, PsiDriftProfile, CustomDriftProfile]
|
SpcDriftProfile, PsiDriftProfile or CustomDriftProfile |
Source code in python/scouter/stubs.pyi
create_genai_drift_profile ¶
create_genai_drift_profile(
config: GenAIEvalConfig,
tasks: Sequence[LLMJudgeTask | AssertionTask],
) -> GenAIEvalProfile
Initialize a GenAIEvalProfile for LLM evaluation and drift detection.
LLM evaluations are run asynchronously on the scouter server.
Overview
GenAI evaluations are defined using assertion tasks and LLM judge tasks. Assertion tasks evaluate specific metrics based on model responses, and do not require the use of an LLM judge or extra call. It is recommended to use assertion tasks whenever possible to reduce cost and latency. LLM judge tasks leverage an additional LLM call to evaluate model responses based on more complex criteria. Together, these tasks provide a flexible framework for monitoring LLM performance and detecting drift over time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
GenAIEvalConfig
|
The configuration for the GenAI drift profile containing space, name, version, and alert settings. |
required |
tasks
|
List[LLMJudgeTask | AssertionTask]
|
List of evaluation tasks to include in the profile. Can contain both AssertionTask and LLMJudgeTask instances. At least one task (assertion or LLM judge) is required. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
GenAIEvalProfile |
GenAIEvalProfile
|
Configured profile ready for GenAI drift monitoring. |
Raises:
| Type | Description |
|---|---|
ProfileError
|
If workflow validation fails, metrics are empty when no workflow is provided, or if workflow tasks don't match metric names. |
Examples:
Basic usage with metrics only:
>>> config = GenAIEvalConfig("my_space", "my_model", "1.0")
>>> tasks = [
... LLMJudgeTask(
... id="response_relevance",
... prompt=relevance_prompt,
... expected_value=7,
... field_path="score",
... operator=ComparisonOperator.GreaterThanOrEqual,
... description="Ensure relevance score >= 7"
... )
... ]
>>> profile = Drifter().create_genai_drift_profile(config, tasks)
Source code in python/scouter/stubs.pyi
DynamicRetrievalConfig ¶
DynamicRetrievalConfig(
mode: Optional[DynamicRetrievalMode] = None,
dynamic_threshold: Optional[float] = None,
)
Configuration for dynamic retrieval behavior.
Controls when and how retrieval is triggered.
Examples:
>>> config = DynamicRetrievalConfig(
... mode=DynamicRetrievalMode.ModeDynamic,
... dynamic_threshold=0.5
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
Optional[DynamicRetrievalMode]
|
Retrieval mode |
None
|
dynamic_threshold
|
Optional[float]
|
Threshold for dynamic retrieval |
None
|
Source code in python/scouter/stubs.pyi
DynamicRetrievalMode ¶
Mode for dynamic retrieval behavior.
Controls when the model triggers retrieval operations.
Examples:
ElasticSearchParams ¶
Parameters for Elasticsearch API.
Configures Elasticsearch index and search template.
Examples:
>>> params = ElasticSearchParams(
... index="my-index",
... search_template="my-template",
... num_hits=10
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
str
|
Elasticsearch index name |
required |
search_template
|
str
|
Search template name |
required |
num_hits
|
Optional[int]
|
Number of hits to request |
None
|
Source code in python/scouter/stubs.pyi
Embedder ¶
Embedder(
provider: Provider | str,
config: Optional[
OpenAIEmbeddingConfig | GeminiEmbeddingConfig
] = None,
)
Class for creating embeddings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider
|
Provider | str
|
The provider to use for the embedder. This can be a Provider enum or a string representing the provider. |
required |
config
|
Optional[OpenAIEmbeddingConfig | GeminiEmbeddingConfig]
|
The configuration to use for the embedder. This can be a Pydantic BaseModel class representing the configuration for the provider. If no config is provided, defaults to OpenAI provider configuration. |
None
|
Source code in python/scouter/stubs.pyi
embed ¶
embed(
input: str | List[str] | PredictRequest,
) -> (
OpenAIEmbeddingResponse
| GeminiEmbeddingResponse
| PredictResponse
)
Create embeddings for input.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input
|
str | List[str] | PredictRequest
|
The input to embed. Type depends on provider: - OpenAI/Gemini: str | List[str] - Vertex: PredictRequest |
required |
Returns:
| Type | Description |
|---|---|
OpenAIEmbeddingResponse | GeminiEmbeddingResponse | PredictResponse
|
Provider-specific response type. |
OpenAIEmbeddingResponse | GeminiEmbeddingResponse | PredictResponse
|
OpenAIEmbeddingResponse for OpenAI, |
OpenAIEmbeddingResponse | GeminiEmbeddingResponse | PredictResponse
|
GeminiEmbeddingResponse for Gemini, |
OpenAIEmbeddingResponse | GeminiEmbeddingResponse | PredictResponse
|
PredictResponse for Vertex. |
Examples:
## OpenAI
embedder = Embedder(Provider.OpenAI)
response = embedder.embed(input="Test input")
## Gemini
embedder = Embedder(Provider.Gemini, config=GeminiEmbeddingConfig(model="gemini-embedding-001"))
response = embedder.embed(input="Test input")
## Vertex
from potato_head.google import PredictRequest
embedder = Embedder(Provider.Vertex)
response = embedder.embed(input=PredictRequest(text="Test input"))
Source code in python/scouter/stubs.pyi
EmbeddingObject ¶
EmbeddingTaskType ¶
Task type for embedding generation.
Specifies the intended use case for embeddings, which may affect how they are computed.
Examples:
Classification
class-attribute
instance-attribute
¶
Classification tasks
RetrievalDocument
class-attribute
instance-attribute
¶
Document for retrieval tasks
RetrievalQuery
class-attribute
instance-attribute
¶
Query for retrieval tasks
SemanticSimilarity
class-attribute
instance-attribute
¶
Semantic similarity comparison
TaskTypeUnspecified
class-attribute
instance-attribute
¶
Unspecified task type
EnterpriseWebSearch ¶
EnterpriseWebSearch(
exclude_domains: Optional[List[str]] = None,
blocking_confidence: Optional[
PhishBlockThreshold
] = None,
)
Enterprise web search tool configuration.
Configures enterprise-grade web search with compliance features.
Examples:
>>> search = EnterpriseWebSearch(
... exclude_domains=["example.com"],
... blocking_confidence=PhishBlockThreshold.BlockHighAndAbove
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
exclude_domains
|
Optional[List[str]]
|
Domains to exclude from results |
None
|
blocking_confidence
|
Optional[PhishBlockThreshold]
|
Phishing blocking threshold |
None
|
Source code in python/scouter/stubs.pyi
EqualWidthBinning ¶
This strategy divides the range of values into bins of equal width. Several binning rules are supported to automatically determine the appropriate number of bins based on the input distribution.
Note
Detailed explanations of each method are provided in their respective constructors or documentation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
method
|
EqualWidthMethods
|
Specifies how the number of bins should be determined. Options include: - Manual(num_bins): Explicitly sets the number of bins. - SquareRoot, Sturges, Rice, Doane, Scott, TerrellScott, FreedmanDiaconis: Rules that infer bin counts from data. Defaults to Doane(). |
Doane()
|
Source code in python/scouter/stubs.pyi
method
property
writable
¶
Specifies how the number of bins should be determined.
EvaluationConfig ¶
EvaluationConfig(
embedder: Optional[Embedder] = None,
embedding_targets: Optional[List[str]] = None,
compute_similarity: bool = False,
compute_histograms: bool = False,
)
Configuration options for LLM evaluation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
embedder
|
Optional[Embedder]
|
Optional Embedder instance to use for generating embeddings for similarity-based metrics. If not provided, no embeddings will be generated. |
None
|
embedding_targets
|
Optional[List[str]]
|
Optional list of context keys to generate embeddings for. If not provided, embeddings will be generated for all string fields in the record context. |
None
|
compute_similarity
|
bool
|
Whether to compute similarity between embeddings. Default is False. |
False
|
compute_histograms
|
bool
|
Whether to compute histograms for all calculated features (metrics, embeddings, similarities). Default is False. |
False
|
Source code in python/scouter/stubs.pyi
EvaluationTaskType ¶
Types of evaluation tasks for LLM assessments.
EventDetails ¶
ExecutableCode ¶
ExternalApi ¶
ExternalApi(
api_spec: ApiSpecType,
endpoint: str,
auth_config: Optional[AuthConfig] = None,
simple_search_params: Optional[
SimpleSearchParams
] = None,
elastic_search_params: Optional[
ElasticSearchParams
] = None,
)
External API retrieval configuration.
Configures retrieval from external APIs.
Examples:
>>> api = ExternalApi(
... api_spec=ApiSpecType.ElasticSearch,
... endpoint="https://my-es-cluster.com",
... auth_config=AuthConfig(...),
... elastic_search_params=ElasticSearchParams(...)
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_spec
|
ApiSpecType
|
API specification type |
required |
endpoint
|
str
|
API endpoint URL |
required |
auth_config
|
Optional[AuthConfig]
|
Authentication configuration |
None
|
simple_search_params
|
Optional[SimpleSearchParams]
|
Simple search parameters |
None
|
elastic_search_params
|
Optional[ElasticSearchParams]
|
Elasticsearch parameters |
None
|
Source code in python/scouter/stubs.pyi
params
property
¶
The API parameters.
FeatureDrift ¶
FeatureProfile ¶
Features ¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
features
|
List[QueueFeature] | Dict[str, Union[int, float, str]]
|
List of features or a dictionary of key-value pairs. If a list, each item must be an instance of Feature. If a dictionary, each key is the feature name and each value is the feature value. Supported types for values are int, float, and string. |
required |
Example
# Passing a list of features
features = Features(
features=[
Feature.int("feature_1", 1),
Feature.float("feature_2", 2.0),
Feature.string("feature_3", "value"),
]
)
# Passing a dictionary (pydantic model) of features
class MyFeatures(BaseModel):
feature1: int
feature2: float
feature3: str
my_features = MyFeatures(
feature1=1,
feature2=2.0,
feature3="value",
)
features = Features(my_features.model_dump())
Source code in python/scouter/stubs.pyi
File ¶
File(
file_data: Optional[str] = None,
file_id: Optional[str] = None,
filename: Optional[str] = None,
)
File reference for OpenAI chat completion messages.
This class represents a file that can be included in a message, either by providing file data directly or referencing a file by ID.
Examples:
>>> # File by ID
>>> file = File(file_id="file-abc123", filename="document.pdf")
>>>
>>> # File with data
>>> file = File(
... file_data="base64_encoded_data",
... filename="document.pdf"
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_data
|
Optional[str]
|
Base64 encoded file data |
None
|
file_id
|
Optional[str]
|
OpenAI file ID |
None
|
filename
|
Optional[str]
|
File name |
None
|
Source code in python/scouter/stubs.pyi
FileContentPart ¶
FileContentPart(
file_data: Optional[str] = None,
file_id: Optional[str] = None,
filename: Optional[str] = None,
)
File content part for OpenAI chat messages.
This class represents a file as part of a message's content.
Examples:
>>> file_part = FileContentPart(
... file_id="file-abc123",
... filename="document.pdf"
... )
>>> file_part.type
'file'
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_data
|
Optional[str]
|
Base64 encoded file data |
None
|
file_id
|
Optional[str]
|
OpenAI file ID |
None
|
filename
|
Optional[str]
|
File name |
None
|
Source code in python/scouter/stubs.pyi
FileData ¶
URI-based media data reference.
References media stored in Google Cloud Storage or other URIs.
Examples:
>>> file_data = FileData(
... mime_type="image/png",
... file_uri="gs://my-bucket/image.png",
... display_name="Example Image"
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mime_type
|
str
|
IANA MIME type |
required |
file_uri
|
str
|
URI to the file (e.g., gs:// URL) |
required |
display_name
|
Optional[str]
|
Optional display name |
None
|
Source code in python/scouter/stubs.pyi
FileSearch ¶
File search tool configuration.
Enables searching in file stores.
Examples:
>>> file_search = FileSearch(
... file_search_store_names=["my-store"],
... metadata_filter="category='docs'",
... top_k=5
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_search_store_names
|
List[str]
|
File store names to search |
required |
metadata_filter
|
str
|
Metadata filter expression |
required |
top_k
|
int
|
Number of top results |
required |
Source code in python/scouter/stubs.pyi
Filter ¶
Filter(
metadata_filter: Optional[str] = None,
vector_distance_threshold: Optional[float] = None,
vector_similarity_threshold: Optional[float] = None,
)
Filtering configuration for RAG retrieval.
Configures metadata and vector-based filtering.
Examples:
>>> # Metadata filtering
>>> filter = Filter(
... metadata_filter="category = 'technical'",
... vector_similarity_threshold=0.7
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metadata_filter
|
Optional[str]
|
Metadata filter expression |
None
|
vector_distance_threshold
|
Optional[float]
|
Maximum vector distance |
None
|
vector_similarity_threshold
|
Optional[float]
|
Minimum vector similarity |
None
|
Source code in python/scouter/stubs.pyi
FinishReason ¶
Reason why generation stopped.
Indicates why the model stopped generating tokens.
Examples:
Blocklist
class-attribute
instance-attribute
¶
Stopped due to blocklist match
FinishReasonUnspecified
class-attribute
instance-attribute
¶
Unspecified reason
ImageOther
class-attribute
instance-attribute
¶
Image generation stopped for other reasons
ImageProhibitedContent
class-attribute
instance-attribute
¶
Generated image contains prohibited content
ImageRecitation
class-attribute
instance-attribute
¶
Generated image may be recitation
ImageSafety
class-attribute
instance-attribute
¶
Generated image violates safety policies
MalformedFunctionCall
class-attribute
instance-attribute
¶
Stopped due to malformed function call
MaxTokens
class-attribute
instance-attribute
¶
Maximum token limit reached
NoImage
class-attribute
instance-attribute
¶
Expected image but none generated
ProhibitedContent
class-attribute
instance-attribute
¶
Stopped due to prohibited content
Recitation
class-attribute
instance-attribute
¶
Stopped due to potential recitation
Spii
class-attribute
instance-attribute
¶
Stopped due to sensitive personally identifiable information
Stop
class-attribute
instance-attribute
¶
Natural stopping point or stop sequence reached
UnexpectedToolCall
class-attribute
instance-attribute
¶
Unexpected tool call generated
FreedmanDiaconis ¶
Function ¶
FunctionCall ¶
FunctionCall(
name: str,
id: Optional[str] = None,
args: Optional[Dict[str, Any]] = None,
will_continue: Optional[bool] = None,
partial_args: Optional[List[PartialArgs]] = None,
)
Function call request from the model.
Represents a function that the model wants to call, including the function name and arguments.
Examples:
>>> call = FunctionCall(
... name="get_weather",
... args={"location": "San Francisco", "units": "celsius"},
... id="call_123"
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Function name to call |
required |
id
|
Optional[str]
|
Unique call identifier |
None
|
args
|
Optional[Dict[str, Any]]
|
Function arguments as dictionary |
None
|
will_continue
|
Optional[bool]
|
Whether this is the final part of the call |
None
|
partial_args
|
Optional[List[PartialArgs]]
|
Incrementally streamed arguments |
None
|
Source code in python/scouter/stubs.pyi
FunctionCallingConfig ¶
FunctionCallingConfig(
mode: Optional[Mode] = None,
allowed_function_names: Optional[List[str]] = None,
)
Configuration for function calling behavior.
Controls how the model handles function calls, including whether functions are required and which functions are allowed.
Examples:
>>> # Require specific functions
>>> config = FunctionCallingConfig(
... mode=Mode.Any,
... allowed_function_names=["get_weather", "search_web"]
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
Optional[Mode]
|
Function calling mode |
None
|
allowed_function_names
|
Optional[List[str]]
|
List of allowed function names (for ANY mode) |
None
|
Source code in python/scouter/stubs.pyi
FunctionChoice ¶
Specification for a specific function to call.
This class identifies a specific function by name for tool calling.
Examples:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the function to call |
required |
Source code in python/scouter/stubs.pyi
FunctionDeclaration ¶
Function declaration for tool use.
Defines a function that the model can call, including its name, description, parameters, and return type.
Examples:
>>> func = FunctionDeclaration(
... name="get_weather",
... description="Get current weather for a location",
... parameters=Schema(
... type=SchemaType.Object,
... properties={
... "location": Schema(type=SchemaType.String),
... "units": Schema(
... type=SchemaType.String,
... enum_=["celsius", "fahrenheit"]
... )
... },
... required=["location"]
... )
... )
parameters_json_schema
property
¶
Parameters as raw JSON schema.
FunctionDefinition ¶
FunctionDefinition(
name: str,
description: Optional[str] = None,
parameters: Optional[Any] = None,
strict: Optional[bool] = None,
)
Definition of a function tool for OpenAI chat completions.
This class defines a function that can be called by the model, including its name, description, parameters schema, and strict mode setting.
Examples:
>>> # Simple function
>>> func = FunctionDefinition(
... name="get_weather",
... description="Get weather for a location"
... )
>>>
>>> # With parameters
>>> params = {
... "type": "object",
... "properties": {
... "location": {"type": "string"}
... },
... "required": ["location"]
... }
>>> func = FunctionDefinition(
... name="get_weather",
... description="Get weather",
... parameters=params,
... strict=True
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the function |
required |
description
|
Optional[str]
|
Description of what the function does |
None
|
parameters
|
Optional[Any]
|
JSON schema for function parameters |
None
|
strict
|
Optional[bool]
|
Whether to use strict schema validation |
None
|
Source code in python/scouter/stubs.pyi
FunctionResponse ¶
FunctionTool ¶
Function tool for OpenAI chat completions.
This class wraps a function definition to create a callable tool for the model.
Examples:
>>> func = FunctionDefinition(name="get_weather")
>>> tool = FunctionTool(function=func, type="function")
>>> tool.type
'function'
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
function
|
FunctionDefinition
|
The function definition |
required |
type
|
str
|
Tool type (typically "function") |
required |
Source code in python/scouter/stubs.pyi
FunctionToolChoice ¶
Tool choice configuration for a specific function.
This class specifies that the model should call a specific function tool.
Examples:
>>> function = FunctionChoice(name="get_weather")
>>> tool_choice = FunctionToolChoice(function=function)
>>> tool_choice.type
'function'
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
function
|
FunctionChoice
|
The function to call |
required |
Source code in python/scouter/stubs.pyi
FunctionType ¶
Enumeration of function types.
GeminiContent ¶
GeminiContent(
parts: Union[
str,
Part,
List[
Union[
str,
Part,
Blob,
FileData,
FunctionCall,
FunctionResponse,
ExecutableCode,
CodeExecutionResult,
]
],
],
role: Optional[str] = None,
)
Multi-part message content.
Represents a complete message from a user or model, consisting of one or more parts. This is the fundamental message structure for Gemini API.
Examples:
>>> # Simple text message
>>> content = GeminiContent(
... role="user",
... parts="What's the weather in San Francisco?"
... )
>>> # Multi-part message with image
>>> content = GeminiContent(
... role="user",
... parts=[
... "What's in this image?",
... Blob(mime_type="image/png", data=image_data)
... ]
... )
>>> # Function call response
>>> content = GeminiContent(
... role="model",
... parts=[
... FunctionCall(
... name="get_weather",
... args={"location": "San Francisco"}
... )
... ]
... )
>>> # Function result
>>> content = GeminiContent(
... role="function",
... parts=[
... FunctionResponse(
... name="get_weather",
... response={"output": {"temperature": 72}}
... )
... ]
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ExecutableCode,
|
CodeExecutionResult]]]
|
Content from typing import Any, Dict, List, Optional, Union from the message |
required |
role
|
Optional[str]
|
Role of the message sender (e.g., "user", "model", "function") |
None
|
Source code in python/scouter/stubs.pyi
bind ¶
bind(
name: Optional[str] = None,
value: Optional[str | int | float | bool | list] = None,
) -> GeminiContent
Bind variables to the message content. Args: name (Optional[str]): The variable name to bind. value (Optional[Union[str, int, float, bool, list]]): The variable value to bind. Returns: GeminiContent: New content with variables bound.
Source code in python/scouter/stubs.pyi
bind_mut ¶
bind_mut(
name: Optional[str] = None,
value: Optional[str | int | float | bool | list] = None,
) -> None
Bind variables to the message content in place. Args: name (Optional[str]): The variable name to bind. value (Optional[Union[str, int, float, bool, list]]): The variable value to bind. Returns: None
Source code in python/scouter/stubs.pyi
model_dump ¶
text ¶
Get the text content of the first part, if available. Returns an empty string if the first part is not text. This is meant for convenience when working with simple text messages.
GeminiEmbeddingConfig ¶
GeminiEmbeddingConfig(
model: Optional[str] = None,
output_dimensionality: Optional[int] = None,
task_type: Optional[EmbeddingTaskType] = None,
)
Configuration for Gemini embeddings.
Configures embedding generation including dimensionality and task type.
Examples:
>>> config = GeminiEmbeddingConfig(
... model="text-embedding-004",
... output_dimensionality=768,
... task_type=EmbeddingTaskType.RetrievalDocument
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Optional[str]
|
Model name |
None
|
output_dimensionality
|
Optional[int]
|
Output embedding dimensionality |
None
|
task_type
|
Optional[EmbeddingTaskType]
|
Task type for embeddings |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If neither model nor task_type is provided |
Source code in python/scouter/stubs.pyi
GeminiEmbeddingResponse ¶
GeminiSettings ¶
GeminiSettings(
labels: Optional[Dict[str, str]] = None,
tool_config: Optional[ToolConfig] = None,
generation_config: Optional[GenerationConfig] = None,
safety_settings: Optional[List[SafetySetting]] = None,
model_armor_config: Optional[ModelArmorConfig] = None,
extra_body: Optional[Any] = None,
cached_content: Optional[str] = None,
tools: Optional[List[GeminiTool]] = None,
)
Settings for Gemini/Google API requests.
Comprehensive configuration for all aspects of model behavior including generation, safety, tools, and more.
Examples:
>>> settings = GeminiSettings(
... generation_config=GenerationConfig(
... temperature=0.7,
... max_output_tokens=1024
... ),
... safety_settings=[
... SafetySetting(
... category=HarmCategory.HarmCategoryHateSpeech,
... threshold=HarmBlockThreshold.BlockMediumAndAbove
... )
... ],
... tool_config=ToolConfig(
... function_calling_config=FunctionCallingConfig(mode=Mode.Auto)
... )
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
labels
|
Optional[Dict[str, str]]
|
Metadata labels |
None
|
tool_config
|
Optional[ToolConfig]
|
Tool configuration |
None
|
generation_config
|
Optional[GenerationConfig]
|
Generation configuration |
None
|
safety_settings
|
Optional[List[SafetySetting]]
|
Safety filter settings |
None
|
model_armor_config
|
Optional[ModelArmorConfig]
|
Model Armor configuration |
None
|
extra_body
|
Optional[Any]
|
Additional request parameters |
None
|
cached_content
|
Optional[str]
|
Cached content resource name |
None
|
tools
|
Optional[List[Tool]]
|
Tools available to the model |
None
|
Source code in python/scouter/stubs.pyi
GeminiThinkingConfig ¶
GeminiThinkingConfig(
include_thoughts: Optional[bool] = None,
thinking_budget: Optional[int] = None,
thinking_level: Optional[ThinkingLevel] = None,
)
Configuration for model thinking/reasoning features.
Controls the model's internal reasoning process, including whether to include thoughts in the response and the computational budget.
Examples:
>>> # Enable high-level thinking with thoughts included
>>> config = ThinkingConfig(
... include_thoughts=True,
... thinking_level=ThinkingLevel.High
... )
>>> # Limit thinking budget
>>> config = ThinkingConfig(
... include_thoughts=False,
... thinking_budget=1000
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include_thoughts
|
Optional[bool]
|
Whether to include reasoning steps in response |
None
|
thinking_budget
|
Optional[int]
|
Token budget for thinking process |
None
|
thinking_level
|
Optional[ThinkingLevel]
|
Depth of reasoning to apply |
None
|
Source code in python/scouter/stubs.pyi
GeminiTool ¶
GeminiTool(
function_declarations: Optional[
List[FunctionDeclaration]
] = None,
retrieval: Optional[Retrieval] = None,
google_search_retrieval: Optional[
GoogleSearchRetrieval
] = None,
code_execution: Optional[CodeExecution] = None,
google_search: Optional[GoogleSearchNum] = None,
google_maps: Optional[GoogleMaps] = None,
enterprise_web_search: Optional[
EnterpriseWebSearch
] = None,
parallel_ai_search: Optional[ParallelAiSearch] = None,
computer_use: Optional[ComputerUse] = None,
url_context: Optional[UrlContext] = None,
file_search: Optional[FileSearch] = None,
)
Tool definition for model use.
Defines tools/functions that the model can use during generation. Tools enable the model to perform actions or retrieve information.
Examples:
>>> # Function tool
>>> tool = Tool(
... function_declarations=[
... FunctionDeclaration(
... name="get_weather",
... description="Get weather for a location",
... parameters=Schema(...)
... )
... ]
... )
>>> # Google Search tool
>>> tool = Tool(
... google_search=GoogleSearchNum(
... vertex_search=VertexGoogleSearch()
... )
... )
>>> # Multiple tools
>>> tool = Tool(
... function_declarations=[...],
... google_search=GoogleSearchNum(...),
... code_execution=CodeExecution()
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
function_declarations
|
Optional[List[FunctionDeclaration]]
|
Function declarations |
None
|
retrieval
|
Optional[Retrieval]
|
Retrieval tool configuration |
None
|
google_search_retrieval
|
Optional[GoogleSearchRetrieval]
|
Google Search retrieval configuration |
None
|
code_execution
|
Optional[CodeExecution]
|
Code execution tool |
None
|
google_search
|
Optional[GoogleSearchNum]
|
Google Search tool |
None
|
google_maps
|
Optional[GoogleMaps]
|
Google Maps tool |
None
|
enterprise_web_search
|
Optional[EnterpriseWebSearch]
|
Enterprise web search tool |
None
|
parallel_ai_search
|
Optional[ParallelAiSearch]
|
Parallel.ai search tool |
None
|
computer_use
|
Optional[ComputerUse]
|
Computer use tool |
None
|
url_context
|
Optional[UrlContext]
|
URL context tool |
None
|
file_search
|
Optional[FileSearch]
|
File search tool |
None
|
Source code in python/scouter/stubs.pyi
GenAIAlertConfig ¶
GenAIAlertConfig(
dispatch_config: Optional[
SlackDispatchConfig | OpsGenieDispatchConfig
] = None,
schedule: Optional[str | CommonCrons] = None,
alert_condition: Optional[AlertCondition] = None,
)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dispatch_config
|
Optional[SlackDispatchConfig | OpsGenieDispatchConfig]
|
Alert dispatch config. Defaults to console |
None
|
schedule
|
Optional[str | CommonCrons]
|
Schedule to run monitor. Defaults to daily at midnight |
None
|
alert_condition
|
Optional[AlertCondition]
|
Alert condition for a GenAI drift profile |
None
|
Source code in python/scouter/stubs.pyi
GenAIEvalConfig ¶
GenAIEvalConfig(
space: str = "__missing__",
name: str = "__missing__",
version: str = "0.1.0",
sample_ratio: float = 1.0,
alert_config: GenAIAlertConfig = GenAIAlertConfig(),
)
space:
Space to associate with the config
name:
Name to associate with the config
version:
Version to associate with the config. Defaults to 0.1.0
sample_ratio:
Sample rate percentage for data collection. Must be between 0.0 and 1.0.
Defaults to 1.0 (100%).
alert_config:
Custom metric alert configuration
Source code in python/scouter/stubs.pyi
load_from_json_file
staticmethod
¶
Load config from json file Args: path: Path to json file to load config from.
model_dump_json ¶
update_config_args ¶
update_config_args(
space: Optional[str] = None,
name: Optional[str] = None,
version: Optional[str] = None,
alert_config: Optional[GenAIAlertConfig] = None,
) -> None
Inplace operation that updates config args Args: space: Space to associate with the config name: Name to associate with the config version: Version to associate with the config alert_config: LLM alert configuration
Source code in python/scouter/stubs.pyi
GenAIEvalDataset ¶
GenAIEvalDataset(
records: Sequence[GenAIEvalRecord],
tasks: Sequence[LLMJudgeTask | AssertionTask],
)
Defines the dataset used for LLM evaluation
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
records
|
List[GenAIEvalRecord]
|
List of LLM evaluation records to be evaluated. |
required |
tasks
|
List[LLMJudgeTask | AssertionTask]
|
List of evaluation tasks to apply to the records. |
required |
Source code in python/scouter/stubs.pyi
assertion_tasks
property
¶
Get the list of assertion tasks in this dataset
llm_judge_tasks
property
¶
Get the list of LLM judge tasks in this dataset
records
property
¶
Get the list of LLM evaluation records in this dataset
evaluate ¶
Evaluate the records using the defined tasks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
Optional[EvaluationConfig]
|
Optional configuration for the evaluation process. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
GenAIEvalResults |
GenAIEvalResults
|
The results of the evaluation. |
Source code in python/scouter/stubs.pyi
print_execution_plan ¶
with_updated_contexts_by_id ¶
Create a new GenAIEvalDataset with updated contexts for specific records.
Example
updated_contexts = { ... "record_1_uid": {"new_field": "new_value"}, ... "record_2_uid": {"another_field": 123} ... } new_dataset = dataset.with_updated_contexts_by_id(updated_contexts)
Args: updated_contexts (Dict[str, Any]): A dictionary mapping record UIDs to their new context data. Returns: GenAIEvalDataset: A new dataset instance with the updated contexts.
Source code in python/scouter/stubs.pyi
GenAIEvalProfile ¶
Profile for LLM evaluation and drift detection.
GenAIEvalProfile combines assertion tasks and LLM judge tasks into a unified evaluation framework for monitoring LLM performance. Evaluations run asynchronously on the Scouter server, enabling scalable drift detection without blocking your application.
Architecture
The profile automatically orchestrates two types of evaluation tasks:
- Assertion Tasks: Fast, deterministic rule-based validations
- Execute locally without additional LLM calls
- Ideal for structural validation, threshold checks, pattern matching
-
Zero latency overhead, minimal cost
-
LLM Judge Tasks: Advanced reasoning-based evaluations
- Leverage additional LLM calls for complex assessments
- Automatically compiled into an internal Workflow for execution
- Support dependencies to chain evaluations and pass results
- Ideal for semantic similarity, quality assessment, factuality checks
Task Execution Order
Tasks are executed based on their dependency graph using topological sort:
╔══════════════════════════════════════════════════════════════╗
║ TASK EXECUTION ARCHITECTURE ║
╠══════════════════════════════════════════════════════════════╣
║ ║
║ Level 0: Independent Tasks (no dependencies) ║
║ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ║
║ │ Assertion A │ │ Assertion B │ │ LLM Judge X │ ║
║ └──────┬──────┘ └──────┬──────┘ └──────┬──────┘ ║
║ │ │ │ ║
║ └────────┬───────┴────────┬───────┘ ║
║ │ │ ║
║ Level 1: Tasks depending on Level 0 ║
║ ┌────────▼────────┐ ┌────▼────────┐ ║
║ │ LLM Judge Y │ │Assertion C │ ║
║ │ (depends: A, X) │ │(depends: B) │ ║
║ └────────┬────────┘ └────┬────────┘ ║
║ │ │ ║
║ Level 2: Final aggregation tasks ║
║ └────────┬───────┘ ║
║ ┌────────▼────────┐ ║
║ │ LLM Judge Z │ ║
║ │ (depends: Y, C) │ ║
║ └─────────────────┘ ║
║ ║
╚══════════════════════════════════════════════════════════════╝
Workflow Generation
When LLM judge tasks are present, the profile automatically: 1. Builds an internal Workflow from LLMJudgeTask configurations 2. Validates task dependencies form a valid DAG 3. Ensures Prompt configurations are compatible with execution 4. Optimizes execution order for parallel processing where possible
Common Use Cases
- Multi-stage LLM evaluation (relevance → quality → toxicity)
- Hybrid assertion + LLM judge pipelines (fast checks, then deep analysis)
- Dependent evaluations (use upstream results in downstream prompts)
- Cost-optimized monitoring (assertions for 90%, LLM judges for 10%)
Examples:
Pure assertion-based monitoring (no LLM calls):
>>> config = GenAIEvalConfig(
... space="production",
... name="chatbot",
... version="1.0",
... sample_ratio=10
... )
>>>
>>> tasks = [
... AssertionTask(
... id="response_length",
... field_path="response",
... operator=ComparisonOperator.HasLength,
... expected_value={"min": 10, "max": 500},
... description="Ensure response is reasonable length"
... ),
... AssertionTask(
... id="confidence_threshold",
... field_path="metadata.confidence",
... operator=ComparisonOperator.GreaterThanOrEqual,
... expected_value=0.7,
... description="Require minimum confidence"
... )
... ]
>>>
>>> profile = GenAIEvalProfile(
... config=config,
... tasks=tasks
... )
LLM judge-based semantic monitoring:
>>> relevance_prompt = Prompt(
... system_instructions="Evaluate response relevance to query",
... messages="Query: {{input}}\nResponse: {{response}}\nRate 0-10:",
... model="gpt-4o-mini",
... provider=Provider.OpenAI,
... output_type=Score
... )
>>>
>>> judge_tasks = [
... LLMJudgeTask(
... id="relevance_judge",
... prompt=relevance_prompt,
... expected_value=7,
... field_path="score",
... operator=ComparisonOperator.GreaterThanOrEqual,
... description="Ensure relevance score >= 7"
... )
... ]
>>>
>>> profile = GenAIEvalProfile(
... config=config,
... tasks=judge_tasks
... )
Hybrid monitoring with dependencies:
>>> # Fast assertion checks first
>>> assertion_tasks = [
... AssertionTask(
... id="not_empty",
... field_path="response",
... operator=ComparisonOperator.HasLength,
... expected_value={"min": 1},
... description="Response must not be empty"
... )
... ]
>>>
>>> # Deep LLM analysis only if assertions pass
>>> quality_prompt = Prompt(
... system_instructions="Assess response quality",
... messages="{{response}}",
... model="claude-3-5-sonnet-20241022",
... provider=Provider.Anthropic,
... output_type=Score
... )
>>>
>>> judge_tasks = [
... LLMJudgeTask(
... id="quality_judge",
... prompt=quality_prompt,
... expected_value=8,
... field_path="score",
... operator=ComparisonOperator.GreaterThanOrEqual,
... depends_on=["not_empty"], # Only run if assertion passes
... description="Quality assessment after validation"
... )
... ]
>>>
>>> profile = GenAIEvalProfile(
... config=config,
... tasks=assertion_tasks + judge_tasks
... )
Multi-stage dependent LLM judges:
>>> # Stage 1: Relevance check
>>> relevance_task = LLMJudgeTask(
... id="relevance",
... prompt=relevance_prompt,
... expected_value=7,
... field_path="score",
... operator=ComparisonOperator.GreaterThanOrEqual
... )
>>>
>>> # Stage 2: Toxicity check (only if relevant)
>>> toxicity_prompt = Prompt(...)
>>> toxicity_task = LLMJudgeTask(
... id="toxicity",
... prompt=toxicity_prompt,
... expected_value=0.2,
... field_path="relevance.score",
... operator=ComparisonOperator.LessThan,
... depends_on=["relevance"] # Chain evaluations
... )
>>>
>>> # Stage 3: Final quality (only if relevant and non-toxic)
>>> quality_task = LLMJudgeTask(
... id="quality",
... prompt=quality_prompt,
... expected_value=8,
... field_path="toxicity.score",
... operator=ComparisonOperator.GreaterThanOrEqual,
... depends_on=["relevance", "toxicity"] # Multiple deps
... )
>>>
>>> profile = GenAIEvalProfile(
... config=config,
... tasks=[relevance_task, toxicity_task, quality_task]
... )
Note
- At least one task (assertion or LLM judge) is required
- LLM judge tasks are automatically compiled into an internal Workflow
- Task dependencies must form a valid DAG (no circular dependencies)
- Execution order is optimized via topological sort
- Independent tasks at the same level can execute in parallel
- Failed tasks halt execution of dependent downstream tasks
Creates a profile that combines assertion tasks and LLM judge tasks into a unified evaluation framework. LLM judge tasks are automatically compiled into an internal Workflow for execution on the Scouter server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
GenAIEvalConfig
|
Configuration for the GenAI drift profile containing space, name, version, sample rate, and alert settings. |
required |
tasks
|
List[Union[AssertionTask, LLMJudgeTask]]
|
List of evaluation tasks to include in the profile. Can contain both AssertionTask and LLMJudgeTask instances. At least one task (assertion or LLM judge) is required. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
GenAIEvalProfile |
Configured profile ready for GenAI drift monitoring. |
Raises:
| Type | Description |
|---|---|
ProfileError
|
If validation fails due to: - Empty task lists (both assertion_tasks and llm_judge_tasks are None/empty) - Circular dependencies in task dependency graph - Invalid task configurations (malformed prompts, missing fields, etc.) |
Examples:
Assertion-only profile:
>>> config = GenAIEvalConfig(space="prod", name="bot", version="1.0")
>>> assertions = [
... AssertionTask(id="length_check", ...),
... AssertionTask(id="confidence_check", ...)
... ]
>>> profile = GenAIEvalProfile(config, tasks=assertions)
LLM judge-only profile:
>>> judges = [
... LLMJudgeTask(id="relevance", prompt=..., ...),
... LLMJudgeTask(id="quality", prompt=..., depends_on=["relevance"])
... ]
>>> profile = GenAIEvalProfile(config, tasks=judges)
Hybrid profile:
Source code in python/scouter/stubs.pyi
14360 14361 14362 14363 14364 14365 14366 14367 14368 14369 14370 14371 14372 14373 14374 14375 14376 14377 14378 14379 14380 14381 14382 14383 14384 14385 14386 14387 14388 14389 14390 14391 14392 14393 14394 14395 14396 14397 14398 14399 14400 14401 14402 14403 14404 14405 14406 14407 14408 14409 14410 14411 14412 14413 | |
assertion_tasks
property
¶
List of assertion tasks for deterministic validation.
Assertions execute without additional LLM calls, providing fast, cost-effective validation of structural properties, thresholds, and patterns.
config
property
¶
Configuration for the drift profile.
Contains space, name, version, sample rate, and alert settings.
llm_judge_tasks
property
¶
List of LLM judge tasks for reasoning-based evaluation.
LLM judges use additional LLM calls to assess complex criteria like semantic similarity, quality, and factuality. Automatically compiled into an internal Workflow for execution.
scouter_version
property
¶
Scouter version used to create this profile.
Used for compatibility tracking and migration support.
uid
property
writable
¶
Unique identifier for the drift profile.
Derived from the config's space, name, and version. Used for tracking and querying evaluation results.
from_file
staticmethod
¶
Load profile from JSON file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Path to the JSON file containing the profile. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
GenAIEvalProfile |
GenAIEvalProfile
|
Loaded profile instance. |
Raises:
| Type | Description |
|---|---|
ProfileError
|
If file doesn't exist, is malformed, or invalid. |
Example
profile = GenAIEvalProfile.from_file(Path("my_profile.json"))
Source code in python/scouter/stubs.pyi
get_execution_plan ¶
Get the execution plan for all tasks.
Returns task IDs grouped by execution level based on dependency graph. Tasks at the same level can execute in parallel. Each subsequent level depends on completion of all previous levels.
Uses topological sort to determine optimal execution order while respecting task dependencies.
Returns:
| Type | Description |
|---|---|
List[List[str]]
|
List[List[str]]: Nested list where each inner list contains task IDs for that execution level. Level 0 contains tasks with no dependencies, Level 1 contains tasks depending only on Level 0, etc. |
Raises:
| Type | Description |
|---|---|
ProfileError
|
If circular dependencies are detected in the task graph. |
Example
plan = profile.get_execution_plan() print(f"Level 0 (parallel): {plan[0]}") print(f"Level 1 (after L0): {plan[1]}") print(f"Total levels: {len(plan)}")
Output: Level 0 (parallel): ['assertion_a', 'assertion_b', 'judge_x'] Level 1 (after L0): ['judge_y', 'assertion_c'] Total levels: 2
Source code in python/scouter/stubs.pyi
has_assertions ¶
Check if profile contains assertion tasks.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if assertion_tasks is non-empty, False otherwise. |
Example
if profile.has_assertions(): ... print("Profile includes fast assertion checks")
Source code in python/scouter/stubs.pyi
has_llm_tasks ¶
Check if profile contains LLM judge tasks.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if llm_judge_tasks is non-empty, False otherwise. |
Example
if profile.has_llm_tasks(): ... print("Profile uses LLM judges (additional cost/latency)")
Source code in python/scouter/stubs.pyi
model_dump ¶
Serialize profile to dictionary.
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dict[str, Any]: Dictionary representation of the profile. |
Example
data = profile.model_dump() print(data["config"]["space"]) print(f"Task count: {len(data['assertion_tasks'])}")
Source code in python/scouter/stubs.pyi
model_dump_json ¶
Serialize profile to JSON string.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
JSON string representation of the profile including config, tasks, workflow (if present), and metadata. |
Example
json_str = profile.model_dump_json()
Save to file, send to API, etc.¶
Source code in python/scouter/stubs.pyi
model_validate
staticmethod
¶
Load profile from dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Dict[str, Any]
|
Dictionary representation of the profile. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
GenAIEvalProfile |
GenAIEvalProfile
|
Reconstructed profile instance. |
Raises:
| Type | Description |
|---|---|
ProfileError
|
If dictionary structure is invalid or missing required fields. |
Example
data = {"config": {...}, "assertion_tasks": [...]} profile = GenAIEvalProfile.model_validate(data)
Source code in python/scouter/stubs.pyi
model_validate_json
staticmethod
¶
Load profile from JSON string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_string
|
str
|
JSON string representation of the profile. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
GenAIEvalProfile |
GenAIEvalProfile
|
Reconstructed profile instance. |
Raises:
| Type | Description |
|---|---|
ProfileError
|
If JSON is malformed or invalid. |
Example
json_str = '{"config": {...}, "assertion_tasks": [...]}' profile = GenAIEvalProfile.model_validate_json(json_str)
Source code in python/scouter/stubs.pyi
print_execution_plan ¶
save_to_json ¶
Save profile to JSON file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Optional[Path]
|
Optional path to save the profile. If None, saves to "genai_eval_profile.json" in the current directory. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Path |
Path
|
Path where the profile was saved. |
Example
path = profile.save_to_json(Path("my_profile.json")) print(f"Saved to: {path}")
Source code in python/scouter/stubs.pyi
update_config_args ¶
update_config_args(
space: Optional[str] = None,
name: Optional[str] = None,
version: Optional[str] = None,
uid: Optional[str] = None,
alert_config: Optional[GenAIAlertConfig] = None,
) -> None
Update profile configuration in-place.
Modifies the profile's config without recreating the entire profile. Useful for adjusting space/name/version after initial creation or updating alert settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
space
|
Optional[str]
|
New model space. If None, keeps existing value. |
None
|
name
|
Optional[str]
|
New model name. If None, keeps existing value. |
None
|
version
|
Optional[str]
|
New model version. If None, keeps existing value. |
None
|
uid
|
Optional[str]
|
New unique identifier. If None, keeps existing value. |
None
|
alert_config
|
Optional[GenAIAlertConfig]
|
New alert configuration. If None, keeps existing value. |
None
|
Example
profile.update_config_args( ... space="production", ... alert_config=GenAIAlertConfig(schedule="0 /6 * * ") ... )
Source code in python/scouter/stubs.pyi
GenAIEvalRecord ¶
LLM record containing context tied to a Large Language Model interaction that is used to evaluate drift in LLM responses.
Examples:
>>> record = GenAIEvalRecord(
... context={
... "input": "What is the capital of France?",
... "response": "Paris is the capital of France."
... },
... )
>>> print(record.context["input"])
"What is the capital of France?"
then used to inject context into the evaluation prompts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
Dict[str, Any] | BaseModel
|
Additional context information as a dictionary or a pydantic BaseModel. During evaluation,
this will be merged with the input and response data and passed to the assigned
evaluation prompts. So if you're evaluation prompts expect additional context via
bound variables (e.g., |
required |
id
|
Optional[str]
|
Optional unique identifier for the record. |
None
|
session_id
|
Optional[str]
|
Optional session identifier to group related records. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If context is not a dict or a pydantic BaseModel. |
Source code in python/scouter/stubs.pyi
context
property
¶
Get the contextual information.
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
The context data as a Python object (deserialized from JSON). |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the stored JSON cannot be converted to a Python object. |
model_dump_json ¶
update_context_field ¶
Update a specific field in the context. If the key does not exist, it will be added.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The key of the context field to update. |
required |
value
|
Any
|
The new value for the context field. |
required |
Source code in python/scouter/stubs.pyi
GenAIEvalResultSet ¶
Defines the results of a specific evaluation run
GenAIEvalResults ¶
Defines the results of an LLM eval metric
errored_tasks
property
¶
Get a list of record IDs that had errors during evaluation
histograms
property
¶
Get histograms for all calculated features (metrics, embeddings, similarities)
as_table ¶
Pretty print the workflow or task results as a table
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
show_tasks
|
bool
|
Whether to show individual task results or just the workflow summary. Default is False meaning only the workflow summary is shown. |
False
|
Source code in python/scouter/stubs.pyi
compare_to ¶
Compare the current evaluation results to a baseline with a regression threshold.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
baseline
|
GenAIEvalResults
|
The baseline evaluation results to compare against. |
required |
regression_threshold
|
float
|
The threshold for considering a regression significant. |
required |
Returns:
| Type | Description |
|---|---|
ComparisonResults
|
ComparisonResults |
Source code in python/scouter/stubs.pyi
model_dump_json ¶
model_validate_json
staticmethod
¶
Validate and create an GenAIEvalResults instance from a JSON string
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_string
|
str
|
JSON string to validate and create the GenAIEvalResults instance from. |
required |
Source code in python/scouter/stubs.pyi
to_dataframe ¶
Convert the results to a Pandas or Polars DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
polars
|
bool
|
Whether to return a Polars DataFrame. If False, a Pandas DataFrame will be returned. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
DataFrame |
Any
|
A Pandas or Polars DataFrame containing the results. |
Source code in python/scouter/stubs.pyi
GenAIEvalSet ¶
Evaluation set for a specific evaluation run
failed_tasks
property
¶
Get the number of tasks that failed in this evaluation set
pass_rate
property
¶
Get the pass rate (percentage of passed tasks) in this evaluation set
passed_tasks
property
¶
Get the number of tasks that passed in this evaluation set
record_uid
property
¶
Get the unique identifier for the records in this evaluation set
records
property
¶
Get the list of task results in this evaluation set
as_table ¶
Pretty print the evaluation workflow or task results as a table
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
show_tasks
|
bool
|
Whether to show individual task results or just the summary. Default is False meaning only the workflow summary is shown. |
False
|
Source code in python/scouter/stubs.pyi
GenAIEvalTaskResult ¶
Individual task result from an LLM evaluation run
actual
property
¶
Get the actual value that was evaluated.
Returns:
| Type | Description |
|---|---|
Any
|
The actual value as a Python object (deserialized from JSON). |
expected
property
¶
Get the expected value for comparison.
Returns:
| Type | Description |
|---|---|
Any
|
The expected value as a Python object (deserialized from JSON). |
field_path
property
¶
Get the field path used for value extraction, if any
record_uid
property
¶
Get the unique identifier for the record associated with this task result
task_type
property
¶
Get the type of evaluation task (Assertion, LLMJudge, or HumanValidation)
GenerateContentResponse ¶
GenerationConfig ¶
GenerationConfig(
stop_sequences: Optional[List[str]] = None,
response_mime_type: Optional[str] = None,
response_json_schema: Optional[Any] = None,
response_modalities: Optional[List[Modality]] = None,
thinking_config: Optional[GeminiThinkingConfig] = None,
temperature: Optional[float] = None,
top_p: Optional[float] = None,
top_k: Optional[int] = None,
candidate_count: Optional[int] = None,
max_output_tokens: Optional[int] = None,
response_logprobs: Optional[bool] = None,
logprobs: Optional[int] = None,
presence_penalty: Optional[float] = None,
frequency_penalty: Optional[float] = None,
seed: Optional[int] = None,
audio_timestamp: Optional[bool] = None,
media_resolution: Optional[MediaResolution] = None,
speech_config: Optional[SpeechConfig] = None,
enable_affective_dialog: Optional[bool] = None,
enable_enhanced_civic_answers: Optional[bool] = None,
image_config: Optional[ImageConfig] = None,
)
Configuration for content generation behavior.
Controls all aspects of how the model generates responses including sampling parameters, output format, modalities, and more.
Examples:
>>> # Basic text generation
>>> config = GenerationConfig(
... temperature=0.7,
... max_output_tokens=1024,
... top_p=0.95
... )
>>> # Structured JSON output
>>> config = GenerationConfig(
... response_mime_type="application/json",
... response_json_schema={"type": "object", ...},
... temperature=0.3
... )
>>> # Multi-modal with thinking
>>> config = GenerationConfig(
... response_modalities=[Modality.Text, Modality.Image],
... thinking_config=ThinkingConfig(
... include_thoughts=True,
... thinking_level=ThinkingLevel.High
... ),
... temperature=0.5
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stop_sequences
|
Optional[List[str]]
|
Sequences that stop generation |
None
|
response_mime_type
|
Optional[str]
|
MIME type for response (e.g., "application/json") |
None
|
response_json_schema
|
Optional[Any]
|
JSON schema for structured output |
None
|
response_modalities
|
Optional[List[Modality]]
|
Output modalities to include |
None
|
thinking_config
|
Optional[GeminiThinkingConfig]
|
Configuration for thinking/reasoning |
None
|
temperature
|
Optional[float]
|
Sampling temperature (0.0-2.0) |
None
|
top_p
|
Optional[float]
|
Nucleus sampling threshold |
None
|
top_k
|
Optional[int]
|
Top-k sampling threshold |
None
|
candidate_count
|
Optional[int]
|
Number of candidates to generate |
None
|
max_output_tokens
|
Optional[int]
|
Maximum tokens to generate |
None
|
response_logprobs
|
Optional[bool]
|
Whether to return log probabilities |
None
|
logprobs
|
Optional[int]
|
Number of top log probabilities to return |
None
|
presence_penalty
|
Optional[float]
|
Penalty for token presence (-2.0 to 2.0) |
None
|
frequency_penalty
|
Optional[float]
|
Penalty for token frequency (-2.0 to 2.0) |
None
|
seed
|
Optional[int]
|
Random seed for deterministic generation |
None
|
audio_timestamp
|
Optional[bool]
|
Whether to include audio timestamps |
None
|
media_resolution
|
Optional[MediaResolution]
|
Resolution for media processing |
None
|
speech_config
|
Optional[SpeechConfig]
|
Configuration for speech synthesis |
None
|
enable_affective_dialog
|
Optional[bool]
|
Enable emotion detection/adaptation |
None
|
enable_enhanced_civic_answers
|
Optional[bool]
|
Enable enhanced civic answers |
None
|
image_config
|
Optional[ImageConfig]
|
Configuration for image generation |
None
|
Source code in python/scouter/stubs.pyi
4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 | |
GetProfileRequest ¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Profile name |
required |
space
|
str
|
Profile space |
required |
version
|
str
|
Profile version |
required |
drift_type
|
DriftType
|
Profile drift type. A (repo/name/version can be associated with more than one drift type) |
required |
Source code in python/scouter/stubs.pyi
GoogleDate ¶
GoogleMaps ¶
Google Maps tool configuration.
Configures Google Maps integration.
Examples:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
enable_widget
|
bool
|
Whether to enable widget context token |
False
|
Source code in python/scouter/stubs.pyi
GoogleSearch ¶
GoogleSearchNum ¶
GoogleSearchNum(
gemini_search: Optional[GoogleSearch] = None,
vertex_search: Optional[VertexGoogleSearch] = None,
)
Union type for Google Search configurations.
Represents either Gemini or Vertex Google Search configuration.
Examples:
Exactly one of gemini_search or vertex_search must be provided.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gemini_search
|
Optional[GoogleSearch]
|
Gemini API search configuration |
None
|
vertex_search
|
Optional[VertexGoogleSearch]
|
Vertex API search configuration |
None
|
Source code in python/scouter/stubs.pyi
GoogleSearchRetrieval ¶
Google Search retrieval tool configuration.
Configures Google Search with dynamic retrieval.
Examples:
>>> retrieval = GoogleSearchRetrieval(
... dynamic_retrieval_config=DynamicRetrievalConfig(
... mode=DynamicRetrievalMode.ModeDynamic
... )
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dynamic_retrieval_config
|
Optional[DynamicRetrievalConfig]
|
Dynamic retrieval configuration |
None
|
Source code in python/scouter/stubs.pyi
dynamic_retrieval_config
property
¶
The dynamic retrieval configuration.
GoogleServiceAccountConfig ¶
Google Service Account authentication configuration.
Configures service account authentication.
Examples:
>>> config = GoogleServiceAccountConfig(
... service_account="[email protected]"
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
service_account
|
Optional[str]
|
Service account email |
None
|
Source code in python/scouter/stubs.pyi
Grammar ¶
Grammar definition for structured custom tool outputs.
This class defines a grammar that constrains custom tool outputs to follow specific syntax rules.
Examples:
>>> grammar = Grammar(
... definition="number: /[0-9]+/",
... syntax="lark"
... )
>>> grammar.syntax
'lark'
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
definition
|
str
|
The grammar definition |
required |
syntax
|
str
|
Grammar syntax type ("lark" or "regex") |
required |
Source code in python/scouter/stubs.pyi
GrammarFormat ¶
Grammar-based format for custom tool outputs.
This class wraps a grammar definition to create a structured output format for custom tools.
Examples:
>>> grammar = Grammar(definition="...", syntax="lark")
>>> format = GrammarFormat(grammar=grammar, type="grammar")
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grammar
|
Grammar
|
The grammar definition |
required |
type
|
str
|
Format type (typically "grammar") |
required |
Source code in python/scouter/stubs.pyi
GroundingChunk ¶
Grounding chunk wrapper.
Wraps a grounding chunk source.
Examples:
GroundingChunkType ¶
Union type for grounding chunk sources.
Represents different types of grounding sources.
Examples:
GroundingMetadata ¶
Grounding metadata for a response.
Contains all grounding information including sources, supports, and search queries.
Examples:
>>> metadata = GroundingMetadata(
... web_search_queries=["query1", "query2"],
... grounding_chunks=[GroundingChunk(...)],
... grounding_supports=[GroundingSupport(...)]
... )
GroundingSupport ¶
GrpcConfig ¶
GrpcConfig(
server_uri: Optional[str] = None,
username: Optional[str] = None,
password: Optional[str] = None,
)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
server_uri
|
Optional[str]
|
URL of the gRPC server to publish messages to. If not provided, the value of the SCOUTER_GRPC_URI environment variable is used. |
None
|
username
|
Optional[str]
|
Username for basic authentication. If not provided, the value of the SCOUTER_USERNAME environment variable is used. |
None
|
password
|
Optional[str]
|
Password for basic authentication. If not provided, the value of the SCOUTER_PASSWORD environment variable is used. |
None
|
Source code in python/scouter/stubs.pyi
GrpcSpanExporter ¶
GrpcSpanExporter(
batch_export: bool = True,
export_config: Optional[OtelExportConfig] = None,
sample_ratio: Optional[float] = None,
)
Exporter that sends spans to a gRPC endpoint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch_export
|
bool
|
Whether to use batch exporting. Defaults to True. |
True
|
export_config
|
Optional[OtelExportConfig]
|
Configuration for exporting spans. |
None
|
sample_ratio
|
Optional[float]
|
The sampling ratio for traces. If None, defaults to always sample. |
None
|
Source code in python/scouter/stubs.pyi
compression
property
¶
Get the compression type used for exporting spans.
HarmBlockMethod ¶
Method for blocking harmful content.
Specifies whether blocking decisions use probability or severity scores.
Examples:
HarmBlockThreshold ¶
Thresholds for blocking harmful content.
Defines sensitivity levels for blocking content based on harm probability.
Examples:
BlockLowAndAbove
class-attribute
instance-attribute
¶
Block content with low or higher harm probability
BlockMediumAndAbove
class-attribute
instance-attribute
¶
Block content with medium or higher harm probability
BlockNone
class-attribute
instance-attribute
¶
Do not block any content
BlockOnlyHigh
class-attribute
instance-attribute
¶
Block only high harm probability content
HarmBlockThresholdUnspecified
class-attribute
instance-attribute
¶
Unspecified threshold
Off
class-attribute
instance-attribute
¶
Turn off safety filtering entirely
HarmCategory ¶
Harm categories for safety filtering in Google/Gemini API.
Defines categories of potentially harmful content that can be detected and filtered by the model's safety systems.
Examples:
HarmCategoryDangerous
class-attribute
instance-attribute
¶
Dangerous content
HarmCategoryDangerousContent
class-attribute
instance-attribute
¶
Dangerous content (alternative)
HarmCategoryDerogatory
class-attribute
instance-attribute
¶
Derogatory content
HarmCategoryHarassment
class-attribute
instance-attribute
¶
Harassment content
HarmCategoryHateSpeech
class-attribute
instance-attribute
¶
Hate speech content
HarmCategoryMedical
class-attribute
instance-attribute
¶
Medical misinformation
HarmCategorySexual
class-attribute
instance-attribute
¶
Sexual content
HarmCategorySexuallyExplicit
class-attribute
instance-attribute
¶
Sexually explicit content
HarmCategoryToxicity
class-attribute
instance-attribute
¶
Toxic content
HarmCategoryUnspecified
class-attribute
instance-attribute
¶
Unspecified harm category
HarmCategoryViolence
class-attribute
instance-attribute
¶
Violent content
HarmProbability ¶
HarmSeverity ¶
Severity level of harmful content.
Indicates the severity of potentially harmful content.
Examples:
HarmSeverityHigh
class-attribute
instance-attribute
¶
High severity
HarmSeverityMedium
class-attribute
instance-attribute
¶
Medium severity
HarmSeverityNegligible
class-attribute
instance-attribute
¶
Negligible severity
HarmSeverityUnspecified
class-attribute
instance-attribute
¶
Unspecified severity
Histogram ¶
HttpBasicAuthConfig ¶
HTTP Basic authentication configuration.
Configures HTTP Basic authentication for external APIs.
Examples:
>>> config = HttpBasicAuthConfig(
... credential_secret="projects/my-project/secrets/credentials"
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
credential_secret
|
str
|
Secret manager resource name for credentials |
required |
Source code in python/scouter/stubs.pyi
HttpConfig ¶
HttpConfig(
server_uri: Optional[str] = None,
username: Optional[str] = None,
password: Optional[str] = None,
auth_token: Optional[str] = None,
)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
server_uri
|
Optional[str]
|
URL of the HTTP server to publish messages to. If not provided, the value of the HTTP_server_uri environment variable is used. |
None
|
username
|
Optional[str]
|
Username for basic authentication. |
None
|
password
|
Optional[str]
|
Password for basic authentication. |
None
|
auth_token
|
Optional[str]
|
Authorization token to use for authentication. |
None
|
Source code in python/scouter/stubs.pyi
HttpElementLocation ¶
Location of HTTP authentication element.
Specifies where authentication information appears in HTTP requests.
Examples:
HttpSpanExporter ¶
HttpSpanExporter(
batch_export: bool = True,
export_config: Optional[OtelExportConfig] = None,
sample_ratio: Optional[float] = None,
)
Exporter that sends spans to an HTTP endpoint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch_export
|
bool
|
Whether to use batch exporting. Defaults to True. |
True
|
export_config
|
Optional[OtelExportConfig]
|
Configuration for exporting spans. |
None
|
sample_ratio
|
Optional[float]
|
The sampling ratio for traces. If None, defaults to always sample. |
None
|
Source code in python/scouter/stubs.pyi
compression
property
¶
Get the compression type used for exporting spans.
ImageBlockParam ¶
Image content block parameter.
Image content with source and optional cache control.
Examples:
>>> # Base64 image
>>> source = Base64ImageSource(media_type="image/jpeg", data="...")
>>> block = ImageBlockParam(source=source, cache_control=None)
>>>
>>> # URL image
>>> source = UrlImageSource(url="https://example.com/image.jpg")
>>> block = ImageBlockParam(source=source, cache_control=None)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
Any
|
Image source (Base64ImageSource or UrlImageSource) |
required |
cache_control
|
Optional[CacheControl]
|
Cache control settings |
None
|
Source code in python/scouter/stubs.pyi
ImageConfig ¶
Configuration for image generation features.
Controls aspect ratio and size for generated images.
Examples:
>>> # Generate widescreen 4K image
>>> config = ImageConfig(
... aspect_ratio="16:9",
... image_size="4K"
... )
>>> # Generate square 1K image
>>> config = ImageConfig(
... aspect_ratio="1:1",
... image_size="1K"
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
aspect_ratio
|
Optional[str]
|
Desired aspect ratio (e.g., "16:9", "1:1") |
None
|
image_size
|
Optional[str]
|
Image size ("1K", "2K", "4K") |
None
|
Source code in python/scouter/stubs.pyi
ImageContentPart ¶
Image content part for OpenAI chat messages.
This class represents an image as part of a message's content.
Examples:
>>> image_part = ImageContentPart(
... url="https://example.com/image.jpg",
... detail="high"
... )
>>> image_part.type
'image_url'
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
Image URL (can be HTTP URL or data URL) |
required |
detail
|
Optional[str]
|
Detail level ("low", "high", or "auto") |
None
|
Source code in python/scouter/stubs.pyi
ImageUrl ¶
Image URL reference for OpenAI chat messages.
This class represents an image by URL with optional detail level.
Examples:
>>> # Standard detail
>>> image = ImageUrl(url="https://example.com/image.jpg")
>>>
>>> # High detail
>>> image = ImageUrl(
... url="https://example.com/image.jpg",
... detail="high"
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
Image URL (can be HTTP URL or data URL) |
required |
detail
|
Optional[str]
|
Detail level ("low", "high", or "auto") |
None
|
Source code in python/scouter/stubs.pyi
InnerAllowedTools ¶
InputAudioContentPart ¶
Audio content part for OpenAI chat messages.
This class represents audio input as part of a message's content.
Examples:
>>> audio_part = InputAudioContentPart(
... data="base64_encoded_audio",
... format="wav"
... )
>>> audio_part.type
'input_audio'
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
str
|
Base64 encoded audio data |
required |
format
|
str
|
Audio format (e.g., "wav", "mp3") |
required |
Source code in python/scouter/stubs.pyi
InputAudioData ¶
Audio data for input in OpenAI chat messages.
This class represents audio input data with format specification.
Examples:
>>> audio_data = InputAudioData(
... data="base64_encoded_audio",
... format="wav"
... )
>>> audio_data.format
'wav'
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
str
|
Base64 encoded audio data |
required |
format
|
str
|
Audio format (e.g., "wav", "mp3") |
required |
Source code in python/scouter/stubs.pyi
Interval ¶
KafkaConfig ¶
KafkaConfig(
username: Optional[str] = None,
password: Optional[str] = None,
brokers: Optional[str] = None,
topic: Optional[str] = None,
compression_type: Optional[str] = None,
message_timeout_ms: int = 600000,
message_max_bytes: int = 2097164,
log_level: LogLevel = LogLevel.Info,
config: Dict[str, str] = {},
max_retries: int = 3,
)
This configuration supports both authenticated (SASL) and unauthenticated connections. When credentials are provided, SASL authentication is automatically enabled with secure defaults.
Authentication Priority (first match wins): 1. Direct parameters (username/password) 2. Environment variables (KAFKA_USERNAME/KAFKA_PASSWORD) 3. Configuration dictionary (sasl.username/sasl.password)
SASL Security Defaults
- security.protocol: "SASL_SSL" (override via KAFKA_SECURITY_PROTOCOL env var)
- sasl.mechanism: "PLAIN" (override via KAFKA_SASL_MECHANISM env var)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
username
|
Optional[str]
|
SASL username for authentication. Fallback: KAFKA_USERNAME environment variable. |
None
|
password
|
Optional[str]
|
SASL password for authentication. Fallback: KAFKA_PASSWORD environment variable. |
None
|
brokers
|
Optional[str]
|
Comma-separated list of Kafka broker addresses (host:port). Fallback: KAFKA_BROKERS environment variable. Default: "localhost:9092" |
None
|
topic
|
Optional[str]
|
Target Kafka topic for message publishing. Fallback: KAFKA_TOPIC environment variable. Default: "scouter_monitoring" |
None
|
compression_type
|
Optional[str]
|
Message compression algorithm. Options: "none", "gzip", "snappy", "lz4", "zstd" Default: "gzip" |
None
|
message_timeout_ms
|
int
|
Maximum time to wait for message delivery (milliseconds). Default: 600000 (10 minutes) |
600000
|
message_max_bytes
|
int
|
Maximum message size in bytes. Default: 2097164 (~2MB) |
2097164
|
log_level
|
LogLevel
|
Logging verbosity for the Kafka producer. Default: LogLevel.Info |
Info
|
config
|
Dict[str, str]
|
Additional Kafka producer configuration parameters. See: https://kafka.apache.org/documentation/#producerconfigs Note: Direct parameters take precedence over config dictionary values. |
{}
|
max_retries
|
int
|
Maximum number of retry attempts for failed message deliveries. Default: 3 |
3
|
Examples:
Basic usage (unauthenticated):
SASL authentication:
config = KafkaConfig(
username="my_user",
password="my_password",
brokers="secure-kafka:9093",
topic="secure_topic"
)
Advanced configuration:
config = KafkaConfig(
brokers="kafka:9092",
compression_type="lz4",
config={
"acks": "all",
"batch.size": "32768",
"linger.ms": "10"
}
)
Source code in python/scouter/stubs.pyi
11036 11037 11038 11039 11040 11041 11042 11043 11044 11045 11046 11047 11048 11049 11050 11051 11052 11053 11054 11055 11056 11057 11058 11059 11060 11061 11062 11063 11064 11065 11066 11067 11068 11069 11070 11071 11072 11073 11074 11075 11076 11077 11078 11079 11080 11081 11082 11083 11084 11085 11086 11087 11088 11089 11090 11091 11092 11093 11094 11095 11096 11097 11098 11099 11100 11101 11102 11103 11104 11105 11106 11107 11108 11109 11110 11111 11112 11113 11114 11115 11116 11117 11118 11119 11120 11121 11122 11123 11124 11125 11126 11127 11128 11129 11130 11131 | |
LLMJudgeTask ¶
LLMJudgeTask(
id: str,
prompt: Prompt,
expected_value: Any,
field_path: Optional[str],
operator: ComparisonOperator,
description: Optional[str] = None,
depends_on: Optional[List[str]] = None,
max_retries: Optional[int] = None,
condition: bool = False,
)
LLM-powered evaluation task for complex assessments.
Uses an additional LLM call to evaluate responses based on sophisticated criteria that require reasoning, context understanding, or subjective judgment. LLM judges are ideal for evaluations that cannot be captured by deterministic rules, such as semantic similarity, quality assessment, or nuanced criteria.
Unlike AssertionTask which provides efficient, deterministic rule-based evaluation, LLMJudgeTask leverages an LLM's reasoning capabilities for: - Semantic similarity and relevance assessment - Quality, coherence, and fluency evaluation - Factual accuracy and hallucination detection - Tone, sentiment, and style analysis - Custom evaluation criteria requiring judgment - Complex reasoning over multiple context elements
The LLM judge executes a prompt that receives context (either raw or from dependencies) and returns a response that is then compared against the expected value using the specified operator.
Common Use Cases
- Evaluate semantic similarity between generated and reference answers
- Assess response quality on subjective criteria (helpfulness, clarity)
- Detect factual inconsistencies or hallucinations
- Score tone appropriateness for different audiences
- Judge whether responses meet complex, nuanced requirements
Examples:
Basic relevance check using LLM judge:
>>> # Define a prompt that evaluates relevance
>>> relevance_prompt = Prompt(
... system_instructions="Evaluate if the response is relevant to the query",
... messages="Given the query '{{query}}' and response '{{response}}', rate the relevance from 0 to 10 as an integer.",
... model="gpt-4",
... provider= Provider.OpenAI,
... output_type=Score # returns a structured output with schema {"score": float, "reason": str}
... )
>>> # Context at runtime: {"query": "What is AI?", "response": "AI is..."}
>>> task = LLMJudgeTask(
... id="relevance_judge",
... prompt=relevance_prompt,
... expected_value=8,
... field_path="score",
... operator=ComparisonOperator.GreaterThanOrEqual,
... description="Ensure response relevance score >= 8"
... )
Factuality check with structured output:
>>> # Prompt returns a Pydantic model with factuality assessment
>>> from pydantic import BaseModel
>>> class FactCheckResult(BaseModel):
... is_factual: bool
... confidence: float
>>> fact_check_prompt = Prompt(
... system_instructions="Verify factual claims in the response",
... messages="Assess the factual accuracy of the response: '{{response}}'. Provide a JSON with fields 'is_factual' (bool) and 'confidence' (float).", # pylint: disable=line-too-long
... model="gpt-4",
... provider= Provider.OpenAI,
... output_type=FactCheckResult
... )
>>> # Context: {"response": "Paris is the capital of France"}
>>> task = LLMJudgeTask(
... id="fact_checker",
... prompt=fact_check_prompt,
... expected_value={"is_factual": True, "confidence": 0.95},
... field_path="response",
... operator=ComparisonOperator.Contains
... )
Quality assessment with dependencies:
>>> # This judge depends on previous relevance check
>>> quality_prompt = Prompt(
... system_instructions="Assess the overall quality of the response",
... messages="Given the response '{{response}}', rate its quality from 0 to 5",
... model="gemini-3.0-flash",
... provider= Provider.Google,
... output_type=Score
... )
>>> task = LLMJudgeTask(
... id="quality_judge",
... prompt=quality_prompt,
... expected_value=0.7,
... field_path=None,
... operator=ComparisonOperator.GreaterThan,
... depends_on=["relevance_judge"],
... description="Evaluate overall quality after relevance check"
... )
Note: - LLM judge tasks incur additional latency and cost vs assertions - Scouter does not auto-inject any additional prompts or context apart from what is defined in the Prompt object - For tasks that contain dependencies, upstream results are passed as context to downstream tasks. - Use dependencies to chain evaluations and pass results between tasks - max_retries helps handle transient LLM failures (defaults to 3) - Field paths work the same as AssertionTask (dot-notation for nested access) - Consider cost/latency tradeoffs when designing judge evaluations
Creates an evaluation task that uses an LLM to assess responses based on sophisticated criteria requiring reasoning or subjective judgment. The LLM receives context (raw or from dependencies) and returns a response that is compared against the expected value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str
|
Unique identifier for the task. Will be converted to lowercase. Used to reference this task in dependencies and results. |
required |
prompt
|
Prompt
|
Prompt configuration defining the LLM evaluation task. |
required |
expected_value
|
Any
|
The expected value to compare against the LLM's response. Type depends on prompt response type. Can be any JSON-serializable type: str, int, float, bool, list, dict, or None. |
required |
field_path
|
Optional[str]
|
Optional dot-notation path to extract value from context before passing to the LLM prompt (e.g., "response.text"), the entire response will be evaluated. |
required |
operator
|
ComparisonOperator
|
Comparison operator to apply between LLM response and expected_value |
required |
description
|
Optional[str]
|
Optional human-readable description of what this judge evaluates. |
None
|
depends_on
|
Optional[List[str]]
|
Optional list of task IDs that must complete successfully before this task executes. Results from dependencies are passed to the LLM prompt as additional context parameters. Empty list if not provided. |
None
|
max_retries
|
Optional[int]
|
Optional maximum number of retry attempts if the LLM call fails (network errors, rate limits, etc.). Defaults to 3 if not provided. Set to 0 to disable retries. |
None
|
condition
|
bool
|
If True, this judge task acts as a condition for subsequent tasks. If the judge fails, dependent tasks will be skipped and this task will be excluded from final results. |
False
|
Source code in python/scouter/stubs.pyi
depends_on
property
writable
¶
List of task IDs this task depends on.
Dependency results are passed to the LLM prompt as additional context parameters, enabling chained evaluations.
expected_value
property
¶
Expected value to compare against LLM response.
Returns:
| Type | Description |
|---|---|
Any
|
The expected value as a Python object (deserialized from internal |
Any
|
JSON representation). |
field_path
property
¶
Dot-notation path to extract value from context before LLM evaluation.
If specified, extracts nested value from context (e.g., "response.text") and passes it to the LLM prompt. If None, the entire context or dependency results are passed.
max_retries
property
writable
¶
Maximum number of retry attempts for LLM call failures.
Handles transient failures like network errors or rate limits. Defaults to 3 if not specified during initialization.
operator
property
¶
Comparison operator for evaluating LLM response against expected value.
For Score responses: use numeric operators (GreaterThan, Equals, etc.) For Pydantic responses: use structural operators (Contains, Equals, etc.)
prompt
property
¶
Prompt configuration for the LLM evaluation task.
Defines the LLM model, evaluation instructions, and response format. The prompt must have response_type of Score or Pydantic.
LLMTestServer ¶
Mock server for OpenAI API. This class is used to simulate the OpenAI API for testing purposes.
Source code in python/scouter/stubs.pyi
Language ¶
Programming language for executable code.
Specifies the language used when the model generates executable code.
Examples:
LatLng ¶
Geographic coordinates.
Represents a latitude/longitude pair for location-based features.
Examples:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
latitude
|
float
|
Latitude in degrees |
required |
longitude
|
float
|
Longitude in degrees |
required |
Source code in python/scouter/stubs.pyi
LatencyMetrics ¶
LlmRanker ¶
LLM-based ranker configuration.
Uses an LLM to rank RAG results.
Examples:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_name
|
Optional[str]
|
Model name for ranking |
None
|
Source code in python/scouter/stubs.pyi
LogContent ¶
Log probability content for a single token.
This class contains detailed probability information for a token generated by the model.
Examples:
LogProbs ¶
Log probability information for OpenAI responses.
This class contains log probability data for both generated content and refusals.
Examples:
LoggingConfig ¶
LoggingConfig(
show_threads: bool = True,
log_level: LogLevel = LogLevel.Info,
write_level: WriteLevel = WriteLevel.Stdout,
use_json: bool = False,
)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
show_threads
|
bool
|
Whether to include thread information in log messages. Default is True. |
True
|
log_level
|
LogLevel
|
Log level for the logger. Default is LogLevel.Info. |
Info
|
write_level
|
WriteLevel
|
Write level for the logger. Default is WriteLevel.Stdout. |
Stdout
|
use_json
|
bool
|
Whether to write log messages in JSON format. Default is False. |
False
|
Source code in python/scouter/stubs.pyi
LogprobsCandidate ¶
LogprobsResult ¶
Manual ¶
Divides the feature range into a fixed number of equally sized bins.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_bins
|
int
|
The exact number of bins to create. |
required |
Source code in python/scouter/stubs.pyi
ManualRoutingMode ¶
Configuration for manual model routing.
Explicitly specifies which model to use instead of automatic selection.
Examples:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_name
|
str
|
Name of the model to use |
required |
Source code in python/scouter/stubs.pyi
Maps ¶
MediaResolution ¶
Media resolution levels for input processing.
Controls the token resolution at which media content is sampled, affecting quality and token usage.
Examples:
MediaResolutionHigh
class-attribute
instance-attribute
¶
High resolution with zoomed reframing (256 tokens)
MediaResolutionLow
class-attribute
instance-attribute
¶
Low resolution (64 tokens)
MediaResolutionMedium
class-attribute
instance-attribute
¶
Medium resolution (256 tokens)
MediaResolutionUnspecified
class-attribute
instance-attribute
¶
Unspecified resolution
MessageParam ¶
Message parameter for chat completion requests.
Input message with role and content.
Examples:
>>> # Simple text message
>>> msg = MessageParam(content="Hello, Claude!", role="user")
>>>
>>> # Message with mixed content
>>> text_block = TextBlockParam(text="Describe this:", cache_control=None, citations=None)
>>> image_source = UrlImageSource(url="https://example.com/image.jpg")
>>> image_block = ImageBlockParam(source=image_source, cache_control=None)
>>> msg = MessageParam(content=[text_block, image_block], role="user")
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
_ContentType
|
Message content (string, content block or list of content blocks) |
required |
role
|
str
|
Message role ("user" or "assistant") |
required |
Source code in python/scouter/stubs.pyi
bind ¶
bind(
name: Optional[str] = None,
value: Optional[str | int | float | bool | list] = None,
) -> MessageParam
Bind variables to the message content. Args: name (Optional[str]): The variable name to bind. value (Optional[Union[str, int, float, bool, list]]): The variable value to bind. Returns: MessageParam: A new MessageParam instance with bound variables.
Source code in python/scouter/stubs.pyi
bind_mut ¶
bind_mut(
name: Optional[str] = None,
value: Optional[str | int | float | bool | list] = None,
) -> None
Bind variables to the message content in place. Args: name (Optional[str]): The variable name to bind. value (Optional[Union[str, int, float, bool, list]]): The variable value to bind. Returns: None
Source code in python/scouter/stubs.pyi
model_dump ¶
text ¶
Get the text content of the first part, if available. Returns an empty string if the first part is not text. This is meant for convenience when working with simple text messages.
Metadata ¶
Request metadata.
Metadata associated with the API request.
Examples:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id
|
Optional[str]
|
External user identifier |
None
|
Source code in python/scouter/stubs.pyi
Metric ¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the metric |
required |
value
|
float | int
|
Value to assign to the metric. Can be an int or float but will be converted to float. |
required |
Source code in python/scouter/stubs.pyi
Metrics ¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metrics
|
List[Metric] | Dict[str, Union[int, float]]
|
List of metrics or a dictionary of key-value pairs. If a list, each item must be an instance of Metric. If a dictionary, each key is the metric name and each value is the metric value. |
required |
Example
```python
Passing a list of metrics¶
metrics = Metrics( metrics=[ Metric("metric_1", 1.0), Metric("metric_2", 2.5), Metric("metric_3", 3), ] )
Passing a dictionary (pydantic model) of metrics¶
class MyMetrics(BaseModel): metric1: float metric2: int
my_metrics = MyMetrics( metric1=1.0, metric2=2, )
metrics = Metrics(my_metrics.model_dump())
Source code in python/scouter/stubs.pyi
MissingTask ¶
MockConfig ¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Arbitrary keyword arguments to set as attributes. |
{}
|
Source code in python/scouter/stubs.pyi
Modality ¶
Content modality types supported by the model.
Defines the types of content (text, image, audio, etc.) that can be included in requests and responses.
Examples:
ModalityUnspecified
class-attribute
instance-attribute
¶
Unspecified modality
ModalityTokenCount ¶
Token count by modality.
Breaks down token usage by content type (text, image, audio, etc.).
Examples:
Mode ¶
Function calling mode for tool usage.
Controls how the model handles function/tool calls during generation.
Examples:
ModelArmorConfig ¶
ModelArmorConfig(
prompt_template_name: Optional[str] = None,
response_template_name: Optional[str] = None,
)
Configuration for Model Armor security filtering.
Model Armor provides safety and security filtering for prompts and responses using customized templates.
Examples:
>>> config = ModelArmorConfig(
... prompt_template_name="projects/my-project/locations/us/templates/strict",
... response_template_name="projects/my-project/locations/us/templates/moderate"
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt_template_name
|
Optional[str]
|
Template for prompt screening |
None
|
response_template_name
|
Optional[str]
|
Template for response screening |
None
|
Source code in python/scouter/stubs.pyi
ModelRoutingPreference ¶
Preference for automatic model routing.
Controls how models are selected when using automatic routing, balancing quality, cost, and performance.
Examples:
ModelSettings ¶
Bases: Generic[T]
Configuration settings for LLM models.
Unified interface for provider-specific model settings.
Examples:
>>> from potato_head.openai import OpenAIChatSettings
>>> settings = OpenAIChatSettings(temperature=0.7, max_tokens=1000)
>>> model_settings = ModelSettings(settings)
>>>
>>> # Or extract from existing settings
>>> openai_settings = model_settings.settings
MultiSpeakerVoiceConfig ¶
Configuration for multi-speaker text-to-speech.
Configures voices for multiple speakers in a conversation or dialogue.
Examples:
>>> config = MultiSpeakerVoiceConfig(
... speaker_voice_configs=[
... SpeakerVoiceConfig(
... speaker="Alice",
... voice_config=VoiceConfig(
... prebuilt_voice_config=PrebuiltVoiceConfig(voice_name="Puck")
... )
... ),
... SpeakerVoiceConfig(
... speaker="Bob",
... voice_config=VoiceConfig(
... prebuilt_voice_config=PrebuiltVoiceConfig(voice_name="Charon")
... )
... )
... ]
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
speaker_voice_configs
|
List[SpeakerVoiceConfig]
|
List of speaker voice configurations |
required |
Source code in python/scouter/stubs.pyi
speaker_voice_configs
property
¶
The speaker voice configurations.
NumericStats ¶
OauthConfig ¶
OAuth authentication configuration.
Configures OAuth authentication for external APIs.
Examples:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
access_token
|
Optional[str]
|
OAuth access token |
None
|
service_account
|
Optional[str]
|
Service account email |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If configuration is invalid |
Source code in python/scouter/stubs.pyi
OauthConfigValue ¶
Union type for OAuth configuration.
Represents either an access token or service account OAuth configuration.
Examples:
>>> # Using service account
>>> config = OauthConfigValue(
... service_account="[email protected]"
... )
Exactly one of access_token or service_account must be provided.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
access_token
|
Optional[str]
|
OAuth access token |
None
|
service_account
|
Optional[str]
|
Service account email |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If both or neither are provided |
Source code in python/scouter/stubs.pyi
ObservabilityMetrics ¶
Observer ¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uid
|
str
|
Unique identifier for the observer |
required |
Source code in python/scouter/stubs.pyi
OidcConfig ¶
OIDC authentication configuration.
Configures OIDC authentication for external APIs.
Examples:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id_token
|
Optional[str]
|
OIDC ID token |
None
|
service_account
|
Optional[str]
|
Service account email |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If configuration is invalid |
Source code in python/scouter/stubs.pyi
OpenAIChatResponse ¶
Response from OpenAI chat completion API.
This class represents a complete response from the chat completion API, including all choices, usage statistics, and metadata.
Examples:
>>> # Basic usage
>>> response = OpenAIChatResponse(...)
>>> print(response.choices[0].message.content)
>>>
>>> # Accessing metadata
>>> print(f"Model: {response.model}")
>>> print(f"ID: {response.id}")
>>> print(f"Created: {response.created}")
>>>
>>> # Usage statistics
>>> print(f"Total tokens: {response.usage.total_tokens}")
system_fingerprint
property
¶
System fingerprint for backend configuration.
OpenAIChatSettings ¶
OpenAIChatSettings(
max_completion_tokens: Optional[int] = None,
temperature: Optional[float] = None,
top_p: Optional[float] = None,
top_k: Optional[int] = None,
frequency_penalty: Optional[float] = None,
timeout: Optional[float] = None,
parallel_tool_calls: Optional[bool] = None,
seed: Optional[int] = None,
logit_bias: Optional[Dict[str, int]] = None,
stop_sequences: Optional[List[str]] = None,
logprobs: Optional[bool] = None,
audio: Optional[AudioParam] = None,
metadata: Optional[Dict[str, str]] = None,
modalities: Optional[List[str]] = None,
n: Optional[int] = None,
prediction: Optional[Prediction] = None,
presence_penalty: Optional[float] = None,
prompt_cache_key: Optional[str] = None,
reasoning_effort: Optional[str] = None,
safety_identifier: Optional[str] = None,
service_tier: Optional[str] = None,
store: Optional[bool] = None,
stream: Optional[bool] = None,
stream_options: Optional[StreamOptions] = None,
tool_choice: Optional[OpenAIToolChoice] = None,
tools: Optional[List[OpenAITool]] = None,
top_logprobs: Optional[int] = None,
verbosity: Optional[str] = None,
extra_body: Optional[Any] = None,
)
Settings for OpenAI chat completion requests.
This class provides comprehensive configuration options for OpenAI chat completions, including sampling parameters, tool usage, audio output, caching, and more.
Examples:
>>> # Basic settings
>>> settings = OpenAIChatSettings(
... max_completion_tokens=1000,
... temperature=0.7,
... top_p=0.9
... )
>>>
>>> # With tools
>>> func = FunctionDefinition(name="get_weather")
>>> tool = Tool(function=FunctionTool(function=func, type="function"))
>>> settings = OpenAIChatSettings(
... tools=[tool],
... tool_choice=ToolChoice.from_mode(ToolChoiceMode.Auto)
... )
>>>
>>> # With audio output
>>> audio = AudioParam(format="mp3", voice="alloy")
>>> settings = OpenAIChatSettings(
... audio=audio,
... modalities=["text", "audio"]
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_completion_tokens
|
Optional[int]
|
Maximum tokens for completion (including reasoning tokens) |
None
|
temperature
|
Optional[float]
|
Sampling temperature (0.0 to 2.0) |
None
|
top_p
|
Optional[float]
|
Nucleus sampling parameter (0.0 to 1.0) |
None
|
top_k
|
Optional[int]
|
Top-k sampling parameter |
None
|
frequency_penalty
|
Optional[float]
|
Frequency penalty (-2.0 to 2.0) |
None
|
timeout
|
Optional[float]
|
Request timeout in seconds |
None
|
parallel_tool_calls
|
Optional[bool]
|
Enable parallel function calling |
None
|
seed
|
Optional[int]
|
Random seed for deterministic sampling |
None
|
logit_bias
|
Optional[Dict[str, int]]
|
Token bias map (-100 to 100) |
None
|
stop_sequences
|
Optional[List[str]]
|
Stop sequences (max 4) |
None
|
logprobs
|
Optional[bool]
|
Return log probabilities |
None
|
audio
|
Optional[AudioParam]
|
Audio output configuration |
None
|
metadata
|
Optional[Dict[str, str]]
|
Request metadata (max 16 key-value pairs) |
None
|
modalities
|
Optional[List[str]]
|
Output modalities (e.g., ["text", "audio"]) |
None
|
n
|
Optional[int]
|
Number of completions to generate |
None
|
prediction
|
Optional[Prediction]
|
Predicted output configuration |
None
|
presence_penalty
|
Optional[float]
|
Presence penalty (-2.0 to 2.0) |
None
|
prompt_cache_key
|
Optional[str]
|
Cache key for prompt caching |
None
|
reasoning_effort
|
Optional[str]
|
Reasoning effort level (e.g., "low", "medium", "high") |
None
|
safety_identifier
|
Optional[str]
|
User identifier for safety checks |
None
|
service_tier
|
Optional[str]
|
Service tier ("auto", "default", "flex", "priority") |
None
|
store
|
Optional[bool]
|
Store completion for later retrieval |
None
|
stream
|
Optional[bool]
|
Stream response with SSE |
None
|
stream_options
|
Optional[StreamOptions]
|
Streaming configuration |
None
|
tool_choice
|
Optional[ToolChoice]
|
Tool choice configuration |
None
|
tools
|
Optional[List[Tool]]
|
Available tools |
None
|
top_logprobs
|
Optional[int]
|
Number of top log probs to return (0-20) |
None
|
verbosity
|
Optional[str]
|
Response verbosity ("low", "medium", "high") |
None
|
extra_body
|
Optional[Any]
|
Additional request parameters |
None
|
Source code in python/scouter/stubs.pyi
1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 | |
OpenAIEmbeddingConfig ¶
OpenAIEmbeddingConfig(
model: str,
dimensions: Optional[int] = None,
encoding_format: Optional[str] = None,
user: Optional[str] = None,
)
Configuration for OpenAI embedding requests.
This class provides settings for embedding generation, including model selection, dimensions, and encoding format.
Examples:
>>> # Standard configuration
>>> config = OpenAIEmbeddingConfig(
... model="text-embedding-3-small"
... )
>>>
>>> # Custom dimensions
>>> config = OpenAIEmbeddingConfig(
... model="text-embedding-3-large",
... dimensions=512
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
str
|
Model ID for embeddings |
required |
dimensions
|
Optional[int]
|
Number of dimensions for output embeddings |
None
|
encoding_format
|
Optional[str]
|
Format for embeddings ("float" or "base64") |
None
|
user
|
Optional[str]
|
User identifier for tracking |
None
|
Source code in python/scouter/stubs.pyi
OpenAIEmbeddingResponse ¶
Response from OpenAI embedding API.
This class represents a complete response from the embedding API, including all generated embeddings and usage statistics.
Examples:
OpenAITool ¶
Tool for OpenAI chat completions.
This class represents either a function tool or custom tool that can be called by the model.
Examples:
>>> # Function tool
>>> func = FunctionDefinition(name="get_weather")
>>> func_tool = FunctionTool(function=func, type="function")
>>> tool = Tool(function=func_tool)
>>>
>>> # Custom tool
>>> custom = CustomDefinition(name="analyzer")
>>> custom_tool = CustomTool(custom=custom, type="custom")
>>> tool = Tool(custom=custom_tool)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
function
|
Optional[FunctionTool]
|
Function tool definition |
None
|
custom
|
Optional[CustomTool]
|
Custom tool definition |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If both or neither tool types are provided |
Source code in python/scouter/stubs.pyi
OpenAIToolChoice ¶
Tool choice configuration for chat completions.
This class configures how the model should handle tool calling, supporting multiple modes including simple mode selection, specific tool choice, and allowed tools constraints.
Examples:
>>> # Simple mode
>>> choice = ToolChoice.from_mode(ToolChoiceMode.Auto)
>>>
>>> # Specific function
>>> choice = ToolChoice.from_function("get_weather")
>>>
>>> # Custom tool
>>> choice = ToolChoice.from_custom("custom_tool")
>>>
>>> # Allowed tools
>>> allowed = AllowedTools.from_function_names(
... AllowedToolsMode.Auto,
... ["get_weather"]
... )
>>> choice = ToolChoice.from_allowed_tools(allowed)
from_allowed_tools
staticmethod
¶
Create tool choice from allowed tools.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
allowed_tools
|
AllowedTools
|
Allowed tools configuration |
required |
Returns:
| Name | Type | Description |
|---|---|---|
ToolChoice |
OpenAIToolChoice
|
Tool choice configured with allowed tools |
Source code in python/scouter/stubs.pyi
from_custom
staticmethod
¶
Create tool choice for custom tool.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
custom_name
|
str
|
Name of the custom tool to call |
required |
Returns:
| Name | Type | Description |
|---|---|---|
ToolChoice |
OpenAIToolChoice
|
Tool choice configured for custom tool |
Source code in python/scouter/stubs.pyi
from_function
staticmethod
¶
Create tool choice for specific function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
function_name
|
str
|
Name of the function to call |
required |
Returns:
| Name | Type | Description |
|---|---|---|
ToolChoice |
OpenAIToolChoice
|
Tool choice configured for function |
Source code in python/scouter/stubs.pyi
from_mode
staticmethod
¶
Create tool choice from mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
ToolChoiceMode
|
The tool choice mode |
required |
Returns:
| Name | Type | Description |
|---|---|---|
ToolChoice |
OpenAIToolChoice
|
Tool choice configured with mode |
Source code in python/scouter/stubs.pyi
OpsGenieDispatchConfig ¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
team
|
str
|
Opsegenie team to be notified in the event of drift |
required |
Source code in python/scouter/stubs.pyi
OtelExportConfig ¶
OtelExportConfig(
endpoint: Optional[str],
protocol: OtelProtocol = OtelProtocol.HttpBinary,
timeout: Optional[int] = None,
compression: Optional[CompressionType] = None,
headers: Optional[dict[str, str]] = None,
)
Configuration for exporting spans.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
Optional[str]
|
The endpoint for exporting spans. Can be either an HTTP or gRPC endpoint. |
required |
protocol
|
Protocol
|
The protocol to use for exporting spans. Defaults to HttpBinary. |
HttpBinary
|
timeout
|
Optional[int]
|
The timeout for requests in seconds. |
None
|
compression
|
Optional[CompressionType]
|
The compression type for requests. |
None
|
headers
|
Optional[dict[str, str]]
|
Optional HTTP headers to include in requests. |
None
|
Source code in python/scouter/stubs.pyi
compression
property
¶
Get the compression type used for exporting spans.
OtelProtocol ¶
Enumeration of protocols for HTTP exporting.
Outcome ¶
Code execution outcome status.
Indicates the result of executing generated code.
Examples:
PageSpan ¶
ParallelAiSearch ¶
Parallel.ai search tool configuration.
Configures search using the Parallel.ai engine.
Examples:
>>> search = ParallelAiSearch(
... api_key="my-api-key",
... custom_configs={
... "source_policy": {"include_domains": ["google.com"]},
... "maxResults": 10
... }
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_key
|
Optional[str]
|
Parallel.ai API key |
None
|
custom_configs
|
Optional[Dict[str, Any]]
|
Custom configuration parameters |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If configuration is invalid |
Source code in python/scouter/stubs.pyi
Part ¶
Part(
data: Union[
str,
Blob,
FileData,
FunctionCall,
FunctionResponse,
ExecutableCode,
CodeExecutionResult,
],
thought: Optional[bool] = None,
thought_signature: Optional[str] = None,
part_metadata: Optional[PartMetadata] = None,
media_resolution: Optional[MediaResolution] = None,
video_metadata: Optional[VideoMetadata] = None,
)
A part of a multi-part message.
Represents a single piece of content which can be text, media, function calls, or other data types.
Examples:
>>> # Image part
>>> part = Part(
... data=Blob(
... mime_type="image/png",
... data=base64_encoded_data
... )
... )
>>> # Function call part
>>> part = Part(
... data=FunctionCall(
... name="get_weather",
... args={"location": "NYC"}
... )
... )
>>> # Part with metadata
>>> part = Part(
... data="Analyze this carefully",
... thought=True,
... media_resolution=MediaResolution.MediaResolutionHigh
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Union[str, Blob, FileData, FunctionCall, FunctionResponse, ExecutableCode, CodeExecutionResult]
|
The content data (text, blob, function call, etc.) |
required |
thought
|
Optional[bool]
|
Whether this is part of the model's reasoning |
None
|
thought_signature
|
Optional[str]
|
Signature for reusing thoughts |
None
|
part_metadata
|
Optional[PartMetadata]
|
Custom metadata |
None
|
media_resolution
|
Optional[MediaResolution]
|
Media resolution level |
None
|
video_metadata
|
Optional[VideoMetadata]
|
Video-specific metadata |
None
|
Source code in python/scouter/stubs.pyi
data
property
¶
data: Union[
str,
Blob,
FileData,
FunctionCall,
FunctionResponse,
ExecutableCode,
CodeExecutionResult,
]
The content data.
PartMetadata ¶
Custom metadata for content parts.
Allows arbitrary structured metadata to be attached to parts.
Examples:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
struct_
|
Optional[Dict[str, Any]]
|
Arbitrary metadata dictionary |
None
|
Source code in python/scouter/stubs.pyi
PartialArgs ¶
PartialArgs(
json_path: str,
will_continue: Optional[bool] = None,
null_value: Optional[bool] = None,
number_value: Optional[float] = None,
string_value: Optional[str] = None,
bool_value: Optional[bool] = None,
)
Partial function call arguments for streaming.
Represents incrementally streamed function call arguments.
Examples:
>>> args = PartialArgs(
... json_path="$.location",
... string_value="New York",
... will_continue=True
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_path
|
str
|
JSON Path (RFC 9535) to the argument |
required |
will_continue
|
Optional[bool]
|
Whether more parts follow for this path |
None
|
null_value
|
Optional[bool]
|
Null value |
None
|
number_value
|
Optional[float]
|
Numeric value |
None
|
string_value
|
Optional[str]
|
String value |
None
|
bool_value
|
Optional[bool]
|
Boolean value |
None
|
Source code in python/scouter/stubs.pyi
PhishBlockThreshold ¶
Phishing/malicious URL blocking threshold.
Controls the confidence level required to block potentially malicious URLs.
Examples:
>>> threshold = PhishBlockThreshold.BlockMediumAndAbove
>>> threshold.value
'BLOCK_MEDIUM_AND_ABOVE'
BlockHighAndAbove
class-attribute
instance-attribute
¶
Block high confidence and above
BlockHigherAndAbove
class-attribute
instance-attribute
¶
Block higher confidence and above
BlockLowAndAbove
class-attribute
instance-attribute
¶
Block low confidence and above
BlockMediumAndAbove
class-attribute
instance-attribute
¶
Block medium confidence and above
BlockOnlyExtremelyHigh
class-attribute
instance-attribute
¶
Block only extremely high confidence
BlockVeryHighAndAbove
class-attribute
instance-attribute
¶
Block very high confidence and above
PhishBlockThresholdUnspecified
class-attribute
instance-attribute
¶
Unspecified threshold
PlainTextSource ¶
Plain text document source.
Plain text document data.
Examples:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
str
|
Plain text content |
required |
Source code in python/scouter/stubs.pyi
PrebuiltVoiceConfig ¶
Configuration for prebuilt voice selection.
Selects a prebuilt voice for text-to-speech generation.
Examples:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
voice_name
|
str
|
Name of the prebuilt voice |
required |
Source code in python/scouter/stubs.pyi
PredictRequest ¶
Prediction API request.
Generic prediction request for embedding and other endpoints.
Examples:
>>> request = PredictRequest(
... instances=[{"content": {"parts": [{"text": "Hello"}]}}],
... parameters={"outputDimensionality": 768}
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instances
|
Any
|
Input instances |
required |
parameters
|
Optional[Any]
|
Request parameters |
None
|
Source code in python/scouter/stubs.pyi
PredictResponse ¶
Prediction ¶
Configuration for predicted outputs in OpenAI requests.
This class provides configuration for predicted outputs, which can greatly improve response times when large parts of the model response are known ahead of time.
Examples:
>>> content = Content(text="Expected response")
>>> prediction = Prediction(type="content", content=content)
>>> prediction.type
'content'
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type
|
str
|
Type of prediction (typically "content") |
required |
content
|
Content
|
The predicted content |
required |
Source code in python/scouter/stubs.pyi
PredictionContentPart ¶
Content part for predicted outputs in OpenAI requests.
This class represents a single content part within a predicted output, used to improve response times when large parts of the response are known.
Examples:
>>> part = PredictionContentPart(type="text", text="Hello, world!")
>>> part.type
'text'
>>> part.text
'Hello, world!'
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type
|
str
|
Type of content (typically "text") |
required |
text
|
str
|
The predicted text content |
required |
Source code in python/scouter/stubs.pyi
model_dump ¶
Convert content part to a dictionary.
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dict[str, Any]: Dictionary representation of content part |
ProfileStatusRequest ¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Model name |
required |
space
|
str
|
Model space |
required |
version
|
str
|
Model version |
required |
drift_type
|
DriftType
|
Profile drift type. A (repo/name/version can be associated with more than one drift type) |
required |
active
|
bool
|
Whether to set the profile as active or inactive |
required |
Source code in python/scouter/stubs.pyi
Prompt ¶
Prompt(
messages: PromptMessage,
model: str,
provider: Provider | str,
system_instructions: Optional[PromptMessage] = None,
model_settings: Optional[
ModelSettings
| OpenAIChatSettings
| GeminiSettings
| AnthropicSettings
] = None,
output_type: Optional[Any] = None,
)
Prompt for interacting with an LLM API.
The Prompt class handles message parsing, provider-specific formatting, and structured output configuration for LLM interactions.
Main parsing logic: 1. Extract model settings if provided, otherwise use provider default settings 2. Messages and system instructions are parsed into provider-specific formats (OpenAIChatMessage, AnthropicMessage, or GeminiContent) 3. String messages are automatically converted to appropriate message types based on provider 4. Lists of messages are parsed with each item checked and converted accordingly 5. After parsing, a complete provider request structure is built
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
PromptMessage
|
The user message(s) to use in the prompt |
required |
model
|
str
|
The model identifier to use (e.g., "gpt-4o", "claude-3-5-sonnet-20241022") |
required |
provider
|
Provider | str
|
The provider to use for the prompt (e.g., "openai", "anthropic", "google") |
required |
system_instruction
|
Optional[PromptMessage]
|
Optional system instruction(s). Can be: |
required |
model_settings
|
Optional[ModelSettings | OpenAIChatSettings | GeminiSettings | AnthropicSettings]
|
Optional model-specific settings (temperature, max_tokens, etc.) If None, provider default settings will be used |
None
|
output_type
|
Optional[Pydantic BaseModel | Score]
|
Optional structured output format.The provided format will be parsed into a JSON schema for structured outputs |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If message types are invalid or incompatible with the provider |
Source code in python/scouter/stubs.pyi
all_messages
property
¶
All messages in the prompt, including system instructions, user messages, tools, etc. This is helpful for accessing the complete set of messages in the prompt.
anthropic_message
property
¶
The last user message as an Anthropic MessageParam object. Returns the last user message converted to Anthropic MessageParam format. Raises: TypeError: If the provider is not Anthropic
anthropic_messages
property
¶
The user messages as Anthropic MessageParam objects. Returns the user messages converted to Anthropic MessageParam format. Raises: TypeError: If the provider is not Anthropic
gemini_message
property
¶
The last user message as a Google GeminiContent object. Returns the last user message converted to Google GeminiContent format. Raises: TypeError: If the provider is not Google/Gemini
gemini_messages
property
¶
The user messages as Google GeminiContent objects. Returns the user messages converted to Google GeminiContent format. Raises: TypeError: If the provider is not Google/Gemini
message
property
¶
The last user message in the prompt.
Returns a list of provider-specific message objects that were parsed from the input during initialization.
messages
property
¶
The user message(s) in the prompt.
Returns a list of provider-specific message objects that were parsed from the input during initialization.
model_identifier
property
¶
Concatenation of provider and model for identifying the model.
This is commonly used with frameworks like pydantic_ai to identify which model to use for an agent.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Format is "{provider}:{model}" (e.g., "openai:gpt-4o") |
model_settings
property
¶
The model settings used for the prompt.
Returns the provider-specific settings (OpenAIChatSettings, GeminiSettings, or AnthropicSettings) wrapped in a ModelSettings union type.
openai_message
property
¶
The last user message as an OpenAI ChatMessage object. Returns the last user message converted to OpenAI ChatMessage format. Raises: TypeError: If the provider is not OpenAI
openai_messages
property
¶
The user messages as OpenAI ChatMessage objects. Returns the user messages converted to OpenAI ChatMessage format. Raises: TypeError: If the provider is not OpenAI
parameters
property
¶
Extracted named parameters from the prompt messages.
Returns a list of all variable placeholders found in the prompt using the ${variable_name} syntax. These can be bound to values using the bind() or bind_mut() methods.
response_json_schema
property
¶
The JSON schema for structured output responses if provided.
Returns the raw JSON schema string that was generated from the output_type parameter during initialization. Returns None if no response format was specified.
response_json_schema_pretty
property
¶
The pretty-printed JSON schema for structured output responses if provided.
system_instructions
property
¶
The system instruction message(s) in the prompt.
Returns a list of provider-specific message objects for system instructions. Returns an empty list if no system instructions were provided.
bind ¶
bind(
name: Optional[str] = None,
value: Optional[str | int | float | bool | list] = None,
**kwargs: Any
) -> Prompt
Bind variables in the prompt (immutable operation).
Creates a new Prompt object with variables bound to values. This iterates over all user messages and replaces ${variable_name} placeholders with the provided values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
Optional[str]
|
The name of a single variable to bind (without ${} syntax) |
None
|
value
|
Optional[str | int | float | bool | list]
|
The value to bind the variable to. Must be JSON serializable. |
None
|
**kwargs
|
Any
|
Additional variables to bind. Keys are variable names, values are the values to bind. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
Prompt |
Prompt
|
A new Prompt object with variables bound. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If no binding arguments are provided or if values are not JSON serializable. |
Example
prompt = Prompt(
messages="Hello ${name}, you scored ${score}/100",
model="gpt-4o",
provider="openai",
)
# Single variable binding
bound = prompt.bind("name", "Alice")
# Multiple variable binding
bound = prompt.bind(name="Alice", score=95)
# Original prompt is unchanged
print(prompt.parameters) # ["name", "score"]
print(bound.parameters) # []
Source code in python/scouter/stubs.pyi
bind_mut ¶
bind_mut(
name: Optional[str] = None,
value: Optional[str | int | float | bool | list] = None,
**kwargs: Any
) -> None
Bind variables in the prompt (mutable operation).
Modifies the current Prompt object by binding variables to values. This iterates over all user messages and replaces ${variable_name} placeholders with the provided values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
Optional[str]
|
The name of a single variable to bind (without ${} syntax) |
None
|
value
|
Optional[str | int | float | bool | list]
|
The value to bind the variable to. Must be JSON serializable. |
None
|
**kwargs
|
Any
|
Additional variables to bind. Keys are variable names, values are the values to bind. |
{}
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If no binding arguments are provided or if values are not JSON serializable. |
Example
Source code in python/scouter/stubs.pyi
from_path
staticmethod
¶
Load a prompt from a JSON file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
The path to the prompt JSON file. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Prompt |
Prompt
|
The loaded prompt object. |
Raises:
| Type | Description |
|---|---|
IOError
|
If the file cannot be read |
ValueError
|
If the JSON is invalid or cannot be parsed into a Prompt |
Source code in python/scouter/stubs.pyi
model_dump ¶
Returns the Prompt request object as a dictionary. For instance, if Provider is OpenAI, this will return the OpenAIChatRequest as a dict that can be passed to the OpenAI SDK.
model_dump_json ¶
Serialize the Prompt to a JSON string.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
JSON string representation of the Prompt. |
Example
Source code in python/scouter/stubs.pyi
model_validate_json
staticmethod
¶
Validate and parse a Prompt from a JSON string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_string
|
str
|
A JSON string representation of a Prompt object. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Prompt |
Prompt
|
The parsed Prompt object. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the JSON is invalid or cannot be parsed into a Prompt |
Example
Source code in python/scouter/stubs.pyi
save_prompt ¶
Save the prompt to a JSON file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Optional[Path]
|
The path to save the prompt to. If None, saves to the current working directory with default filename "prompt.json". |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Path |
Path
|
The path where the prompt was saved. |
Example
Source code in python/scouter/stubs.pyi
PromptFeedback ¶
PromptTokenDetails ¶
Detailed token usage for input prompt.
This class provides information about tokens used in the prompt, including cached tokens and audio tokens.
Examples:
Provider ¶
Provider enumeration for LLM services.
Specifies which LLM provider to use for prompts, agents, and workflows.
Examples:
PsiAlertConfig ¶
PsiAlertConfig(
dispatch_config: Optional[
SlackDispatchConfig | OpsGenieDispatchConfig
] = None,
schedule: Optional[str | CommonCrons] = None,
features_to_monitor: List[str] = [],
threshold: Optional[
PsiThresholdType
] = PsiChiSquareThreshold(),
)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dispatch_config
|
Optional[SlackDispatchConfig | OpsGenieDispatchConfig]
|
Alert dispatch configuration to use. Defaults to an internal "Console" type where the alerts will be logged to the console |
None
|
schedule
|
Optional[str | CommonCrons]
|
Schedule to run monitor. Defaults to daily at midnight |
None
|
features_to_monitor
|
List[str]
|
List of features to monitor. Defaults to empty list, which means all features |
[]
|
threshold
|
Optional[PsiThresholdType]
|
Configuration that helps determine how to calculate PSI critical values. Defaults to PsiChiSquareThreshold, which uses the chi-square distribution. |
PsiChiSquareThreshold()
|
Source code in python/scouter/stubs.pyi
features_to_monitor
property
writable
¶
Return the features to monitor
PsiChiSquareThreshold ¶
Uses the asymptotic chi-square distribution of PSI.
The chi-square method is generally more statistically rigorous than normal approximation, especially for smaller sample sizes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
alpha
|
float
|
Significance level (0.0 to 1.0, exclusive). Common values: 0.05 (95% confidence), 0.01 (99% confidence) |
0.05
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If alpha not in range (0.0, 1.0) |
Source code in python/scouter/stubs.pyi
PsiDriftConfig ¶
PsiDriftConfig(
space: str = "__missing__",
name: str = "__missing__",
version: str = "0.1.0",
alert_config: PsiAlertConfig = PsiAlertConfig(),
config_path: Optional[Path] = None,
categorical_features: Optional[list[str]] = None,
binning_strategy: (
QuantileBinning | EqualWidthBinning
) = QuantileBinning(num_bins=10),
)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
space
|
str
|
Model space |
'__missing__'
|
name
|
str
|
Model name |
'__missing__'
|
version
|
str
|
Model version. Defaults to 0.1.0 |
'0.1.0'
|
alert_config
|
PsiAlertConfig
|
Alert configuration |
PsiAlertConfig()
|
config_path
|
Optional[Path]
|
Optional path to load config from. |
None
|
categorical_features
|
Optional[list[str]]
|
List of features to treat as categorical for PSI calculation. |
None
|
binning_strategy
|
QuantileBinning | EqualWidthBinning
|
Strategy for binning continuous features during PSI calculation. Supports: - QuantileBinning (R-7 method, Hyndman & Fan Type 7). - EqualWidthBinning which divides the range of values into fixed-width bins. Default is QuantileBinning with 10 bins. You can also specify methods like Doane's rule with EqualWidthBinning. |
QuantileBinning(num_bins=10)
|
Source code in python/scouter/stubs.pyi
binning_strategy
property
writable
¶
binning_strategy
categorical_features
property
writable
¶
list of categorical features
load_from_json_file
staticmethod
¶
Load config from json file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Path to json file to load config from. |
required |
model_dump_json ¶
update_config_args ¶
update_config_args(
space: Optional[str] = None,
name: Optional[str] = None,
version: Optional[str] = None,
alert_config: Optional[PsiAlertConfig] = None,
categorical_features: Optional[list[str]] = None,
binning_strategy: Optional[
QuantileBinning | EqualWidthBinning
] = None,
) -> None
Inplace operation that updates config args
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
space
|
Optional[str]
|
Model space |
None
|
name
|
Optional[str]
|
Model name |
None
|
version
|
Optional[str]
|
Model version |
None
|
alert_config
|
Optional[PsiAlertConfig]
|
Alert configuration |
None
|
categorical_features
|
Optional[list[str]]
|
Categorical features |
None
|
binning_strategy
|
Optional[QuantileBinning | EqualWidthBinning]
|
Binning strategy |
None
|
Source code in python/scouter/stubs.pyi
PsiDriftMap ¶
Drift map of features
features
property
¶
Returns dictionary of features and their reported drift, if any
model_dump_json ¶
model_validate_json
staticmethod
¶
Load drift map from json file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_string
|
str
|
JSON string representation of the drift map |
required |
save_to_json ¶
Save drift map to json file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Optional[Path]
|
Optional path to save the drift map. If None, outputs to |
None
|
Returns:
| Type | Description |
|---|---|
Path
|
Path to the saved json file |
Source code in python/scouter/stubs.pyi
PsiDriftProfile ¶
from_file
staticmethod
¶
Load drift profile from file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Path to the file |
required |
model_dump ¶
model_dump_json ¶
model_validate
staticmethod
¶
Load drift profile from dictionary
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Dict[str, Any]
|
DriftProfile dictionary |
required |
model_validate_json
staticmethod
¶
Load drift profile from json
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_string
|
str
|
JSON string representation of the drift profile |
required |
save_to_json ¶
Save drift profile to json file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Optional[Path]
|
Optional path to save the drift profile. If None, outputs to |
None
|
Returns:
| Type | Description |
|---|---|
Path
|
Path to the saved json file |
Source code in python/scouter/stubs.pyi
update_config_args ¶
update_config_args(
space: Optional[str] = None,
name: Optional[str] = None,
version: Optional[str] = None,
alert_config: Optional[PsiAlertConfig] = None,
categorical_features: Optional[list[str]] = None,
binning_strategy: Optional[
QuantileBinning | EqualWidthBinning
] = None,
) -> None
Inplace operation that updates config args
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
Optional[str]
|
Model name |
None
|
space
|
Optional[str]
|
Model space |
None
|
version
|
Optional[str]
|
Model version |
None
|
alert_config
|
Optional[PsiAlertConfig]
|
Alert configuration |
None
|
categorical_features
|
Optional[list[str]]
|
Categorical Features |
None
|
binning_strategy
|
Optional[QuantileBinning | EqualWidthBinning]
|
Binning strategy |
None
|
Source code in python/scouter/stubs.pyi
PsiFeatureDriftProfile ¶
PsiFixedThreshold ¶
Uses a predetermined PSI threshold value, similar to traditional "rule of thumb" approaches (e.g., 0.10 for moderate drift, 0.25 for significant drift).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
threshold
|
float
|
Fixed PSI threshold value (must be positive). Common industry values: 0.10, 0.25 |
0.25
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If threshold is not positive |
Source code in python/scouter/stubs.pyi
PsiNormalThreshold ¶
Uses the asymptotic normal distribution of PSI to calculate critical values for population drift detection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
alpha
|
float
|
Significance level (0.0 to 1.0, exclusive). Common values: 0.05 (95% confidence), 0.01 (99% confidence) |
0.05
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If alpha not in range (0.0, 1.0) |
Source code in python/scouter/stubs.pyi
PsiRecord ¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uid
|
str
|
Unique identifier for the psi record. Must correspond to an existing entity in Scouter. |
required |
feature
|
str
|
Feature name |
required |
bin_id
|
int
|
Bundle ID |
required |
bin_count
|
int
|
Bundle ID |
required |
Source code in python/scouter/stubs.pyi
model_dump_json ¶
QuantileBinning ¶
This strategy uses the R-7 quantile method (Hyndman & Fan Type 7) to compute bin edges. It is the default quantile method in R and provides continuous, median-unbiased estimates that are approximately unbiased for normal distributions.
The R-7 method defines quantiles using
- m = 1 - p
- j = floor(n * p + m)
- h = n * p + m - j
- Q(p) = (1 - h) * x[j] + h * x[j+1]
Reference
Hyndman, R. J. & Fan, Y. (1996). "Sample quantiles in statistical packages." The American Statistician, 50(4), pp. 361–365. PDF: https://www.amherst.edu/media/view/129116/original/Sample+Quantiles.pdf
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_bins
|
int
|
Number of bins to compute using the R-7 quantile method. |
10
|
Source code in python/scouter/stubs.pyi
num_bins
property
writable
¶
The number of bins you want created using the r7 quantile method
Quantiles ¶
Queue ¶
Individual queue associated with a drift profile
insert ¶
Insert a record into the queue
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item
|
Union[Features, Metrics, GenAIEvalRecord]
|
Item to insert into the queue. Can be an instance for Features, Metrics, or GenAIEvalRecord. |
required |
Example
Source code in python/scouter/stubs.pyi
QueueFeature ¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the feature |
required |
value
|
Any
|
Value of the feature. Can be an int, float, or string. |
required |
Example
Source code in python/scouter/stubs.pyi
categorical
staticmethod
¶
Create a categorical feature
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the feature |
required |
value
|
str
|
Value of the feature |
required |
float
staticmethod
¶
Create a float feature
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the feature |
required |
value
|
float
|
Value of the feature |
required |
int
staticmethod
¶
Create an integer feature
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the feature |
required |
value
|
int
|
Value of the feature |
required |
string
staticmethod
¶
Create a string feature
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the feature |
required |
value
|
str
|
Value of the feature |
required |
RabbitMQConfig ¶
RabbitMQConfig(
host: Optional[str] = None,
port: Optional[int] = None,
username: Optional[str] = None,
password: Optional[str] = None,
queue: Optional[str] = None,
max_retries: int = 3,
)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
host
|
Optional[str]
|
RabbitMQ host. If not provided, the value of the RABBITMQ_HOST environment variable is used. |
None
|
port
|
Optional[int]
|
RabbitMQ port. If not provided, the value of the RABBITMQ_PORT environment variable is used. |
None
|
username
|
Optional[str]
|
RabbitMQ username. If not provided, the value of the RABBITMQ_USERNAME environment variable is used. |
None
|
password
|
Optional[str]
|
RabbitMQ password. If not provided, the value of the RABBITMQ_PASSWORD environment variable is used. |
None
|
queue
|
Optional[str]
|
RabbitMQ queue to publish messages to. If not provided, the value of the RABBITMQ_QUEUE environment variable is used. |
None
|
max_retries
|
int
|
Maximum number of retries to attempt when publishing messages. Default is 3. |
3
|
Source code in python/scouter/stubs.pyi
RagChunk ¶
RagResource ¶
RAG corpus and file specification.
Specifies which RAG corpus and optionally which files to use.
Examples:
>>> # Use entire corpus
>>> resource = RagResource(
... rag_corpus="projects/my-project/locations/us/ragCorpora/my-corpus"
... )
>>> # Use specific files from corpus
>>> resource = RagResource(
... rag_corpus="projects/my-project/locations/us/ragCorpora/my-corpus",
... rag_file_ids=["file1", "file2"]
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rag_corpus
|
Optional[str]
|
RAG corpus resource name |
None
|
rag_file_ids
|
Optional[List[str]]
|
List of file IDs within the corpus |
None
|
Source code in python/scouter/stubs.pyi
RagRetrievalConfig ¶
RagRetrievalConfig(
top_k: Optional[int] = None,
filter: Optional[Filter] = None,
ranking: Optional[Ranking] = None,
)
Configuration for RAG retrieval behavior.
Controls filtering, ranking, and other retrieval parameters.
Examples:
>>> config = RagRetrievalConfig(
... top_k=5,
... filter=Filter(metadata_filter="category='technical'"),
... ranking=Ranking(
... rank_service=RankService(model_name="semantic-ranker-512@latest")
... )
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
top_k
|
Optional[int]
|
Number of top results to retrieve |
None
|
filter
|
Optional[Filter]
|
Filtering configuration |
None
|
ranking
|
Optional[Ranking]
|
Ranking configuration |
None
|
Source code in python/scouter/stubs.pyi
RankService ¶
Rank service configuration.
Configures the ranking service for RAG results.
Examples:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_name
|
Optional[str]
|
Model name for ranking |
None
|
Source code in python/scouter/stubs.pyi
Ranking ¶
Ranking and reranking configuration.
Configures how RAG results are ranked.
Examples:
>>> # Using rank service
>>> ranking = Ranking(
... rank_service=RankService(model_name="semantic-ranker-512@latest")
... )
>>> # Using LLM ranker
>>> ranking = Ranking(
... llm_ranker=LlmRanker(model_name="gemini-1.5-flash")
... )
Exactly one of rank_service or llm_ranker must be provided.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rank_service
|
Optional[RankService]
|
Rank service configuration |
None
|
llm_ranker
|
Optional[LlmRanker]
|
LLM ranker configuration |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If both or neither are provided |
Source code in python/scouter/stubs.pyi
RankingConfig ¶
RedactedThinkingBlock ¶
RedactedThinkingBlockParam ¶
Redacted thinking content block parameter.
Redacted version of Claude's thinking process.
Examples:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
str
|
Redacted thinking data |
required |
Source code in python/scouter/stubs.pyi
RedisConfig ¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
address
|
str
|
Redis address. If not provided, the value of the REDIS_ADDR environment variable is used and defaults to "redis://localhost:6379". |
None
|
channel
|
str
|
Redis channel to publish messages to. If not provided, the value of the REDIS_CHANNEL environment variable is used and defaults to "scouter_monitoring". |
required |
Source code in python/scouter/stubs.pyi
ResponseLogProbs ¶
tokens
property
¶
The log probabilities of the tokens in the response. This is primarily used for debugging and analysis purposes.
ResponseType ¶
Type of structured response.
Indicates the expected response format for structured outputs.
Examples:
Retrieval ¶
Retrieval tool configuration.
Enables the model to retrieve information from external sources.
Examples:
>>> retrieval = Retrieval(
... source=RetrievalSource(
... vertex_ai_search=VertexAISearch(
... datastore="projects/my-project/..."
... )
... ),
... disable_attribution=False
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
RetrievalSource
|
Retrieval source configuration |
required |
disable_attribution
|
Optional[bool]
|
Whether to disable attribution |
None
|
Source code in python/scouter/stubs.pyi
RetrievalConfig ¶
Configuration for retrieval operations.
Provides location and language context for retrieval tools.
Examples:
>>> config = RetrievalConfig(
... lat_lng=LatLng(latitude=37.7749, longitude=-122.4194),
... language_code="en-US"
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lat_lng
|
LatLng
|
Geographic coordinates |
required |
language_code
|
str
|
Language code |
required |
Source code in python/scouter/stubs.pyi
RetrievalMetadata ¶
Metadata about retrieval operations.
Contains scores and information about retrieval behavior.
Examples:
google_search_dynamic_retrieval_score
property
¶
Score for dynamic retrieval likelihood.
RetrievalSource ¶
RetrievalSource(
vertex_ai_search: Optional[VertexAISearch] = None,
vertex_rag_store: Optional[VertexRagStore] = None,
external_api: Optional[ExternalApi] = None,
)
Union type for retrieval sources.
Represents one of several retrieval source types.
Examples:
Exactly one source type must be provided.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vertex_ai_search
|
Optional[VertexAISearch]
|
Vertex AI Search configuration |
None
|
vertex_rag_store
|
Optional[VertexRagStore]
|
Vertex RAG Store configuration |
None
|
external_api
|
Optional[ExternalApi]
|
External API configuration |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If configuration is invalid |
Source code in python/scouter/stubs.pyi
RetrievedContext ¶
Rice ¶
Role ¶
Message role in conversation.
Indicates the role of a message sender in a conversation.
Examples:
RouteMetrics ¶
RoutingConfig ¶
Model routing configuration wrapper.
Wraps the routing mode configuration.
Examples:
>>> config = RoutingConfig(
... routing_config=RoutingConfigMode(
... auto_mode=AutoRoutingMode(
... model_routing_preference=ModelRoutingPreference.Balanced
... )
... )
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
routing_config
|
RoutingConfigMode
|
The routing mode configuration |
required |
Source code in python/scouter/stubs.pyi
RoutingConfigMode ¶
RoutingConfigMode(
auto_mode: Optional[AutoRoutingMode] = None,
manual_mode: Optional[ManualRoutingMode] = None,
)
Union type for routing configuration modes.
Represents either automatic or manual routing configuration.
Examples:
>>> # Automatic routing
>>> mode = RoutingConfigMode(
... auto_mode=AutoRoutingMode(
... model_routing_preference=ModelRoutingPreference.Balanced
... )
... )
>>> # Manual routing
>>> mode = RoutingConfigMode(
... manual_mode=ManualRoutingMode(model_name="gemini-2.0-flash-exp")
... )
Exactly one of auto_mode or manual_mode must be provided.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
auto_mode
|
Optional[AutoRoutingMode]
|
Automatic routing configuration |
None
|
manual_mode
|
Optional[ManualRoutingMode]
|
Manual routing configuration |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If both or neither modes are provided |
Source code in python/scouter/stubs.pyi
RustyLogger ¶
debug ¶
Log a debug message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
Message to log. |
required |
args
|
Any
|
Additional arguments to format the message. |
()
|
error ¶
Log an error message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
Message to log. |
required |
args
|
Any
|
Additional arguments to format the message. |
()
|
get_logger
staticmethod
¶
Get a logger with the provided name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
Optional[LoggingConfig]
|
Logging configuration options. |
None
|
info ¶
Log an info message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
Message to log. |
required |
args
|
Any
|
Additional arguments to format the message. |
()
|
setup_logging
staticmethod
¶
Setup logging with the provided configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
Optional[LoggingConfig]
|
Logging configuration options. |
None
|
trace ¶
Log a trace message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
Message to log. |
required |
args
|
Any
|
Additional arguments to format the message. |
()
|
warn ¶
Log a warning message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
Message to log. |
required |
args
|
Any
|
Additional arguments to format the message. |
()
|
SafetyRating ¶
Safety rating for content.
Provides detailed safety assessment including probability and severity.
Examples:
>>> rating = SafetyRating(
... category=HarmCategory.HarmCategoryHateSpeech,
... probability=HarmProbability.Low,
... probability_score=0.2,
... severity=HarmSeverity.HarmSeverityLow,
... severity_score=0.15,
... blocked=False
... )
overwritten_threshold
property
¶
Overwritten threshold for image output.
SafetySetting ¶
Safety filtering configuration for harmful content.
Controls how the model handles potentially harmful content in specific harm categories. Each setting applies to one harm category.
Examples:
>>> # Block hate speech with medium threshold
>>> setting = SafetySetting(
... category=HarmCategory.HarmCategoryHateSpeech,
... threshold=HarmBlockThreshold.BlockMediumAndAbove
... )
>>> # Disable blocking for harassment
>>> setting = SafetySetting(
... category=HarmCategory.HarmCategoryHarassment,
... threshold=HarmBlockThreshold.BlockNone
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
category
|
HarmCategory
|
The harm category to configure |
required |
threshold
|
HarmBlockThreshold
|
The blocking threshold to apply |
required |
Source code in python/scouter/stubs.pyi
Schema ¶
Schema(
type: Optional[SchemaType] = None,
format: Optional[str] = None,
title: Optional[str] = None,
description: Optional[str] = None,
nullable: Optional[bool] = None,
enum_: Optional[List[str]] = None,
max_items: Optional[str] = None,
min_items: Optional[str] = None,
properties: Optional[Dict[str, Schema]] = None,
required: Optional[List[str]] = None,
min_properties: Optional[str] = None,
max_properties: Optional[str] = None,
min_length: Optional[str] = None,
max_length: Optional[str] = None,
pattern: Optional[str] = None,
example: Optional[Any] = None,
any_of: Optional[List[Schema]] = None,
property_ordering: Optional[List[str]] = None,
default: Optional[Any] = None,
items: Optional[Schema] = None,
minimum: Optional[float] = None,
maximum: Optional[float] = None,
)
JSON Schema definition for structured outputs and parameters.
Defines the structure, types, and constraints for JSON data used in function parameters and structured outputs. Based on OpenAPI 3.0 schema.
Examples:
>>> # Simple string schema
>>> schema = Schema(
... type=SchemaType.String,
... description="User's name",
... min_length="1",
... max_length="100"
... )
>>> # Object schema with properties
>>> schema = Schema(
... type=SchemaType.Object,
... properties={
... "name": Schema(type=SchemaType.String),
... "age": Schema(type=SchemaType.Integer, minimum=0.0)
... },
... required=["name"]
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type
|
Optional[SchemaType]
|
The data type (string, number, object, etc.) |
None
|
format
|
Optional[str]
|
Format hint for the type (e.g., "date-time") |
None
|
title
|
Optional[str]
|
Human-readable title |
None
|
description
|
Optional[str]
|
Description of the schema |
None
|
nullable
|
Optional[bool]
|
Whether null values are allowed |
None
|
enum_
|
Optional[List[str]]
|
List of allowed values |
None
|
max_items
|
Optional[str]
|
Maximum array length (for arrays) |
None
|
min_items
|
Optional[str]
|
Minimum array length (for arrays) |
None
|
properties
|
Optional[Dict[str, Schema]]
|
Object properties (for objects) |
None
|
required
|
Optional[List[str]]
|
Required property names (for objects) |
None
|
min_properties
|
Optional[str]
|
Minimum number of properties (for objects) |
None
|
max_properties
|
Optional[str]
|
Maximum number of properties (for objects) |
None
|
min_length
|
Optional[str]
|
Minimum string length (for strings) |
None
|
max_length
|
Optional[str]
|
Maximum string length (for strings) |
None
|
pattern
|
Optional[str]
|
Regular expression pattern (for strings) |
None
|
example
|
Optional[Any]
|
Example value |
None
|
any_of
|
Optional[List[Schema]]
|
List of alternative schemas |
None
|
property_ordering
|
Optional[List[str]]
|
Order of properties |
None
|
default
|
Optional[Any]
|
Default value |
None
|
items
|
Optional[Schema]
|
Schema for array items (for arrays) |
None
|
minimum
|
Optional[float]
|
Minimum numeric value (for numbers) |
None
|
maximum
|
Optional[float]
|
Maximum numeric value (for numbers) |
None
|
Source code in python/scouter/stubs.pyi
3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 | |
SchemaType ¶
Schema type definitions for Google/Gemini API.
Defines the available data types that can be used in schema definitions for structured outputs and function parameters.
Examples:
Score ¶
A class representing a score with a score value and a reason. This is typically used as a response type for tasks/prompts that require scoring or evaluation of results.
Example:
Prompt(
model="openai:gpt-4o",
messages="What is the score of this response?",
system_instructions="system_prompt",
response_format=Score,
)
Scott ¶
ScouterClient ¶
Helper client for interacting with Scouter Server
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
Optional[HttpConfig]
|
HTTP configuration for interacting with the server. |
None
|
Source code in python/scouter/stubs.pyi
download_profile ¶
Download profile
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
GetProfileRequest
|
GetProfileRequest |
required |
path
|
Optional[Path]
|
Path to save profile |
required |
Returns:
| Type | Description |
|---|---|
str
|
Path to downloaded profile |
Source code in python/scouter/stubs.pyi
get_alerts ¶
Get alerts
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
DriftAlertPaginationRequest
|
DriftAlertPaginationRequest |
required |
Returns:
| Type | Description |
|---|---|
DriftAlertPaginationResponse
|
DriftAlertPaginationResponse |
get_binned_drift ¶
Get drift map from server
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
drift_request
|
DriftRequest
|
DriftRequest object |
required |
drift_type
|
DriftType
|
Drift type for request |
required |
Returns:
| Type | Description |
|---|---|
Any
|
Drift map of type BinnedMetrics | BinnedPsiFeatureMetrics | BinnedSpcFeatureMetrics |
Source code in python/scouter/stubs.pyi
get_genai_task_binned_drift ¶
Get GenAI task drift map from server Args: drift_request: DriftRequest object
get_paginated_traces ¶
Get paginated traces Args: filters: TraceFilters object Returns: TracePaginationResponse
get_tags ¶
Get tags for an entity
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity_type
|
str
|
Entity type |
required |
entity_id
|
str
|
Entity ID |
required |
Returns:
| Type | Description |
|---|---|
TagsResponse
|
TagsResponse |
get_trace_baggage ¶
Get trace baggage
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trace_id
|
str
|
Trace ID |
required |
Returns:
| Type | Description |
|---|---|
TraceBaggageResponse
|
TraceBaggageResponse |
get_trace_metrics ¶
Get trace metrics
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
TraceMetricsRequest
|
TraceMetricsRequest |
required |
Returns:
| Type | Description |
|---|---|
TraceMetricsResponse
|
TraceMetricsResponse |
get_trace_spans ¶
Get trace spans
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trace_id
|
str
|
Trace ID |
required |
service_name
|
Optional[str]
|
Service name |
None
|
Returns:
| Type | Description |
|---|---|
TraceSpansResponse
|
TraceSpansResponse |
Source code in python/scouter/stubs.pyi
register_profile ¶
register_profile(
profile: Any,
set_active: bool = False,
deactivate_others: bool = False,
) -> bool
Registers a drift profile with the server
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profile
|
Any
|
Drift profile |
required |
set_active
|
bool
|
Whether to set the profile as active or inactive |
False
|
deactivate_others
|
bool
|
Whether to deactivate other profiles |
False
|
Returns:
| Type | Description |
|---|---|
bool
|
boolean |
Source code in python/scouter/stubs.pyi
update_profile_status ¶
Update profile status
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
ProfileStatusRequest
|
ProfileStatusRequest |
required |
Returns:
| Type | Description |
|---|---|
bool
|
boolean |
ScouterQueue ¶
Main queue class for Scouter. Publishes drift records to the configured transport
transport_config
property
¶
Return the transport configuration used by the queue
from_path
staticmethod
¶
from_path(
path: Dict[str, Path],
transport_config: Union[
KafkaConfig,
RabbitMQConfig,
RedisConfig,
HttpConfig,
GrpcConfig,
],
) -> ScouterQueue
Initializes Scouter queue from one or more drift profile paths.
╔══════════════════════════════════════════════════════════════════════════╗
║ SCOUTER QUEUE ARCHITECTURE ║
╠══════════════════════════════════════════════════════════════════════════╣
║ ║
║ Python Runtime (Client) ║
║ ┌────────────────────────────────────────────────────────────────────┐ ║
║ │ ScouterQueue.from_path() │ ║
║ │ • Load drift profiles (SPC, PSI, Custom, LLM) │ ║
║ │ • Configure transport (Kafka, RabbitMQ, Redis, HTTP, gRPC) │ ║
║ └───────────────────────────┬────────────────────────────────────────┘ ║
║ │ ║
║ ▼ ║
║ ┌────────────────────────────────────────────────────────────────────┐ ║
║ │ queue["profile_alias"].insert(Features | Metrics | GenAIEvalRecord) │ ║
║ └───────────────────────────┬────────────────────────────────────────┘ ║
║ │ ║
╚══════════════════════════════╪═══════════════════════════════════════════╝
│
│ Language Boundary
│
╔══════════════════════════════╪═══════════════════════════════════════════╗
║ Rust Runtime (Producer) ▼ ║
║ ┌────────────────────────────────────────────────────────────────────┐ ║
║ │ Queue<T> (per profile) │ ║
║ │ • Buffer records in memory │ ║
║ │ • Validate against drift profile schema │ ║
║ │ • Convert to ServerRecord format │ ║
║ └───────────────────────────┬────────────────────────────────────────┘ ║
║ │ ║
║ ▼ ║
║ ┌────────────────────────────────────────────────────────────────────┐ ║
║ │ Transport Producer │ ║
║ │ • KafkaProducer → Kafka brokers │ ║
║ │ • RabbitMQProducer → RabbitMQ exchange │ ║
║ │ • RedisProducer → Redis pub/sub │ ║
║ │ • HttpProducer → HTTP endpoint │ ║
║ │ • GrpcProducer → gRPC server │ ║
║ └───────────────────────────┬────────────────────────────────────────┘ ║
║ │ ║
╚══════════════════════════════╪═══════════════════════════════════════════╝
│
│ Network/Message Bus
│
╔══════════════════════════════╪═══════════════════════════════════════════╗
║ Scouter Server ▼ ║
║ ┌────────────────────────────────────────────────────────────────────┐ ║
║ │ Consumer (Kafka/RabbitMQ/Redis/HTTP/gRPC) │ ║
║ │ • Receive drift records │ ║
║ │ • Deserialize & validate │ ║
║ └───────────────────────────┬────────────────────────────────────────┘ ║
║ │ ║
║ ▼ ║
║ ┌────────────────────────────────────────────────────────────────────┐ ║
║ │ Processing Pipeline │ ║
║ │ • Calculate drift metrics (SPC, PSI) │ ║
║ │ • Evaluate alert conditions │ ║
║ │ • Store in PostgreSQL │ ║
║ │ • Dispatch alerts (Slack, OpsGenie, Console) │ ║
║ └────────────────────────────────────────────────────────────────────┘ ║
║ ║
╚══════════════════════════════════════════════════════════════════════════╝
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Dict[str, Path]
|
Dictionary of drift profile paths. Each key is a user-defined alias for accessing a queue. Supported profile types: • SpcDriftProfile - Statistical Process Control monitoring • PsiDriftProfile - Population Stability Index monitoring • CustomDriftProfile - Custom metric monitoring • GenAIEvalProfile - LLM evaluation monitoring |
required |
transport_config
|
Union[KafkaConfig, RabbitMQConfig, RedisConfig, HttpConfig, GrpcConfig]
|
Transport configuration for the queue publisher. Available transports: • KafkaConfig - Apache Kafka message bus • RabbitMQConfig - RabbitMQ message broker • RedisConfig - Redis pub/sub • HttpConfig - Direct HTTP to Scouter server • GrpcConfig - Direct gRPC to Scouter server |
required |
Returns:
| Name | Type | Description |
|---|---|---|
ScouterQueue |
ScouterQueue
|
Configured queue with Rust-based producers for each drift profile. |
Examples:
Basic SPC monitoring with Kafka: >>> queue = ScouterQueue.from_path( ... path={"spc": Path("spc_drift_profile.json")}, ... transport_config=KafkaConfig( ... brokers="localhost:9092", ... topic="scouter_monitoring", ... ), ... ) >>> queue["spc"].insert( ... Features(features=[ ... Feature("feature_1", 1.5), ... Feature("feature_2", 2.3), ... ]) ... )
Multi-profile monitoring with HTTP: >>> queue = ScouterQueue.from_path( ... path={ ... "spc": Path("spc_profile.json"), ... "psi": Path("psi_profile.json"), ... "custom": Path("custom_profile.json"), ... }, ... transport_config=HttpConfig( ... server_uri="http://scouter-server:8000", ... ), ... ) >>> queue["psi"].insert(Features(...)) >>> queue["custom"].insert(Metrics(...))
LLM monitoring with gRPC: >>> queue = ScouterQueue.from_path( ... path={"genai_eval": Path("genai_profile.json")}, ... transport_config=GrpcConfig( ... server_uri="http://scouter-server:50051", ... username="monitoring_user", ... password="secure_password", ... ), ... ) >>> queue["genai_eval"].insert( ... GenAIEvalRecord(context={"input": "...", "response": "..."}) ... )
Source code in python/scouter/stubs.pyi
12037 12038 12039 12040 12041 12042 12043 12044 12045 12046 12047 12048 12049 12050 12051 12052 12053 12054 12055 12056 12057 12058 12059 12060 12061 12062 12063 12064 12065 12066 12067 12068 12069 12070 12071 12072 12073 12074 12075 12076 12077 12078 12079 12080 12081 12082 12083 12084 12085 12086 12087 12088 12089 12090 12091 12092 12093 12094 12095 12096 12097 12098 12099 12100 12101 12102 12103 12104 12105 12106 12107 12108 12109 12110 12111 12112 12113 12114 12115 12116 12117 12118 12119 12120 12121 12122 12123 12124 12125 12126 12127 12128 12129 12130 12131 12132 12133 12134 12135 12136 12137 12138 12139 12140 12141 12142 12143 12144 12145 12146 12147 12148 12149 12150 12151 12152 12153 12154 12155 12156 12157 12158 12159 12160 12161 12162 12163 12164 12165 12166 12167 12168 12169 12170 12171 12172 12173 12174 12175 12176 12177 12178 12179 12180 12181 12182 12183 12184 12185 12186 12187 12188 12189 | |
ScouterTestServer ¶
ScouterTestServer(
cleanup: bool = True,
rabbit_mq: bool = False,
kafka: bool = False,
openai: bool = False,
base_path: Optional[Path] = None,
)
When the test server is used as a context manager, it will start the server in a background thread and set the appropriate env vars so that the client can connect to the server. The server will be stopped when the context manager exits and the env vars will be reset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cleanup
|
bool
|
Whether to cleanup the server after the test. Defaults to True. |
True
|
rabbit_mq
|
bool
|
Whether to use RabbitMQ as the transport. Defaults to False. |
False
|
kafka
|
bool
|
Whether to use Kafka as the transport. Defaults to False. |
False
|
openai
|
bool
|
Whether to create a mock OpenAITest server. Defaults to False. |
False
|
base_path
|
Optional[Path]
|
The base path for the server. Defaults to None. This is primarily used for testing loading attributes from a pyproject.toml file. |
None
|
Source code in python/scouter/stubs.pyi
SearchEntryPoint ¶
SearchResultBlockParam ¶
SearchResultBlockParam(
content: List[TextBlockParam],
source: str,
title: str,
cache_control: Optional[CacheControl] = None,
citations: Optional[CitationsConfigParams] = None,
)
Search result content block parameter.
Search result content with text blocks, source, and title.
Examples:
>>> content = [TextBlockParam(text="Result content", cache_control=None, citations=None)]
>>> block = SearchResultBlockParam(
... content=content,
... source="https://example.com",
... title="Search Result",
... cache_control=None,
... citations=None
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
List[TextBlockParam]
|
List of text content blocks |
required |
source
|
str
|
Source URL or identifier |
required |
title
|
str
|
Result title |
required |
cache_control
|
Optional[CacheControl]
|
Cache control settings |
None
|
citations
|
Optional[CitationsConfigParams]
|
Citations configuration |
None
|
Source code in python/scouter/stubs.pyi
Segment ¶
ServerRecord ¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
record
|
Any
|
Server record to initialize |
required |
Source code in python/scouter/stubs.pyi
record
property
¶
Return the drift server record.
ServerRecords ¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
records
|
List[ServerRecord]
|
List of server records |
required |
Source code in python/scouter/stubs.pyi
ServerToolUseBlock ¶
ServerToolUseBlockParam ¶
ServerToolUseBlockParam(
id: str,
name: str,
input: Any,
cache_control: Optional[CacheControl] = None,
)
Server tool use content block parameter.
Represents a server-side tool call made by the model.
Examples:
>>> block = ServerToolUseBlockParam(
... id="server_tool_123",
... name="web_search",
... input={"query": "latest news"},
... cache_control=None
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str
|
Tool call ID |
required |
name
|
str
|
Tool name |
required |
input
|
Any
|
Tool input parameters |
required |
cache_control
|
Optional[CacheControl]
|
Cache control settings |
None
|
Source code in python/scouter/stubs.pyi
SimpleSearchParams ¶
SlackDispatchConfig ¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel
|
str
|
Slack channel name for where alerts will be reported |
required |
Source code in python/scouter/stubs.pyi
SourceFlaggingUri ¶
SpanEvent ¶
Represents an event within a span.
SpanKind ¶
Enumeration of span kinds.
SpanLink ¶
Represents a link to another span.
SpcAlert ¶
SpcAlertConfig ¶
SpcAlertConfig(
rule: Optional[SpcAlertRule] = None,
dispatch_config: Optional[
SlackDispatchConfig | OpsGenieDispatchConfig
] = None,
schedule: Optional[str | CommonCrons] = None,
features_to_monitor: List[str] = [],
)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rule
|
Optional[SpcAlertRule]
|
Alert rule to use. Defaults to Standard |
None
|
dispatch_config
|
Optional[SlackDispatchConfig | OpsGenieDispatchConfig]
|
Alert dispatch config. Defaults to console |
None
|
schedule
|
Optional[str | CommonCrons]
|
Schedule to run monitor. Defaults to daily at midnight |
None
|
features_to_monitor
|
List[str]
|
List of features to monitor. Defaults to empty list, which means all features |
[]
|
Source code in python/scouter/stubs.pyi
features_to_monitor
property
writable
¶
Return the features to monitor
SpcAlertRule ¶
SpcAlertRule(
rule: str = "8 16 4 8 2 4 1 1",
zones_to_monitor: List[AlertZone] = [
AlertZone.Zone1,
AlertZone.Zone2,
AlertZone.Zone3,
AlertZone.Zone4,
],
)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rule
|
str
|
Rule to use for alerting. Eight digit integer string. Defaults to '8 16 4 8 2 4 1 1' |
'8 16 4 8 2 4 1 1'
|
zones_to_monitor
|
List[AlertZone]
|
List of zones to monitor. Defaults to all zones. |
[Zone1, Zone2, Zone3, Zone4]
|
Source code in python/scouter/stubs.pyi
SpcDriftConfig ¶
SpcDriftConfig(
space: str = "__missing__",
name: str = "__missing__",
version: str = "0.1.0",
sample_size: int = 25,
alert_config: SpcAlertConfig = SpcAlertConfig(),
config_path: Optional[Path] = None,
)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
space
|
str
|
Model space |
'__missing__'
|
name
|
str
|
Model name |
'__missing__'
|
version
|
str
|
Model version. Defaults to 0.1.0 |
'0.1.0'
|
sample_size
|
int
|
Sample size |
25
|
alert_config
|
SpcAlertConfig
|
Alert configuration |
SpcAlertConfig()
|
config_path
|
Optional[Path]
|
Optional path to load config from. |
None
|
Source code in python/scouter/stubs.pyi
load_from_json_file
staticmethod
¶
Load config from json file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Path to json file to load config from. |
required |
model_dump_json ¶
update_config_args ¶
update_config_args(
space: Optional[str] = None,
name: Optional[str] = None,
version: Optional[str] = None,
sample_size: Optional[int] = None,
alert_config: Optional[SpcAlertConfig] = None,
) -> None
Inplace operation that updates config args
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
space
|
Optional[str]
|
Model space |
None
|
name
|
Optional[str]
|
Model name |
None
|
version
|
Optional[str]
|
Model version |
None
|
sample_size
|
Optional[int]
|
Sample size |
None
|
alert_config
|
Optional[SpcAlertConfig]
|
Alert configuration |
None
|
Source code in python/scouter/stubs.pyi
SpcDriftMap ¶
Drift map of features
features
property
¶
Returns dictionary of features and their data profiles
model_dump_json ¶
model_validate_json
staticmethod
¶
Load drift map from json file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_string
|
str
|
JSON string representation of the drift map |
required |
save_to_json ¶
Save drift map to json file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Optional[Path]
|
Optional path to save the drift map. If None, outputs to |
None
|
Returns:
| Type | Description |
|---|---|
Path
|
Path to the saved json file |
Source code in python/scouter/stubs.pyi
SpcDriftProfile ¶
from_file
staticmethod
¶
Load drift profile from file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Path to the file |
required |
model_dump ¶
model_dump_json ¶
model_validate
staticmethod
¶
Load drift profile from dictionary
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Dict[str, Any]
|
DriftProfile dictionary |
required |
model_validate_json
staticmethod
¶
Load drift profile from json
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_string
|
str
|
JSON string representation of the drift profile |
required |
save_to_json ¶
Save drift profile to json file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Optional[Path]
|
Optional path to save the drift profile. If None, outputs to |
None
|
Returns:
| Type | Description |
|---|---|
Path
|
Path to the saved json file |
Source code in python/scouter/stubs.pyi
update_config_args ¶
update_config_args(
space: Optional[str] = None,
name: Optional[str] = None,
version: Optional[str] = None,
sample_size: Optional[int] = None,
alert_config: Optional[SpcAlertConfig] = None,
) -> None
Inplace operation that updates config args
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
Optional[str]
|
Model name |
None
|
space
|
Optional[str]
|
Model space |
None
|
version
|
Optional[str]
|
Model version |
None
|
sample_size
|
Optional[int]
|
Sample size |
None
|
alert_config
|
Optional[SpcAlertConfig]
|
Alert configuration |
None
|
Source code in python/scouter/stubs.pyi
SpcFeatureDrift ¶
SpcFeatureDriftProfile ¶
SpcRecord ¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uid
|
str
|
Unique identifier for the spc record. Must correspond to an existing entity in Scouter. |
required |
feature
|
str
|
Feature name |
required |
value
|
float
|
Feature value |
required |
Source code in python/scouter/stubs.pyi
model_dump_json ¶
SpeakerVoiceConfig ¶
Voice configuration for a specific speaker.
Maps a speaker identifier to a voice configuration for multi-speaker text-to-speech.
Examples:
>>> config = SpeakerVoiceConfig(
... speaker="Alice",
... voice_config=VoiceConfig(
... prebuilt_voice_config=PrebuiltVoiceConfig(voice_name="Puck")
... )
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
speaker
|
str
|
Speaker identifier/name |
required |
voice_config
|
VoiceConfig
|
Voice configuration for this speaker |
required |
Source code in python/scouter/stubs.pyi
SpeechConfig ¶
SpeechConfig(
voice_config: Optional[VoiceConfig] = None,
multi_speaker_voice_config: Optional[
MultiSpeakerVoiceConfig
] = None,
language_code: Optional[str] = None,
)
Configuration for speech synthesis.
Controls text-to-speech generation including voice selection and language.
Examples:
>>> # Single speaker
>>> config = SpeechConfig(
... voice_config=VoiceConfig(
... prebuilt_voice_config=PrebuiltVoiceConfig(voice_name="Puck")
... ),
... language_code="en-US"
... )
>>> # Multiple speakers
>>> config = SpeechConfig(
... multi_speaker_voice_config=MultiSpeakerVoiceConfig(...),
... language_code="en-US"
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
voice_config
|
Optional[VoiceConfig]
|
Single voice configuration |
None
|
multi_speaker_voice_config
|
Optional[MultiSpeakerVoiceConfig]
|
Multi-speaker configuration |
None
|
language_code
|
Optional[str]
|
ISO 639-1 language code |
None
|
Source code in python/scouter/stubs.pyi
SquareRoot ¶
StdoutSpanExporter ¶
Exporter that outputs spans to standard output (stdout).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch_export
|
bool
|
Whether to use batch exporting. Defaults to False. |
False
|
sample_ratio
|
Optional[float]
|
The sampling ratio for traces. If None, defaults to always sample. |
None
|
Source code in python/scouter/stubs.pyi
StopReason ¶
Reason for generation stopping.
Indicates why Claude stopped generating.
Examples:
>>> reason = response.stop_reason
>>> if reason == StopReason.EndTurn:
... print("Natural stopping point")
StopSequence
class-attribute
instance-attribute
¶
Stop sequence encountered
StreamOptions ¶
Options for streaming chat completion responses.
This class provides configuration for streaming behavior, including usage information and obfuscation settings.
Examples:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include_obfuscation
|
Optional[bool]
|
Whether to include obfuscation in the stream |
None
|
include_usage
|
Optional[bool]
|
Whether to include usage information in the stream |
None
|
Source code in python/scouter/stubs.pyi
StringStats ¶
Sturges ¶
SystemPrompt ¶
System prompt for Anthropic messages.
System-level instructions for Claude.
Examples:
>>> # Simple system prompt
>>> prompt = SystemPrompt(content="You are a helpful assistant.")
>>>
>>> # System prompt with multiple blocks
>>> blocks = [
... TextBlockParam(text="You are helpful.", cache_control=None, citations=None),
... TextBlockParam(text="Be concise.", cache_control=None, citations=None)
... ]
>>> prompt = SystemPrompt(content=blocks)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
Any
|
System prompt content (string or list of TextBlockParam) |
required |
Source code in python/scouter/stubs.pyi
TagRecord ¶
Represents a single tag record associated with an entity.
TagsResponse ¶
Response structure containing a list of tag records.
Task ¶
Task(
agent_id: str,
prompt: Prompt,
id: Optional[str] = None,
dependencies: List[str] = [],
max_retries: int = 3,
)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_id
|
str
|
The ID of the agent that will execute the task. |
required |
prompt
|
Prompt
|
The prompt to use for the task. |
required |
id
|
Optional[str]
|
The ID of the task. If None, a random uuid7 will be generated. |
None
|
dependencies
|
List[str]
|
The dependencies of the task. |
[]
|
max_retries
|
int
|
The maximum number of retries for the task if it fails. Defaults to 3. |
3
|
Source code in python/scouter/stubs.pyi
TaskComparison ¶
Represents a comparison between the same task in baseline and comparison evaluations
baseline_passed
property
¶
Check if the task passed in the baseline evaluation
comparison_passed
property
¶
Check if the task passed in the comparison evaluation
record_uid
property
¶
Get the record unique identifier associated with this task comparison
status_changed
property
¶
Check if the task's pass/fail status changed between evaluations
TaskEvent ¶
A class representing an event that occurs during the execution of a task in a workflow.
details
property
¶
Additional details about the event. This can include information such as error messages or other relevant data.
timestamp
property
¶
The timestamp of the event. This is the time when the event occurred.
updated_at
property
¶
The timestamp of when the event was last updated. This is useful for tracking changes to the event.
TaskList ¶
TaskList is a collection of Task objects used in a Workflow.
items
property
¶
Dictionary of tasks in the TaskList where keys are task IDs and values are Task objects.
TaskStatus ¶
Status of a task in a workflow.
Indicates the current state of task execution.
Examples:
TerrellScott ¶
TestSpanExporter ¶
Exporter for testing that collects spans in memory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch_export
|
bool
|
Whether to use batch exporting. Defaults to True. |
True
|
Source code in python/scouter/stubs.pyi
TextBlock ¶
TextBlockParam ¶
TextBlockParam(
text: str,
cache_control: Optional[CacheControl] = None,
citations: Optional[Any] = None,
)
Text content block parameter.
Regular text content with optional cache control and citations.
Examples:
>>> # Simple text block
>>> block = TextBlockParam(text="Hello, world!", cache_control=None, citations=None)
>>>
>>> # With cache control
>>> cache = CacheControl(cache_type="ephemeral", ttl="5m")
>>> block = TextBlockParam(text="Hello", cache_control=cache, citations=None)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Text content |
required |
cache_control
|
Optional[CacheControl]
|
Cache control settings |
None
|
citations
|
Optional[Any]
|
Citation information |
None
|
Source code in python/scouter/stubs.pyi
TextContentPart ¶
Text content part for OpenAI chat messages.
This class represents text as part of a message's content.
Examples:
>>> text_part = TextContentPart(text="Hello, world!")
>>> text_part.text
'Hello, world!'
>>> text_part.type
'text'
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Text content |
required |
Source code in python/scouter/stubs.pyi
TextFormat ¶
Text format for custom tool outputs.
This class defines unconstrained free-form text output format for custom tools.
Examples:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type
|
str
|
Format type (typically "text") |
required |
Source code in python/scouter/stubs.pyi
ThinkingBlock ¶
ThinkingBlockParam ¶
Thinking content block parameter.
Claude's internal thinking/reasoning process.
Examples:
>>> block = ThinkingBlockParam(
... thinking="Let me think about this...",
... signature="signature_string"
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
thinking
|
str
|
The thinking content |
required |
signature
|
Optional[str]
|
Cryptographic signature |
None
|
Source code in python/scouter/stubs.pyi
ThinkingLevel ¶
Level of model thinking/reasoning to apply.
Controls the depth of reasoning the model performs before generating its final response.
Examples:
ThinkingLevelUnspecified
class-attribute
instance-attribute
¶
Unspecified thinking level
TokenLogProbs ¶
ToolCall ¶
Tool call information from OpenAI responses.
This class represents a single tool call made by the model during generation.
Examples:
ToolChoiceMode ¶
Mode for tool choice behavior in chat completions.
This enum defines how the model should handle tool calls during generation.
Examples:
ToolConfig ¶
ToolConfig(
function_calling_config: Optional[
FunctionCallingConfig
] = None,
retrieval_config: Optional[RetrievalConfig] = None,
)
Configuration for tool usage.
Controls function calling and retrieval behavior across all tools.
Examples:
>>> config = ToolConfig(
... function_calling_config=FunctionCallingConfig(mode=Mode.Auto),
... retrieval_config=RetrievalConfig(
... lat_lng=LatLng(latitude=37.7749, longitude=-122.4194),
... language_code="en-US"
... )
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
function_calling_config
|
Optional[FunctionCallingConfig]
|
Function calling configuration |
None
|
retrieval_config
|
Optional[RetrievalConfig]
|
Retrieval configuration |
None
|
Source code in python/scouter/stubs.pyi
ToolDefinition ¶
Definition of a tool for allowed tools configuration.
This class defines a tool that can be included in an allowed tools list.
Examples:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
function_name
|
str
|
Name of the function this tool wraps |
required |
Source code in python/scouter/stubs.pyi
ToolResultBlockParam ¶
ToolResultBlockParam(
tool_use_id: str,
is_error: Optional[bool] = None,
cache_control: Optional[CacheControl] = None,
content: Optional[List[Any]] = None,
)
Tool result content block parameter.
Contains the result from executing a tool.
Examples:
>>> # Success result
>>> content = [TextBlockParam(text="Result data", cache_control=None, citations=None)]
>>> block = ToolResultBlockParam(
... tool_use_id="tool_call_123",
... is_error=False,
... cache_control=None,
... content=content
... )
>>>
>>> # Error result
>>> block = ToolResultBlockParam(
... tool_use_id="tool_call_123",
... is_error=True,
... cache_control=None,
... content=None
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tool_use_id
|
str
|
ID of the tool call this is a result for |
required |
is_error
|
Optional[bool]
|
Whether this is an error result |
None
|
cache_control
|
Optional[CacheControl]
|
Cache control settings |
None
|
content
|
Optional[List[Any]]
|
Result content blocks |
None
|
Source code in python/scouter/stubs.pyi
ToolUseBlock ¶
ToolUseBlockParam ¶
Tool use content block parameter.
Represents a tool call made by the model.
Examples:
>>> block = ToolUseBlockParam(
... id="tool_call_123",
... name="get_weather",
... input={"location": "San Francisco"},
... cache_control=None
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str
|
Tool call ID |
required |
name
|
str
|
Tool name |
required |
input
|
Any
|
Tool input parameters |
required |
cache_control
|
Optional[CacheControl]
|
Cache control settings |
None
|
Source code in python/scouter/stubs.pyi
TopCandidates ¶
TopLogProbs ¶
Top log probability information for a token.
This class represents one of the top alternative tokens considered by the model, with its log probability.
Examples:
TraceBaggageRecord ¶
Represents a single baggage record associated with a trace.
TraceBaggageResponse ¶
Response structure containing trace baggage records.
TraceFilters ¶
TraceFilters(
service_name: Optional[str] = None,
has_errors: Optional[bool] = None,
status_code: Optional[int] = None,
start_time: Optional[datetime] = None,
end_time: Optional[datetime] = None,
limit: Optional[int] = None,
cursor_created_at: Optional[datetime] = None,
cursor_trace_id: Optional[str] = None,
)
A struct for filtering traces, generated from Rust pyclass.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
service_name
|
Optional[str]
|
Service name filter |
None
|
has_errors
|
Optional[bool]
|
Filter by presence of errors |
None
|
status_code
|
Optional[int]
|
Filter by root span status code |
None
|
start_time
|
Optional[datetime]
|
Start time boundary (UTC) |
None
|
end_time
|
Optional[datetime]
|
End time boundary (UTC) |
None
|
limit
|
Optional[int]
|
Maximum number of results to return |
None
|
cursor_created_at
|
Optional[datetime]
|
Pagination cursor: created at timestamp |
None
|
cursor_trace_id
|
Optional[str]
|
Pagination cursor: trace ID |
None
|
Source code in python/scouter/stubs.pyi
TraceListItem ¶
Represents a summary item for a trace in a list view.
TraceMetricBucket ¶
Represents aggregated trace metrics for a specific time bucket.
TraceMetricsRequest ¶
TraceMetricsRequest(
start_time: datetime,
end_time: datetime,
bucket_interval: str,
space: Optional[str] = None,
name: Optional[str] = None,
version: Optional[str] = None,
)
Request payload for fetching trace metrics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_time
|
datetime
|
Start time boundary (UTC) |
required |
end_time
|
datetime
|
End time boundary (UTC) |
required |
bucket_interval
|
str
|
The time interval for metric aggregation buckets (e.g., '1 minutes', '30 minutes') |
required |
space
|
Optional[str]
|
Model space filter |
None
|
name
|
Optional[str]
|
Model name filter |
None
|
version
|
Optional[str]
|
Model version filter |
None
|
Source code in python/scouter/stubs.pyi
TraceMetricsResponse ¶
Response structure containing aggregated trace metrics.
TracePaginationResponse ¶
Response structure for paginated trace list requests.
TraceSpan ¶
Detailed information for a single span within a trace.
TraceSpansResponse ¶
Response structure containing a list of spans for a trace.
TrafficType ¶
UrlCitation ¶
URL citation from OpenAI web search.
This class represents a citation to a web source used by the model when web search is enabled.
Examples:
UrlContext ¶
UrlContextMetadata ¶
UrlImageSource ¶
URL-based image source.
Image referenced by URL.
Examples:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
Image URL |
required |
Source code in python/scouter/stubs.pyi
UrlMetadata ¶
UrlPDFSource ¶
URL-based PDF source.
PDF document referenced by URL.
Examples:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
PDF document URL |
required |
Source code in python/scouter/stubs.pyi
UrlRetrievalStatus ¶
Status of URL retrieval operation.
Indicates whether a URL was successfully retrieved by the tool.
Examples:
>>> status = UrlRetrievalStatus.UrlRetrievalStatusSuccess
>>> status.value
'URL_RETRIEVAL_STATUS_SUCCESS'
Usage ¶
Token usage statistics for OpenAI chat completions.
This class provides comprehensive token usage information, including detailed breakdowns for both prompt and completion tokens.
Examples:
>>> # Accessing usage information
>>> usage = response.usage
>>> print(f"Total tokens: {usage.total_tokens}")
>>> print(f"Prompt tokens: {usage.prompt_tokens}")
>>> print(f"Completion tokens: {usage.completion_tokens}")
>>>
>>> # Detailed breakdown
>>> print(f"Cached tokens: {usage.prompt_tokens_details.cached_tokens}")
>>> print(f"Reasoning tokens: {usage.completion_tokens_details.reasoning_tokens}")
UsageMetadata ¶
Token usage metadata for a request/response.
Provides detailed breakdown of token usage across different components.
Examples:
>>> usage = UsageMetadata(
... prompt_token_count=100,
... candidates_token_count=50,
... total_token_count=150,
... cached_content_token_count=20
... )
cache_tokens_details
property
¶
Cache tokens by modality.
cached_content_token_count
property
¶
Tokens from cached content.
candidates_token_count
property
¶
Tokens in generated candidates.
candidates_tokens_details
property
¶
Candidate tokens by modality.
prompt_tokens_details
property
¶
Prompt tokens by modality.
tool_use_prompt_token_count
property
¶
Tokens from tool use results.
tool_use_prompt_tokens_details
property
¶
Tool use tokens by modality.
UsageObject ¶
VertexAISearch ¶
VertexAISearch(
datastore: Optional[str] = None,
engine: Optional[str] = None,
max_results: Optional[int] = None,
filter: Optional[str] = None,
data_store_specs: Optional[List[DataStoreSpec]] = None,
)
Vertex AI Search retrieval configuration.
Configures retrieval from Vertex AI Search datastores or engines.
Examples:
>>> # Using a datastore
>>> search = VertexAISearch(
... datastore="projects/my-project/locations/us/collections/default/dataStores/my-store",
... max_results=5
... )
>>> # Using an engine with multiple datastores
>>> search = VertexAISearch(
... engine="projects/my-project/locations/us/collections/default/engines/my-engine",
... data_store_specs=[
... DataStoreSpec(data_store="store1", filter="category:a"),
... DataStoreSpec(data_store="store2", filter="category:b")
... ]
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datastore
|
Optional[str]
|
Datastore resource name |
None
|
engine
|
Optional[str]
|
Engine resource name |
None
|
max_results
|
Optional[int]
|
Maximum number of results (default 10, max 10) |
None
|
filter
|
Optional[str]
|
Filter expression |
None
|
data_store_specs
|
Optional[List[DataStoreSpec]]
|
Datastore specifications (for engines) |
None
|
Source code in python/scouter/stubs.pyi
data_store_specs
property
¶
Datastore specifications.
VertexGoogleSearch ¶
VertexGoogleSearch(
exclude_domains: Optional[List[str]] = None,
blocking_confidence: Optional[
PhishBlockThreshold
] = None,
)
Google Search tool configuration (Vertex API).
Configures Google Search with domain blocking and phishing filters.
Examples:
>>> search = VertexGoogleSearch(
... exclude_domains=["example.com", "spam.com"],
... blocking_confidence=PhishBlockThreshold.BlockMediumAndAbove
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
exclude_domains
|
Optional[List[str]]
|
Domains to exclude from results |
None
|
blocking_confidence
|
Optional[PhishBlockThreshold]
|
Phishing blocking threshold |
None
|
Source code in python/scouter/stubs.pyi
VertexRagStore ¶
Vertex RAG Store retrieval configuration.
Configures retrieval from Vertex RAG Store.
Examples:
>>> store = VertexRagStore(
... rag_resources=[
... RagResource(
... rag_corpus="projects/my-project/locations/us/ragCorpora/my-corpus"
... )
... ],
... rag_retrieval_config=RagRetrievalConfig(top_k=5),
... similarity_top_k=10
... )
VideoMetadata ¶
VoiceConfig ¶
Voice configuration for speech generation.
Configures the voice to use for text-to-speech.
Examples:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prebuilt_voice_config
|
PrebuiltVoiceConfig
|
Prebuilt voice to use |
required |
Source code in python/scouter/stubs.pyi
prebuilt_voice_config
property
¶
The prebuilt voice configuration.
Web ¶
WebSearchResultBlock ¶
WebSearchResultBlockParam ¶
WebSearchResultBlockParam(
encrypted_content: str,
title: str,
url: str,
page_agent: Optional[str] = None,
)
Web search result block parameter.
Contains a single web search result.
Examples:
>>> block = WebSearchResultBlockParam(
... encrypted_content="encrypted_data",
... title="Search Result",
... url="https://example.com",
... page_agent="5 hours ago"
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encrypted_content
|
str
|
Encrypted content data |
required |
title
|
str
|
Result title |
required |
url
|
str
|
Result URL |
required |
page_agent
|
Optional[str]
|
Page age information |
None
|
Source code in python/scouter/stubs.pyi
WebSearchToolResultBlock ¶
WebSearchToolResultBlockParam ¶
WebSearchToolResultBlockParam(
tool_use_id: str,
content: List[WebSearchResultBlockParam],
cache_control: Optional[CacheControl] = None,
)
Web search tool result block parameter.
Contains multiple web search results from a tool call.
Examples:
>>> results = [WebSearchResultBlockParam(...), WebSearchResultBlockParam(...)]
>>> block = WebSearchToolResultBlockParam(
... tool_use_id="search_123",
... content=results,
... cache_control=None
... )
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tool_use_id
|
str
|
ID of the web search tool call |
required |
content
|
List[WebSearchResultBlockParam]
|
List of search results |
required |
cache_control
|
Optional[CacheControl]
|
Cache control settings |
None
|
Source code in python/scouter/stubs.pyi
WebSearchToolResultError ¶
Workflow ¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the workflow. |
required |
Source code in python/scouter/stubs.pyi
is_workflow
property
¶
Returns True if the workflow is a valid workflow, otherwise False. This is used to determine if the workflow can be executed.
add_agent ¶
Add an agent to the workflow.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
Agent
|
The agent to add to the workflow. |
required |
add_agents ¶
add_task ¶
Add a task to the workflow.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task
|
Task
|
The task to add to the workflow. |
required |
output_type
|
Optional[Any]
|
The output type to use for the task. This can either be a Pydantic |
required |
Source code in python/scouter/stubs.pyi
add_task_output_types ¶
Add output types for tasks in the workflow. This is primarily used for rehydrating the task output types when loading a workflow from JSON, as python objects are not serializable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task_output_types
|
Dict[str, Any]
|
A dictionary mapping task IDs to their output types.
This can either be a Pydantic |
required |
Source code in python/scouter/stubs.pyi
add_tasks ¶
Add multiple tasks to the workflow.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tasks
|
List[Task]
|
The tasks to add to the workflow. |
required |
execute_task ¶
Execute a single task in the workflow by its ID. Args: task_id (str): The ID of the task to execute. global_context (Optional[Any]): Any serializable global context to bind to the task before execution. This is typically a dictionary or Pydantic BaseModel. Returns: Any:
Source code in python/scouter/stubs.pyi
execution_plan ¶
Get the execution plan for the workflow.
Returns:
| Type | Description |
|---|---|
Dict[str, List[str]]
|
Dict[str, List[str]]: A dictionary where the keys are task IDs and the values are lists of task IDs that the task depends on. |
Source code in python/scouter/stubs.pyi
is_complete ¶
Check if the workflow is complete.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the workflow is complete, False otherwise. |
model_dump_json ¶
model_validate_json
staticmethod
¶
Load a workflow from a JSON string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_string
|
str
|
The JSON string to validate. |
required |
output_types
|
Optional[Dict[str, Any]]
|
A dictionary mapping task IDs to their output types.
This can either be a Pydantic |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Workflow |
Workflow
|
The workflow object. |
Source code in python/scouter/stubs.pyi
pending_count ¶
Get the number of pending tasks in the workflow.
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The number of pending tasks in the workflow. |
run ¶
Run the workflow. This will execute all tasks in the workflow and return when all tasks are complete.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
global_context
|
Optional[Dict[str, Any]]
|
A dictionary of global context to bind to the workflow. All tasks in the workflow will have this context bound to them. |
None
|
Source code in python/scouter/stubs.pyi
WorkflowComparison ¶
Represents a comparison between matching workflows in baseline and comparison evaluations
baseline_pass_rate
property
¶
Get the baseline workflow pass rate (0.0 to 1.0)
comparison_pass_rate
property
¶
Get the comparison workflow pass rate (0.0 to 1.0)
pass_rate_delta
property
¶
Get the change in pass rate (positive = improvement, negative = regression)
task_comparisons
property
¶
Get detailed task-by-task comparisons for this workflow
WorkflowResult ¶
events
property
¶
The events that occurred during the workflow execution. This is a list of dictionaries where each dictionary contains information about the event such as the task ID, status, and timestamp.
result
property
¶
The result from the last task of the workflow if it has been executed, otherwise None.
WorkflowTask ¶
Python-specific task interface for Task objects and results
result
property
¶
The result of the task if it has been executed, otherwise None.
flush_tracer ¶
get_current_active_span ¶
Get the current active span.
Returns:
| Name | Type | Description |
|---|---|---|
ActiveSpan |
ActiveSpan
|
The current active span. Raises an error if no active span exists. |
get_function_type ¶
Determine the function type (sync, async, generator, async generator).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
Callable[..., Any]
|
The function to analyze. |
required |
get_tracing_headers_from_current_span ¶
Get tracing headers from the current active span and global propagator.
Returns:
| Type | Description |
|---|---|
Dict[str, str]
|
Dict[str, str]: A dictionary of tracing headers. |
init_tracer ¶
init_tracer(
service_name: str = "scouter_service",
scope: str = "scouter.tracer.{version}",
transport_config: Optional[
HttpConfig
| KafkaConfig
| RabbitMQConfig
| RedisConfig
| GrpcConfig
] = None,
exporter: Optional[
HttpSpanExporter
| GrpcSpanExporter
| StdoutSpanExporter
| TestSpanExporter
] = None,
batch_config: Optional[BatchConfig] = None,
sample_ratio: Optional[float] = None,
) -> None
Initialize the tracer for a service with dual export capability.
╔════════════════════════════════════════════╗
║ DUAL EXPORT ARCHITECTURE ║
╠════════════════════════════════════════════╣
║ ║
║ Your Application ║
║ │ ║
║ │ init_tracer() ║
║ │ ║
║ ├──────────────────┬ ║
║ │ │ ║
║ ▼ ▼ ║
║ ┌─────────────┐ ┌──────────────┐ ║
║ │ Transport │ │ Optional │ ║
║ │ to │ │ OTEL │ ║
║ │ Scouter │ │ Exporter │ ║
║ │ (Required) │ │ │ ║
║ └──────┬──────┘ └──────┬───────┘ ║
║ │ │ ║
║ │ │ ║
║ ┌────▼────┐ ┌────▼────┐ ║
║ │ Scouter │ │ OTEL │ ║
║ │ Server │ │Collector│ ║
║ └─────────┘ └─────────┘ ║
║ ║
╚════════════════════════════════════════════╝
┌─ REQUIRED: Scouter Export ────────────────────────────────────────────────┐
│ │
│ All spans are ALWAYS exported to Scouter via transport_config: │
│ • HttpConfig → HTTP endpoint (default) │
│ • GrpcConfig → gRPC endpoint │
│ • KafkaConfig → Kafka topic │
│ • RabbitMQConfig→ RabbitMQ queue │
│ • RedisConfig → Redis stream/channel │
│ │
└───────────────────────────────────────────────────────────────────────────┘
┌─ OPTIONAL: OTEL Export ───────────────────────────────────────────────────┐
│ │
│ Optionally export spans to external OTEL-compatible systems: │
│ • HttpSpanExporter → OTEL Collector (HTTP) │
│ • GrpcSpanExporter → OTEL Collector (gRPC) │
│ • StdoutSpanExporter → Console output (debugging) │
│ • TestSpanExporter → In-memory (testing) │
│ │
│ If None: Only Scouter export is active (NoOpExporter) │
│ │
└───────────────────────────────────────────────────────────────────────────┘
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
service_name
|
str
|
The required name of the service this tracer is associated with. This is typically a logical identifier for the application or component. Default: "scouter_service" |
'scouter_service'
|
scope
|
str
|
The scope for the tracer. Used to differentiate tracers by version or environment. Default: "scouter.tracer.{version}" |
'scouter.tracer.{version}'
|
transport_config
|
HttpConfig | GrpcConfig | KafkaConfig | RabbitMQConfig | RedisConfig | None
|
Configuration for sending spans to Scouter. If None, defaults to HttpConfig. Supported transports: • HttpConfig : Export to Scouter via HTTP • GrpcConfig : Export to Scouter via gRPC • KafkaConfig : Export to Scouter via Kafka • RabbitMQConfig : Export to Scouter via RabbitMQ • RedisConfig : Export to Scouter via Redis |
None
|
exporter
|
HttpSpanExporter | GrpcSpanExporter | StdoutSpanExporter | TestSpanExporter | None
|
Optional secondary exporter for OpenTelemetry-compatible backends. If None, spans are ONLY sent to Scouter (NoOpExporter used internally). Available exporters: • HttpSpanExporter : Send to OTEL Collector via HTTP • GrpcSpanExporter : Send to OTEL Collector via gRPC • StdoutSpanExporter : Write to stdout (debugging) • TestSpanExporter : Collect in-memory (testing) |
None
|
batch_config
|
BatchConfig | None
|
Configuration for batch span export. If provided, spans are queued and exported in batches. If None and the exporter supports batching, default batch settings apply. Batching improves performance for high-throughput applications. |
None
|
sample_ratio
|
float | None
|
Sampling ratio for tracing. A value between 0.0 and 1.0. All provided values are clamped between 0.0 and 1.0. If None, all spans are sampled (no sampling). |
None
|
Examples:
Basic setup (Scouter only via HTTP): >>> init_tracer(service_name="my-service")
Scouter via Kafka + OTEL Collector: >>> init_tracer( ... service_name="my-service", ... transport_config=KafkaConfig(brokers="kafka:9092"), ... exporter=HttpSpanExporter( ... export_config=OtelExportConfig( ... endpoint="http://otel-collector:4318" ... ) ... ) ... )
Scouter via gRPC + stdout debugging: >>> init_tracer( ... service_name="my-service", ... transport_config=GrpcConfig(server_uri="grpc://scouter:50051"), ... exporter=StdoutSpanExporter() ... )
Notes
• Spans are ALWAYS exported to Scouter via transport_config • OTEL export via exporter is completely optional • Both exports happen in parallel without blocking each other • Use batch_config to optimize performance for high-volume tracing
See Also
- HttpConfig, GrpcConfig, KafkaConfig, RabbitMQConfig, RedisConfig
- HttpSpanExporter, GrpcSpanExporter, StdoutSpanExporter, TestSpanExporter
- BatchConfig
Source code in python/scouter/stubs.pyi
9562 9563 9564 9565 9566 9567 9568 9569 9570 9571 9572 9573 9574 9575 9576 9577 9578 9579 9580 9581 9582 9583 9584 9585 9586 9587 9588 9589 9590 9591 9592 9593 9594 9595 9596 9597 9598 9599 9600 9601 9602 9603 9604 9605 9606 9607 9608 9609 9610 9611 9612 9613 9614 9615 9616 9617 9618 9619 9620 9621 9622 9623 9624 9625 9626 9627 9628 9629 9630 9631 9632 9633 9634 9635 9636 9637 9638 9639 9640 9641 9642 9643 9644 9645 9646 9647 9648 9649 9650 9651 9652 9653 9654 9655 9656 9657 9658 9659 9660 9661 9662 9663 9664 9665 9666 9667 9668 9669 9670 9671 9672 9673 9674 9675 9676 9677 9678 9679 9680 9681 9682 9683 9684 9685 9686 9687 9688 9689 9690 9691 9692 9693 9694 9695 9696 9697 9698 9699 9700 9701 9702 9703 9704 9705 | |