Просмотр исходного кода

Merge pull request #1252 from feitianbubu/pr/fix-playgroud-user-setting

fix: playground write user context to check acceptUnsetRatio
Calcium-Ion 8 месяцев назад
Родитель
Сommit
34fed74f64
1 измененных файлов с 9 добавлено и 0 удалено
  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)
 	middleware.SetupContextForSelectedChannel(c, channel, playgroundRequest.Model)
 	c.Set(constant.ContextKeyRequestStartTime, time.Now())
 	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)
 	Relay(c)
 }
 }