aboutsummaryrefslogtreecommitdiffstats
path: root/main.go
diff options
context:
space:
mode:
authorterminaldweller <devi@terminaldweller.com>2024-05-10 13:57:48 +0000
committerterminaldweller <devi@terminaldweller.com>2024-05-10 13:57:48 +0000
commita99da1884552b70e60dcbf5f9a91aceea28bdfc0 (patch)
tree45f0c8d28c943049dbce9477e3cf6d3f0993e442 /main.go
parentWIP (diff)
downloadmilla-a99da1884552b70e60dcbf5f9a91aceea28bdfc0.tar.gz
milla-a99da1884552b70e60dcbf5f9a91aceea28bdfc0.zip
WIP
Diffstat (limited to '')
-rw-r--r--main.go49
1 files changed, 34 insertions, 15 deletions
diff --git a/main.go b/main.go
index 88dc33f..540e15d 100644
--- a/main.go
+++ b/main.go
@@ -224,24 +224,43 @@ func runIRC(appConfig TomlConfig, ircChan chan *girc.Client) {
}
defer response.Body.Close()
- var ollamaResponse OllamaResponse
- err = json.NewDecoder(response.Body).Decode(&ollamaResponse)
- if err != nil {
- client.Cmd.ReplyTo(event, fmt.Sprintf("error: %s", err.Error()))
+ var writer bytes.Buffer
+ if appConfig.Chat {
+ var ollamaChatResponse OllamaChatMessages
+ err = json.NewDecoder(response.Body).Decode(&ollamaChatResponse)
+ if err != nil {
+ client.Cmd.ReplyTo(event, fmt.Sprintf("error: %s", err.Error()))
+ }
- return
- }
+ err = quick.Highlight(&writer,
+ ollamaChatResponse.Messages[0].Content,
+ "markdown",
+ appConfig.ChromaFormatter,
+ appConfig.ChromaStyle)
+ if err != nil {
+ client.Cmd.ReplyTo(event, fmt.Sprintf("error: %s", err.Error()))
- var writer bytes.Buffer
- err = quick.Highlight(&writer,
- ollamaResponse.Response,
- "markdown",
- appConfig.ChromaFormatter,
- appConfig.ChromaStyle)
- if err != nil {
- client.Cmd.ReplyTo(event, fmt.Sprintf("error: %s", err.Error()))
+ return
+ }
+ } else {
+ var ollamaResponse OllamaResponse
+ err = json.NewDecoder(response.Body).Decode(&ollamaResponse)
+ if err != nil {
+ client.Cmd.ReplyTo(event, fmt.Sprintf("error: %s", err.Error()))
- return
+ return
+ }
+
+ err = quick.Highlight(&writer,
+ ollamaResponse.Response,
+ "markdown",
+ appConfig.ChromaFormatter,
+ appConfig.ChromaStyle)
+ if err != nil {
+ client.Cmd.ReplyTo(event, fmt.Sprintf("error: %s", err.Error()))
+
+ return
+ }
}
log.Println(writer.String())