system.utility package

Submodules

system.utility.custom_exceptions module

module for custom exceptions used in the application.

exception system.utility.custom_exceptions.ModelLoadError[source]

Bases: Exception

Raised when a model fails to load.

system.utility.logger module

module to log system events

system.utility.logger.register_http_logging(app)[source]

Processing time logger for HTTP requests and response status.

system.utility.model module

Gemini model initialization and caching with API setup.

system.utility.model.get_model() → LiteLlm[source]

Return the cached model name, or raise if not loaded.

system.utility.model.load_model(model_name: str = 'groq/openai/gpt-oss-20b')[source]

Load and cache the model name on startup.

system.utility.schema module

Schema definitions for API endpoints.

class system.utility.schema.AgentOutputSchema(*, result: str, findings: str | None = None, plot: str | None = None, status: str = 'success', timestamp: str)[source]

Bases: BaseModel

Agent response schema.

findings: str | None
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

plot: str | None
result: str
status: str
timestamp: str
class system.utility.schema.UserInputSchema(*, ticker: Annotated[str, MinLen(min_length=1), MaxLen(max_length=6)])[source]

Bases: BaseModel

Ticker input validation schema.

model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

ticker: str
classmethod validate_ticker(value: str) → str[source]

Validate and normalize ticker to uppercase.

system.utility.utils module

Utility helpers for the project.

Includes functions to build retry configuration and environment variable handling.

system.utility.utils.get_env(name: str, default: str = '') → str[source]

Get environment variable with sanitization (strip quotes and whitespace).

system.utility.utils.retry_config()[source]

Return retry configuration for transient HTTP errors.

Handles rate limits and temporary service unavailability.

system.utility.utils.retry_on_exception(max_attempts: int = 3, delay: float = 1.0, backoff: float = 2.0)[source]

Decorator to retry a function on exception.

Parameters:
  • max_attempts – Maximum number of attempts

  • delay – Initial delay between attempts

  • backoff – Multiplier for delay on each retry

Module contents