mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
feat(llm): add llm_types filters and cleanup dify cli (#24458)
This commit is contained in:
@@ -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
@@ -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
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user