File size: 2,521 Bytes
7f03ffe 1b86d8a d919708 ead0f7d 87b09dd 1b86d8a ead0f7d 87b09dd ead0f7d bbbddac ead0f7d 87b09dd bbbddac 7f03ffe 87b09dd bbbddac 87b09dd bbbddac 87b09dd ead0f7d bbbddac ead0f7d d919708 1b86d8a 87b09dd 1b86d8a bbbddac 87b09dd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# api/models.py
from pydantic import BaseModel, Field
from typing import List, Optional
from fastapi_users import schemas
from datetime import datetime
# Pydantic schemas for fastapi-users
class UserRead(schemas.BaseUser[int]):
id: int
email: str
is_active: bool = True
is_superuser: bool = False
display_name: Optional[str] = None
preferred_model: Optional[str] = None
job_title: Optional[str] = None
education: Optional[str] = None
interests: Optional[str] = None
additional_info: Optional[str] = None
conversation_style: Optional[str] = None
model_config = {"from_attributes": True}
class UserCreate(schemas.BaseUserCreate):
email: str
password: str
is_active: Optional[bool] = True
is_superuser: Optional[bool] = False
display_name: Optional[str] = None
preferred_model: Optional[str] = None
job_title: Optional[str] = None
education: Optional[str] = None
interests: Optional[str] = None
additional_info: Optional[str] = None
conversation_style: Optional[str] = None
model_config = {"from_attributes": True}
# Pydantic schema for updating user settings
class UserUpdate(BaseModel):
display_name: Optional[str] = None
preferred_model: Optional[str] = None
job_title: Optional[str] = None
education: Optional[str] = None
interests: Optional[str] = None
additional_info: Optional[str] = None
conversation_style: Optional[str] = None
model_config = {"from_attributes": True}
# Pydantic schemas للمحادثات
class MessageOut(BaseModel):
id: int
role: str
content: str
created_at: datetime
model_config = {"from_attributes": True}
class ConversationCreate(BaseModel):
title: Optional[str] = None
class ConversationOut(BaseModel):
id: int
conversation_id: str
title: Optional[str]
created_at: datetime
updated_at: datetime
messages: List[MessageOut] = []
model_config = {"from_attributes": True}
# نموذج طلب الاستعلام
class QueryRequest(BaseModel):
message: str
system_prompt: Optional[str] = "You are an expert assistant providing detailed, comprehensive, and well-structured responses."
history: Optional[List[dict]] = []
temperature: Optional[float] = 0.7
max_new_tokens: Optional[int] = 2048
enable_browsing: Optional[bool] = True
output_format: Optional[str] = "text"
title: Optional[str] = None
ConversationOut.model_revalidate = True
MessageOut.model_revalidate = True
|