]> git.giacomolli.uk - onechat/blobdiff - view_layout.go
Separate multiline Go statements
[onechat] / view_layout.go
index 3db2f017ed8b46e120c24605e25b9ea99e07099b..a2d4825a7d57b82897e798ec64a9e4913579509f 100644 (file)
@@ -14,6 +14,30 @@ import (
 // agent.
 const viewLayoutFileName = "layout.json"
 
+// ViewLayout splits the view of a turn request into user messages that only
+// grow between batches. The view goes out as the same messages as in the
+// request before, while their lines give the same text, and the new lines
+// follow as one new message. So the end of the view of each earlier turn stays
+// a message end. On the ChatGPT backend, the first request of a turn with this
+// layout read the view of the turn before from the prompt cache in each of 10
+// turns, and with the view in one message it missed once in 5.
+//
+// The first message starts with "<chat>\n". The closing tag goes into the
+// state message after the view, so that no view message changes when lines
+// come. The layout keeps the line count and a hash of the text of each message
+// in layout.json, so it outlives a restart.
+type ViewLayout struct {
+       path     string
+       Messages []ViewLayoutMessage `json:"messages"`
+}
+
+// ViewLayoutMessage is one view message: its number of lines and the hash of
+// its text.
+type ViewLayoutMessage struct {
+       Lines int    `json:"lines"`
+       Hash  string `json:"hash"`
+}
+
 // loadViewLayout reads the layout at path. A missing file gives an empty
 // layout.
 func loadViewLayout(path string) (*ViewLayout, error) {
@@ -38,23 +62,6 @@ func loadViewLayout(path string) (*ViewLayout, error) {
        return layout, nil
 }
 
-// ViewLayout splits the view of a turn request into user messages that only
-// grow between batches. The view goes out as the same messages as in the
-// request before, while their lines give the same text, and the new lines
-// follow as one new message. So the end of the view of each earlier turn stays
-// a message end. On the ChatGPT backend, the first request of a turn with this
-// layout read the view of the turn before from the prompt cache in each of 10
-// turns, and with the view in one message it missed once in 5.
-//
-// The first message starts with "<chat>\n". The closing tag goes into the
-// state message after the view, so that no view message changes when lines
-// come. The layout keeps the line count and a hash of the text of each message
-// in layout.json, so it outlives a restart.
-type ViewLayout struct {
-       path     string
-       Messages []ViewLayoutMessage `json:"messages"`
-}
-
 // Split returns the view messages for lines and saves the layout. It keeps the
 // earlier messages up to the first one whose text differs, and puts the rest
 // of the lines into one new message.
@@ -103,13 +110,6 @@ func (l *ViewLayout) Split(lines []string) ([]string, error) {
        return texts, nil
 }
 
-// ViewLayoutMessage is one view message: its number of lines and the hash of
-// its text.
-type ViewLayoutMessage struct {
-       Lines int    `json:"lines"`
-       Hash  string `json:"hash"`
-}
-
 // viewMessage returns the text of a view message with lines. The first one
 // opens the chat.
 func viewMessage(first bool, lines []string) string {