summaryrefslogtreecommitdiff
path: root/models/models.go
diff options
context:
space:
mode:
authorGrail Finder <wohilas@gmail.com>2024-11-16 06:41:52 +0300
committerGrail Finder <wohilas@gmail.com>2024-11-16 06:41:52 +0300
commit84b06c0da5854f153aa31b668f60914e4bb74fc5 (patch)
tree8983fe48041f5f3e52c0be72d0c9d8ca07de25e8 /models/models.go
parent3cbad31a16bc82ff6e29410927578242d158b97a (diff)
Feat: read from chat files
Diffstat (limited to 'models/models.go')
-rw-r--r--models/models.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/models/models.go b/models/models.go
index dd1dace..30ba548 100644
--- a/models/models.go
+++ b/models/models.go
@@ -1,5 +1,10 @@
package models
+import (
+ "fmt"
+ "strings"
+)
+
// type FuncCall struct {
// XMLName xml.Name `xml:"tool_call"`
// Name string `xml:"name"`
@@ -56,6 +61,22 @@ type MessagesStory struct {
Content string `json:"content"`
}
+func (m MessagesStory) ToText() string {
+ icon := ""
+ switch m.Role {
+ case "assistant":
+ icon = "<🤖>: "
+ case "user":
+ icon = "<user>: "
+ case "system":
+ icon = "<system>: "
+ case "tool":
+ icon = "<tool>: "
+ }
+ textMsg := fmt.Sprintf("%s%s\n", icon, m.Content)
+ return strings.ReplaceAll(textMsg, "\n\n", "\n")
+}
+
type ChatBody struct {
Model string `json:"model"`
Stream bool `json:"stream"`