feat(llm): add llm_types filters and cleanup dify cli (#24458)

This commit is contained in:
Zexi Li
2026-03-16 18:05:05 +08:00
committed by GitHub
parent 04d29503ee
commit 3dcc91434c
6 changed files with 17 additions and 26 deletions
-20
View File
@@ -1,20 +0,0 @@
package llm
import (
"yunion.io/x/onecloud/cmd/climc/shell"
modules "yunion.io/x/onecloud/pkg/mcclient/modules/llm"
base_options "yunion.io/x/onecloud/pkg/mcclient/options"
options "yunion.io/x/onecloud/pkg/mcclient/options/llm"
)
// dify-sku commands operate on llm_sku with llm_type=dify (unified SKU table).
func init() {
cmd := shell.NewResourceCmd(&modules.LLMSku).WithKeyword("dify-sku")
cmd.List(new(options.DifySkuListOptions))
cmd.Show(new(options.DifySkuShowOptions))
cmd.Update(new(options.DifySkuUpdateOptions))
cmd.Create(new(options.DifySkuCreateOptions))
cmd.Delete(new(options.DifySkuDeleteOptions))
cmd.Perform("public", &base_options.BasePublicOptions{})
cmd.Perform("private", &base_options.BaseIdOptions{})
}
+4 -3
View File
@@ -110,9 +110,10 @@ type LLMBaseListInput struct {
type LLMListInput struct {
LLMBaseListInput
LLMSku string `json:"llm_sku"`
LLMImage string `json:"llm_image"`
LLMType string `json:"llm_type"` // filter by linked SKU's llm_type (e.g. dify)
LLMSku string `json:"llm_sku"`
LLMImage string `json:"llm_image"`
LLMTypes []string `json:"llm_types"` // filter by linked SKU's llm_types (e.g. [dify, openclaw])
LLMType string `json:"llm_type"` // filter by linked SKU's llm_type (e.g. dify)
}
type ModelInfo struct {
+2 -1
View File
@@ -168,7 +168,8 @@ type LLMSkuListInput struct {
apis.SharableVirtualResourceListInput
MountedModelResourceListInput
LLMType string `json:"llm_type"`
LLMType string `json:"llm_type"`
LLMTypes []string `json:"llm_types"`
}
type LLMSkuCreateInput struct {
+5
View File
@@ -145,6 +145,11 @@ func (man *SLLMManager) ListItemFilter(ctx context.Context, q *sqlchemy.SQuery,
q = q.Join(skuQ, sqlchemy.Equals(q.Field("llm_sku_id"), skuQ.Field("id")))
q = q.Filter(sqlchemy.Equals(skuQ.Field("llm_type"), input.LLMType))
}
if len(input.LLMTypes) > 0 {
skuQ := GetLLMSkuManager().Query().SubQuery()
q = q.Join(skuQ, sqlchemy.Equals(q.Field("llm_sku_id"), skuQ.Field("id")))
q = q.Filter(sqlchemy.In(skuQ.Field("llm_type"), input.LLMTypes))
}
return q, nil
}
+3
View File
@@ -71,6 +71,9 @@ func (man *SLLMSkuManager) ListItemFilter(
if len(input.LLMType) > 0 {
q = q.Equals("llm_type", input.LLMType)
}
if len(input.LLMTypes) > 0 {
q = q.Filter(sqlchemy.In(q.Field("llm_type"), input.LLMTypes))
}
q, err = man.SMountedModelsResourceManager.ListItemFilter(ctx, q, userCred, input.MountedModelResourceListInput)
if err != nil {
return nil, errors.Wrap(err, "SMountedAppsResourceManager")
+3 -2
View File
@@ -28,8 +28,9 @@ type LLMBaseListOptions struct {
type LLMListOptions struct {
LLMBaseListOptions
LlmSku string `help:"filter by llm sku"`
LlmImage string `help:"filter by llm image"`
LlmSku string `help:"filter by llm sku"`
LlmImage string `help:"filter by llm image"`
LLMTypes []string `help:"filter by llm types"`
}
func (o *LLMListOptions) Params() (jsonutils.JSONObject, error) {