| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- package llm
- import (
- "yunion.io/x/jsonutils"
- "yunion.io/x/pkg/errors"
- computeapi "yunion.io/x/onecloud/pkg/apis/compute"
- api "yunion.io/x/onecloud/pkg/apis/llm"
- "yunion.io/x/onecloud/pkg/cloudcommon/cmdline"
- "yunion.io/x/onecloud/pkg/mcclient/options"
- )
- type DifyListOptions struct {
- LLMBaseListOptions
- DifySku string `help:"filter by dify sku"`
- }
- func (o *DifyListOptions) Params() (jsonutils.JSONObject, error) {
- params, err := options.ListStructToParams(o)
- if err != nil {
- return nil, err
- }
- if o.Used != nil {
- params.Set("unused", jsonutils.JSONFalse)
- }
- params.Set("llm_type", jsonutils.NewString(string(api.LLM_CONTAINER_DIFY)))
- return params, nil
- }
- type DifyShowOptions struct {
- options.BaseShowOptions
- }
- func (o *DifyShowOptions) Params() (jsonutils.JSONObject, error) {
- return options.StructToParams(o)
- }
- type DifyCreateOptions struct {
- LLMBaseCreateOptions
- DIFY_SKU_ID string `help:"dify sku id or name" json:"llm_sku_id"`
- }
- func (o *DifyCreateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.Marshal(o)
- if len(o.Net) > 0 {
- nets := make([]*computeapi.NetworkConfig, 0)
- for i, n := range o.Net {
- net, err := cmdline.ParseNetworkConfig(n, i)
- if err != nil {
- return nil, errors.Wrapf(err, "parse network config %s", n)
- }
- nets = append(nets, net)
- }
- params.(*jsonutils.JSONDict).Add(jsonutils.Marshal(nets), "nets")
- }
- return params, nil
- }
- func (o *DifyCreateOptions) GetCountParam() int {
- return o.Count
- }
- type DifyDeleteOptions struct {
- options.BaseIdOptions
- }
- func (o *DifyDeleteOptions) GetId() string {
- return o.ID
- }
- func (o *DifyDeleteOptions) Params() (jsonutils.JSONObject, error) {
- return options.StructToParams(o)
- }
- type DifyStartOptions struct {
- options.BaseIdsOptions
- }
- func (o *DifyStartOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(o), nil
- }
- type DifyStopOptions struct {
- options.BaseIdsOptions
- }
- func (o *DifyStopOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(o), nil
- }
|