Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions agentops/instrumentation/openai/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""Configuration for OpenAI instrumentation.

This module provides a global configuration object that can be used to customize
the behavior of OpenAI instrumentation across all components.
"""

from typing import Callable, Optional, Dict
from typing_extensions import Protocol


class UploadImageCallable(Protocol):
"""Protocol for the upload_base64_image function."""

async def __call__(self, trace_id: str, span_id: str, image_name: str, base64_string: str) -> str:
"""Upload a base64 image and return the URL."""
...

Check warning on line 16 in agentops/instrumentation/openai/config.py

View check run for this annotation

Codecov / codecov/patch

agentops/instrumentation/openai/config.py#L16

Added line #L16 was not covered by tests


class Config:
"""Global configuration for OpenAI instrumentation.

Attributes:
enrich_token_usage: Whether to calculate token usage for streaming responses
enrich_assistant: Whether to enrich assistant responses with additional data
exception_logger: Optional function to log exceptions
get_common_metrics_attributes: Function to get common attributes for metrics
upload_base64_image: Optional async function to upload base64 images
enable_trace_context_propagation: Whether to propagate trace context in headers
"""

enrich_token_usage: bool = True
enrich_assistant: bool = True
exception_logger: Optional[Callable[[Exception], None]] = None
get_common_metrics_attributes: Callable[[], Dict[str, str]] = lambda: {}
upload_base64_image: Optional[UploadImageCallable] = None
enable_trace_context_propagation: bool = True
Loading
Loading