Project

General

Profile

SendRequest() method » History » Version 4

Tomislav Pleše, 09/20/2025 02:31 PM

1 1 Tomislav Pleše
# SendRequest() method
2 2 Tomislav Pleše
3 4 Tomislav Pleše
Context is created from message with following roles: 
4
* system (content: instructions to AI model), 
5
* assistant (content: AI model responses), 
6
* user (content: user prompts)
7 1 Tomislav Pleše
8 4 Tomislav Pleše
9
Cases for the flow of sending requests to AI model:
10
11 1 Tomislav Pleše
1. Root Point - First Prompt
12
    * FE - Create new Point
13
    * FE - Show new Point on Screen - only the Prompt
14 4 Tomislav Pleše
    * FE - Create Context - messageList from:
15
        * previous Points
16
        * previous Points (Prompt + Response)
17
        * . List is ascending: from the first message, down to the newest prompt. Since there is only this first Prompt, add only that.
18
    * FE - Send new Point and messageList to BE
19 2 Tomislav Pleše
    * BE - Save new Point to DB
20 4 Tomislav Pleše
    * BE - Send messageList (in this case onltPrompt to OpenAI
21 1 Tomislav Pleše
    * BE - Receive the Response from OpenAI
22 4 Tomislav Pleše
    * BE - Save Response to DB (in the new Point document)
23
    * BE - Send the new Point (with updated Response) to FE
24 1 Tomislav Pleše
    * FE - Show updated new Point on Screen - both Prompt and Response
25 2 Tomislav Pleše
26 1 Tomislav Pleše
2. Existing Point - Second prompt
27 3 Tomislav Pleše
    * FE - Create new Point
28 4 Tomislav Pleše
    * FE - Show new Point on Screen -  only the Prompt, under the previous Point
29
    * FE - Create Context - message list from previous Points (Prompt + Response). List is ascending: from the first message, down to the newest prompt.
30 3 Tomislav Pleše
    * FE - Send new Point and the messageList to BE
31
    * BE - Save new Point to DB
32 4 Tomislav Pleše
    * BE - Receive the Response from OpenAI
33 3 Tomislav Pleše
    * BE - Send Prompt to OpenAI
34
    * BE - Receive the Response from OpenAI
35
    * BE - Save Response to DB (with the new Point)
36
    * BE- Send the new Point (with updated Response) to FE
37 2 Tomislav Pleše
    * FE - Show updated new Point on Screen - both Prompt and Response
38
3. New shard - prompt
39 1 Tomislav Pleše
4. Existing Shard - prompt