File size: 2,521 Bytes
dd39508 0f53af1 1c64423 accd7bc 35909d0 0f53af1 accd7bc 35909d0 accd7bc c2e047f accd7bc 35909d0 c2e047f dd39508 35909d0 c2e047f 35909d0 c2e047f 35909d0 accd7bc c2e047f accd7bc 1c64423 0f53af1 35909d0 0f53af1 c2e047f 35909d0 |
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
|