change ai provider from openai to openrouter
All checks were successful
Build and Push Docker Container / build-and-push (push) Successful in 2m1s

This commit is contained in:
2026-02-14 20:00:19 +01:00
parent 85529fab67
commit c30a9f3f3e
2 changed files with 4 additions and 19 deletions

View File

@@ -1,5 +1,5 @@
# --- Stage 1: Build the Go application ---
FROM golang:1.23 AS builder
FROM golang:1.24 AS builder
ENV CGO_ENABLED=0
ENV GOOS=linux

View File

@@ -7,8 +7,6 @@ import (
"fmt"
"io"
"net/http"
"github.com/pkoukk/tiktoken-go"
)
type response struct {
@@ -24,14 +22,14 @@ type OpenAi struct {
}
func (oai *OpenAi) Summarize(text string) (string, error) {
apiURL := "https://api.openai.com/v1/chat/completions"
apiURL := "https://openrouter.ai/api/v1/chat/completions"
// Request payload
payload := map[string]interface{}{
"model": "gpt-4o-mini",
"model": "google/gemini-2.5-flash-lite",
"messages": []map[string]string{
{
"role": "developer",
"role": "system",
"content": "Fasse den folgenden Zeitungsartikel in maximal 75 Wörtern zusammen. Konzentriere dich auf die wichtigsten Informationen, wie das Hauptthema, die zentralen Aussagen und relevante Hintergründe. Gib **außschließlich** die Zusammenfassung zurück.",
},
{
@@ -88,16 +86,3 @@ func (oai *OpenAi) Summarize(text string) (string, error) {
return content, nil
}
func (oai *OpenAi) CountTokens(text string) int {
tkm, err := tiktoken.GetEncoding("o200k_base")
if err != nil {
err = fmt.Errorf("getEncoding: %v", err)
return -1
}
// encode
token := tkm.Encode(text, nil, nil)
return len(token)
}