diff --git a/examples/custom-provider/main.go b/examples/custom-provider/main.go index ffb5e346..2c2e0474 100644 --- a/examples/custom-provider/main.go +++ b/examples/custom-provider/main.go @@ -141,6 +141,10 @@ func (MyExecutor) CountTokens(context.Context, *coreauth.Auth, clipexec.Request, return clipexec.Response{}, errors.New("count tokens not implemented") } +func (MyExecutor) Embed(context.Context, *coreauth.Auth, clipexec.Request, clipexec.Options) (clipexec.Response, error) { + return clipexec.Response{}, errors.New("embeddings not implemented") +} + func (MyExecutor) ExecuteStream(ctx context.Context, a *coreauth.Auth, req clipexec.Request, opts clipexec.Options) (<-chan clipexec.StreamChunk, error) { ch := make(chan clipexec.StreamChunk, 1) go func() { diff --git a/internal/api/server.go b/internal/api/server.go index 2ed843c2..4826c3fc 100644 --- a/internal/api/server.go +++ b/internal/api/server.go @@ -629,7 +629,7 @@ func (s *Server) managementAvailabilityMiddleware() gin.HandlerFunc { func (s *Server) serveManagementControlPanel(c *gin.Context) { // Hidden fallback: only allow localhost and explicit opt-in. - if !isLocalClient(c.ClientIP()) { + if !isLocalClient(c) { c.AbortWithStatus(http.StatusNotFound) return } @@ -686,10 +686,6 @@ func (s *Server) serveManagementControlPanel(c *gin.Context) { c.String(http.StatusOK, html) } -func isLocalClient(ip string) bool { - return ip == "127.0.0.1" || ip == "::1" -} - func (s *Server) enableKeepAlive(timeout time.Duration, onTimeout func()) { if timeout <= 0 || onTimeout == nil { return diff --git a/sdk/api/handlers/handlers.go b/sdk/api/handlers/handlers.go index ed89e41f..b9e48d76 100644 --- a/sdk/api/handlers/handlers.go +++ b/sdk/api/handlers/handlers.go @@ -157,7 +157,7 @@ func (h *BaseAPIHandler) GetContextWithCancel(handler interfaces.APIHandler, c * newCtx = context.WithValue(newCtx, "gin", c) newCtx = context.WithValue(newCtx, "handler", handler) return newCtx, func(params ...interface{}) { - if h.Cfg.RequestLog && len(params) == 1 { + if h != nil && h.Cfg != nil && h.Cfg.RequestLog && len(params) == 1 { var payload []byte switch data := params[0].(type) { case []byte: