aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorterminaldweller <devi@terminaldweller.com>2024-02-20 07:05:31 +0000
committerterminaldweller <devi@terminaldweller.com>2024-02-20 07:05:31 +0000
commit2c689c19fd2a30654bf196e0f6cb164c7e41113c (patch)
treef602071dcbf6f76309f8c7f31cd342e9ebd12b83
parentupdated the README (diff)
downloadmilla-2c689c19fd2a30654bf196e0f6cb164c7e41113c.tar.gz
milla-2c689c19fd2a30654bf196e0f6cb164c7e41113c.zip
gemini is finally fixed
-rw-r--r--go.mod2
-rw-r--r--main.go22
2 files changed, 15 insertions, 9 deletions
diff --git a/go.mod b/go.mod
index 0d90b86..622cc45 100644
--- a/go.mod
+++ b/go.mod
@@ -8,6 +8,7 @@ require (
github.com/lrstanley/girc v0.0.0-20240125042120-9add3166e52e
github.com/pelletier/go-toml/v2 v2.1.1
github.com/sashabaranov/go-openai v1.19.3
+ golang.org/x/net v0.20.0
google.golang.org/api v0.163.0
)
@@ -32,7 +33,6 @@ require (
go.opentelemetry.io/otel/metric v1.22.0 // indirect
go.opentelemetry.io/otel/trace v1.22.0 // indirect
golang.org/x/crypto v0.18.0 // indirect
- golang.org/x/net v0.20.0 // indirect
golang.org/x/oauth2 v0.16.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.16.0 // indirect
diff --git a/main.go b/main.go
index 69d909f..2fda234 100644
--- a/main.go
+++ b/main.go
@@ -174,6 +174,7 @@ func runIRC(appConfig TomlConfig, ircChan chan *girc.Client) {
}
})
} else if appConfig.Provider == "gemini" {
+ log.Println("fuck prime")
irc.Handlers.AddBg(girc.PRIVMSG, func(client *girc.Client, event girc.Event) {
if strings.HasPrefix(event.Last(), appConfig.IrcNick+": ") {
prompt := strings.TrimPrefix(event.Last(), appConfig.IrcNick+": ")
@@ -182,15 +183,18 @@ func runIRC(appConfig TomlConfig, ircChan chan *girc.Client) {
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(appConfig.RequestTimeout)*time.Second)
defer cancel()
- transport := http.Transport{
- Proxy: http.ProxyFromEnvironment,
- }
- httpClient := http.Client{
- Transport: &transport,
- Timeout: time.Duration(appConfig.RequestTimeout) * time.Second,
- }
+ // dialer := proxy.FromEnvironment()
+
+ // transport := http.Transport{
+ // Dial: dialer.Dial,
+ // }
+ // httpClient := http.Client{
+ // Transport: &transport,
+ // Timeout: time.Duration(appConfig.RequestTimeout) * time.Second,
+ // }
- clientGemini, err := genai.NewClient(ctx, option.WithAPIKey(appConfig.Apikey), option.WithHTTPClient(&httpClient))
+ // clientGemini, err := genai.NewClient(ctx, option.WithAPIKey(appConfig.Apikey), option.WithHTTPClient(&httpClient))
+ clientGemini, err := genai.NewClient(ctx, option.WithAPIKey(appConfig.Apikey))
if err != nil {
client.Cmd.ReplyTo(event, girc.Fmt(fmt.Sprintf("error: %s", err.Error())))
@@ -202,12 +206,14 @@ func runIRC(appConfig TomlConfig, ircChan chan *girc.Client) {
model.SetTemperature(float32(appConfig.Temp))
model.SetTopK(appConfig.TopK)
model.SetTopP(appConfig.TopP)
+ log.Println("fuck")
resp, err := model.GenerateContent(ctx, genai.Text(prompt))
if err != nil {
client.Cmd.ReplyTo(event, girc.Fmt(fmt.Sprintf("error: %s", err.Error())))
return
}
+ log.Println("fuck two")
var writer bytes.Buffer
err = quick.Highlight(