aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--docker-compose.yaml20
-rw-r--r--go.mod2
-rw-r--r--main.go24
3 files changed, 22 insertions, 24 deletions
diff --git a/docker-compose.yaml b/docker-compose.yaml
index 49829c8..67ddf0e 100644
--- a/docker-compose.yaml
+++ b/docker-compose.yaml
@@ -24,25 +24,5 @@ services:
- ALL
environment:
- SERVER_DEPLOYMENT_TYPE=deployment
- # prettier:
- # build:
- # context: ./prettier
- # deploy:
- # resources:
- # limits:
- # memory: 128M
- # logging:
- # driver: "json-file"
- # options:
- # max-size: "100m"
- # networks:
- # - millanet
- # restart: unless-stopped
- # cap_drop:
- # - ALL
- # cap_add:
- # - NET_BIND_SERVICE
- # ports:
- # - "127.0.0.1:9001:9001"
networks:
millanet:
diff --git a/go.mod b/go.mod
index ca25460..94412d4 100644
--- a/go.mod
+++ b/go.mod
@@ -8,7 +8,6 @@ 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.24.0
google.golang.org/api v0.176.1
)
@@ -36,6 +35,7 @@ require (
go.opentelemetry.io/otel/metric v1.24.0 // indirect
go.opentelemetry.io/otel/trace v1.24.0 // indirect
golang.org/x/crypto v0.22.0 // indirect
+ golang.org/x/net v0.24.0 // indirect
golang.org/x/oauth2 v0.19.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.19.0 // indirect
diff --git a/main.go b/main.go
index a5ffbdd..c2c3565 100644
--- a/main.go
+++ b/main.go
@@ -80,14 +80,13 @@ type MemoryElement struct {
Content string `json:"content"`
}
-func printResponse(resp *genai.GenerateContentResponse) string {
+func returnGeminiResponse(resp *genai.GenerateContentResponse) string {
result := ""
for _, cand := range resp.Candidates {
if cand.Content != nil {
for _, part := range cand.Content.Parts {
result += fmt.Sprintln(part)
- log.Println(part)
}
}
}
@@ -241,6 +240,8 @@ func runIRC(appConfig TomlConfig, ircChan chan *girc.Client) {
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(appConfig.RequestTimeout)*time.Second)
defer cancel()
+ // api and http client dont work together
+ // https://github.com/google/generative-ai-go/issues/80
// httpClient := http.Client{}
// allProxy := os.Getenv("ALL_PROXY")
// if allProxy != "" {
@@ -287,10 +288,27 @@ func runIRC(appConfig TomlConfig, ircChan chan *girc.Client) {
// return
// }
+ geminiResponse := returnGeminiResponse(resp)
+ log.Println(geminiResponse)
+
+ cs.History = append(cs.History, &genai.Content{
+ Parts: []genai.Part{
+ genai.Text(prompt),
+ },
+ Role: "user",
+ })
+
+ cs.History = append(cs.History, &genai.Content{
+ Parts: []genai.Part{
+ genai.Text(geminiResponse),
+ },
+ Role: "model",
+ })
+
var writer bytes.Buffer
err = quick.Highlight(
&writer,
- printResponse(resp),
+ geminiResponse,
"markdown",
appConfig.ChromaFormatter,
appConfig.ChromaStyle)