🔍 Code Extractor

class SummarizationConfig

Maturity: 34

A configuration wrapper class that manages settings for a text summarization model by encapsulating a SummarizationModel instance.

File:
/tf/active/vicechatdev/chromadb-cleanup/src/summarization/models.py
Lines:
8 - 17
Complexity:
simple

Purpose

SummarizationConfig serves as a configuration container for text summarization operations. It initializes and manages a SummarizationModel instance with specified parameters (model name, token limits, and temperature settings) and provides a method to retrieve the current model configuration as a dictionary. This class acts as a facade pattern, simplifying access to model configuration details.

Source Code

class SummarizationConfig:
    def __init__(self, model_name: str, max_tokens: int = 150, temperature: float = 0.7):
        self.model = SummarizationModel(model_name=model_name, max_tokens=max_tokens, temperature=temperature)

    def get_model_config(self):
        return {
            "model_name": self.model.model_name,
            "max_tokens": self.model.max_tokens,
            "temperature": self.model.temperature
        }

Parameters

Name Type Default Kind
bases - -

Parameter Details

model_name: String identifier for the summarization model to be used. This should correspond to a valid model name recognized by the SummarizationModel class (e.g., 'gpt-3.5-turbo', 'claude-2'). Required parameter with no default value.

max_tokens: Integer specifying the maximum number of tokens the model should generate in its summary output. Controls the length of generated summaries. Default value is 150 tokens. Must be a positive integer.

temperature: Float value between 0.0 and 1.0 controlling the randomness of model outputs. Lower values (closer to 0) produce more deterministic and focused summaries, while higher values (closer to 1) produce more creative and varied outputs. Default value is 0.7.

Return Value

Instantiation returns a SummarizationConfig object that contains a configured SummarizationModel instance. The get_model_config() method returns a dictionary with three keys: 'model_name' (str), 'max_tokens' (int), and 'temperature' (float), representing the current configuration of the underlying model.

Class Interface

Methods

__init__(self, model_name: str, max_tokens: int = 150, temperature: float = 0.7)

Purpose: Initializes a new SummarizationConfig instance by creating and storing a SummarizationModel with the specified configuration parameters

Parameters:

  • model_name: String identifier for the summarization model to use
  • max_tokens: Maximum number of tokens for model output (default: 150)
  • temperature: Sampling temperature for output randomness (default: 0.7)

Returns: None (constructor)

get_model_config(self) -> dict

Purpose: Retrieves the current configuration settings of the underlying SummarizationModel as a dictionary

Returns: Dictionary containing 'model_name' (str), 'max_tokens' (int), and 'temperature' (float) keys with their corresponding values from the model instance

Attributes

Name Type Description Scope
model SummarizationModel Instance of SummarizationModel configured with the parameters provided during initialization. This attribute provides direct access to the underlying model for summarization operations. instance

Dependencies

  • pydantic

Required Imports

from pydantic import BaseModel

Usage Example

# Instantiate the configuration with default settings
config = SummarizationConfig(model_name='gpt-3.5-turbo')

# Instantiate with custom settings
config = SummarizationConfig(
    model_name='gpt-4',
    max_tokens=200,
    temperature=0.5
)

# Retrieve the current model configuration
model_settings = config.get_model_config()
print(model_settings)
# Output: {'model_name': 'gpt-4', 'max_tokens': 200, 'temperature': 0.5}

# Access the underlying model directly
model = config.model
print(model.model_name)  # 'gpt-4'

Best Practices

  • Always provide a valid model_name that is supported by the SummarizationModel class to avoid initialization errors
  • Keep temperature values between 0.0 and 1.0 for predictable behavior; values outside this range may cause unexpected results
  • Set max_tokens appropriately based on your use case: lower values (50-100) for brief summaries, higher values (200-500) for detailed summaries
  • The class creates a SummarizationModel instance during initialization, so instantiation may have side effects depending on SummarizationModel's constructor
  • Use get_model_config() to inspect current settings before making summarization calls
  • This class is stateless after initialization - the configuration cannot be modified after creation; create a new instance if different settings are needed
  • The underlying model instance is publicly accessible via the 'model' attribute, allowing direct interaction if needed

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class SummarizationModel 76.3% similar

    A Pydantic data model class that defines the configuration schema for a text summarization model, including model name, token limits, and temperature settings.

    From: /tf/active/vicechatdev/chromadb-cleanup/src/summarization/models.py
  • function create_summary 62.3% similar

    Creates a text summary using OpenAI's GPT models or returns a truncated version as fallback when API key is unavailable.

    From: /tf/active/vicechatdev/chromadb-cleanup/src/summarization/summarizer.py
  • function summarize_text 53.1% similar

    A deprecated standalone function that was originally designed to summarize groups of similar documents but now only returns the input documents unchanged with a deprecation warning.

    From: /tf/active/vicechatdev/chromadb-cleanup/src/summarization/summarizer.py
  • class Config 51.8% similar

    Configuration class that manages application-wide settings, directory structures, API keys, and operational parameters for a statistical analysis application.

    From: /tf/active/vicechatdev/vice_ai/smartstat_config.py
  • class AnalysisConfiguration 48.3% similar

    A dataclass that encapsulates configuration parameters for statistical analysis operations, including analysis type, variables, and statistical thresholds.

    From: /tf/active/vicechatdev/vice_ai/models.py
← Back to Browse