Project

General

Profile

SendRequest() method » History » Version 7

Tomislav Pleše, 09/21/2025 08:59 AM

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 6 Tomislav Pleše
    1. FE - Create new Point
18
    2. FE - Show new Point on Screen - only the Prompt
19
    3. FE - Create Context as the messageList.
20
    4. FE - Send new Point and the messageList to BE
21
    5. BE - Save new Point to DB
22
    6. BE - Send messageList to OpenAI. The JSON should comprise of: model, messages, max_tokens
23
    7. BE - Receive the Response from OpenAI
24
    8. BE - Save Response to DB (into the previously saved new Point document)
25
    9. BE - Send the new Point (with updated Response and other elements like Metadata) to FE
26
    10. FE - Show updated new Point on Screen - node consisting of both Prompt message content and Response message content 
27 1 Tomislav Pleše
28 2 Tomislav Pleše
2. Existing Point - Second prompt
29 6 Tomislav Pleše
    1. FE - Create new Point
30
    2. FE - Show new Point on Screen - the Prompt, under the previous Point
31
    3. FE - Create Context as the messageList.
32
    4. FE - Send new Point and the messageList to BE
33
    5. BE - Save new Point to DB
34
    6. BE - Send messageList to OpenAI. The JSON should comprise of: model, messages, max_tokens
35
    7. BE - Receive the Response from OpenAI
36
    8. BE - Save Response to DB (into the previously saved new Point document)
37
    9. BE - Send the new Point (with updated Response and other elements like Metadata) to FE
38
    10. FE - Show updated new Point on Screen - node consisting of both Prompt message content and Response message content 
39
40 7 Tomislav Pleše
3. New shard - sub-prompt under a Regular Point that by this becomes a Shard  
41
    1. FE - Create new Point
42
    2. FE - Show new Point on Screen - only the Prompt
43
    3. FE - Create Context as the messageList.
44
    4. FE - Send new Point and the messageList to BE
45
    5. BE - Save new Point to DB
46
    6. BE - Send messageList to OpenAI. The JSON should comprise of: model, messages, max_tokens
47
    7. BE - Receive the Response from OpenAI
48
    8. BE - Save Response to DB (into the previously saved new Point document)
49
    9. BE - Send the new Point (with updated Response and other elements like Metadata) to FE
50
    10. FE - Show updated new Point on Screen - node consisting of both Prompt message content and Response message content 
51 6 Tomislav Pleše
52 7 Tomislav Pleše
4. Existing Shard - sub-prompt under a Point that has already been a Shard