Feat: read from chat files
This commit is contained in:
@@ -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"`
|
||||
|
||||
Reference in New Issue
Block a user