reface to openteam

This commit is contained in:
Sakurasan
2025-04-16 18:01:27 +08:00
parent bc223d6530
commit e7ffc9e8b9
92 changed files with 5345 additions and 1273 deletions

View File

@@ -4,9 +4,9 @@ import (
"net/http"
"strings"
"opencatd-open/pkg/claude"
"opencatd-open/pkg/google"
"opencatd-open/pkg/openai"
"opencatd-open/llm/claude"
"opencatd-open/llm/google"
"opencatd-open/llm/openai"
"github.com/gin-gonic/gin"
)

View File

@@ -5,32 +5,17 @@ import (
"net"
"net/http"
"net/http/httputil"
"opencatd-open/pkg/claude"
oai "opencatd-open/pkg/openai"
"opencatd-open/store"
"opencatd-open/llm/claude"
oai "opencatd-open/llm/openai"
"time"
"github.com/gin-gonic/gin"
)
func HandleProxy(c *gin.Context) {
var (
localuser bool
)
auth := c.Request.Header.Get("Authorization")
if len(auth) > 7 && auth[:7] == "Bearer " {
localuser = store.IsExistAuthCache(auth[7:])
c.Set("localuser", auth[7:])
}
if c.Request.URL.Path == "/v1/complete" {
if localuser {
claude.ClaudeProxy(c)
return
} else {
HandleReverseProxy(c, "api.anthropic.com")
return
}
claude.ClaudeProxy(c)
return
}
if c.Request.URL.Path == "/v1/audio/transcriptions" {
oai.WhisperProxy(c)
@@ -52,19 +37,7 @@ func HandleProxy(c *gin.Context) {
}
if c.Request.URL.Path == "/v1/chat/completions" {
if localuser {
if store.KeysCache.ItemCount() == 0 {
c.JSON(http.StatusBadGateway, gin.H{"error": gin.H{
"message": "No Api-Key Available",
}})
return
}
ChatHandler(c)
return
}
} else {
HandleReverseProxy(c, "api.openai.com")
ChatHandler(c)
return
}