Browse Source

fix: playground write user context to check acceptUnsetRatio

skynono 8 months ago
parent
commit
fb8aac650f
1 changed files with 9 additions and 0 deletions
  1. 9 0
      controller/playground.go

+ 9 - 0
controller/playground.go

@@ -66,5 +66,14 @@ func Playground(c *gin.Context) {
 	}
 	middleware.SetupContextForSelectedChannel(c, channel, playgroundRequest.Model)
 	c.Set(constant.ContextKeyRequestStartTime, time.Now())
+
+	// Write user context to ensure acceptUnsetRatio is available
+	userId := c.GetInt("id")
+	userCache, err := model.GetUserCache(userId)
+	if err != nil {
+		openaiErr = service.OpenAIErrorWrapperLocal(err, "get_user_cache_failed", http.StatusInternalServerError)
+		return
+	}
+	userCache.WriteContext(c)
 	Relay(c)
 }