Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(backend/shared): save all messages in ai chat to db bb-454 #541

Open
wants to merge 283 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
283 commits
Select commit Hold shift + click to select a range
1b34e26
refactor(backend): fix imports bb-203
AndriiLevin Sep 10, 2024
4a20f29
feat(backend): add Task Entity bb-203
AndriiLevin Sep 10, 2024
33cb75c
feat(backend): add Task db Model and add relations bb-203
AndriiLevin Sep 10, 2024
9c7ac76
feat(backend): add TaskRepository boilerplate bb-203
AndriiLevin Sep 10, 2024
2bfb504
feat(backend): add TaskService boilerplate bb-203
AndriiLevin Sep 10, 2024
9c4d587
feat(backend): add TaskController boilerplate adn add it to server A…
AndriiLevin Sep 10, 2024
d8cfc26
feat(shared): add Api paths for TaskController bb-203
AndriiLevin Sep 10, 2024
0df4313
feat(backend): add task Module and imports bb-203
AndriiLevin Sep 10, 2024
8b15de0
feat(shared): add TaskSuggestionsResponseDto and exports for AI assis…
AndriiLevin Sep 10, 2024
c3e3247
feat(shared): add TaskGetAllResponseDto and exports bb-203
AndriiLevin Sep 10, 2024
340bc4d
feat(backend): add migration to crate Task table and updated enums bb…
AndriiLevin Sep 10, 2024
9f107fe
refactor(backend): fix imports in AI module bb-203
AndriiLevin Sep 10, 2024
559314b
feat(frontend): add chatApi bb-340
yulyaolshanska Sep 12, 2024
520bb03
feat(frontend): add chat page with mock data bb-340
yulyaolshanska Sep 12, 2024
0f1bfbd
fix(backend): threadId bb-340
yulyaolshanska Sep 12, 2024
f3e16c9
refactor(frontend): chat state bb-340
yulyaolshanska Sep 12, 2024
175c4e0
refactor(frontend): add taskList to data bb-340
yulyaolshanska Sep 12, 2024
a1a56b7
Merge branch 'main' into 340-ai-chat
yulyaolshanska Sep 12, 2024
88e3f00
feat(frontend): add type for message array bb-340
yulyaolshanska Sep 13, 2024
549ef88
feat(frontend): add messageComponent bb-340
yulyaolshanska Sep 13, 2024
218e562
refactor(shared): change Assistant Api Path bb-203
AndriiLevin Sep 13, 2024
68c8dea
feat(shared): add TaskSuggestionsResponseDto bb-203
AndriiLevin Sep 13, 2024
da1ddce
feat(shared): add TaskSuggestionRequestDto bb-203
AndriiLevin Sep 13, 2024
72893a5
feat(shared): add TaskSuggestionRequest validation bb-203
AndriiLevin Sep 13, 2024
45f30b6
feat(shared): add BalanceWheelAnalysisResponseDto bb-203
AndriiLevin Sep 13, 2024
23a2f72
feat(shared): add AiAssistantValidationRule bb-203
AndriiLevin Sep 13, 2024
bd78d96
feat(shared): add AiAssistantValidationMessage bb-203
AndriiLevin Sep 13, 2024
656d5cd
feat(shared): add addMessageToThread validation schema bb-203
AndriiLevin Sep 13, 2024
3209901
refactor(shared): refactor export Ai assistant module bb-203
AndriiLevin Sep 13, 2024
0c59900
feat(shared): add ThreadMessageCreateDto bb-203
AndriiLevin Sep 13, 2024
8f47073
refactor(backend): change AnalyzeBalanceScoresTool function bb-203
AndriiLevin Sep 13, 2024
82bff3d
refactor(backend): change GenerateTaskByCategoryTool function bb-203
AndriiLevin Sep 13, 2024
aee7143
feat(backend): add OpenAiFunctionName bb-203
AndriiLevin Sep 13, 2024
afa1d9c
refactor(backend): change OpenAiPromptTemplates Message bb-203
AndriiLevin Sep 13, 2024
95f290e
feat(backend): add OpenAiRunThreadRequestDto type bb-203
AndriiLevin Sep 13, 2024
dade212
feat(backend): add AiAssistantMessage validation schema bb-203
AndriiLevin Sep 13, 2024
92a06f8
feat(backend): add generate Task method / change API calling bb-203
AndriiLevin Sep 13, 2024
6082c75
refactor(backend): add more settings to OpenAiAssistantConfig bb-203
AndriiLevin Sep 13, 2024
e93fd51
refactor(backend): refactor open-ai module exports and files bb-203
AndriiLevin Sep 13, 2024
8085512
feat(backend): add init chat functionality bb-203
AndriiLevin Sep 13, 2024
7db8329
feat(backend): add suggest task functionality bb-203
AndriiLevin Sep 13, 2024
630272d
feat(backend): add suggestTasksForCategories to AiAssistantService an…
AndriiLevin Sep 13, 2024
69ad7a2
feat(backend): add suggestTasksForCategories to AiAssistantController…
AndriiLevin Sep 13, 2024
2d9199c
refactor(backend): refactor file structure end import in AI Assistant…
AndriiLevin Sep 13, 2024
5688d87
refactor(shared): refactor file structure end import in AI Assistant …
AndriiLevin Sep 13, 2024
166aa57
Merge branch 'main' into 203-feat-AI-Integration bb-203
AndriiLevin Sep 13, 2024
9d9ca62
feat(frontend): merge ai backend bb-340
yulyaolshanska Sep 13, 2024
ed0e480
feat(main): update readme with Task db model bb-203
AndriiLevin Sep 13, 2024
b4e35a0
feat(backend/shared): add question field in balance score response …
AndriiLevin Sep 13, 2024
650c13f
feat(backend): add question field to response bb-340
yulyaolshanska Sep 13, 2024
e6313cc
feat(frontend): change wheel width bb-340
yulyaolshanska Sep 13, 2024
2b7a24d
feat(frontend): change message type bb-340
yulyaolshanska Sep 13, 2024
5f83bcf
feat(frontend): add messages on initConversation bb-340
yulyaolshanska Sep 13, 2024
fd990be
feat(frontend): add buttons bb-340
yulyaolshanska Sep 13, 2024
9d47ae3
Merge branch '203-feat-AI-Integration' into 340-ai-chat
yulyaolshanska Sep 13, 2024
4a9430a
feat(shared): add TaskCreateDto bb-203
AndriiLevin Sep 14, 2024
4ebcab2
feat(shared): add ChangeTaskSuggestionRequestDto bb-203
AndriiLevin Sep 14, 2024
4ca888b
feat(shared): add ChangeTaskSuggestionRequest validation schema/rule/…
AndriiLevin Sep 14, 2024
de0943b
refactor(shared): add TaskCreateDto to TaskSuggestionsResponseDto bb…
AndriiLevin Sep 14, 2024
3322a1a
feat(backend): add changeTask to AiAssistantController bb-203
AndriiLevin Sep 14, 2024
7d07b9e
feat(backend): add changeTask() to AiAssistantService bb-203
AndriiLevin Sep 14, 2024
7656f29
feat(backend): add changeTask Helper bb-203
AndriiLevin Sep 14, 2024
146facb
refactor(backend): change task fields names to be the same as in Dto…
AndriiLevin Sep 14, 2024
0ae35ee
feat(backend): add OpenAi function for change task bb-203
AndriiLevin Sep 14, 2024
e9c7eed
feat(shared): add route for accepting Task bb-203
AndriiLevin Sep 14, 2024
c6ea558
feat(backend): add create() to TaskRepository and add exports bb-203
AndriiLevin Sep 14, 2024
8803c97
feat(backend): add createTask() to AiAssistantController bb-203
AndriiLevin Sep 14, 2024
8b3de74
feat(backend): add createTask() to AiAssistantService bb-203
AndriiLevin Sep 14, 2024
0af1fb6
chore(backend): update import in Ai Module bb-203
AndriiLevin Sep 14, 2024
ec79675
feat(backend): update Ai Module to handle multiple runs bb-203
AndriiLevin Sep 15, 2024
e16a89e
feat(backend): add swagger to AiAssistantController bb-203
AndriiLevin Sep 15, 2024
1c4df15
refactor(shared): rename AiAssistantApiPath path bb-203
AndriiLevin Sep 15, 2024
82d956f
refactor(shared): change AiAssistantValidationRule and schema bb-203
AndriiLevin Sep 15, 2024
cc223c4
feat(shared): add INDEX_ONE constant bb-340
yulyaolshanska Sep 15, 2024
522e328
feat(shared): add type AppDispatch bb-340
yulyaolshanska Sep 15, 2024
daf2d85
feat(frontend): import types bb-340
yulyaolshanska Sep 15, 2024
8d4cdea
refactor(frontend): message type bb-340
yulyaolshanska Sep 15, 2024
0493c0d
feat(frontend): add getTasksForCategories to Api bb-340
yulyaolshanska Sep 15, 2024
4e64531
feat(frontend): add handleButtonAction helper bb-340
yulyaolshanska Sep 15, 2024
c3780c5
feat(frontend): add ConfirmationButtons component bb-340
yulyaolshanska Sep 15, 2024
d0c6819
feat(frontend): handleCategoriesSubmit bb-340
yulyaolshanska Sep 15, 2024
9d651c9
feat(frontend): get tasl list bb-340
yulyaolshanska Sep 15, 2024
6aeadf0
fix(frontend/backend): change type for categoryId, remove score bb-340
yulyaolshanska Sep 15, 2024
1073436
fix(frontend): handleFormSubmit wrapper bb-340
yulyaolshanska Sep 15, 2024
134b26d
refactor(frontend): clean code bb-340
yulyaolshanska Sep 15, 2024
dcfd1ba
Merge branch '203-feat-AI-Integration' into 340-ai-chat
yulyaolshanska Sep 15, 2024
877ce6d
refactor(shared): change AiAssistantValidationRule and schema bb-203
AndriiLevin Sep 15, 2024
a6ce443
refactor(backend): delete redundant score field in lowestCategories …
AndriiLevin Sep 15, 2024
6d02e3a
refactor(backend): delete redundant score field in lowestCategories …
AndriiLevin Sep 15, 2024
f5e6575
refactor(backend): fix names in TaskSuggestionRequestDto bb-203
AndriiLevin Sep 15, 2024
ea41b46
fix(frontend/backend): merge conflict bb-340
yulyaolshanska Sep 15, 2024
941266c
refactor(backend): fix names in TaskSuggestionRequest validation bb…
AndriiLevin Sep 15, 2024
9a8be45
refactor(backend): fix names in TaskSuggestionRequest dto bb-203
AndriiLevin Sep 15, 2024
aad378e
refactor(backend): fix types in lowestCategories bb-203
AndriiLevin Sep 15, 2024
b0db003
Merge branch 'main' into 203-feat-AI-Integration bb-203
AndriiLevin Sep 15, 2024
e8f2649
Merge branch 'main' into 203-feat-AI-Integration
AndriiLevin Sep 16, 2024
5ee1709
refactor(backend): change names for Assistant tools bb-203
AndriiLevin Sep 16, 2024
cc35c28
chore(backend): update and fix dependencies bb-203
AndriiLevin Sep 16, 2024
24ee13f
refactor(backend): update handleRequiresAction for more clear code b…
AndriiLevin Sep 16, 2024
e99f6b0
refactor(backend): refactor methods to create prompts to reduce nestl…
AndriiLevin Sep 16, 2024
668c312
refactor(backend): refactor names in init-chat files bb-203
AndriiLevin Sep 16, 2024
f73f5c1
refactor(backend): refactor generate AI response files to reduce nest…
AndriiLevin Sep 16, 2024
3e49cd2
refactor(main): delete duplicated Task table from readme bb-203
AndriiLevin Sep 16, 2024
798216b
refactor(backend): rename validation schemas in AI Module bb-203
AndriiLevin Sep 16, 2024
b1e7afc
fix(backend): caught errors if OpenAi severs not responding bb-203
AndriiLevin Sep 16, 2024
b6b3c94
Merge branch 'main' into 203-feat-AI-Integration
AndriiLevin Sep 16, 2024
d4b4ec5
feat(backend): add task deadline according to app logic bb-203
AndriiLevin Sep 17, 2024
f074911
refactor(backend): refactor files and names in OpenAI module (Ai => A…
AndriiLevin Sep 17, 2024
0914e93
refactor(shared): change api path names bb-203
AndriiLevin Sep 17, 2024
7e60b19
refactor(shared): change BalanceWheelAnalysisResponseDto for more rea…
AndriiLevin Sep 17, 2024
2638bfc
refactor(shared): change AiAssistantValidationRule and schemas bb-203
AndriiLevin Sep 17, 2024
ca18ae7
refactor(shared): change code to follow B27 bb-203
AndriiLevin Sep 17, 2024
6948c1d
refactor(shared): change code to follow B27 bb-203
AndriiLevin Sep 17, 2024
fd25e70
refactor(shared): change code to follow B27 bb-203
AndriiLevin Sep 17, 2024
340631b
refactor(backend): change name in validation schema bb-203
AndriiLevin Sep 17, 2024
b1983d0
refactor(backend): add run status enum bb-203
AndriiLevin Sep 17, 2024
310f641
refactor(backend): rename Assistant validation schema bb-203
AndriiLevin Sep 17, 2024
10438f2
refactor(backend): refactor helpers not to disable linter rules bb-203
AndriiLevin Sep 17, 2024
3645380
refactor(backend/shared): change validation names bb-203
AndriiLevin Sep 17, 2024
967a7f8
Merge remote-tracking branch 'origin/main' into 203-feat-AI-Integration
AndriiLevin Sep 17, 2024
536dd0c
feat(frontend): add types, enum bb-340
yulyaolshanska Sep 17, 2024
4db4aec
refactor(frontend): use types, enum bb-340
yulyaolshanska Sep 17, 2024
f89b384
feat(frontend): add styles bb-340
yulyaolshanska Sep 17, 2024
bb835eb
Merge branch 'main' into 203-feat-AI-Integration
AndriiLevin Sep 17, 2024
cf76c17
refactor(backend): change files names bb-203
AndriiLevin Sep 18, 2024
c92c9fc
refactor(backend): change const names bb-203
AndriiLevin Sep 18, 2024
9deb0c2
refactor(shared): fix imports in TaskDto bb-203
AndriiLevin Sep 18, 2024
177cd6d
refactor(shared): fix text in AiAssistantValidationMessage bb-203
AndriiLevin Sep 18, 2024
eca3f0d
refactor: rewritten handle next step as a redux action bb-357
ihorLysak Sep 18, 2024
bb349cb
refactor(backend): change error message bb-203
AndriiLevin Sep 18, 2024
ac04c05
fix: changed env variable name in env.example bb-340
ihorLysak Sep 18, 2024
68b0c2d
refactor(backend): add enum for function name bb-203
AndriiLevin Sep 18, 2024
e45ef66
refactor(backend): fix file names spelling bb-203
AndriiLevin Sep 18, 2024
fdd3675
refactor(backend): fix env name bb-203
AndriiLevin Sep 18, 2024
7369886
Merge remote-tracking branch 'origin/main' into 203-feat-AI-Integration
AndriiLevin Sep 18, 2024
462526a
refactor: merged main. resolved conflicts, changed typing for chat on…
ihorLysak Sep 19, 2024
df9c6ba
feat: fixed balance wheel chart display, added message loader to chat…
ihorLysak Sep 19, 2024
84cd4b6
feat(shared): add ChatMessageAuthor enum bb-203
AndriiLevin Sep 19, 2024
8974fce
feat(shared): add ChatMessageType enum bb-203
AndriiLevin Sep 19, 2024
4b38f08
feat(shared): add TextMessage type bb-203
AndriiLevin Sep 19, 2024
1a47ceb
feat(shared): add TaskMessage type bb-203
AndriiLevin Sep 19, 2024
7499939
feat(shared): add QuestionMessage type bb-203
AndriiLevin Sep 19, 2024
1beb661
feat(shared): add SelectedCategory type bb-203
AndriiLevin Sep 19, 2024
50a0923
feat(shared): add BalanceWheelMessage type bb-203
AndriiLevin Sep 19, 2024
29d42a6
feat(shared): add ChatMessageDto type bb-203
AndriiLevin Sep 19, 2024
b653f99
feat(shared): add chat module and export chain bb-203
AndriiLevin Sep 19, 2024
cf1cd9b
feat(shared): add explain task path to AIAssistantApiPath bb-203
AndriiLevin Sep 19, 2024
3c0ab41
feat(shared): add validation message to AIAssistantValidationMessage…
AndriiLevin Sep 19, 2024
f6ab751
feat(shared): add AIAssistantResponseDto type bb-203
AndriiLevin Sep 19, 2024
e869f5f
feat(shared): add AIAssistantRequestDto type bb-203
AndriiLevin Sep 19, 2024
8dfbf2c
refactor(shared): change taskSuggestionRequest validation to have pa…
AndriiLevin Sep 19, 2024
3df3e42
refactor(shared): rename AIAssistantValidationRule and uses in code b…
AndriiLevin Sep 19, 2024
d721dee
refactor(shared): chane export chain in Assistant module bb-203
AndriiLevin Sep 19, 2024
af67e9b
fix(backend): fix to pass score to Assistant bb-203
AndriiLevin Sep 19, 2024
f9951dc
refactor(backend): change scores response to be ChatMessageDto bb-203
AndriiLevin Sep 19, 2024
daed7e6
refactor(backend): change response_structure in analyze balance tool…
AndriiLevin Sep 19, 2024
5ee49ca
refactor(backend): change dto name in generateSuggestTaskPrompt/runTa…
AndriiLevin Sep 19, 2024
64b037c
refactor(backend): change response type to chat Messages in TaskSugg…
AndriiLevin Sep 19, 2024
a413add
refactor(backend/shared): change import export for Assistant module …
AndriiLevin Sep 19, 2024
320afaa
chore(main): update package-lock.json bb-203
AndriiLevin Sep 19, 2024
c84dd50
feat(main): add explain task prompt template bb-203
AndriiLevin Sep 19, 2024
cdb538a
feat(main): add explain task validation bb-203
AndriiLevin Sep 19, 2024
7f12ff2
feat(main): add explain task prompt generation bb-203
AndriiLevin Sep 19, 2024
eafd1ba
feat(main): add explain task helper bb-203
AndriiLevin Sep 19, 2024
4d2b735
feat(shared/backend): add taskActionRequestSchema validation bb-203
AndriiLevin Sep 19, 2024
bbd0567
feat(backend): add generate Explain TaskSuggestions Response bb-203
AndriiLevin Sep 19, 2024
2c7a848
feat(backend): add Explain Task in AiAssistantService bb-203
AndriiLevin Sep 19, 2024
b636a68
feat(backend): add Explain Task in AiAssistantController bb-203
AndriiLevin Sep 19, 2024
0d51ab5
refactor(backend): add TaskSuggestionsResponseDto to generateChangeT…
AndriiLevin Sep 19, 2024
4d72f92
refactor(backend): change types to accept task methods bb-203
AndriiLevin Sep 19, 2024
49c6086
feat(backend): add explain task OpenAI tool bb-203
AndriiLevin Sep 19, 2024
5dfdab0
feat(backend): add motivation message to explain task bb-203
AndriiLevin Sep 19, 2024
cedcffe
Merge branch 'main' into 203-feat-AI-Integration
AndriiLevin Sep 19, 2024
c0cf474
refactor: commit made for myke bb-340
ihorLysak Sep 20, 2024
f77d35d
feat(backend): add migrations to add chat message table bb-454
marharita08 Sep 20, 2024
09c05af
feat(backend/shared): add thread id to user entity bb-454
marharita08 Sep 20, 2024
b6f0e4a
refactor: rewritten initial messages to be stored on frontend bb-340
ihorLysak Sep 20, 2024
fc1f2c1
refactor: three lowest categories are now selected on frontend bb-340
ihorLysak Sep 21, 2024
4d73954
fix: merged main, resolved conflicts bb-340
ihorLysak Sep 21, 2024
b7f96f4
feat(backend/shared): add chat message module bb-454
marharita08 Sep 21, 2024
9e326c0
Merge branch 'main' into 454-feat-save-all-messages-in-ai-chat-to-db
marharita08 Sep 21, 2024
fc9da91
feat(backend): save thread id on chat initialization bb-454
marharita08 Sep 21, 2024
257a997
feat(backend): return chat history if user has thread id bb-454
marharita08 Sep 21, 2024
afc6296
feat(shared/backend): add ChatMessageCreateDto bb-454
AndriiLevin Sep 21, 2024
1610c23
feat(backend): save draft variant of user messages bb-454
marharita08 Sep 21, 2024
ca2150d
feat(backend): add creating ChatMessageCreateDto in helpers and cal…
AndriiLevin Sep 21, 2024
7742b96
Merge remote-tracking branch 'origin/454-feat-save-all-messages-in-ai…
AndriiLevin Sep 21, 2024
52c0f5d
feat(backend/shared): update chat message types bb-454
marharita08 Sep 21, 2024
21f7577
fix(backend): fix issue with thread id bb-454
marharita08 Sep 21, 2024
34267c1
feat: implemented chat message sending bb-340
ihorLysak Sep 22, 2024
ac1ac6a
Merge branch 'main' into 340-ai-chat
ihorLysak Sep 22, 2024
21a7f72
refactor: changed position of message loader bb-340
ihorLysak Sep 22, 2024
e153d59
refactor: remade buttonMode to be based of enum bb-340
ihorLysak Sep 22, 2024
55f5de3
fix(backend): add migration to update type of text in chat_message ta…
marharita08 Sep 22, 2024
1c6a1ac
feat: intermediate commit bb-340
ihorLysak Sep 22, 2024
784d377
Merge branch 'main' into 340-ai-chat
ihorLysak Sep 22, 2024
ad22278
Merge branch 'main' into 454-feat-save-all-messages-in-ai-chat-to-db
marharita08 Sep 22, 2024
8d13039
refactor: rewritten types for ai assistant outputs bb-340
ihorLysak Sep 22, 2024
24587e1
feat(backend/shared): update ai assistant request dto type bb-454
marharita08 Sep 22, 2024
e4f8858
refactor: rewritten types for ai assistant outputs bb-340
ihorLysak Sep 22, 2024
4b584f5
feat: update readme bb-454
marharita08 Sep 22, 2024
0a1e3eb
Merge branch 'main' into 454-feat-save-all-messages-in-ai-chat-to-db
marharita08 Sep 23, 2024
1166618
feat: commit for myke to merge bb-340
ihorLysak Sep 23, 2024
c6b5a76
feat(backend/shared): update types for request and response for ai as…
marharita08 Sep 23, 2024
d5bc084
fix(backend): fox saving messages in wrong order bb-454
marharita08 Sep 23, 2024
e329736
feat(backend): update swagger comments bb-454
marharita08 Sep 23, 2024
e37453b
fix: resolved conflicts, changed category property of taskDto to cate…
ihorLysak Sep 23, 2024
a7c38af
fix(backend): update typping for chat message model bb-454
marharita08 Sep 23, 2024
44bdf92
Merge branch 'main' into 454-feat-save-all-messages-in-ai-chat-to-db
marharita08 Sep 23, 2024
429966e
feat: added createTasksFromSuggestions feature, added scroll to botto…
ihorLysak Sep 23, 2024
5f196b7
feat: task suggestions are now in a single message bb-340
ihorLysak Sep 23, 2024
77ffcf0
Merge branch 'main' of https://github.com/BinaryStudioAcademy/bsa-202…
ihorLysak Sep 23, 2024
339e19a
refactor: merged main bb-340
ihorLysak Sep 23, 2024
15bd655
fix: changed task.category to task.categoryName in mobile task-card c…
ihorLysak Sep 23, 2024
81b2006
refactor: removed comment and redundant type bb-340
ihorLysak Sep 24, 2024
ce483b3
refactor: removed unnecessary state variables extractions from chat c…
ihorLysak Sep 24, 2024
939b935
refactor: removed duplicate type imports bb-340
ihorLysak Sep 24, 2024
6c77a3e
refactor: removed duplicate type imports bb-340
ihorLysak Sep 24, 2024
8111bd3
refactor: changed AI assistant api pth enum bb-340
ihorLysak Sep 24, 2024
c141df2
refactor: changed AI assistant api pth enum bb-340
ihorLysak Sep 24, 2024
3317fef
refactor: changed AI assistant api pth enum bb-340
ihorLysak Sep 24, 2024
d90554f
refactor: renamed createMultipleTasks into create tasks bb-340
ihorLysak Sep 24, 2024
30d6d2d
refactor: renamed ButtonsModeOption enum bb-340
ihorLysak Sep 24, 2024
74adf2d
refactor: changed constant file name, changed enum name in suggestion…
ihorLysak Sep 24, 2024
467e598
refactor: rewritten getThreeLowestScores into an arrow function bb-340
ihorLysak Sep 24, 2024
12a59f9
refactor: renamed handlers in suggestions-creation-options bb-340
ihorLysak Sep 24, 2024
203dfa6
refactor: renamed enums inside of suggestions manipulation options co…
ihorLysak Sep 24, 2024
e4ef312
refactor: renamed enums inside of suggestions manipulation options co…
ihorLysak Sep 24, 2024
0f8c80f
refactor: stringifaction of payload for retake quiz is done on API le…
ihorLysak Sep 24, 2024
3c44c0c
refactor: moved checkIsTask into a separate folder bb-340
ihorLysak Sep 24, 2024
63dafa0
fix: merged main, resolved conflicts bb-340
ihorLysak Sep 24, 2024
f5d4253
refactor: renamed helper to get categories with three lowest scores b…
ihorLysak Sep 24, 2024
d79e424
refactor: renamed isTaskMessage typeguard helper bb-340
ihorLysak Sep 24, 2024
2a13aaf
refactor: renamed icon svg imports bb-340
ihorLysak Sep 24, 2024
bcfb0c8
refactor: changed SuggestionsCreationButtonLabel enum values bb-340
ihorLysak Sep 24, 2024
3e84f51
Merge branch '340-ai-chat' into 454-feat-save-all-messages-in-ai-chat…
marharita08 Sep 24, 2024
9ffbb29
Merge branch '340-ai-chat' into 454-feat-save-all-messages-in-ai-chat…
marharita08 Sep 24, 2024
720c95e
feat(frontend/backend/shared): save user message on accept multiple t…
marharita08 Sep 25, 2024
6c55503
feat(frontend/backend/shared): update types of requests, show chat hi…
marharita08 Sep 25, 2024
ae80820
Merge branch 'main' into 454-feat-save-all-messages-in-ai-chat-to-db
marharita08 Sep 25, 2024
176840b
fix(frontend/backend/shared): fix issues with chat bb-454
marharita08 Sep 25, 2024
44c2a06
feat(backend): update swagger comments for ai assistant bb-454
marharita08 Sep 25, 2024
b40b72c
feat(backend): move saving of array of text messages to chat message …
marharita08 Sep 25, 2024
89a9713
Merge branch 'main' into 454-feat-save-all-messages-in-ai-chat-to-db
marharita08 Sep 25, 2024
885ec50
Merge branch 'main' into 454-feat-save-all-messages-in-ai-chat-to-db
marharita08 Sep 26, 2024
cea6905
Merge branch 'main' into 454-feat-save-all-messages-in-ai-chat-to-db
marharita08 Sep 27, 2024
f77bbe1
Merge branch 'main' into 454-feat-save-all-messages-in-ai-chat-to-db
marharita08 Sep 27, 2024
7084c9e
feat(frontend/backend/shared): send assistant and users messages on b…
marharita08 Sep 27, 2024
7f9c4cf
Merge branch 'main' into 454-feat-save-all-messages-in-ai-chat-to-db
marharita08 Sep 27, 2024
3b0ada6
Merge branch 'main' into 454-feat-save-all-messages-in-ai-chat-to-db
marharita08 Sep 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { type Knex } from "knex";

const TABLE_NAME = "user_details";

const COLUMN_NAME = "thread_id";

function up(knex: Knex): Promise<void> {
return knex.schema.alterTable(TABLE_NAME, (table) => {
table.string(COLUMN_NAME).unique();
});
}

function down(knex: Knex): Promise<void> {
return knex.schema.alterTable(TABLE_NAME, (table) => {
table.dropColumn(COLUMN_NAME);
});
}

export { down, up };
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { type Knex } from "knex";

const TableName = {
CHAT_MESSAGES: "chat_messages",
USER_DETAILS: "user_details",
} as const;

const ColumnName = {
AUTHOR: "author",
CREATED_AT: "created_at",
ID: "id",
IS_READ: "is_read",
TASK: "task",
TEXT: "text",
THREAD_ID: "thread_id",
TYPE: "type",
UPDATED_AT: "updated_at",
} as const;

const ChatMessageType = {
TASK: "task",
TEXT: "text",
} as const;

const ChatMessageAuthor = {
ASSISTANT: "assistant",
USER: "user",
} as const;

const DELETE_STRATEGY = "CASCADE";

function up(knex: Knex): Promise<void> {
return knex.schema.createTable(TableName.CHAT_MESSAGES, (table) => {
table.increments(ColumnName.ID).primary();
table.timestamp(ColumnName.CREATED_AT).defaultTo(knex.fn.now());
table.timestamp(ColumnName.UPDATED_AT).defaultTo(knex.fn.now());
table
.enum(ColumnName.AUTHOR, [
ChatMessageAuthor.ASSISTANT,
ChatMessageAuthor.USER,
])
.notNullable();
table.boolean(ColumnName.IS_READ).notNullable().defaultTo(false);
table
.enum(ColumnName.TYPE, [ChatMessageType.TASK, ChatMessageType.TEXT])
.notNullable();
table.string(ColumnName.TEXT);
table.json(ColumnName.TASK);
table
.string(ColumnName.THREAD_ID)
.notNullable()
.references(ColumnName.THREAD_ID)
.inTable(TableName.USER_DETAILS)
.onDelete(DELETE_STRATEGY);
});
}

function down(knex: Knex): Promise<void> {
return knex.schema.dropTableIfExists(TableName.CHAT_MESSAGES);
}

export { down, up };
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { type Knex } from "knex";

const TABLE_NAME = "chat_messages";
const COLUMN_NAME = "text";

function up(knex: Knex): Promise<void> {
return knex.schema.alterTable(TABLE_NAME, function (table) {
table.text(COLUMN_NAME).alter();
});
}

function down(knex: Knex): Promise<void> {
return knex.schema.alterTable(TABLE_NAME, function (table) {
table.string(COLUMN_NAME).alter();
});
}

export { down, up };
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const DatabaseTableName = {
CATEGORIES: "categories",
CHAT_MESSAGES: "chat_messages",
FILES: "files",
MIGRATIONS: "migrations",
ONBOARDING_ANSWERS: "onboarding_answers",
Expand Down
101 changes: 37 additions & 64 deletions apps/backend/src/modules/ai-assistant/ai-assistant.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ import { type UserDto } from "~/modules/users/users.js";
import { type AIAssistantService } from "./ai-assistant.service.js";
import { AIAssistantApiPath } from "./libs/enums/enums.js";
import {
type AIAssistantAcceptTaskRequestDto,
type AIAssistantChangeTaskRequestDto,
type AIAssistantCreateMultipleTasksDto,
type AIAssistantRequestDto,
type AIAssistantExplainTaskRequestDto,
type AIAssistantSuggestTaskRequestDto,
type ThreadMessageCreateDto,
} from "./libs/types/types.js";
Expand Down Expand Up @@ -286,6 +288,7 @@ class AIAssistantController extends BaseController {
this.addMessageToConversation(
options as APIHandlerOptions<{
body: ThreadMessageCreateDto;
user: UserDto;
}>,
),
method: "POST",
Expand All @@ -299,7 +302,7 @@ class AIAssistantController extends BaseController {
handler: (options) =>
this.changeTaskSuggestion(
options as APIHandlerOptions<{
body: AIAssistantRequestDto;
body: AIAssistantChangeTaskRequestDto;
user: UserDto;
}>,
),
Expand All @@ -314,7 +317,7 @@ class AIAssistantController extends BaseController {
handler: (options) =>
this.explainTasksSuggestion(
options as APIHandlerOptions<{
body: AIAssistantRequestDto;
body: AIAssistantExplainTaskRequestDto;
user: UserDto;
}>,
),
Expand Down Expand Up @@ -359,7 +362,7 @@ class AIAssistantController extends BaseController {
handler: (options) =>
this.acceptTask(
options as APIHandlerOptions<{
body: AIAssistantRequestDto;
body: AIAssistantAcceptTaskRequestDto;
user: UserDto;
}>,
),
Expand Down Expand Up @@ -387,11 +390,10 @@ class AIAssistantController extends BaseController {
* schema:
* type: object
* properties:
* threadId:
* text:
* type: string
* description: Identifier for the thread
* example: "thread_5kL0dVY9ADvmNz8U33P7qFX3"
* payload:
* description: Text of user message
* task:
* $ref: '#/components/schemas/TaskPayload'
* responses:
* 200:
Expand All @@ -404,7 +406,7 @@ class AIAssistantController extends BaseController {

private async acceptTask(
options: APIHandlerOptions<{
body: AIAssistantRequestDto;
body: AIAssistantAcceptTaskRequestDto;
user: UserDto;
}>,
): Promise<APIHandlerResponse> {
Expand All @@ -420,7 +422,7 @@ class AIAssistantController extends BaseController {
* @swagger
* /assistant/chat/accept-tasks:
* post:
* summary: Accept tasks suggestions
* summary: Accept task suggestions
* tags:
* - AI Assistant
* security:
Expand All @@ -430,27 +432,23 @@ class AIAssistantController extends BaseController {
* content:
* application/json:
* schema:
* type: object
* type: array
* properties:
* threadId:
* type: string
* description: Identifier for the thread
* example: "thread_5kL0dVY9ADvmNz8U33P7qFX3"
* payload:
* type: array
* description: Array of tasks to accept
* items:
* $ref: '#/components/schemas/TaskPayload'
* $ref: '#/components/schemas/TaskPayload'
* responses:
* 200:
* description: Returns the accepted tasks
* description: Returns the accepted task
* content:
* application/json:
* schema:
* type: array
* items:
* $ref: '#/components/schemas/Task'
* $ref: '#/components/schemas/Task'
*/

private async acceptTasks(
options: APIHandlerOptions<{
body: AIAssistantCreateMultipleTasksDto;
Expand Down Expand Up @@ -485,10 +483,6 @@ class AIAssistantController extends BaseController {
* type: string
* description: The text message to add to the thread
* example: "Hello, how can I assist you?"
* threadId:
* type: string
* description: Identifier for the conversation thread
* example: "thread_abc123"
* responses:
* 200:
* description: Indicates if the message was successfully added
Expand All @@ -502,12 +496,13 @@ class AIAssistantController extends BaseController {
private async addMessageToConversation(
options: APIHandlerOptions<{
body: ThreadMessageCreateDto;
user: UserDto;
}>,
): Promise<APIHandlerResponse> {
const { body } = options;
const { body, user } = options;

return {
payload: await this.openAIService.addMessageToThread(body),
payload: await this.openAIService.addMessageToThread(body, user),
status: HTTPCode.OK,
};
}
Expand All @@ -528,14 +523,11 @@ class AIAssistantController extends BaseController {
* schema:
* type: object
* properties:
* threadId:
* text:
* type: string
* description: Identifier for the thread
* example: "thread_5kL0dVY9ADvmNz8U33P7qFX3"
* payload:
* type: array
* items:
* $ref: '#/components/schemas/TaskPayload'
* description: Text of user message
* task:
* $ref: '#/components/schemas/TaskPayload'
* responses:
* 200:
* description: Returns task suggestions for the provided categories
Expand All @@ -551,14 +543,10 @@ class AIAssistantController extends BaseController {
* oneOf:
* - $ref: '#/components/schemas/ChatMessageText'
* - $ref: '#/components/schemas/ChatMessageTask'
* threadId:
* type: string
* description: Identifier for the chat thread.
* example: "thread_QwWiRV7jFYMz0i0YGcRvcRsU"
*/
private async changeTaskSuggestion(
options: APIHandlerOptions<{
body: AIAssistantRequestDto;
body: AIAssistantChangeTaskRequestDto;
user: UserDto;
}>,
): Promise<APIHandlerResponse> {
Expand Down Expand Up @@ -586,14 +574,11 @@ class AIAssistantController extends BaseController {
* schema:
* type: object
* properties:
* threadId:
* text:
* type: string
* description: Identifier for the thread
* example: "thread_5kL0dVY9ADvmNz8U33P7qFX3"
* payload:
* type: array
* items:
* $ref: '#/components/schemas/TaskPayload'
* description: Text of user message
* task:
* $ref: '#/components/schemas/TaskPayload'
* responses:
* 200:
* description: Returns explanations for the provided task suggestions
Expand All @@ -609,20 +594,17 @@ class AIAssistantController extends BaseController {
* oneOf:
* - $ref: '#/components/schemas/ChatMessageTextExplanation'
* - $ref: '#/components/schemas/ChatMessageTask'
* threadId:
* type: string
* description: Identifier for the chat thread.
* example: "thread_QwWiRV7jFYMz0i0YGcRvcRsU"
*/
private async explainTasksSuggestion(
options: APIHandlerOptions<{
body: AIAssistantRequestDto;
body: AIAssistantExplainTaskRequestDto;
user: UserDto;
}>,
): Promise<APIHandlerResponse> {
const { body } = options;
const { body, user } = options;

return {
payload: await this.openAIService.explainTasksSuggestion(body),
payload: await this.openAIService.explainTaskSuggestion(body, user),
status: HTTPCode.OK,
};
}
Expand Down Expand Up @@ -651,10 +633,6 @@ class AIAssistantController extends BaseController {
* type: array
* description: Array of chat messages (initially empty).
* example: []
* threadId:
* type: string
* description: Identifier for the chat thread.
* example: "thread_QwWiRV7jFYMz0i0YGcRvcRsU"
*/
private async initializeNewChat(
options: APIHandlerOptions<{
Expand Down Expand Up @@ -690,10 +668,9 @@ class AIAssistantController extends BaseController {
* description: Array of selected categories for task suggestions
* items:
* $ref: '#/components/schemas/SelectedCategory'
* threadId:
* text:
* type: string
* description: Identifier for the thread
* example: "thread_abc123"
* description:Text of user message
* responses:
* 200:
* description: Returns task suggestions for the provided categories
Expand All @@ -709,21 +686,17 @@ class AIAssistantController extends BaseController {
* oneOf:
* - $ref: '#/components/schemas/ChatMessageText'
* - $ref: '#/components/schemas/ChatMessageTask'
* threadId:
* type: string
* description: Identifier for the chat thread.
* example: "thread_QwWiRV7jFYMz0i0YGcRvcRsU"
*/
private async suggestTasksForCategories(
options: APIHandlerOptions<{
body: AIAssistantSuggestTaskRequestDto;
user: UserDto;
}>,
): Promise<APIHandlerResponse> {
const { body } = options;
const { body, user } = options;

return {
payload: await this.openAIService.suggestTasksForCategories(body),
payload: await this.openAIService.suggestTasksForCategories(body, user),
status: HTTPCode.OK,
};
}
Expand Down
Loading
Loading