mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-15 05:04:27 +08:00
Go: add drop instance models (#14485)
### What problem does this PR solve? 1. drop instance model 2. Fix issue of drop instance but not drop models. ### Type of change - [x] New Feature (non-breaking change which adds functionality) Signed-off-by: Jin Hai <haijin.chn@gmail.com>
This commit is contained in:
@@ -682,7 +682,7 @@ func (h *ProviderHandler) AddCustomModel(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if req.ModelType == "" {
|
||||
if req.ModelTypes == nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{
|
||||
"code": 400,
|
||||
"message": "Model type is required",
|
||||
@@ -707,6 +707,54 @@ func (h *ProviderHandler) AddCustomModel(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
type DropInstanceModelRequest struct {
|
||||
Models []string `json:"models" binding:"required"`
|
||||
}
|
||||
|
||||
func (h *ProviderHandler) DropInstanceModels(c *gin.Context) {
|
||||
providerName := c.Param("provider_name")
|
||||
if providerName == "" {
|
||||
c.JSON(http.StatusBadRequest, gin.H{
|
||||
"code": 400,
|
||||
"message": "Provider name is required",
|
||||
})
|
||||
return
|
||||
}
|
||||
instanceName := c.Param("instance_name")
|
||||
if instanceName == "" {
|
||||
c.JSON(http.StatusBadRequest, gin.H{
|
||||
"code": 400,
|
||||
"message": "Instance name is required",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
var req DropInstanceModelRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": common.CodeBadRequest,
|
||||
"message": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
userID := c.GetString("user_id")
|
||||
|
||||
_, err := h.modelProviderService.DropInstanceModels(providerName, instanceName, userID, req.Models)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": common.CodeServerError,
|
||||
"message": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 0,
|
||||
"message": "success",
|
||||
})
|
||||
}
|
||||
|
||||
type ChatToModelRequest struct {
|
||||
ProviderName *string `json:"provider_name"`
|
||||
InstanceName *string `json:"instance_name"`
|
||||
@@ -768,6 +816,7 @@ func (h *ProviderHandler) ChatToModel(c *gin.Context) {
|
||||
chatConfig := models.ChatConfig{
|
||||
Thinking: &req.Thinking,
|
||||
Stream: &req.Stream,
|
||||
Vision: nil,
|
||||
Stop: &[]string{},
|
||||
DoSample: nil,
|
||||
MaxTokens: nil,
|
||||
|
||||
Reference in New Issue
Block a user