diff options
author | Grail Finder <wohilas@gmail.com> | 2024-12-02 19:58:03 +0300 |
---|---|---|
committer | Grail Finder <wohilas@gmail.com> | 2024-12-02 19:58:03 +0300 |
commit | a5ab816c9434022159548ac0d1872160b3c8908d (patch) | |
tree | a4e68c334f2a514f02afd65a1bb70eff415fb8cd /models/models.go | |
parent | 8d3997baff25f28c23441699be7692f853cf1f0f (diff) |
Feat: add character card support
Diffstat (limited to 'models/models.go')
-rw-r--r-- | models/models.go | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/models/models.go b/models/models.go index 02bec00..0373e9b 100644 --- a/models/models.go +++ b/models/models.go @@ -5,12 +5,6 @@ import ( "strings" ) -// type FuncCall struct { -// XMLName xml.Name `xml:"tool_call"` -// Name string `xml:"name"` -// Args []string `xml:"args"` -// } - type FuncCall struct { Name string `json:"name"` Args []string `json:"args"` @@ -56,12 +50,12 @@ type LLMRespChunk struct { } `json:"usage"` } -type MessagesStory struct { +type RoleMsg struct { Role string `json:"role"` Content string `json:"content"` } -func (m MessagesStory) ToText(i int) string { +func (m RoleMsg) ToText(i int) string { icon := "" switch m.Role { case "assistant": @@ -72,20 +66,22 @@ func (m MessagesStory) ToText(i int) string { icon = fmt.Sprintf("(%d) <system>: ", i) case "tool": icon = fmt.Sprintf("(%d) <tool>: ", i) + default: + icon = fmt.Sprintf("(%d) <%s>: ", i, m.Role) } 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"` - Messages []MessagesStory `json:"messages"` + Model string `json:"model"` + Stream bool `json:"stream"` + Messages []RoleMsg `json:"messages"` } type ChatToolsBody struct { - Model string `json:"model"` - Messages []MessagesStory `json:"messages"` + Model string `json:"model"` + Messages []RoleMsg `json:"messages"` Tools []struct { Type string `json:"type"` Function struct { |