SendRequest() method » History » Revision 17
« Previous |
Revision 17/19
(diff)
| Next »
Tomislav Pleše, 09/21/2025 01:42 PM
SendRequest() method¶
Regular prompt¶
Context for regular Point is created from message with following roles:
- system (content: instructions to AI model),
- assistant (content: AI model responses),
- user (content: user prompts)
Context for regular Point 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).
This is how the context is created for the Sub-prompt:
|- T-001: Shard-01 <-- 12. added to context (the text from the endPosition up to the start of the Response message - dissregarding any text that comes after the endPosition)
| |- T-004: Point
| |- T-015: Point
|- T-001: Shard-02 <-- 11. added to context (the text from the endPosition up to the start of the Response message - dissregarding any text that comes after the endPosition - this includes point "<-- 12.")
| |- T-016: Point <-- 10. added to context
| |- T-017: Point <-- 9. added to context
| |- T-005: Shard-01 <-- 8. added to context (the text from the endPosition up to the start of the Response message - dissregarding any text that comes after the endPosition)
| | |- T-006: Point <-- 7. added to context
| | |- T-014: Point <-- 6. added to context
| | |- T-007: Shard-01 <-- 5. added to context
| | | |- T-010: Point
| | | |- T-013: Point
| | |- T-007: Shard-02 <-- 3. added to context (the text from the endPosition up to the start of the Response message - dissregarding any text that comes after the endPosition - this includes point "<-- 4.")
| | | |- T-011: Point <-- 2. added to context
| | | |- T-012: Point <-- 1. starting point
| | |- T-007: Shard-03
| | |- T-008: Point
| |- T-005: Shard-02
| | |- T-018: Point
| |- T-005: Shard-03
| |- T-009: Point
|- T-001: Shard-03
|- T-002: Point
|- T-003: Point
So this is the Context when it's a sub-prompt from a Shard:
- 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: [012, 011, 007(S01+S02), 014, 006, 005(S01), 017, 016, 001(S01+S02) ]
- last element is the newest user prompt
-
Root Point - First Prompt
- FE - Create new Point
- FE - Show new Point on Screen - only the Prompt
- FE - Create Context as the messageList.
- FE - Send new Point and the messageList to BE
- BE - Save new Point to DB
- BE - Send messageList to OpenAI. The JSON should comprise of: model, messages, max_tokens
- BE - Receive the Response from OpenAI
- BE - Save Response to DB (into the previously saved new Point document)
- BE - Send the new Point (with updated Response and other elements like Metadata) to FE
- FE - Show updated new Point on Screen - node consisting of both Prompt message content and Response message content
-
Existing Point - Second prompt
- FE - Create new Point
- FE - Show new Point on Screen - the Prompt, under the previous Point
- FE - Create Context as the messageList.
- FE - Send new Point and the messageList to BE
- BE - Save new Point to DB
- BE - Send messageList to OpenAI. The JSON should comprise of: model, messages, max_tokens
- BE - Receive the Response from OpenAI
- BE - Save Response to DB (into the previously saved new Point document)
- BE - Send the new Point (with updated Response and other elements like Metadata) to FE
- FE - Show updated new Point on Screen - node consisting of both Prompt message content and Response message content
-
New shard -
- FE - User selects a portion of the current Point's response
- FE - And from this selected text, the new Prompt is started (user can add more text to the selected text)
- FE - User then sends this new Prompt to the AI model
- FE - From this new Prompt is created a new Point
- 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)
- FE - The new Point is added to the shardPointChildren list inside the Shard
- 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.
- FE - The new node (with the new prompt) is placed indented under the first part (first shard) in the tree view
- FE - Create Context as the messageList. This is how the context for the Shard is created:
- FE - Send new Point, the current Point (which has become Shard) and the messageList to BE
- BE - Save new Point to DB
- BE - Update the current Point (the one that bacame Shard)
- BE - Send messageList to OpenAI. The JSON should comprise of: model, messages, max_tokens
- BE - Receive the Response from OpenAI
- BE - Save Response to DB (into the previously saved new Point document)
- BE - Send the new Point (with updated Response and other elements like Metadata) to FE
- FE - Show updated new Point on Screen - node consisting of both Prompt message content and Response message content
-
Existing Shard - sub-prompt under a Point that has already been a Shard
Updated by Tomislav Pleše 3 months ago · 19 revisions