返回 Pixelle-Video
llm.py
根目录 / api / schemas / llm.py
1 # Copyright (C) 2025 AIDC-AI
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 # http://www.apache.org/licenses/LICENSE-2.0
7 # Unless required by applicable law or agreed to in writing, software
8 # distributed under the License is distributed on an "AS IS" BASIS,
9 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 # See the License for the specific language governing permissions and
11 # limitations under the License.
12
13 """
14 LLM API schemas
15 """
16
17 from typing import Optional
18 from pydantic import BaseModel, Field
19
20
21 class LLMChatRequest(BaseModel):
22 """LLM chat request"""
23 prompt: str = Field(..., description="User prompt")
24 temperature: float = Field(0.7, ge=0.0, le=2.0, description="Temperature (0.0-2.0)")
25 max_tokens: int = Field(2000, ge=1, le=32000, description="Maximum tokens")
26
27 class Config:
28 json_schema_extra = {
29 "example": {
30 "prompt": "Explain the concept of atomic habits in 3 sentences",
31 "temperature": 0.7,
32 "max_tokens": 2000
33 }
34 }
35
36
37 class LLMChatResponse(BaseModel):
38 """LLM chat response"""
39 success: bool = True
40 message: str = "Success"
41 content: str = Field(..., description="Generated response")
42 tokens_used: Optional[int] = Field(None, description="Tokens used (if available)")
43
44
44 lines PYTHON