From 84b06c0da5854f153aa31b668f60914e4bb74fc5 Mon Sep 17 00:00:00 2001 From: Grail Finder Date: Sat, 16 Nov 2024 06:41:52 +0300 Subject: Feat: read from chat files --- models/models.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'models/models.go') 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 = ": " + case "system": + icon = ": " + case "tool": + icon = ": " + } + 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"` -- cgit v1.2.3