diff options
author | terminaldweller <devi@terminaldweller.com> | 2024-10-28 22:28:16 +0000 |
---|---|---|
committer | terminaldweller <devi@terminaldweller.com> | 2024-10-28 22:28:16 +0000 |
commit | e22d58cee6d9bb963f879fde8890e7743269afb3 (patch) | |
tree | 7521268ce29b4fca3b97bfe7451a828b7b880ca5 /main.go | |
parent | added a new option, context. fixed a bug with the custom commands where the c... (diff) | |
download | milla-e22d58cee6d9bb963f879fde8890e7743269afb3.tar.gz milla-e22d58cee6d9bb963f879fde8890e7743269afb3.zip |
added openrouter as a provider
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 38 |
1 files changed, 37 insertions, 1 deletions
@@ -405,6 +405,27 @@ func handleCustomCommand( if result != "" { sendToIRC(client, event, result, appConfig.ChromaFormatter) } + case "openrouter": + var memory []MemoryElement + + for _, log := range logs { + memory = append(memory, MemoryElement{ + Role: "user", + Content: log.Log, + }) + } + + for _, customContext := range customCommand.Context { + memory = append(memory, MemoryElement{ + Role: "user", + Content: customContext, + }) + } + + result := ORRequestProcessor(appConfig, client, event, &memory, customCommand.Prompt) + if result != "" { + sendToIRC(client, event, result, appConfig.ChromaFormatter) + } default: } } @@ -681,7 +702,7 @@ func DoOllamaRequest( ctx, cancel := context.WithTimeout(context.Background(), time.Duration(appConfig.RequestTimeout)*time.Second) defer cancel() - request, err := http.NewRequest(http.MethodPost, appConfig.OllamaEndpoint, bytes.NewBuffer(jsonPayload)) + request, err := http.NewRequest(http.MethodPost, appConfig.Endpoint, bytes.NewBuffer(jsonPayload)) if err != nil { return "", err @@ -1011,6 +1032,10 @@ func DoChatGPTRequest( config := openai.DefaultConfig(appConfig.Apikey) config.HTTPClient = &httpClient + if appConfig.Endpoint != "" { + config.BaseURL = appConfig.Endpoint + log.Print(config.BaseURL) + } gptClient := openai.NewClientWithConfig(config) @@ -1264,6 +1289,8 @@ func runIRC(appConfig TomlConfig) { var GPTMemory []openai.ChatCompletionMessage + var ORMemory []MemoryElement + poolChan := make(chan *pgxpool.Pool, 1) irc := girc.New(girc.Config{ @@ -1363,6 +1390,15 @@ func runIRC(appConfig TomlConfig) { } ChatGPTHandler(irc, &appConfig, &GPTMemory) + case "openrouter": + for _, context := range appConfig.Context { + ORMemory = append(ORMemory, MemoryElement{ + Role: "user", + Content: context, + }) + } + + ORHandler(irc, &appConfig, &ORMemory) } go LoadAllPlugins(&appConfig, irc) |