Scaffold V2 backend foundation
This commit is contained in:
@@ -0,0 +1 @@
|
||||
|
||||
22
ai_knowledge_base_v2/apps/backend/app/schemas/auth.py
Normal file
22
ai_knowledge_base_v2/apps/backend/app/schemas/auth.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from app.schemas.user import UserProfile
|
||||
|
||||
|
||||
class SendSmsRequest(BaseModel):
|
||||
phone: str = Field(min_length=11, max_length=20)
|
||||
|
||||
|
||||
class LoginRequest(BaseModel):
|
||||
phone: str = Field(min_length=11, max_length=20)
|
||||
code: str = Field(min_length=4, max_length=8)
|
||||
|
||||
|
||||
class LoginResponse(BaseModel):
|
||||
token: str
|
||||
expiredAt: datetime
|
||||
user: UserProfile
|
||||
42
ai_knowledge_base_v2/apps/backend/app/schemas/chat.py
Normal file
42
ai_knowledge_base_v2/apps/backend/app/schemas/chat.py
Normal file
@@ -0,0 +1,42 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
|
||||
from app.schemas.common import ORMModel
|
||||
|
||||
|
||||
class CreateSessionResponse(BaseModel):
|
||||
sessionId: int
|
||||
|
||||
|
||||
class ChatSessionRead(ORMModel):
|
||||
model_config = ConfigDict(from_attributes=True, populate_by_name=True)
|
||||
|
||||
id: int
|
||||
title: str
|
||||
messageCount: int = Field(alias="message_count")
|
||||
updatedAt: datetime = Field(alias="updated_at")
|
||||
|
||||
|
||||
class ChatMessageRead(ORMModel):
|
||||
id: int
|
||||
role: str
|
||||
content: str
|
||||
message_status: str
|
||||
created_at: datetime
|
||||
|
||||
|
||||
class UpdateSessionTitleRequest(BaseModel):
|
||||
sessionId: int
|
||||
title: str = Field(min_length=1, max_length=100)
|
||||
|
||||
|
||||
class ChatCompletionRequest(BaseModel):
|
||||
sessionId: int
|
||||
message: str = Field(min_length=1, max_length=4000)
|
||||
|
||||
|
||||
class StopChatRequest(BaseModel):
|
||||
sessionId: int
|
||||
7
ai_knowledge_base_v2/apps/backend/app/schemas/common.py
Normal file
7
ai_knowledge_base_v2/apps/backend/app/schemas/common.py
Normal file
@@ -0,0 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
|
||||
|
||||
class ORMModel(BaseModel):
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
20
ai_knowledge_base_v2/apps/backend/app/schemas/user.py
Normal file
20
ai_knowledge_base_v2/apps/backend/app/schemas/user.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from pydantic import Field
|
||||
|
||||
from app.schemas.common import ORMModel
|
||||
|
||||
|
||||
class UserProfile(ORMModel):
|
||||
id: int
|
||||
phone: str
|
||||
name: str
|
||||
nickname: str | None = None
|
||||
dailyLimit: int = Field(alias="daily_chat_limit")
|
||||
todayUsed: int = Field(alias="daily_chat_used")
|
||||
status: int
|
||||
effective_at: datetime | None = None
|
||||
expired_at: datetime | None = None
|
||||
last_login_at: datetime | None = None
|
||||
Reference in New Issue
Block a user