Project

General

Profile

Actions

SendRequest() method » History » Revision 11

« Previous | Revision 11/19 (diff) | Next »
Tomislav Pleše, 09/21/2025 11:59 AM


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

Sub-prompt

Sub-prompt is a prompt that is created from the contents of the Response of the currently selected Point (node - prompt + response). Flow:

  1. FE - User selects a portion of the current Point's response
  2. FE - And from this selected text, the new Prompt is started (user can add more text to the selected text)
  3. FE - User then sends this new Prompt to the AI model
  4. FE - From this new Prompt is created a new Point
  5. FE - The current Point (from which the selected text comes from) now becomes a Shard Point (Shard is added to that Point). This Shard has an Anchor (containing among other: the start and end positions of the selected text)
  6. FE - The new Point is added to the shardPointChildren list inside the Shard
  7. FE - On the phone's screen, the node's Response message part (in the tree view) is split into two (sharding): first part (shard) is the text before the end position of the selected text (in the Anchor), and the second part (shard) is the text after that and till the end of the Response.
  8. FE - The new node (with the new prompt) is placed indented under the first part (first shard) in the tree view
  9. FE - Create Context as the messageList. This is how the context for the Shard is created:

creates a new regular Point
5. selectedRegular Point
1st Sharding - Regular Point becomes Shard Point (ThreadMap = not empty, ShardList = empty) - Shard is created and added to ShardList, new Point is added to ShardPointChildren

  • previous Response creates a new Point that is inserted in between the response of a current Regular Point. The splitting of the current Point is at the point of that by this becomes a Shard

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 the messageList.
    4. FE - Send new Point and the messageList to BE
    5. BE - Save new Point to DB
    6. BE - Send messageList to OpenAI. The JSON should comprise of: model, messages, max_tokens
    7. BE - Receive the Response from OpenAI
    8. BE - Save Response to DB (into the previously saved new Point document)
    9. BE - Send the new Point (with updated Response and other elements like Metadata) 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 - the Prompt, under the previous Point
    3. FE - Create Context as the messageList.
    4. FE - Send new Point and the messageList to BE
    5. BE - Save new Point to DB
    6. BE - Send messageList to OpenAI. The JSON should comprise of: model, messages, max_tokens
    7. BE - Receive the Response from OpenAI
    8. BE - Save Response to DB (into the previously saved new Point document)
    9. BE - Send the new Point (with updated Response and other elements like Metadata) to FE
    10. FE - Show updated new Point on Screen - node consisting of both Prompt message content and Response message content
  3. New shard -

    1. FE - Create new Point
    2. FE - Create a Shard in the current Prompt
  4. FE -
    3. FE - Show new Point on Screen - the Prompt, under the previous Point
    3. FE - Create Context as the messageList.
    4. FE - Send new Point and the messageList to BE
    5. BE - Save new Point to DB
    6. BE - Send messageList to OpenAI. The JSON should comprise of: model, messages, max_tokens
    7. BE - Receive the Response from OpenAI
    8. BE - Save Response to DB (into the previously saved new Point document)
    9. BE - Send the new Point (with updated Response and other elements like Metadata) to FE
    10. FE - Show updated new Point on Screen - node consisting of both Prompt message content and Response message content

  5. Existing Shard - sub-prompt under a Point that has already been a Shard

Updated by Tomislav Pleše 3 months ago · 19 revisions