mirror of
https://github.com/wassname/Open-Assistant.git
synced 2026-06-28 16:20:34 +08:00
add config defaults for postgres dev docker image, support setting POSTGRES_PASSWORD
This commit is contained in:
@@ -1 +1,2 @@
|
||||
.venv
|
||||
*.pyc
|
||||
|
||||
+18
-2
@@ -1,6 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# touch
|
||||
from typing import List, Optional, Union
|
||||
from typing import Any, Dict, List, Optional, Union
|
||||
|
||||
from pydantic import AnyHttpUrl, BaseSettings, PostgresDsn, validator
|
||||
|
||||
@@ -8,8 +7,25 @@ from pydantic import AnyHttpUrl, BaseSettings, PostgresDsn, validator
|
||||
class Settings(BaseSettings):
|
||||
PROJECT_NAME: str = "open-chatGPT backend"
|
||||
API_V1_STR: str = "/api/v1"
|
||||
|
||||
POSTGRES_SERVER: str = "localhost:5432"
|
||||
POSTGRES_USER: str = "postgres"
|
||||
POSTGRES_PASSWORD: str = "postgres"
|
||||
POSTGRES_DB: str = "postgres"
|
||||
DATABASE_URI: Optional[PostgresDsn] = None
|
||||
|
||||
@validator("DATABASE_URI", pre=True)
|
||||
def assemble_db_connection(cls, v: Optional[str], values: Dict[str, Any]) -> Any:
|
||||
if isinstance(v, str):
|
||||
return v
|
||||
return PostgresDsn.build(
|
||||
scheme="postgresql",
|
||||
user=values.get("POSTGRES_USER"),
|
||||
password=values.get("POSTGRES_PASSWORD"),
|
||||
host=values.get("POSTGRES_SERVER"),
|
||||
path=f"/{values.get('POSTGRES_DB') or ''}",
|
||||
)
|
||||
|
||||
BACKEND_CORS_ORIGINS: List[AnyHttpUrl] = []
|
||||
UPDATE_ALEMBIC: bool = True
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ from pydantic import BaseModel
|
||||
class TaskRequest(BaseModel):
|
||||
"""The frontend asks the backend for a task."""
|
||||
|
||||
type: Literal
|
||||
type: str
|
||||
user_id: Optional[str] = None
|
||||
|
||||
|
||||
@@ -21,14 +21,14 @@ class Task(BaseModel):
|
||||
"""A task is a unit of work that the backend gives to the frontend."""
|
||||
|
||||
id: UUID = pydantic.Field(default_factory=UUID)
|
||||
type: Literal
|
||||
type: str
|
||||
addressed_users: Optional[list[str]] = None
|
||||
|
||||
|
||||
class TaskResponse(BaseModel):
|
||||
"""A task response is a message from the frontend to acknowledge the given task."""
|
||||
|
||||
type: Literal
|
||||
type: str
|
||||
status: Literal["success", "failure"]
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ class TaskDone(Task):
|
||||
class Interaction(BaseModel):
|
||||
"""An interaction is a message from the frontend to the backend."""
|
||||
|
||||
type: Literal
|
||||
type: str
|
||||
user_id: str
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
export DATABASE_URI=postgresql://postgres:postgres@localhost:5432/postgres
|
||||
|
||||
uvicorn app.main:app --reload
|
||||
|
||||
Reference in New Issue
Block a user