Commit Graph

48 Commits

Author SHA1 Message Date
Andreas Köpf ead51ff423 770 tree manager allow to specify desired task_type no prompter ranking (#775)
* only ranking assistant replies by default

* add tasks/availability endpoint allow to specify desired task

* move rank_prompter_replies option to TreeManagerConfiguration

* fix type annotation

* remove desired_task_type from _random_task_selection()

* fix typo

* Convert query_tree_size to sqlachemy, return 'full' text-labeling tasks if they were explicitly requested
2023-01-16 20:05:40 +01:00
James Melvin Ebenezer c6fbf5543b 599 add row versioning to backend tables (#710)
* fix: isolation level and nested db.commit() with retry wrappers on concurrent update errors

* refactor: incorporated review comments

changes decorator methods to managed_tx_method and async_managed_tx_method
new enum CommitMode
removed commented commit() from the previous commits

* fix: merge pre-commit errors

* fix: merge pre-commit changes

* fix: conflict in existing OasstErrorCode

* refactor: Added a refresh just to be sure that the select command is triggered on the mapped object

* fix: added refresh for async decorator

Co-authored-by: James Melvin <melvin@gameface.ai>
2023-01-16 08:43:07 +01:00
Andreas Köpf de28d67031 infer role from task in store_text_reply() 2023-01-16 00:19:30 +01:00
Yannic Kilcher cc03376d86 added root tokens and endpoint for adding api keys (#742)
* added root tokens and endpoint for adding api keys

* Change down revision to current alembic head

* removed added_by_root_token

* refactored description

* fixed jinja errors

Co-authored-by: Andreas Köpf <andreas.koepf@provisio.com>
2023-01-15 21:24:25 +00: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 Köpf 8b8326e22f add /by_display_name user query & created_date to FrontEndUser model 2023-01-14 11:03:25 +01:00
Andreas Köpf 945c645818 returning list[FrontEndUser] from api/v1/frontend_users/ endpoint 2023-01-12 22:58:43 +01:00
Andreas Köpf 025d20e638 shuffle ranking options, add simple mode for text-labels 2023-01-11 23:47:56 +01:00
Andreas Köpf f32ec78988 Returning from /api/v1/frontend_users/{auth_method}/{username}
fixes #615
2023-01-11 14:46:29 +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
Oliver Stanley e5abb2dc85 536: Add endpoint to resolve frontend user by auth method and username (#539)
* Add endpoint to resolve frontend user by auth method and username

* Require client ID for frontend user lookup

* Remove unnecessary if check

* Fix PromptRepository -> UserRepository

* Convert to protocol User

* Move User prep

* Address review comments

* 404 -> HTTP_404_NOT_FOUND
2023-01-10 18:20:56 +01:00
Yannic Kilcher ec0f9bb536 Merge pull request #535 from olliestanley/525-refine-hate-speech
525: Refine label for hate_speech
2023-01-08 16:04:42 +01:00
Oliver 570d39edec Refine label for hate_speech 2023-01-08 11:51:32 +00:00
Oliver 78fac2b5f5 Refine label for harmful 2023-01-08 11:44:57 +00:00
Oliver Stanley 710898903d Initial revision to valid text labels (#509) 2023-01-08 10:31:29 +01:00
Andreas Köpf 5e01f421aa add 'help_text' to valid_lables response 2023-01-07 21:48:11 +01:00
Andreas Köpf 5b2cb5dd29 add api/v1/text_labels/valid_labels backend endpoint (#498)
Provides the set of valid text_lables with descriptions via a REST endpoint.
2023-01-07 21:28:24 +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
Oliver Stanley 69bc799cd9 344: Create tasks for text labels (#381)
* Implement label task for initial prompts and replies

* Resolve formatting

* Include missing argument

* Modify text_labels API to match new model, update DB schema accordingly

* Send valid labels as part of label tasks

* Send correctly formatted valid_labels list

* Fix request format

* Fix request details for text-frontend reply label task

* Include message_id in tasks

* Address review comments

* Fix alembic tree
2023-01-06 18:39:04 +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
Graeme Harris c2b6cdb12a Bugfix #173 - Empty task interactions (#373)
* Added pydantic checks for interaction protocols

* Small updated to BE API README for redis and guide to local scripts

* isort linting
2023-01-05 09:19:57 +01:00
Jack Michaud c8aba77a48 chore: pin aiohttp version 2023-01-02 21:11:14 -05:00
Jack Michaud 3dcfe7014e test: add test for unhandled api error 2023-01-02 21:06:00 -05:00
Jack Michaud f66ad30c53 fix: handle empty 204 response 2023-01-02 21:00:23 -05:00
Jack Michaud bc796b70ba test: finish test for handling oasst error 2023-01-02 20:59:59 -05:00
Jack Michaud fbcb0a09e6 chore: move aiohttp client into oasst-shared 2023-01-02 20:38:10 -05:00
Jack Michaud c2a5e08a32 (WIP) test: add test for handling OasstError 2023-01-02 19:07:01 -05:00
Jack Michaud fe21732f8d feat: handle OasstError in OasstApiClient 2023-01-02 19:06:30 -05: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
yeungadrian 4715a53637 #47- Create API endpoints that return leaderboards (#250)
* Leaderboard endpoints proof of concept
- New leaderboards router
- Two endpoints /api/v1/leaderboards/assistant & /api/v1/leaderboards/prompter
- Function in prompt_repository to calculate user scores

* Separating create vs 'eventual' evaluate routes

* Adding display_name to result

* Missing / in routes

* Updating route to be experimental

* Fixing format for pre-commit
2023-01-02 22:38:54 +01:00
Jack Michaud ed115ea17c refactor: move OasstApiClient into oasst-shared (#287)
* refactor: move api_client into oasst-shared

* refactor: move contract tests into oasst-shared

* fix: use new OasstApiClient imports in discord bot
2023-01-02 22:13:20 +01: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
Gareth Davidson 7000e10bc0 apply pre-commit rules 2023-01-02 00:01:45 +00:00
Jack Michaud 904f442f5a fix: indicate that user is optional 2023-01-01 18:58:01 +01:00
Andreas Köpf 7b29582cbb add to protocol.Message 2022-12-31 19:23:54 +01:00
Igor Miagkov ef3a35ff9c fixes 2022-12-31 10:31:31 +01:00
Igor Miagkov 475f48b195 stats api method 2022-12-31 10:31:31 +01:00
Igor Miagkov 13d01b5a2f management api 2022-12-31 10:31:31 +01:00
Andreas Köpf ee14554e1b role='user' -> role='prompter' 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 7743459220 Renaming post to message 2022-12-31 00:18:55 +01:00
Igor Miagkov efafc0173a added support for collective tasks 2022-12-29 21:32:17 +04:00
Andreas Köpf f74fe68f87 add journal table and JournalWriter helper class 2022-12-27 22:37:48 +01:00
Yannic Kilcher 55d003adbe added parens for readability 2022-12-25 19:00:13 +01:00
Yannic Kilcher a37bf6bf41 added text labels to the API 2022-12-25 17:08:57 +01:00
Andreas Köpf aa26c4ad03 fix bot script post oasst_shared creation 2022-12-20 00:55:39 +01:00
Yannic Kilcher b34ef75423 started re-working python code 2022-12-19 18:00:09 +01:00