reface to openteam
This commit is contained in:
@@ -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"
|
||||
)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user