vitalliuss's picture
Initial upload of LLM Feedback Analyzer application
335bb74 verified
Raw History Blame Contribute Delete
1.94 kB
from pydantic import BaseModel, Field
from typing import Optional, List, Dict, Any
class FeedbackAnalysisConfig(BaseModel):
"""Configuration for feedback analysis."""
model: str = Field(..., description="LLM model to use for analysis")
temperature: float = Field(0.0, description="Temperature setting for the LLM")
max_tokens: int = Field(1000, description="Maximum tokens for LLM response")
batch_size: int = Field(10, description="Number of feedback items to process in each batch")
feedback_column: str = Field(..., description="Column name containing the feedback text")
output_column: str = Field(..., description="Column name for the analysis results")
prompt_template: str = Field(..., description="Template for the analysis prompt")
class FeedbackAnalysisResult(BaseModel):
"""Base model for feedback analysis results."""
raw_response: str = Field(..., description="Raw response from the LLM")
parsed_data: Optional[Dict[str, Any]] = Field(None, description="Parsed structured data")
error: Optional[str] = Field(None, description="Error message if parsing failed")
class BatchProcessingStats(BaseModel):
"""Statistics for batch processing."""
total_items: int = Field(..., description="Total number of items to process")
processed_items: int = Field(0, description="Number of items processed")
successful_items: int = Field(0, description="Number of items successfully processed")
failed_items: int = Field(0, description="Number of items that failed processing")
start_time: float = Field(..., description="Processing start time (timestamp)")
end_time: Optional[float] = Field(None, description="Processing end time (timestamp)")
def calculate_progress(self) -> float:
"""Calculate the current progress as a percentage."""
if self.total_items == 0:
return 1.0
return self.processed_items / self.total_items