docker compose
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user