mirror of
https://github.com/wassname/Open-Assistant.git
synced 2026-07-21 12:20:08 +08:00
* add query_incomplete_rankings() * Add SQL queries for TreeManager task selection * first working version of TreeManager.next_task() * remove old generate_task(), add mandatory_labels to text_labels task * Add ConversationMessage list to Ranking tasks * add more sophisticated sql queries to find extendible trees * add TreeManager.query_extendible_parents() * fix task validation, seed data insertion (reviewed) * provide user for task selection in text-frontend * enter 'growing' state * enter 'aborted_low_grade' state * enter 'ranking' state * check tree 'growing' state upon relpy insertion * exclude user from labeling their own messages (added DEBUG_ALLOW_SELF_LABELING setting) * add DEBUG_ALLOW_SELF_LABELING to docker-compose.yaml * fix ranking submission * add query_tree_ranking_results() * add ranked_message_ids to RankingReactionPayload * fix reply_messages instead of prompt_messages * incorment 'ranking_count' of ranked replies * added logic to check_condition_for_scoring_state * changes to msg_tree_state_machine * pre-commit changes * enter 'ready_for_scoring' state * re-add HF embedding call (lost during merge) * use prepare_conversation() helper for seed-data creation * Partially add user specified task selection Co-authored-by: Daniel Hug <danielpatrickhug@gmail.com>
59 lines
1.9 KiB
Python
59 lines
1.9 KiB
Python
from pathlib import Path
|
|
from typing import Any, Dict, List, Optional, Union
|
|
|
|
from pydantic import AnyHttpUrl, BaseSettings, FilePath, PostgresDsn, validator
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
PROJECT_NAME: str = "open-assistant backend"
|
|
API_V1_STR: str = "/api/v1"
|
|
|
|
POSTGRES_HOST: str = "localhost"
|
|
POSTGRES_PORT: str = "5432"
|
|
POSTGRES_USER: str = "postgres"
|
|
POSTGRES_PASSWORD: str = "postgres"
|
|
POSTGRES_DB: str = "postgres"
|
|
DATABASE_URI: Optional[PostgresDsn] = None
|
|
|
|
RATE_LIMIT: bool = True
|
|
REDIS_HOST: str = "localhost"
|
|
REDIS_PORT: str = "6379"
|
|
|
|
DEBUG_ALLOW_ANY_API_KEY: bool = False
|
|
DEBUG_SKIP_API_KEY_CHECK: bool = False
|
|
DEBUG_USE_SEED_DATA: bool = False
|
|
DEBUG_USE_SEED_DATA_PATH: Optional[FilePath] = (
|
|
Path(__file__).parent.parent / "test_data/generic/test_generic_data.json"
|
|
)
|
|
DEBUG_ALLOW_SELF_LABELING: bool = False # allow users to label their own messages
|
|
DEBUG_SKIP_EMBEDDING_COMPUTATION: bool = False
|
|
|
|
HUGGING_FACE_API_KEY: str = ""
|
|
|
|
@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_HOST"),
|
|
port=values.get("POSTGRES_PORT"),
|
|
path=f"/{values.get('POSTGRES_DB') or ''}",
|
|
)
|
|
|
|
BACKEND_CORS_ORIGINS: List[AnyHttpUrl] = []
|
|
UPDATE_ALEMBIC: bool = True
|
|
|
|
@validator("BACKEND_CORS_ORIGINS", pre=True)
|
|
def assemble_cors_origins(cls, v: Union[str, List[str]]) -> Union[List[str], str]:
|
|
if isinstance(v, str) and not v.startswith("["):
|
|
return [i.strip() for i in v.split(",")]
|
|
elif isinstance(v, (list, str)):
|
|
return v
|
|
raise ValueError(v)
|
|
|
|
|
|
settings = Settings(_env_file=".env")
|