Commit Graph

32 Commits

Author SHA1 Message Date
Andreas Köpf 7f562fbbae add managed_tx_function() decorator and use it for startup db-calls 2023-01-16 09:16:28 +01:00
Yannic Kilcher c0cb15bbb0 fixing text frontend and startup creation 2023-01-16 00:11:20 +01:00
Yannic Kilcher 5d441b1570 prepared playbook for prod 2023-01-15 23:30:16 +01:00
Andreas Köpf e58ffd64fa add /api/v1/users/{user_id}/stats endpoint (#744)
* add /api/v1/users/{user_id}/stats endpoint

* return 0 stats and add /api/v1/users/{user_id}/stats/{time_frame}

* use utcnow() as modified date for 0 stats
2023-01-15 20:24:15 +00:00
Andreas Köpf b5bb5bb7c0 Add leaderboard stats, periodic updates via fastapi-utils (#724)
* add leaderboard stats, periodic update via fastapi-utils

* count label tasks for assistant and prompter replies

* Daily stats update every 15 mins, simplify leaderboard endpoint

* add indices for some created_date columns

* make user stats update intervals configurable

* make sure intervals are positive
2023-01-15 12:04:19 +01:00
Andreas Koepf 343853fb57 add TreeManagerConfiguration as sub-module to global pydantic settings class 2023-01-13 15:52:09 +00:00
Andreas Koepf 448d17dd61 Set some message trees into ranking state after seed-data insertion 2023-01-13 13:57:55 +00:00
dhug 9421488619 Add realistic seed data json and update seed_data to properly label task payloads (#613)
* modifies seed_data script to properly label taks types as prompteror assistant

* added realistic data json

* pre-commit changes

* update realistic_seed_data.json 5000 messages -> 450 messages

* pre-commit changes

* modifies seed_data script to properly label taks types as prompteror assistant

* added realistic data json

* pre-commit changes

* update realistic_seed_data.json 5000 messages -> 450 messages

* pre-commit changes

* changed DEBUG_USE_SEED_DATA_PATH to realistic_seed_data, merged with main, ran pre-commit

* Delete 2023_01_10_2052-06cc56417e69_.py

Co-authored-by: Andreas Köpf <andreas.koepf@provisio.com>
2023-01-11 18:48:14 +01:00
Andreas Köpf 14fa08e2e7 Message tree state machine (#555)
* 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>
2023-01-11 10:54:03 +01:00
Andreas Köpf 8906854dbf Extract UserRepository and TaskRepository from PromptRepository
* Extract classes UserRepository and TaskRepository from PromptRepository
* move close_task() to TaskRepository and get_user_leaderboard to UserRepository()
* Use UserRepository in leaderboards endpoint, add type annotation to leaderboards endpoint
2023-01-08 19:08:47 +01:00
Daniel Hug f75a07301b Conversation messages refactor add msg ids (#500)
* update ConversationMessage in protocal.py

* updated ConversationMessage instantiations in tasks.py and util.py to include message_id and frontend_message_id

* changed message_id and frontend_message_id to type UUID

* update ConversationMessage instantiation in main.py to include message_id and frontend_message_id"

* changed frontend_message_id to type str

* ran precomit
2023-01-07 19:16:32 +01:00
Andreas Köpf 96d6717be4 Fetch conversation for seed data tasks, minor model fixes (#485)
* Fetch conversation for seed data, fix models, remove redundant payload type checks
2023-01-07 15:59:54 +01:00
Ken Tsui 043b5eff5a Add DEBUG_USD_SEED_DATA_PATH in config to make seed data flexible (#395)
* Add DEBUG_USD_SEED_DATA_PATH in config to make seed data flexible

* reformat

* Copy test_data folder in Dockerfile.backend, correct DEBUG_USE_SEED_DATA_PATH in cofig

* - make DEBUG_USE_SEED_DATA_PATH to absolute path
- correct test_data path in  Dockerfile.backend
2023-01-07 14:37:30 +01:00
Nil Andreu ee50b573e1 Detoxify Rest API Client (#404)
* [NEW] utils: Endpoint Toxic Roberta

* [NEW] Constants API URL

* [NEW] Git ignore venv

* [NEW] Lint

* [NEW] Backend default args

* [NEW] HUGGINGFACE_API_ERROR

* [NEW] Requests package

* [NEW] Get Toxicity Endpoint

* [NEW] Schema:  ToxicityClassification

[NEW] Constants module

[FIX] Module

* [FIX] Test Key HF

* [NEW] settings: HUGGING_FACE_API_KEY

* [NEW] Remove requests

* [NEW] HuggingFace client

* [NEW] Cleaning code
2023-01-05 16:18:04 +01:00
Jack Michaud 5bb9a397b4 feat: add OasstErrorResponse to protocols
Using a shared protocol to serialize the error in the backend
allows clients to use that same protocol to deserialize it.

Changes to this protocol will be caught in tests.
2023-01-02 19:01:29 -05:00
Jack Michaud c7ac01718c refactor: move OasstError into oasst_shared.exceptions (#289)
* refactor: move OasstError into oasst_shared.exceptions

* fix: update OasstError import

* fix: linter errors
2023-01-02 22:03:53 +01:00
kiritowu 2a2968f6d4 Initialise redis connection for Fastapi limiter 2023-01-03 00:28:05 +08:00
Gareth Davidson 7000e10bc0 apply pre-commit rules 2023-01-02 00:01:45 +00:00
Jack Michaud 29b08875d4 refactor: move print_openapi_schema into main 2023-01-01 18:58:01 +01:00
Andreas Köpf ee14554e1b role='user' -> role='prompter' 2022-12-31 00:18:55 +01:00
Andreas Köpf 26ae43e945 additional forgotten renamings 2022-12-31 00:18:55 +01:00
Andreas Köpf 8b225430a4 BREAKING-CHANGES: Renaming several models/database objects + API protocol
person -> user
work_package -> task
post -> message
thread -> message_tree
2022-12-31 00:18:55 +01:00
alexandrelefourner 35e0c32a08 Updating work_package to task 2022-12-31 00:18:55 +01:00
alexandrelefourner 7743459220 Renaming post to message 2022-12-31 00:18:55 +01:00
Andreas Köpf c5053ed6c9 fix typo: uesr->user 2022-12-29 16:13:30 +01:00
Andreas Köpf 833549f212 add two dummy user replies depth>1 2022-12-29 15:58:35 +01:00
Andreas Köpf 30db7254c7 rename flag to DEBUG_USE_SEED_DATA default False, update compose config 2022-12-29 15:58:35 +01:00
Andreas Köpf c2cb2562d5 add db seed-data check on backend startup 2022-12-29 15:58:35 +01:00
Andreas Köpf 0c3103838b add OasstErrorCode IntEnum, use http.HTTPStatus enum 2022-12-28 19:25:39 +01:00
Andreas Köpf 36c74e238c rename handler function to 2022-12-28 14:22:53 +01:00
Andreas Köpf dda668bcd5 Add OasstError exception class and exception filter 2022-12-28 14:10:15 +01:00
Yannic Kilcher b34ef75423 started re-working python code 2022-12-19 18:00:09 +01:00