fix: address local UI guard and example executor

This commit is contained in:
Finessse
2025-12-20 06:03:11 +07:00
parent 348609a93f
commit d44aadd1fc
3 changed files with 6 additions and 6 deletions
+4
View File
@@ -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() {
+1 -5
View File
@@ -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
+1 -1
View File
@@ -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: