feat(prompt-optimizer): add prompt optimization APIs and database tables
- Added API endpoints for prompt optimization:
* POST /prompt/sessions: Create a new prompt optimization session
* GET /prompt/sessions/{session_id}: Retrieve session message history
* POST /prompt/sessions/{session_id}/messages: Send message and get optimized prompt
* PUT /prompt/model: Create or update system prompt model configuration
- Added database models for prompt optimization:
* prompt_opt_session: Stores session metadata
* prompt_opt_session_history: Stores session message history
* prompt_opt_message: Stores user and assistant messages
* prompt_opt_model_config: Stores system prompt model configurations
- Updated service layer to handle message creation, prompt optimization, and variable parsing
- Added corresponding Pydantic schemas for request and response validation
This commit is contained in:
@@ -15,6 +15,25 @@ class ModelType(StrEnum):
|
||||
EMBEDDING = "embedding"
|
||||
RERANK = "rerank"
|
||||
|
||||
@classmethod
|
||||
def from_str(cls, value: str) -> "ModelType":
|
||||
"""
|
||||
Get a ModelType enum instance from a string value.
|
||||
|
||||
Args:
|
||||
value (str): The string representation of the model type.
|
||||
|
||||
Returns:
|
||||
ModelType: The corresponding ModelType enum object.
|
||||
|
||||
Raises:
|
||||
ValueError: If the given value does not match any ModelType.
|
||||
"""
|
||||
try:
|
||||
return cls(value)
|
||||
except ValueError:
|
||||
raise ValueError(f"Invalid ModelType: {value}")
|
||||
|
||||
|
||||
class ModelProvider(StrEnum):
|
||||
"""模型提供商枚举"""
|
||||
|
||||
Reference in New Issue
Block a user