Project

General

Profile

SendRequest() method » History » Version 5

Tomislav Pleše, 09/20/2025 02:34 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 5 Tomislav Pleše
Context is created as a messageList where:
9
* first element is the assistant role/content if it exists
10
* following elements are an ascending list of user prompts and assistant responses in ascending order
11
* last element is the newest user prompt
12
13 4 Tomislav Pleše
14
Cases for the flow of sending requests to AI model:
15
16 1 Tomislav Pleše
1. Root Point - First Prompt
17
    * FE - Create new Point
18
    * FE - Show new Point on Screen - only the Prompt
19 4 Tomislav Pleše
    * FE - Create Context - messageList from:
20
        * previous Points
21
        * previous Points (Prompt + Response)
22
        * . List is ascending: from the first message, down to the newest prompt. Since there is only this first Prompt, add only that.
23
    * FE - Send new Point and messageList to BE
24 2 Tomislav Pleše
    * BE - Save new Point to DB
25 4 Tomislav Pleše
    * BE - Send messageList (in this case onltPrompt to OpenAI
26 1 Tomislav Pleše
    * BE - Receive the Response from OpenAI
27 4 Tomislav Pleše
    * BE - Save Response to DB (in the new Point document)
28
    * BE - Send the new Point (with updated Response) to FE
29 1 Tomislav Pleše
    * FE - Show updated new Point on Screen - both Prompt and Response
30 2 Tomislav Pleše
31 1 Tomislav Pleše
2. Existing Point - Second prompt
32 3 Tomislav Pleše
    * FE - Create new Point
33 4 Tomislav Pleše
    * FE - Show new Point on Screen -  only the Prompt, under the previous Point
34
    * FE - Create Context - message list from previous Points (Prompt + Response). List is ascending: from the first message, down to the newest prompt.
35 3 Tomislav Pleše
    * FE - Send new Point and the messageList to BE
36
    * BE - Save new Point to DB
37 4 Tomislav Pleše
    * BE - Receive the Response from OpenAI
38 3 Tomislav Pleše
    * BE - Send Prompt to OpenAI
39
    * BE - Receive the Response from OpenAI
40
    * BE - Save Response to DB (with the new Point)
41
    * BE- Send the new Point (with updated Response) to FE
42 2 Tomislav Pleše
    * FE - Show updated new Point on Screen - both Prompt and Response
43
3. New shard - prompt
44 1 Tomislav Pleše
4. Existing Shard - prompt