docker compose

This commit is contained in:
1iaan
2026-04-04 16:30:54 +08:00
parent c1a895258f
commit e993eb6c5c
25 changed files with 241 additions and 95 deletions

View File

@@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"net/http"
"os"
"github.com/sashabaranov/go-openai"
)
@@ -16,7 +17,13 @@ type tokenInfo struct {
}
func GetTokenCount(message openai.ChatCompletionMessage, model string) (int, error) {
url := fmt.Sprintf("http://127.0.0.1:5000/tokenizer/%s", model)
// url := fmt.Sprintf("http://127.0.0.1:5000/tokenizer/%s", model)
tokenizerBaseURL := os.Getenv("TOKENIZER_BASE_URL")
if tokenizerBaseURL == "" {
tokenizerBaseURL = "http://tokenizer:3002"
}
url := fmt.Sprintf("%s/tokenizer/%s", tokenizerBaseURL, model)
info := tokenInfo{}
if err := postJSON(url, &message, &info); err != nil {
return 0, err