Project

General

Profile

SendRequest() method » History » Revision 6

Revision 5 (Tomislav Pleše, 09/20/2025 02:34 PM) → Revision 6/19 (Tomislav Pleše, 09/20/2025 02:44 PM)

# SendRequest() method 

 Context is created from message with following roles:  
 * system (content: instructions to AI model),  
 * assistant (content: AI model responses),  
 * user (content: user prompts) 

 Context is created as a messageList where: 
 * first element is the assistant role/content if it exists 
 * following elements are an ascending list of user prompts and assistant responses in ascending order 
 * last element is the newest user prompt 


 Cases for the flow of sending requests to AI model: 

 1. Root Point - First Prompt 
     1. * FE - Create new Point 
     2. * FE - Show new Point on Screen - only the Prompt 
     3. * FE - Create Context as - messageList from: 
         * previous Points 
         * previous Points (Prompt + Response) 
         * . List is ascending: from the messageList. first message, down to the newest prompt. Since there is only this first Prompt, add only that. 
     4. * FE - Send new Point and the messageList to BE 
     5. * BE - Save new Point to DB 
     6. * BE - Send messageList (in this case onltPrompt to OpenAI. The JSON should comprise of: model, messages, max_tokens OpenAI 
     7. * BE - Receive the Response from OpenAI 
     8. * BE - Save Response to DB (into (in the previously saved new Point document) 
     9. * BE - Send the new Point (with updated Response and other elements like Metadata) Response) to FE 
     10. * FE - Show updated new Point on Screen - node consisting of both Prompt message content and Response message content  

 

 2. Existing Point - Second prompt 
     1. * FE - Create new Point 
     2. * FE - Show new Point on Screen -    only the Prompt, under the previous Point 
     3. * FE - Create Context as - message list from previous Points (Prompt + Response). List is ascending: from the messageList. first message, down to the newest prompt. 
     4. * FE - Send new Point and the messageList to BE 
     5. * BE - Save new Point to DB 
     6. * BE - Receive the Response from OpenAI 
     * BE - Send messageList Prompt to OpenAI. The JSON should comprise of: model, messages, max_tokens OpenAI 
     7. * BE - Receive the Response from OpenAI 
     8. * BE - Save Response to DB (into (with the previously saved new Point document) Point) 
     9. BE - * BE- Send the new Point (with updated Response and other elements like Metadata) Response) to FE 
     10. * FE - Show updated new Point on Screen - node consisting of both Prompt message content and Response message content  

 
 3. New shard - prompt - [to be done later] 

 
 4. Existing Shard - prompt - [to be done later]