diff options
Diffstat (limited to '')
-rw-r--r-- | docker-compose.yaml | 20 | ||||
-rw-r--r-- | go.mod | 2 | ||||
-rw-r--r-- | main.go | 24 |
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: @@ -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 @@ -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) |