89 lines
3.2 KiB
Python
89 lines
3.2 KiB
Python
"""
|
|
Pydantic models for prompt-related data.
|
|
"""
|
|
|
|
from typing import List, Optional, Dict, Any
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class PromptResponse(BaseModel):
|
|
"""Response model for a single prompt."""
|
|
key: str = Field(..., description="Prompt key (e.g., 'prompt00')")
|
|
text: str = Field(..., description="Prompt text content")
|
|
position: int = Field(..., description="Position in history (0 = most recent)")
|
|
|
|
class Config:
|
|
"""Pydantic configuration."""
|
|
from_attributes = True
|
|
|
|
|
|
class PoolStatsResponse(BaseModel):
|
|
"""Response model for pool statistics."""
|
|
total_prompts: int = Field(..., description="Total prompts in pool")
|
|
prompts_per_session: int = Field(..., description="Prompts drawn per session")
|
|
target_pool_size: int = Field(..., description="Target pool volume")
|
|
available_sessions: int = Field(..., description="Available sessions in pool")
|
|
needs_refill: bool = Field(..., description="Whether pool needs refilling")
|
|
|
|
|
|
class HistoryStatsResponse(BaseModel):
|
|
"""Response model for history statistics."""
|
|
total_prompts: int = Field(..., description="Total prompts in history")
|
|
history_capacity: int = Field(..., description="Maximum history capacity")
|
|
available_slots: int = Field(..., description="Available slots in history")
|
|
is_full: bool = Field(..., description="Whether history is full")
|
|
|
|
|
|
class FeedbackWord(BaseModel):
|
|
"""Model for a feedback word with weight."""
|
|
key: str = Field(..., description="Feedback key (e.g., 'feedback00')")
|
|
word: str = Field(..., description="Feedback word")
|
|
weight: int = Field(..., ge=0, le=6, description="Weight from 0-6")
|
|
|
|
|
|
class FeedbackHistoryItem(BaseModel):
|
|
"""Model for a feedback history item (word only, no weight)."""
|
|
key: str = Field(..., description="Feedback key (e.g., 'feedback00')")
|
|
word: str = Field(..., description="Feedback word")
|
|
|
|
|
|
class GeneratePromptsRequest(BaseModel):
|
|
"""Request model for generating prompts."""
|
|
count: Optional[int] = Field(
|
|
None,
|
|
ge=1,
|
|
le=20,
|
|
description="Number of prompts to generate (defaults to settings)"
|
|
)
|
|
use_history: bool = Field(
|
|
True,
|
|
description="Whether to use historic prompts as context"
|
|
)
|
|
use_feedback: bool = Field(
|
|
True,
|
|
description="Whether to use feedback words as context"
|
|
)
|
|
|
|
|
|
class GeneratePromptsResponse(BaseModel):
|
|
"""Response model for generated prompts."""
|
|
prompts: List[str] = Field(..., description="Generated prompts")
|
|
count: int = Field(..., description="Number of prompts generated")
|
|
used_history: bool = Field(..., description="Whether history was used")
|
|
used_feedback: bool = Field(..., description="Whether feedback was used")
|
|
|
|
|
|
class RateFeedbackWordsRequest(BaseModel):
|
|
"""Request model for rating feedback words."""
|
|
ratings: Dict[str, int] = Field(
|
|
...,
|
|
description="Dictionary of word to rating (0-6)"
|
|
)
|
|
|
|
|
|
class RateFeedbackWordsResponse(BaseModel):
|
|
"""Response model for rated feedback words."""
|
|
feedback_words: List[FeedbackWord] = Field(..., description="Rated feedback words")
|
|
added_to_history: bool = Field(..., description="Whether added to history")
|
|
|