瀏覽代碼

AI 角色支持接入第三方工作流

boweniac 3 周之前
父節點
當前提交
46dc5a43b1

+ 25 - 0
desc/wechat/agent.api

@@ -23,6 +23,19 @@ type (
 		DatasetId *string `json:"dataset_id,optional"`
 
 		CollectionId *string `json:"collection_id,optional"`
+
+		// model | model
+        Model  *string `json:"model,optional"`
+
+        // api_base | api_base
+        ApiBase  *string `json:"api_base,optional"`
+
+        // api_key | api_key
+        ApiKey  *string `json:"api_key,optional"`
+
+        // type | 类型 1. 内置 2. 接入
+        Type  *int `json:"type,optional"`
+
     }
 
     // The response data of agent list | Agent列表数据
@@ -59,6 +72,18 @@ type (
 
 		// 租户id
         OrganizationId  *uint64 `json:"organizationId,optional"`
+
+        // model | model
+        Model  *string `json:"model,optional"`
+
+        // api_base | api_base
+        ApiBase  *string `json:"api_base,optional"`
+
+        // api_key | api_key
+        ApiKey  *string `json:"api_key,optional"`
+
+        // type | 类型 1. 内置 2. 接入
+        Type  *int `json:"type,optional"`
     }
 
     // Agent information response | Agent信息返回体

+ 46 - 2
ent/agent.go

@@ -39,6 +39,14 @@ type Agent struct {
 	DatasetID string `json:"dataset_id,omitempty"`
 	// collection_id | 集合ID
 	CollectionID string `json:"collection_id,omitempty"`
+	// model | 模型
+	Model string `json:"model,omitempty"`
+	// api_base | api_base
+	APIBase string `json:"api_base,omitempty"`
+	// api_key | api_key
+	APIKey string `json:"api_key,omitempty"`
+	// type | 类型 1. 内置 2. 接入
+	Type int `json:"type,omitempty"`
 	// Edges holds the relations/edges for other nodes in the graph.
 	// The values are being populated by the AgentQuery when eager-loading is set.
 	Edges        AgentEdges `json:"edges"`
@@ -101,9 +109,9 @@ func (*Agent) scanValues(columns []string) ([]any, error) {
 	values := make([]any, len(columns))
 	for i := range columns {
 		switch columns[i] {
-		case agent.FieldID, agent.FieldStatus, agent.FieldOrganizationID:
+		case agent.FieldID, agent.FieldStatus, agent.FieldOrganizationID, agent.FieldType:
 			values[i] = new(sql.NullInt64)
-		case agent.FieldName, agent.FieldRole, agent.FieldBackground, agent.FieldExamples, agent.FieldDatasetID, agent.FieldCollectionID:
+		case agent.FieldName, agent.FieldRole, agent.FieldBackground, agent.FieldExamples, agent.FieldDatasetID, agent.FieldCollectionID, agent.FieldModel, agent.FieldAPIBase, agent.FieldAPIKey:
 			values[i] = new(sql.NullString)
 		case agent.FieldCreatedAt, agent.FieldUpdatedAt, agent.FieldDeletedAt:
 			values[i] = new(sql.NullTime)
@@ -194,6 +202,30 @@ func (a *Agent) assignValues(columns []string, values []any) error {
 			} else if value.Valid {
 				a.CollectionID = value.String
 			}
+		case agent.FieldModel:
+			if value, ok := values[i].(*sql.NullString); !ok {
+				return fmt.Errorf("unexpected type %T for field model", values[i])
+			} else if value.Valid {
+				a.Model = value.String
+			}
+		case agent.FieldAPIBase:
+			if value, ok := values[i].(*sql.NullString); !ok {
+				return fmt.Errorf("unexpected type %T for field api_base", values[i])
+			} else if value.Valid {
+				a.APIBase = value.String
+			}
+		case agent.FieldAPIKey:
+			if value, ok := values[i].(*sql.NullString); !ok {
+				return fmt.Errorf("unexpected type %T for field api_key", values[i])
+			} else if value.Valid {
+				a.APIKey = value.String
+			}
+		case agent.FieldType:
+			if value, ok := values[i].(*sql.NullInt64); !ok {
+				return fmt.Errorf("unexpected type %T for field type", values[i])
+			} else if value.Valid {
+				a.Type = int(value.Int64)
+			}
 		default:
 			a.selectValues.Set(columns[i], values[i])
 		}
@@ -282,6 +314,18 @@ func (a *Agent) String() string {
 	builder.WriteString(", ")
 	builder.WriteString("collection_id=")
 	builder.WriteString(a.CollectionID)
+	builder.WriteString(", ")
+	builder.WriteString("model=")
+	builder.WriteString(a.Model)
+	builder.WriteString(", ")
+	builder.WriteString("api_base=")
+	builder.WriteString(a.APIBase)
+	builder.WriteString(", ")
+	builder.WriteString("api_key=")
+	builder.WriteString(a.APIKey)
+	builder.WriteString(", ")
+	builder.WriteString("type=")
+	builder.WriteString(fmt.Sprintf("%v", a.Type))
 	builder.WriteByte(')')
 	return builder.String()
 }

+ 44 - 0
ent/agent/agent.go

@@ -37,6 +37,14 @@ const (
 	FieldDatasetID = "dataset_id"
 	// FieldCollectionID holds the string denoting the collection_id field in the database.
 	FieldCollectionID = "collection_id"
+	// FieldModel holds the string denoting the model field in the database.
+	FieldModel = "model"
+	// FieldAPIBase holds the string denoting the api_base field in the database.
+	FieldAPIBase = "api_base"
+	// FieldAPIKey holds the string denoting the api_key field in the database.
+	FieldAPIKey = "api_key"
+	// FieldType holds the string denoting the type field in the database.
+	FieldType = "type"
 	// EdgeWxAgent holds the string denoting the wx_agent edge name in mutations.
 	EdgeWxAgent = "wx_agent"
 	// EdgeTokenAgent holds the string denoting the token_agent edge name in mutations.
@@ -91,6 +99,10 @@ var Columns = []string{
 	FieldOrganizationID,
 	FieldDatasetID,
 	FieldCollectionID,
+	FieldModel,
+	FieldAPIBase,
+	FieldAPIKey,
+	FieldType,
 }
 
 // ValidColumn reports if the column name is valid (part of the table columns).
@@ -119,6 +131,8 @@ var (
 	UpdateDefaultUpdatedAt func() time.Time
 	// NameValidator is a validator for the "name" field. It is called by the builders before save.
 	NameValidator func(string) error
+	// DefaultRole holds the default value on creation for the "role" field.
+	DefaultRole string
 	// DefaultStatus holds the default value on creation for the "status" field.
 	DefaultStatus int
 	// StatusValidator is a validator for the "status" field. It is called by the builders before save.
@@ -137,6 +151,16 @@ var (
 	DefaultCollectionID string
 	// CollectionIDValidator is a validator for the "collection_id" field. It is called by the builders before save.
 	CollectionIDValidator func(string) error
+	// DefaultModel holds the default value on creation for the "model" field.
+	DefaultModel string
+	// DefaultAPIBase holds the default value on creation for the "api_base" field.
+	DefaultAPIBase string
+	// DefaultAPIKey holds the default value on creation for the "api_key" field.
+	DefaultAPIKey string
+	// DefaultType holds the default value on creation for the "type" field.
+	DefaultType int
+	// TypeValidator is a validator for the "type" field. It is called by the builders before save.
+	TypeValidator func(int) error
 )
 
 // OrderOption defines the ordering options for the Agent queries.
@@ -202,6 +226,26 @@ func ByCollectionID(opts ...sql.OrderTermOption) OrderOption {
 	return sql.OrderByField(FieldCollectionID, opts...).ToFunc()
 }
 
+// ByModel orders the results by the model field.
+func ByModel(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldModel, opts...).ToFunc()
+}
+
+// ByAPIBase orders the results by the api_base field.
+func ByAPIBase(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldAPIBase, opts...).ToFunc()
+}
+
+// ByAPIKey orders the results by the api_key field.
+func ByAPIKey(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldAPIKey, opts...).ToFunc()
+}
+
+// ByType orders the results by the type field.
+func ByType(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldType, opts...).ToFunc()
+}
+
 // ByWxAgentCount orders the results by wx_agent count.
 func ByWxAgentCount(opts ...sql.OrderTermOption) OrderOption {
 	return func(s *sql.Selector) {

+ 305 - 0
ent/agent/where.go

@@ -110,6 +110,26 @@ func CollectionID(v string) predicate.Agent {
 	return predicate.Agent(sql.FieldEQ(FieldCollectionID, v))
 }
 
+// Model applies equality check predicate on the "model" field. It's identical to ModelEQ.
+func Model(v string) predicate.Agent {
+	return predicate.Agent(sql.FieldEQ(FieldModel, v))
+}
+
+// APIBase applies equality check predicate on the "api_base" field. It's identical to APIBaseEQ.
+func APIBase(v string) predicate.Agent {
+	return predicate.Agent(sql.FieldEQ(FieldAPIBase, v))
+}
+
+// APIKey applies equality check predicate on the "api_key" field. It's identical to APIKeyEQ.
+func APIKey(v string) predicate.Agent {
+	return predicate.Agent(sql.FieldEQ(FieldAPIKey, v))
+}
+
+// Type applies equality check predicate on the "type" field. It's identical to TypeEQ.
+func Type(v int) predicate.Agent {
+	return predicate.Agent(sql.FieldEQ(FieldType, v))
+}
+
 // CreatedAtEQ applies the EQ predicate on the "created_at" field.
 func CreatedAtEQ(v time.Time) predicate.Agent {
 	return predicate.Agent(sql.FieldEQ(FieldCreatedAt, v))
@@ -360,6 +380,16 @@ func RoleHasSuffix(v string) predicate.Agent {
 	return predicate.Agent(sql.FieldHasSuffix(FieldRole, v))
 }
 
+// RoleIsNil applies the IsNil predicate on the "role" field.
+func RoleIsNil() predicate.Agent {
+	return predicate.Agent(sql.FieldIsNull(FieldRole))
+}
+
+// RoleNotNil applies the NotNil predicate on the "role" field.
+func RoleNotNil() predicate.Agent {
+	return predicate.Agent(sql.FieldNotNull(FieldRole))
+}
+
 // RoleEqualFold applies the EqualFold predicate on the "role" field.
 func RoleEqualFold(v string) predicate.Agent {
 	return predicate.Agent(sql.FieldEqualFold(FieldRole, v))
@@ -740,6 +770,281 @@ func CollectionIDContainsFold(v string) predicate.Agent {
 	return predicate.Agent(sql.FieldContainsFold(FieldCollectionID, v))
 }
 
+// ModelEQ applies the EQ predicate on the "model" field.
+func ModelEQ(v string) predicate.Agent {
+	return predicate.Agent(sql.FieldEQ(FieldModel, v))
+}
+
+// ModelNEQ applies the NEQ predicate on the "model" field.
+func ModelNEQ(v string) predicate.Agent {
+	return predicate.Agent(sql.FieldNEQ(FieldModel, v))
+}
+
+// ModelIn applies the In predicate on the "model" field.
+func ModelIn(vs ...string) predicate.Agent {
+	return predicate.Agent(sql.FieldIn(FieldModel, vs...))
+}
+
+// ModelNotIn applies the NotIn predicate on the "model" field.
+func ModelNotIn(vs ...string) predicate.Agent {
+	return predicate.Agent(sql.FieldNotIn(FieldModel, vs...))
+}
+
+// ModelGT applies the GT predicate on the "model" field.
+func ModelGT(v string) predicate.Agent {
+	return predicate.Agent(sql.FieldGT(FieldModel, v))
+}
+
+// ModelGTE applies the GTE predicate on the "model" field.
+func ModelGTE(v string) predicate.Agent {
+	return predicate.Agent(sql.FieldGTE(FieldModel, v))
+}
+
+// ModelLT applies the LT predicate on the "model" field.
+func ModelLT(v string) predicate.Agent {
+	return predicate.Agent(sql.FieldLT(FieldModel, v))
+}
+
+// ModelLTE applies the LTE predicate on the "model" field.
+func ModelLTE(v string) predicate.Agent {
+	return predicate.Agent(sql.FieldLTE(FieldModel, v))
+}
+
+// ModelContains applies the Contains predicate on the "model" field.
+func ModelContains(v string) predicate.Agent {
+	return predicate.Agent(sql.FieldContains(FieldModel, v))
+}
+
+// ModelHasPrefix applies the HasPrefix predicate on the "model" field.
+func ModelHasPrefix(v string) predicate.Agent {
+	return predicate.Agent(sql.FieldHasPrefix(FieldModel, v))
+}
+
+// ModelHasSuffix applies the HasSuffix predicate on the "model" field.
+func ModelHasSuffix(v string) predicate.Agent {
+	return predicate.Agent(sql.FieldHasSuffix(FieldModel, v))
+}
+
+// ModelIsNil applies the IsNil predicate on the "model" field.
+func ModelIsNil() predicate.Agent {
+	return predicate.Agent(sql.FieldIsNull(FieldModel))
+}
+
+// ModelNotNil applies the NotNil predicate on the "model" field.
+func ModelNotNil() predicate.Agent {
+	return predicate.Agent(sql.FieldNotNull(FieldModel))
+}
+
+// ModelEqualFold applies the EqualFold predicate on the "model" field.
+func ModelEqualFold(v string) predicate.Agent {
+	return predicate.Agent(sql.FieldEqualFold(FieldModel, v))
+}
+
+// ModelContainsFold applies the ContainsFold predicate on the "model" field.
+func ModelContainsFold(v string) predicate.Agent {
+	return predicate.Agent(sql.FieldContainsFold(FieldModel, v))
+}
+
+// APIBaseEQ applies the EQ predicate on the "api_base" field.
+func APIBaseEQ(v string) predicate.Agent {
+	return predicate.Agent(sql.FieldEQ(FieldAPIBase, v))
+}
+
+// APIBaseNEQ applies the NEQ predicate on the "api_base" field.
+func APIBaseNEQ(v string) predicate.Agent {
+	return predicate.Agent(sql.FieldNEQ(FieldAPIBase, v))
+}
+
+// APIBaseIn applies the In predicate on the "api_base" field.
+func APIBaseIn(vs ...string) predicate.Agent {
+	return predicate.Agent(sql.FieldIn(FieldAPIBase, vs...))
+}
+
+// APIBaseNotIn applies the NotIn predicate on the "api_base" field.
+func APIBaseNotIn(vs ...string) predicate.Agent {
+	return predicate.Agent(sql.FieldNotIn(FieldAPIBase, vs...))
+}
+
+// APIBaseGT applies the GT predicate on the "api_base" field.
+func APIBaseGT(v string) predicate.Agent {
+	return predicate.Agent(sql.FieldGT(FieldAPIBase, v))
+}
+
+// APIBaseGTE applies the GTE predicate on the "api_base" field.
+func APIBaseGTE(v string) predicate.Agent {
+	return predicate.Agent(sql.FieldGTE(FieldAPIBase, v))
+}
+
+// APIBaseLT applies the LT predicate on the "api_base" field.
+func APIBaseLT(v string) predicate.Agent {
+	return predicate.Agent(sql.FieldLT(FieldAPIBase, v))
+}
+
+// APIBaseLTE applies the LTE predicate on the "api_base" field.
+func APIBaseLTE(v string) predicate.Agent {
+	return predicate.Agent(sql.FieldLTE(FieldAPIBase, v))
+}
+
+// APIBaseContains applies the Contains predicate on the "api_base" field.
+func APIBaseContains(v string) predicate.Agent {
+	return predicate.Agent(sql.FieldContains(FieldAPIBase, v))
+}
+
+// APIBaseHasPrefix applies the HasPrefix predicate on the "api_base" field.
+func APIBaseHasPrefix(v string) predicate.Agent {
+	return predicate.Agent(sql.FieldHasPrefix(FieldAPIBase, v))
+}
+
+// APIBaseHasSuffix applies the HasSuffix predicate on the "api_base" field.
+func APIBaseHasSuffix(v string) predicate.Agent {
+	return predicate.Agent(sql.FieldHasSuffix(FieldAPIBase, v))
+}
+
+// APIBaseIsNil applies the IsNil predicate on the "api_base" field.
+func APIBaseIsNil() predicate.Agent {
+	return predicate.Agent(sql.FieldIsNull(FieldAPIBase))
+}
+
+// APIBaseNotNil applies the NotNil predicate on the "api_base" field.
+func APIBaseNotNil() predicate.Agent {
+	return predicate.Agent(sql.FieldNotNull(FieldAPIBase))
+}
+
+// APIBaseEqualFold applies the EqualFold predicate on the "api_base" field.
+func APIBaseEqualFold(v string) predicate.Agent {
+	return predicate.Agent(sql.FieldEqualFold(FieldAPIBase, v))
+}
+
+// APIBaseContainsFold applies the ContainsFold predicate on the "api_base" field.
+func APIBaseContainsFold(v string) predicate.Agent {
+	return predicate.Agent(sql.FieldContainsFold(FieldAPIBase, v))
+}
+
+// APIKeyEQ applies the EQ predicate on the "api_key" field.
+func APIKeyEQ(v string) predicate.Agent {
+	return predicate.Agent(sql.FieldEQ(FieldAPIKey, v))
+}
+
+// APIKeyNEQ applies the NEQ predicate on the "api_key" field.
+func APIKeyNEQ(v string) predicate.Agent {
+	return predicate.Agent(sql.FieldNEQ(FieldAPIKey, v))
+}
+
+// APIKeyIn applies the In predicate on the "api_key" field.
+func APIKeyIn(vs ...string) predicate.Agent {
+	return predicate.Agent(sql.FieldIn(FieldAPIKey, vs...))
+}
+
+// APIKeyNotIn applies the NotIn predicate on the "api_key" field.
+func APIKeyNotIn(vs ...string) predicate.Agent {
+	return predicate.Agent(sql.FieldNotIn(FieldAPIKey, vs...))
+}
+
+// APIKeyGT applies the GT predicate on the "api_key" field.
+func APIKeyGT(v string) predicate.Agent {
+	return predicate.Agent(sql.FieldGT(FieldAPIKey, v))
+}
+
+// APIKeyGTE applies the GTE predicate on the "api_key" field.
+func APIKeyGTE(v string) predicate.Agent {
+	return predicate.Agent(sql.FieldGTE(FieldAPIKey, v))
+}
+
+// APIKeyLT applies the LT predicate on the "api_key" field.
+func APIKeyLT(v string) predicate.Agent {
+	return predicate.Agent(sql.FieldLT(FieldAPIKey, v))
+}
+
+// APIKeyLTE applies the LTE predicate on the "api_key" field.
+func APIKeyLTE(v string) predicate.Agent {
+	return predicate.Agent(sql.FieldLTE(FieldAPIKey, v))
+}
+
+// APIKeyContains applies the Contains predicate on the "api_key" field.
+func APIKeyContains(v string) predicate.Agent {
+	return predicate.Agent(sql.FieldContains(FieldAPIKey, v))
+}
+
+// APIKeyHasPrefix applies the HasPrefix predicate on the "api_key" field.
+func APIKeyHasPrefix(v string) predicate.Agent {
+	return predicate.Agent(sql.FieldHasPrefix(FieldAPIKey, v))
+}
+
+// APIKeyHasSuffix applies the HasSuffix predicate on the "api_key" field.
+func APIKeyHasSuffix(v string) predicate.Agent {
+	return predicate.Agent(sql.FieldHasSuffix(FieldAPIKey, v))
+}
+
+// APIKeyIsNil applies the IsNil predicate on the "api_key" field.
+func APIKeyIsNil() predicate.Agent {
+	return predicate.Agent(sql.FieldIsNull(FieldAPIKey))
+}
+
+// APIKeyNotNil applies the NotNil predicate on the "api_key" field.
+func APIKeyNotNil() predicate.Agent {
+	return predicate.Agent(sql.FieldNotNull(FieldAPIKey))
+}
+
+// APIKeyEqualFold applies the EqualFold predicate on the "api_key" field.
+func APIKeyEqualFold(v string) predicate.Agent {
+	return predicate.Agent(sql.FieldEqualFold(FieldAPIKey, v))
+}
+
+// APIKeyContainsFold applies the ContainsFold predicate on the "api_key" field.
+func APIKeyContainsFold(v string) predicate.Agent {
+	return predicate.Agent(sql.FieldContainsFold(FieldAPIKey, v))
+}
+
+// TypeEQ applies the EQ predicate on the "type" field.
+func TypeEQ(v int) predicate.Agent {
+	return predicate.Agent(sql.FieldEQ(FieldType, v))
+}
+
+// TypeNEQ applies the NEQ predicate on the "type" field.
+func TypeNEQ(v int) predicate.Agent {
+	return predicate.Agent(sql.FieldNEQ(FieldType, v))
+}
+
+// TypeIn applies the In predicate on the "type" field.
+func TypeIn(vs ...int) predicate.Agent {
+	return predicate.Agent(sql.FieldIn(FieldType, vs...))
+}
+
+// TypeNotIn applies the NotIn predicate on the "type" field.
+func TypeNotIn(vs ...int) predicate.Agent {
+	return predicate.Agent(sql.FieldNotIn(FieldType, vs...))
+}
+
+// TypeGT applies the GT predicate on the "type" field.
+func TypeGT(v int) predicate.Agent {
+	return predicate.Agent(sql.FieldGT(FieldType, v))
+}
+
+// TypeGTE applies the GTE predicate on the "type" field.
+func TypeGTE(v int) predicate.Agent {
+	return predicate.Agent(sql.FieldGTE(FieldType, v))
+}
+
+// TypeLT applies the LT predicate on the "type" field.
+func TypeLT(v int) predicate.Agent {
+	return predicate.Agent(sql.FieldLT(FieldType, v))
+}
+
+// TypeLTE applies the LTE predicate on the "type" field.
+func TypeLTE(v int) predicate.Agent {
+	return predicate.Agent(sql.FieldLTE(FieldType, v))
+}
+
+// TypeIsNil applies the IsNil predicate on the "type" field.
+func TypeIsNil() predicate.Agent {
+	return predicate.Agent(sql.FieldIsNull(FieldType))
+}
+
+// TypeNotNil applies the NotNil predicate on the "type" field.
+func TypeNotNil() predicate.Agent {
+	return predicate.Agent(sql.FieldNotNull(FieldType))
+}
+
 // HasWxAgent applies the HasEdge predicate on the "wx_agent" edge.
 func HasWxAgent() predicate.Agent {
 	return predicate.Agent(func(s *sql.Selector) {

+ 385 - 3
ent/agent_create.go

@@ -80,6 +80,14 @@ func (ac *AgentCreate) SetRole(s string) *AgentCreate {
 	return ac
 }
 
+// SetNillableRole sets the "role" field if the given value is not nil.
+func (ac *AgentCreate) SetNillableRole(s *string) *AgentCreate {
+	if s != nil {
+		ac.SetRole(*s)
+	}
+	return ac
+}
+
 // SetStatus sets the "status" field.
 func (ac *AgentCreate) SetStatus(i int) *AgentCreate {
 	ac.mutation.SetStatus(i)
@@ -156,6 +164,62 @@ func (ac *AgentCreate) SetNillableCollectionID(s *string) *AgentCreate {
 	return ac
 }
 
+// SetModel sets the "model" field.
+func (ac *AgentCreate) SetModel(s string) *AgentCreate {
+	ac.mutation.SetModel(s)
+	return ac
+}
+
+// SetNillableModel sets the "model" field if the given value is not nil.
+func (ac *AgentCreate) SetNillableModel(s *string) *AgentCreate {
+	if s != nil {
+		ac.SetModel(*s)
+	}
+	return ac
+}
+
+// SetAPIBase sets the "api_base" field.
+func (ac *AgentCreate) SetAPIBase(s string) *AgentCreate {
+	ac.mutation.SetAPIBase(s)
+	return ac
+}
+
+// SetNillableAPIBase sets the "api_base" field if the given value is not nil.
+func (ac *AgentCreate) SetNillableAPIBase(s *string) *AgentCreate {
+	if s != nil {
+		ac.SetAPIBase(*s)
+	}
+	return ac
+}
+
+// SetAPIKey sets the "api_key" field.
+func (ac *AgentCreate) SetAPIKey(s string) *AgentCreate {
+	ac.mutation.SetAPIKey(s)
+	return ac
+}
+
+// SetNillableAPIKey sets the "api_key" field if the given value is not nil.
+func (ac *AgentCreate) SetNillableAPIKey(s *string) *AgentCreate {
+	if s != nil {
+		ac.SetAPIKey(*s)
+	}
+	return ac
+}
+
+// SetType sets the "type" field.
+func (ac *AgentCreate) SetType(i int) *AgentCreate {
+	ac.mutation.SetType(i)
+	return ac
+}
+
+// SetNillableType sets the "type" field if the given value is not nil.
+func (ac *AgentCreate) SetNillableType(i *int) *AgentCreate {
+	if i != nil {
+		ac.SetType(*i)
+	}
+	return ac
+}
+
 // SetID sets the "id" field.
 func (ac *AgentCreate) SetID(u uint64) *AgentCreate {
 	ac.mutation.SetID(u)
@@ -273,6 +337,10 @@ func (ac *AgentCreate) defaults() error {
 		v := agent.DefaultUpdatedAt()
 		ac.mutation.SetUpdatedAt(v)
 	}
+	if _, ok := ac.mutation.Role(); !ok {
+		v := agent.DefaultRole
+		ac.mutation.SetRole(v)
+	}
 	if _, ok := ac.mutation.Status(); !ok {
 		v := agent.DefaultStatus
 		ac.mutation.SetStatus(v)
@@ -293,6 +361,22 @@ func (ac *AgentCreate) defaults() error {
 		v := agent.DefaultCollectionID
 		ac.mutation.SetCollectionID(v)
 	}
+	if _, ok := ac.mutation.Model(); !ok {
+		v := agent.DefaultModel
+		ac.mutation.SetModel(v)
+	}
+	if _, ok := ac.mutation.APIBase(); !ok {
+		v := agent.DefaultAPIBase
+		ac.mutation.SetAPIBase(v)
+	}
+	if _, ok := ac.mutation.APIKey(); !ok {
+		v := agent.DefaultAPIKey
+		ac.mutation.SetAPIKey(v)
+	}
+	if _, ok := ac.mutation.GetType(); !ok {
+		v := agent.DefaultType
+		ac.mutation.SetType(v)
+	}
 	return nil
 }
 
@@ -312,9 +396,6 @@ func (ac *AgentCreate) check() error {
 			return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Agent.name": %w`, err)}
 		}
 	}
-	if _, ok := ac.mutation.Role(); !ok {
-		return &ValidationError{Name: "role", err: errors.New(`ent: missing required field "Agent.role"`)}
-	}
 	if v, ok := ac.mutation.Status(); ok {
 		if err := agent.StatusValidator(v); err != nil {
 			return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "Agent.status": %w`, err)}
@@ -344,6 +425,11 @@ func (ac *AgentCreate) check() error {
 			return &ValidationError{Name: "collection_id", err: fmt.Errorf(`ent: validator failed for field "Agent.collection_id": %w`, err)}
 		}
 	}
+	if v, ok := ac.mutation.GetType(); ok {
+		if err := agent.TypeValidator(v); err != nil {
+			return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Agent.type": %w`, err)}
+		}
+	}
 	return nil
 }
 
@@ -421,6 +507,22 @@ func (ac *AgentCreate) createSpec() (*Agent, *sqlgraph.CreateSpec) {
 		_spec.SetField(agent.FieldCollectionID, field.TypeString, value)
 		_node.CollectionID = value
 	}
+	if value, ok := ac.mutation.Model(); ok {
+		_spec.SetField(agent.FieldModel, field.TypeString, value)
+		_node.Model = value
+	}
+	if value, ok := ac.mutation.APIBase(); ok {
+		_spec.SetField(agent.FieldAPIBase, field.TypeString, value)
+		_node.APIBase = value
+	}
+	if value, ok := ac.mutation.APIKey(); ok {
+		_spec.SetField(agent.FieldAPIKey, field.TypeString, value)
+		_node.APIKey = value
+	}
+	if value, ok := ac.mutation.GetType(); ok {
+		_spec.SetField(agent.FieldType, field.TypeInt, value)
+		_node.Type = value
+	}
 	if nodes := ac.mutation.WxAgentIDs(); len(nodes) > 0 {
 		edge := &sqlgraph.EdgeSpec{
 			Rel:     sqlgraph.O2M,
@@ -591,6 +693,12 @@ func (u *AgentUpsert) UpdateRole() *AgentUpsert {
 	return u
 }
 
+// ClearRole clears the value of the "role" field.
+func (u *AgentUpsert) ClearRole() *AgentUpsert {
+	u.SetNull(agent.FieldRole)
+	return u
+}
+
 // SetStatus sets the "status" field.
 func (u *AgentUpsert) SetStatus(v int) *AgentUpsert {
 	u.Set(agent.FieldStatus, v)
@@ -693,6 +801,84 @@ func (u *AgentUpsert) UpdateCollectionID() *AgentUpsert {
 	return u
 }
 
+// SetModel sets the "model" field.
+func (u *AgentUpsert) SetModel(v string) *AgentUpsert {
+	u.Set(agent.FieldModel, v)
+	return u
+}
+
+// UpdateModel sets the "model" field to the value that was provided on create.
+func (u *AgentUpsert) UpdateModel() *AgentUpsert {
+	u.SetExcluded(agent.FieldModel)
+	return u
+}
+
+// ClearModel clears the value of the "model" field.
+func (u *AgentUpsert) ClearModel() *AgentUpsert {
+	u.SetNull(agent.FieldModel)
+	return u
+}
+
+// SetAPIBase sets the "api_base" field.
+func (u *AgentUpsert) SetAPIBase(v string) *AgentUpsert {
+	u.Set(agent.FieldAPIBase, v)
+	return u
+}
+
+// UpdateAPIBase sets the "api_base" field to the value that was provided on create.
+func (u *AgentUpsert) UpdateAPIBase() *AgentUpsert {
+	u.SetExcluded(agent.FieldAPIBase)
+	return u
+}
+
+// ClearAPIBase clears the value of the "api_base" field.
+func (u *AgentUpsert) ClearAPIBase() *AgentUpsert {
+	u.SetNull(agent.FieldAPIBase)
+	return u
+}
+
+// SetAPIKey sets the "api_key" field.
+func (u *AgentUpsert) SetAPIKey(v string) *AgentUpsert {
+	u.Set(agent.FieldAPIKey, v)
+	return u
+}
+
+// UpdateAPIKey sets the "api_key" field to the value that was provided on create.
+func (u *AgentUpsert) UpdateAPIKey() *AgentUpsert {
+	u.SetExcluded(agent.FieldAPIKey)
+	return u
+}
+
+// ClearAPIKey clears the value of the "api_key" field.
+func (u *AgentUpsert) ClearAPIKey() *AgentUpsert {
+	u.SetNull(agent.FieldAPIKey)
+	return u
+}
+
+// SetType sets the "type" field.
+func (u *AgentUpsert) SetType(v int) *AgentUpsert {
+	u.Set(agent.FieldType, v)
+	return u
+}
+
+// UpdateType sets the "type" field to the value that was provided on create.
+func (u *AgentUpsert) UpdateType() *AgentUpsert {
+	u.SetExcluded(agent.FieldType)
+	return u
+}
+
+// AddType adds v to the "type" field.
+func (u *AgentUpsert) AddType(v int) *AgentUpsert {
+	u.Add(agent.FieldType, v)
+	return u
+}
+
+// ClearType clears the value of the "type" field.
+func (u *AgentUpsert) ClearType() *AgentUpsert {
+	u.SetNull(agent.FieldType)
+	return u
+}
+
 // UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field.
 // Using this option is equivalent to using:
 //
@@ -807,6 +993,13 @@ func (u *AgentUpsertOne) UpdateRole() *AgentUpsertOne {
 	})
 }
 
+// ClearRole clears the value of the "role" field.
+func (u *AgentUpsertOne) ClearRole() *AgentUpsertOne {
+	return u.Update(func(s *AgentUpsert) {
+		s.ClearRole()
+	})
+}
+
 // SetStatus sets the "status" field.
 func (u *AgentUpsertOne) SetStatus(v int) *AgentUpsertOne {
 	return u.Update(func(s *AgentUpsert) {
@@ -926,6 +1119,97 @@ func (u *AgentUpsertOne) UpdateCollectionID() *AgentUpsertOne {
 	})
 }
 
+// SetModel sets the "model" field.
+func (u *AgentUpsertOne) SetModel(v string) *AgentUpsertOne {
+	return u.Update(func(s *AgentUpsert) {
+		s.SetModel(v)
+	})
+}
+
+// UpdateModel sets the "model" field to the value that was provided on create.
+func (u *AgentUpsertOne) UpdateModel() *AgentUpsertOne {
+	return u.Update(func(s *AgentUpsert) {
+		s.UpdateModel()
+	})
+}
+
+// ClearModel clears the value of the "model" field.
+func (u *AgentUpsertOne) ClearModel() *AgentUpsertOne {
+	return u.Update(func(s *AgentUpsert) {
+		s.ClearModel()
+	})
+}
+
+// SetAPIBase sets the "api_base" field.
+func (u *AgentUpsertOne) SetAPIBase(v string) *AgentUpsertOne {
+	return u.Update(func(s *AgentUpsert) {
+		s.SetAPIBase(v)
+	})
+}
+
+// UpdateAPIBase sets the "api_base" field to the value that was provided on create.
+func (u *AgentUpsertOne) UpdateAPIBase() *AgentUpsertOne {
+	return u.Update(func(s *AgentUpsert) {
+		s.UpdateAPIBase()
+	})
+}
+
+// ClearAPIBase clears the value of the "api_base" field.
+func (u *AgentUpsertOne) ClearAPIBase() *AgentUpsertOne {
+	return u.Update(func(s *AgentUpsert) {
+		s.ClearAPIBase()
+	})
+}
+
+// SetAPIKey sets the "api_key" field.
+func (u *AgentUpsertOne) SetAPIKey(v string) *AgentUpsertOne {
+	return u.Update(func(s *AgentUpsert) {
+		s.SetAPIKey(v)
+	})
+}
+
+// UpdateAPIKey sets the "api_key" field to the value that was provided on create.
+func (u *AgentUpsertOne) UpdateAPIKey() *AgentUpsertOne {
+	return u.Update(func(s *AgentUpsert) {
+		s.UpdateAPIKey()
+	})
+}
+
+// ClearAPIKey clears the value of the "api_key" field.
+func (u *AgentUpsertOne) ClearAPIKey() *AgentUpsertOne {
+	return u.Update(func(s *AgentUpsert) {
+		s.ClearAPIKey()
+	})
+}
+
+// SetType sets the "type" field.
+func (u *AgentUpsertOne) SetType(v int) *AgentUpsertOne {
+	return u.Update(func(s *AgentUpsert) {
+		s.SetType(v)
+	})
+}
+
+// AddType adds v to the "type" field.
+func (u *AgentUpsertOne) AddType(v int) *AgentUpsertOne {
+	return u.Update(func(s *AgentUpsert) {
+		s.AddType(v)
+	})
+}
+
+// UpdateType sets the "type" field to the value that was provided on create.
+func (u *AgentUpsertOne) UpdateType() *AgentUpsertOne {
+	return u.Update(func(s *AgentUpsert) {
+		s.UpdateType()
+	})
+}
+
+// ClearType clears the value of the "type" field.
+func (u *AgentUpsertOne) ClearType() *AgentUpsertOne {
+	return u.Update(func(s *AgentUpsert) {
+		s.ClearType()
+	})
+}
+
 // Exec executes the query.
 func (u *AgentUpsertOne) Exec(ctx context.Context) error {
 	if len(u.create.conflict) == 0 {
@@ -1206,6 +1490,13 @@ func (u *AgentUpsertBulk) UpdateRole() *AgentUpsertBulk {
 	})
 }
 
+// ClearRole clears the value of the "role" field.
+func (u *AgentUpsertBulk) ClearRole() *AgentUpsertBulk {
+	return u.Update(func(s *AgentUpsert) {
+		s.ClearRole()
+	})
+}
+
 // SetStatus sets the "status" field.
 func (u *AgentUpsertBulk) SetStatus(v int) *AgentUpsertBulk {
 	return u.Update(func(s *AgentUpsert) {
@@ -1325,6 +1616,97 @@ func (u *AgentUpsertBulk) UpdateCollectionID() *AgentUpsertBulk {
 	})
 }
 
+// SetModel sets the "model" field.
+func (u *AgentUpsertBulk) SetModel(v string) *AgentUpsertBulk {
+	return u.Update(func(s *AgentUpsert) {
+		s.SetModel(v)
+	})
+}
+
+// UpdateModel sets the "model" field to the value that was provided on create.
+func (u *AgentUpsertBulk) UpdateModel() *AgentUpsertBulk {
+	return u.Update(func(s *AgentUpsert) {
+		s.UpdateModel()
+	})
+}
+
+// ClearModel clears the value of the "model" field.
+func (u *AgentUpsertBulk) ClearModel() *AgentUpsertBulk {
+	return u.Update(func(s *AgentUpsert) {
+		s.ClearModel()
+	})
+}
+
+// SetAPIBase sets the "api_base" field.
+func (u *AgentUpsertBulk) SetAPIBase(v string) *AgentUpsertBulk {
+	return u.Update(func(s *AgentUpsert) {
+		s.SetAPIBase(v)
+	})
+}
+
+// UpdateAPIBase sets the "api_base" field to the value that was provided on create.
+func (u *AgentUpsertBulk) UpdateAPIBase() *AgentUpsertBulk {
+	return u.Update(func(s *AgentUpsert) {
+		s.UpdateAPIBase()
+	})
+}
+
+// ClearAPIBase clears the value of the "api_base" field.
+func (u *AgentUpsertBulk) ClearAPIBase() *AgentUpsertBulk {
+	return u.Update(func(s *AgentUpsert) {
+		s.ClearAPIBase()
+	})
+}
+
+// SetAPIKey sets the "api_key" field.
+func (u *AgentUpsertBulk) SetAPIKey(v string) *AgentUpsertBulk {
+	return u.Update(func(s *AgentUpsert) {
+		s.SetAPIKey(v)
+	})
+}
+
+// UpdateAPIKey sets the "api_key" field to the value that was provided on create.
+func (u *AgentUpsertBulk) UpdateAPIKey() *AgentUpsertBulk {
+	return u.Update(func(s *AgentUpsert) {
+		s.UpdateAPIKey()
+	})
+}
+
+// ClearAPIKey clears the value of the "api_key" field.
+func (u *AgentUpsertBulk) ClearAPIKey() *AgentUpsertBulk {
+	return u.Update(func(s *AgentUpsert) {
+		s.ClearAPIKey()
+	})
+}
+
+// SetType sets the "type" field.
+func (u *AgentUpsertBulk) SetType(v int) *AgentUpsertBulk {
+	return u.Update(func(s *AgentUpsert) {
+		s.SetType(v)
+	})
+}
+
+// AddType adds v to the "type" field.
+func (u *AgentUpsertBulk) AddType(v int) *AgentUpsertBulk {
+	return u.Update(func(s *AgentUpsert) {
+		s.AddType(v)
+	})
+}
+
+// UpdateType sets the "type" field to the value that was provided on create.
+func (u *AgentUpsertBulk) UpdateType() *AgentUpsertBulk {
+	return u.Update(func(s *AgentUpsert) {
+		s.UpdateType()
+	})
+}
+
+// ClearType clears the value of the "type" field.
+func (u *AgentUpsertBulk) ClearType() *AgentUpsertBulk {
+	return u.Update(func(s *AgentUpsert) {
+		s.ClearType()
+	})
+}
+
 // Exec executes the query.
 func (u *AgentUpsertBulk) Exec(ctx context.Context) error {
 	if u.create.err != nil {

+ 256 - 0
ent/agent_update.go

@@ -86,6 +86,12 @@ func (au *AgentUpdate) SetNillableRole(s *string) *AgentUpdate {
 	return au
 }
 
+// ClearRole clears the value of the "role" field.
+func (au *AgentUpdate) ClearRole() *AgentUpdate {
+	au.mutation.ClearRole()
+	return au
+}
+
 // SetStatus sets the "status" field.
 func (au *AgentUpdate) SetStatus(i int) *AgentUpdate {
 	au.mutation.ResetStatus()
@@ -202,6 +208,93 @@ func (au *AgentUpdate) SetNillableCollectionID(s *string) *AgentUpdate {
 	return au
 }
 
+// SetModel sets the "model" field.
+func (au *AgentUpdate) SetModel(s string) *AgentUpdate {
+	au.mutation.SetModel(s)
+	return au
+}
+
+// SetNillableModel sets the "model" field if the given value is not nil.
+func (au *AgentUpdate) SetNillableModel(s *string) *AgentUpdate {
+	if s != nil {
+		au.SetModel(*s)
+	}
+	return au
+}
+
+// ClearModel clears the value of the "model" field.
+func (au *AgentUpdate) ClearModel() *AgentUpdate {
+	au.mutation.ClearModel()
+	return au
+}
+
+// SetAPIBase sets the "api_base" field.
+func (au *AgentUpdate) SetAPIBase(s string) *AgentUpdate {
+	au.mutation.SetAPIBase(s)
+	return au
+}
+
+// SetNillableAPIBase sets the "api_base" field if the given value is not nil.
+func (au *AgentUpdate) SetNillableAPIBase(s *string) *AgentUpdate {
+	if s != nil {
+		au.SetAPIBase(*s)
+	}
+	return au
+}
+
+// ClearAPIBase clears the value of the "api_base" field.
+func (au *AgentUpdate) ClearAPIBase() *AgentUpdate {
+	au.mutation.ClearAPIBase()
+	return au
+}
+
+// SetAPIKey sets the "api_key" field.
+func (au *AgentUpdate) SetAPIKey(s string) *AgentUpdate {
+	au.mutation.SetAPIKey(s)
+	return au
+}
+
+// SetNillableAPIKey sets the "api_key" field if the given value is not nil.
+func (au *AgentUpdate) SetNillableAPIKey(s *string) *AgentUpdate {
+	if s != nil {
+		au.SetAPIKey(*s)
+	}
+	return au
+}
+
+// ClearAPIKey clears the value of the "api_key" field.
+func (au *AgentUpdate) ClearAPIKey() *AgentUpdate {
+	au.mutation.ClearAPIKey()
+	return au
+}
+
+// SetType sets the "type" field.
+func (au *AgentUpdate) SetType(i int) *AgentUpdate {
+	au.mutation.ResetType()
+	au.mutation.SetType(i)
+	return au
+}
+
+// SetNillableType sets the "type" field if the given value is not nil.
+func (au *AgentUpdate) SetNillableType(i *int) *AgentUpdate {
+	if i != nil {
+		au.SetType(*i)
+	}
+	return au
+}
+
+// AddType adds i to the "type" field.
+func (au *AgentUpdate) AddType(i int) *AgentUpdate {
+	au.mutation.AddType(i)
+	return au
+}
+
+// ClearType clears the value of the "type" field.
+func (au *AgentUpdate) ClearType() *AgentUpdate {
+	au.mutation.ClearType()
+	return au
+}
+
 // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by IDs.
 func (au *AgentUpdate) AddWxAgentIDs(ids ...uint64) *AgentUpdate {
 	au.mutation.AddWxAgentIDs(ids...)
@@ -420,6 +513,11 @@ func (au *AgentUpdate) check() error {
 			return &ValidationError{Name: "collection_id", err: fmt.Errorf(`ent: validator failed for field "Agent.collection_id": %w`, err)}
 		}
 	}
+	if v, ok := au.mutation.GetType(); ok {
+		if err := agent.TypeValidator(v); err != nil {
+			return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Agent.type": %w`, err)}
+		}
+	}
 	return nil
 }
 
@@ -450,6 +548,9 @@ func (au *AgentUpdate) sqlSave(ctx context.Context) (n int, err error) {
 	if value, ok := au.mutation.Role(); ok {
 		_spec.SetField(agent.FieldRole, field.TypeString, value)
 	}
+	if au.mutation.RoleCleared() {
+		_spec.ClearField(agent.FieldRole, field.TypeString)
+	}
 	if value, ok := au.mutation.Status(); ok {
 		_spec.SetField(agent.FieldStatus, field.TypeInt, value)
 	}
@@ -483,6 +584,33 @@ func (au *AgentUpdate) sqlSave(ctx context.Context) (n int, err error) {
 	if value, ok := au.mutation.CollectionID(); ok {
 		_spec.SetField(agent.FieldCollectionID, field.TypeString, value)
 	}
+	if value, ok := au.mutation.Model(); ok {
+		_spec.SetField(agent.FieldModel, field.TypeString, value)
+	}
+	if au.mutation.ModelCleared() {
+		_spec.ClearField(agent.FieldModel, field.TypeString)
+	}
+	if value, ok := au.mutation.APIBase(); ok {
+		_spec.SetField(agent.FieldAPIBase, field.TypeString, value)
+	}
+	if au.mutation.APIBaseCleared() {
+		_spec.ClearField(agent.FieldAPIBase, field.TypeString)
+	}
+	if value, ok := au.mutation.APIKey(); ok {
+		_spec.SetField(agent.FieldAPIKey, field.TypeString, value)
+	}
+	if au.mutation.APIKeyCleared() {
+		_spec.ClearField(agent.FieldAPIKey, field.TypeString)
+	}
+	if value, ok := au.mutation.GetType(); ok {
+		_spec.SetField(agent.FieldType, field.TypeInt, value)
+	}
+	if value, ok := au.mutation.AddedType(); ok {
+		_spec.AddField(agent.FieldType, field.TypeInt, value)
+	}
+	if au.mutation.TypeCleared() {
+		_spec.ClearField(agent.FieldType, field.TypeInt)
+	}
 	if au.mutation.WxAgentCleared() {
 		edge := &sqlgraph.EdgeSpec{
 			Rel:     sqlgraph.O2M,
@@ -737,6 +865,12 @@ func (auo *AgentUpdateOne) SetNillableRole(s *string) *AgentUpdateOne {
 	return auo
 }
 
+// ClearRole clears the value of the "role" field.
+func (auo *AgentUpdateOne) ClearRole() *AgentUpdateOne {
+	auo.mutation.ClearRole()
+	return auo
+}
+
 // SetStatus sets the "status" field.
 func (auo *AgentUpdateOne) SetStatus(i int) *AgentUpdateOne {
 	auo.mutation.ResetStatus()
@@ -853,6 +987,93 @@ func (auo *AgentUpdateOne) SetNillableCollectionID(s *string) *AgentUpdateOne {
 	return auo
 }
 
+// SetModel sets the "model" field.
+func (auo *AgentUpdateOne) SetModel(s string) *AgentUpdateOne {
+	auo.mutation.SetModel(s)
+	return auo
+}
+
+// SetNillableModel sets the "model" field if the given value is not nil.
+func (auo *AgentUpdateOne) SetNillableModel(s *string) *AgentUpdateOne {
+	if s != nil {
+		auo.SetModel(*s)
+	}
+	return auo
+}
+
+// ClearModel clears the value of the "model" field.
+func (auo *AgentUpdateOne) ClearModel() *AgentUpdateOne {
+	auo.mutation.ClearModel()
+	return auo
+}
+
+// SetAPIBase sets the "api_base" field.
+func (auo *AgentUpdateOne) SetAPIBase(s string) *AgentUpdateOne {
+	auo.mutation.SetAPIBase(s)
+	return auo
+}
+
+// SetNillableAPIBase sets the "api_base" field if the given value is not nil.
+func (auo *AgentUpdateOne) SetNillableAPIBase(s *string) *AgentUpdateOne {
+	if s != nil {
+		auo.SetAPIBase(*s)
+	}
+	return auo
+}
+
+// ClearAPIBase clears the value of the "api_base" field.
+func (auo *AgentUpdateOne) ClearAPIBase() *AgentUpdateOne {
+	auo.mutation.ClearAPIBase()
+	return auo
+}
+
+// SetAPIKey sets the "api_key" field.
+func (auo *AgentUpdateOne) SetAPIKey(s string) *AgentUpdateOne {
+	auo.mutation.SetAPIKey(s)
+	return auo
+}
+
+// SetNillableAPIKey sets the "api_key" field if the given value is not nil.
+func (auo *AgentUpdateOne) SetNillableAPIKey(s *string) *AgentUpdateOne {
+	if s != nil {
+		auo.SetAPIKey(*s)
+	}
+	return auo
+}
+
+// ClearAPIKey clears the value of the "api_key" field.
+func (auo *AgentUpdateOne) ClearAPIKey() *AgentUpdateOne {
+	auo.mutation.ClearAPIKey()
+	return auo
+}
+
+// SetType sets the "type" field.
+func (auo *AgentUpdateOne) SetType(i int) *AgentUpdateOne {
+	auo.mutation.ResetType()
+	auo.mutation.SetType(i)
+	return auo
+}
+
+// SetNillableType sets the "type" field if the given value is not nil.
+func (auo *AgentUpdateOne) SetNillableType(i *int) *AgentUpdateOne {
+	if i != nil {
+		auo.SetType(*i)
+	}
+	return auo
+}
+
+// AddType adds i to the "type" field.
+func (auo *AgentUpdateOne) AddType(i int) *AgentUpdateOne {
+	auo.mutation.AddType(i)
+	return auo
+}
+
+// ClearType clears the value of the "type" field.
+func (auo *AgentUpdateOne) ClearType() *AgentUpdateOne {
+	auo.mutation.ClearType()
+	return auo
+}
+
 // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by IDs.
 func (auo *AgentUpdateOne) AddWxAgentIDs(ids ...uint64) *AgentUpdateOne {
 	auo.mutation.AddWxAgentIDs(ids...)
@@ -1084,6 +1305,11 @@ func (auo *AgentUpdateOne) check() error {
 			return &ValidationError{Name: "collection_id", err: fmt.Errorf(`ent: validator failed for field "Agent.collection_id": %w`, err)}
 		}
 	}
+	if v, ok := auo.mutation.GetType(); ok {
+		if err := agent.TypeValidator(v); err != nil {
+			return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Agent.type": %w`, err)}
+		}
+	}
 	return nil
 }
 
@@ -1131,6 +1357,9 @@ func (auo *AgentUpdateOne) sqlSave(ctx context.Context) (_node *Agent, err error
 	if value, ok := auo.mutation.Role(); ok {
 		_spec.SetField(agent.FieldRole, field.TypeString, value)
 	}
+	if auo.mutation.RoleCleared() {
+		_spec.ClearField(agent.FieldRole, field.TypeString)
+	}
 	if value, ok := auo.mutation.Status(); ok {
 		_spec.SetField(agent.FieldStatus, field.TypeInt, value)
 	}
@@ -1164,6 +1393,33 @@ func (auo *AgentUpdateOne) sqlSave(ctx context.Context) (_node *Agent, err error
 	if value, ok := auo.mutation.CollectionID(); ok {
 		_spec.SetField(agent.FieldCollectionID, field.TypeString, value)
 	}
+	if value, ok := auo.mutation.Model(); ok {
+		_spec.SetField(agent.FieldModel, field.TypeString, value)
+	}
+	if auo.mutation.ModelCleared() {
+		_spec.ClearField(agent.FieldModel, field.TypeString)
+	}
+	if value, ok := auo.mutation.APIBase(); ok {
+		_spec.SetField(agent.FieldAPIBase, field.TypeString, value)
+	}
+	if auo.mutation.APIBaseCleared() {
+		_spec.ClearField(agent.FieldAPIBase, field.TypeString)
+	}
+	if value, ok := auo.mutation.APIKey(); ok {
+		_spec.SetField(agent.FieldAPIKey, field.TypeString, value)
+	}
+	if auo.mutation.APIKeyCleared() {
+		_spec.ClearField(agent.FieldAPIKey, field.TypeString)
+	}
+	if value, ok := auo.mutation.GetType(); ok {
+		_spec.SetField(agent.FieldType, field.TypeInt, value)
+	}
+	if value, ok := auo.mutation.AddedType(); ok {
+		_spec.AddField(agent.FieldType, field.TypeInt, value)
+	}
+	if auo.mutation.TypeCleared() {
+		_spec.ClearField(agent.FieldType, field.TypeInt)
+	}
 	if auo.mutation.WxAgentCleared() {
 		edge := &sqlgraph.EdgeSpec{
 			Rel:     sqlgraph.O2M,

+ 5 - 1
ent/migrate/schema.go

@@ -16,13 +16,17 @@ var (
 		{Name: "updated_at", Type: field.TypeTime, Comment: "Update Time | 修改日期"},
 		{Name: "deleted_at", Type: field.TypeTime, Nullable: true, Comment: "Delete Time | 删除日期"},
 		{Name: "name", Type: field.TypeString, Size: 255, Comment: "name | 角色名称"},
-		{Name: "role", Type: field.TypeString, Comment: "role | 角色设定"},
+		{Name: "role", Type: field.TypeString, Nullable: true, Comment: "role | 角色设定", Default: ""},
 		{Name: "status", Type: field.TypeInt, Nullable: true, Comment: "status | 状态 1-正常 2-禁用", Default: 1},
 		{Name: "background", Type: field.TypeString, Nullable: true, Comment: "background | 背景介绍", Default: ""},
 		{Name: "examples", Type: field.TypeString, Nullable: true, Comment: "examples | 对话案例", Default: ""},
 		{Name: "organization_id", Type: field.TypeUint64, Comment: "organization_id | 租户ID"},
 		{Name: "dataset_id", Type: field.TypeString, Size: 255, Comment: "dataset_id | 知识库ID", Default: ""},
 		{Name: "collection_id", Type: field.TypeString, Size: 255, Comment: "collection_id | 集合ID", Default: ""},
+		{Name: "model", Type: field.TypeString, Nullable: true, Comment: "model | 模型", Default: ""},
+		{Name: "api_base", Type: field.TypeString, Nullable: true, Comment: "api_base | api_base", Default: ""},
+		{Name: "api_key", Type: field.TypeString, Nullable: true, Comment: "api_key | api_key", Default: ""},
+		{Name: "type", Type: field.TypeInt, Nullable: true, Comment: "type | 类型 1. 内置 2. 接入", Default: 1},
 	}
 	// AgentTable holds the schema information for the "agent" table.
 	AgentTable = &schema.Table{

+ 346 - 1
ent/mutation.go

@@ -127,6 +127,11 @@ type AgentMutation struct {
 	addorganization_id *int64
 	dataset_id         *string
 	collection_id      *string
+	model              *string
+	api_base           *string
+	api_key            *string
+	_type              *int
+	add_type           *int
 	clearedFields      map[string]struct{}
 	wx_agent           map[uint64]struct{}
 	removedwx_agent    map[uint64]struct{}
@@ -437,9 +442,22 @@ func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
 	return oldValue.Role, nil
 }
 
+// ClearRole clears the value of the "role" field.
+func (m *AgentMutation) ClearRole() {
+	m.role = nil
+	m.clearedFields[agent.FieldRole] = struct{}{}
+}
+
+// RoleCleared returns if the "role" field was cleared in this mutation.
+func (m *AgentMutation) RoleCleared() bool {
+	_, ok := m.clearedFields[agent.FieldRole]
+	return ok
+}
+
 // ResetRole resets all changes to the "role" field.
 func (m *AgentMutation) ResetRole() {
 	m.role = nil
+	delete(m.clearedFields, agent.FieldRole)
 }
 
 // SetStatus sets the "status" field.
@@ -738,6 +756,223 @@ func (m *AgentMutation) ResetCollectionID() {
 	m.collection_id = nil
 }
 
+// SetModel sets the "model" field.
+func (m *AgentMutation) SetModel(s string) {
+	m.model = &s
+}
+
+// Model returns the value of the "model" field in the mutation.
+func (m *AgentMutation) Model() (r string, exists bool) {
+	v := m.model
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldModel returns the old "model" field's value of the Agent entity.
+// If the Agent object wasn't provided to the builder, the object is fetched from the database.
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
+func (m *AgentMutation) OldModel(ctx context.Context) (v string, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldModel is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldModel requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldModel: %w", err)
+	}
+	return oldValue.Model, nil
+}
+
+// ClearModel clears the value of the "model" field.
+func (m *AgentMutation) ClearModel() {
+	m.model = nil
+	m.clearedFields[agent.FieldModel] = struct{}{}
+}
+
+// ModelCleared returns if the "model" field was cleared in this mutation.
+func (m *AgentMutation) ModelCleared() bool {
+	_, ok := m.clearedFields[agent.FieldModel]
+	return ok
+}
+
+// ResetModel resets all changes to the "model" field.
+func (m *AgentMutation) ResetModel() {
+	m.model = nil
+	delete(m.clearedFields, agent.FieldModel)
+}
+
+// SetAPIBase sets the "api_base" field.
+func (m *AgentMutation) SetAPIBase(s string) {
+	m.api_base = &s
+}
+
+// APIBase returns the value of the "api_base" field in the mutation.
+func (m *AgentMutation) APIBase() (r string, exists bool) {
+	v := m.api_base
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldAPIBase returns the old "api_base" field's value of the Agent entity.
+// If the Agent object wasn't provided to the builder, the object is fetched from the database.
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
+func (m *AgentMutation) OldAPIBase(ctx context.Context) (v string, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldAPIBase requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
+	}
+	return oldValue.APIBase, nil
+}
+
+// ClearAPIBase clears the value of the "api_base" field.
+func (m *AgentMutation) ClearAPIBase() {
+	m.api_base = nil
+	m.clearedFields[agent.FieldAPIBase] = struct{}{}
+}
+
+// APIBaseCleared returns if the "api_base" field was cleared in this mutation.
+func (m *AgentMutation) APIBaseCleared() bool {
+	_, ok := m.clearedFields[agent.FieldAPIBase]
+	return ok
+}
+
+// ResetAPIBase resets all changes to the "api_base" field.
+func (m *AgentMutation) ResetAPIBase() {
+	m.api_base = nil
+	delete(m.clearedFields, agent.FieldAPIBase)
+}
+
+// SetAPIKey sets the "api_key" field.
+func (m *AgentMutation) SetAPIKey(s string) {
+	m.api_key = &s
+}
+
+// APIKey returns the value of the "api_key" field in the mutation.
+func (m *AgentMutation) APIKey() (r string, exists bool) {
+	v := m.api_key
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldAPIKey returns the old "api_key" field's value of the Agent entity.
+// If the Agent object wasn't provided to the builder, the object is fetched from the database.
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
+func (m *AgentMutation) OldAPIKey(ctx context.Context) (v string, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldAPIKey requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
+	}
+	return oldValue.APIKey, nil
+}
+
+// ClearAPIKey clears the value of the "api_key" field.
+func (m *AgentMutation) ClearAPIKey() {
+	m.api_key = nil
+	m.clearedFields[agent.FieldAPIKey] = struct{}{}
+}
+
+// APIKeyCleared returns if the "api_key" field was cleared in this mutation.
+func (m *AgentMutation) APIKeyCleared() bool {
+	_, ok := m.clearedFields[agent.FieldAPIKey]
+	return ok
+}
+
+// ResetAPIKey resets all changes to the "api_key" field.
+func (m *AgentMutation) ResetAPIKey() {
+	m.api_key = nil
+	delete(m.clearedFields, agent.FieldAPIKey)
+}
+
+// SetType sets the "type" field.
+func (m *AgentMutation) SetType(i int) {
+	m._type = &i
+	m.add_type = nil
+}
+
+// GetType returns the value of the "type" field in the mutation.
+func (m *AgentMutation) GetType() (r int, exists bool) {
+	v := m._type
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldType returns the old "type" field's value of the Agent entity.
+// If the Agent object wasn't provided to the builder, the object is fetched from the database.
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
+func (m *AgentMutation) OldType(ctx context.Context) (v int, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldType is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldType requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldType: %w", err)
+	}
+	return oldValue.Type, nil
+}
+
+// AddType adds i to the "type" field.
+func (m *AgentMutation) AddType(i int) {
+	if m.add_type != nil {
+		*m.add_type += i
+	} else {
+		m.add_type = &i
+	}
+}
+
+// AddedType returns the value that was added to the "type" field in this mutation.
+func (m *AgentMutation) AddedType() (r int, exists bool) {
+	v := m.add_type
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// ClearType clears the value of the "type" field.
+func (m *AgentMutation) ClearType() {
+	m._type = nil
+	m.add_type = nil
+	m.clearedFields[agent.FieldType] = struct{}{}
+}
+
+// TypeCleared returns if the "type" field was cleared in this mutation.
+func (m *AgentMutation) TypeCleared() bool {
+	_, ok := m.clearedFields[agent.FieldType]
+	return ok
+}
+
+// ResetType resets all changes to the "type" field.
+func (m *AgentMutation) ResetType() {
+	m._type = nil
+	m.add_type = nil
+	delete(m.clearedFields, agent.FieldType)
+}
+
 // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
 func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
 	if m.wx_agent == nil {
@@ -988,7 +1223,7 @@ func (m *AgentMutation) Type() string {
 // order to get all numeric fields that were incremented/decremented, call
 // AddedFields().
 func (m *AgentMutation) Fields() []string {
-	fields := make([]string, 0, 11)
+	fields := make([]string, 0, 15)
 	if m.created_at != nil {
 		fields = append(fields, agent.FieldCreatedAt)
 	}
@@ -1022,6 +1257,18 @@ func (m *AgentMutation) Fields() []string {
 	if m.collection_id != nil {
 		fields = append(fields, agent.FieldCollectionID)
 	}
+	if m.model != nil {
+		fields = append(fields, agent.FieldModel)
+	}
+	if m.api_base != nil {
+		fields = append(fields, agent.FieldAPIBase)
+	}
+	if m.api_key != nil {
+		fields = append(fields, agent.FieldAPIKey)
+	}
+	if m._type != nil {
+		fields = append(fields, agent.FieldType)
+	}
 	return fields
 }
 
@@ -1052,6 +1299,14 @@ func (m *AgentMutation) Field(name string) (ent.Value, bool) {
 		return m.DatasetID()
 	case agent.FieldCollectionID:
 		return m.CollectionID()
+	case agent.FieldModel:
+		return m.Model()
+	case agent.FieldAPIBase:
+		return m.APIBase()
+	case agent.FieldAPIKey:
+		return m.APIKey()
+	case agent.FieldType:
+		return m.GetType()
 	}
 	return nil, false
 }
@@ -1083,6 +1338,14 @@ func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, e
 		return m.OldDatasetID(ctx)
 	case agent.FieldCollectionID:
 		return m.OldCollectionID(ctx)
+	case agent.FieldModel:
+		return m.OldModel(ctx)
+	case agent.FieldAPIBase:
+		return m.OldAPIBase(ctx)
+	case agent.FieldAPIKey:
+		return m.OldAPIKey(ctx)
+	case agent.FieldType:
+		return m.OldType(ctx)
 	}
 	return nil, fmt.Errorf("unknown Agent field %s", name)
 }
@@ -1169,6 +1432,34 @@ func (m *AgentMutation) SetField(name string, value ent.Value) error {
 		}
 		m.SetCollectionID(v)
 		return nil
+	case agent.FieldModel:
+		v, ok := value.(string)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetModel(v)
+		return nil
+	case agent.FieldAPIBase:
+		v, ok := value.(string)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetAPIBase(v)
+		return nil
+	case agent.FieldAPIKey:
+		v, ok := value.(string)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetAPIKey(v)
+		return nil
+	case agent.FieldType:
+		v, ok := value.(int)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetType(v)
+		return nil
 	}
 	return fmt.Errorf("unknown Agent field %s", name)
 }
@@ -1183,6 +1474,9 @@ func (m *AgentMutation) AddedFields() []string {
 	if m.addorganization_id != nil {
 		fields = append(fields, agent.FieldOrganizationID)
 	}
+	if m.add_type != nil {
+		fields = append(fields, agent.FieldType)
+	}
 	return fields
 }
 
@@ -1195,6 +1489,8 @@ func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
 		return m.AddedStatus()
 	case agent.FieldOrganizationID:
 		return m.AddedOrganizationID()
+	case agent.FieldType:
+		return m.AddedType()
 	}
 	return nil, false
 }
@@ -1218,6 +1514,13 @@ func (m *AgentMutation) AddField(name string, value ent.Value) error {
 		}
 		m.AddOrganizationID(v)
 		return nil
+	case agent.FieldType:
+		v, ok := value.(int)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.AddType(v)
+		return nil
 	}
 	return fmt.Errorf("unknown Agent numeric field %s", name)
 }
@@ -1229,6 +1532,9 @@ func (m *AgentMutation) ClearedFields() []string {
 	if m.FieldCleared(agent.FieldDeletedAt) {
 		fields = append(fields, agent.FieldDeletedAt)
 	}
+	if m.FieldCleared(agent.FieldRole) {
+		fields = append(fields, agent.FieldRole)
+	}
 	if m.FieldCleared(agent.FieldStatus) {
 		fields = append(fields, agent.FieldStatus)
 	}
@@ -1238,6 +1544,18 @@ func (m *AgentMutation) ClearedFields() []string {
 	if m.FieldCleared(agent.FieldExamples) {
 		fields = append(fields, agent.FieldExamples)
 	}
+	if m.FieldCleared(agent.FieldModel) {
+		fields = append(fields, agent.FieldModel)
+	}
+	if m.FieldCleared(agent.FieldAPIBase) {
+		fields = append(fields, agent.FieldAPIBase)
+	}
+	if m.FieldCleared(agent.FieldAPIKey) {
+		fields = append(fields, agent.FieldAPIKey)
+	}
+	if m.FieldCleared(agent.FieldType) {
+		fields = append(fields, agent.FieldType)
+	}
 	return fields
 }
 
@@ -1255,6 +1573,9 @@ func (m *AgentMutation) ClearField(name string) error {
 	case agent.FieldDeletedAt:
 		m.ClearDeletedAt()
 		return nil
+	case agent.FieldRole:
+		m.ClearRole()
+		return nil
 	case agent.FieldStatus:
 		m.ClearStatus()
 		return nil
@@ -1264,6 +1585,18 @@ func (m *AgentMutation) ClearField(name string) error {
 	case agent.FieldExamples:
 		m.ClearExamples()
 		return nil
+	case agent.FieldModel:
+		m.ClearModel()
+		return nil
+	case agent.FieldAPIBase:
+		m.ClearAPIBase()
+		return nil
+	case agent.FieldAPIKey:
+		m.ClearAPIKey()
+		return nil
+	case agent.FieldType:
+		m.ClearType()
+		return nil
 	}
 	return fmt.Errorf("unknown Agent nullable field %s", name)
 }
@@ -1305,6 +1638,18 @@ func (m *AgentMutation) ResetField(name string) error {
 	case agent.FieldCollectionID:
 		m.ResetCollectionID()
 		return nil
+	case agent.FieldModel:
+		m.ResetModel()
+		return nil
+	case agent.FieldAPIBase:
+		m.ResetAPIBase()
+		return nil
+	case agent.FieldAPIKey:
+		m.ResetAPIKey()
+		return nil
+	case agent.FieldType:
+		m.ResetType()
+		return nil
 	}
 	return fmt.Errorf("unknown Agent field %s", name)
 }

+ 22 - 0
ent/runtime/runtime.go

@@ -75,6 +75,10 @@ func init() {
 	agentDescName := agentFields[0].Descriptor()
 	// agent.NameValidator is a validator for the "name" field. It is called by the builders before save.
 	agent.NameValidator = agentDescName.Validators[0].(func(string) error)
+	// agentDescRole is the schema descriptor for role field.
+	agentDescRole := agentFields[1].Descriptor()
+	// agent.DefaultRole holds the default value on creation for the role field.
+	agent.DefaultRole = agentDescRole.Default.(string)
 	// agentDescStatus is the schema descriptor for status field.
 	agentDescStatus := agentFields[2].Descriptor()
 	// agent.DefaultStatus holds the default value on creation for the status field.
@@ -105,6 +109,24 @@ func init() {
 	agent.DefaultCollectionID = agentDescCollectionID.Default.(string)
 	// agent.CollectionIDValidator is a validator for the "collection_id" field. It is called by the builders before save.
 	agent.CollectionIDValidator = agentDescCollectionID.Validators[0].(func(string) error)
+	// agentDescModel is the schema descriptor for model field.
+	agentDescModel := agentFields[8].Descriptor()
+	// agent.DefaultModel holds the default value on creation for the model field.
+	agent.DefaultModel = agentDescModel.Default.(string)
+	// agentDescAPIBase is the schema descriptor for api_base field.
+	agentDescAPIBase := agentFields[9].Descriptor()
+	// agent.DefaultAPIBase holds the default value on creation for the api_base field.
+	agent.DefaultAPIBase = agentDescAPIBase.Default.(string)
+	// agentDescAPIKey is the schema descriptor for api_key field.
+	agentDescAPIKey := agentFields[10].Descriptor()
+	// agent.DefaultAPIKey holds the default value on creation for the api_key field.
+	agent.DefaultAPIKey = agentDescAPIKey.Default.(string)
+	// agentDescType is the schema descriptor for type field.
+	agentDescType := agentFields[11].Descriptor()
+	// agent.DefaultType holds the default value on creation for the type field.
+	agent.DefaultType = agentDescType.Default.(int)
+	// agent.TypeValidator is a validator for the "type" field. It is called by the builders before save.
+	agent.TypeValidator = agentDescType.Validators[0].(func(int) error)
 	agentbaseFields := schema.AgentBase{}.Fields()
 	_ = agentbaseFields
 	// agentbaseDescQ is the schema descriptor for q field.

+ 5 - 1
ent/schema/agent.go

@@ -19,13 +19,17 @@ type Agent struct {
 func (Agent) Fields() []ent.Field {
 	return []ent.Field{
 		field.String("name").MaxLen(255).Comment("name | 角色名称"),
-		field.String("role").Comment("role | 角色设定"),
+		field.String("role").Optional().Default("").Comment("role | 角色设定"),
 		field.Int("status").Optional().Range(1, 2).Default(1).Comment("status | 状态 1-正常 2-禁用"),
 		field.String("background").Optional().Default("").Comment("background | 背景介绍"),
 		field.String("examples").Optional().Default("").Comment("examples | 对话案例"),
 		field.Uint64("organization_id").Positive().Comment("organization_id | 租户ID"),
 		field.String("dataset_id").Default("").MaxLen(255).Comment("dataset_id | 知识库ID"),
 		field.String("collection_id").Default("").MaxLen(255).Comment("collection_id | 集合ID"),
+		field.String("model").Optional().Default("").Comment("model | 模型"),
+		field.String("api_base").Optional().Default("").Comment("api_base | api_base"),
+		field.String("api_key").Optional().Default("").Comment("api_key | api_key"),
+		field.Int("type").Optional().Range(1, 2).Default(1).Comment("type | 类型 1. 内置 2. 接入"),
 	}
 }
 

+ 96 - 0
ent/set_not_nil.go

@@ -248,6 +248,102 @@ func (a *AgentCreate) SetNotNilCollectionID(value *string) *AgentCreate {
 }
 
 // set field if value's pointer is not nil.
+func (a *AgentUpdate) SetNotNilModel(value *string) *AgentUpdate {
+	if value != nil {
+		return a.SetModel(*value)
+	}
+	return a
+}
+
+// set field if value's pointer is not nil.
+func (a *AgentUpdateOne) SetNotNilModel(value *string) *AgentUpdateOne {
+	if value != nil {
+		return a.SetModel(*value)
+	}
+	return a
+}
+
+// set field if value's pointer is not nil.
+func (a *AgentCreate) SetNotNilModel(value *string) *AgentCreate {
+	if value != nil {
+		return a.SetModel(*value)
+	}
+	return a
+}
+
+// set field if value's pointer is not nil.
+func (a *AgentUpdate) SetNotNilAPIBase(value *string) *AgentUpdate {
+	if value != nil {
+		return a.SetAPIBase(*value)
+	}
+	return a
+}
+
+// set field if value's pointer is not nil.
+func (a *AgentUpdateOne) SetNotNilAPIBase(value *string) *AgentUpdateOne {
+	if value != nil {
+		return a.SetAPIBase(*value)
+	}
+	return a
+}
+
+// set field if value's pointer is not nil.
+func (a *AgentCreate) SetNotNilAPIBase(value *string) *AgentCreate {
+	if value != nil {
+		return a.SetAPIBase(*value)
+	}
+	return a
+}
+
+// set field if value's pointer is not nil.
+func (a *AgentUpdate) SetNotNilAPIKey(value *string) *AgentUpdate {
+	if value != nil {
+		return a.SetAPIKey(*value)
+	}
+	return a
+}
+
+// set field if value's pointer is not nil.
+func (a *AgentUpdateOne) SetNotNilAPIKey(value *string) *AgentUpdateOne {
+	if value != nil {
+		return a.SetAPIKey(*value)
+	}
+	return a
+}
+
+// set field if value's pointer is not nil.
+func (a *AgentCreate) SetNotNilAPIKey(value *string) *AgentCreate {
+	if value != nil {
+		return a.SetAPIKey(*value)
+	}
+	return a
+}
+
+// set field if value's pointer is not nil.
+func (a *AgentUpdate) SetNotNilType(value *int) *AgentUpdate {
+	if value != nil {
+		return a.SetType(*value)
+	}
+	return a
+}
+
+// set field if value's pointer is not nil.
+func (a *AgentUpdateOne) SetNotNilType(value *int) *AgentUpdateOne {
+	if value != nil {
+		return a.SetType(*value)
+	}
+	return a
+}
+
+// set field if value's pointer is not nil.
+func (a *AgentCreate) SetNotNilType(value *int) *AgentCreate {
+	if value != nil {
+		return a.SetType(*value)
+	}
+	return a
+}
+
+// set field if value's pointer is not nil.
 func (ab *AgentBaseUpdate) SetNotNilQ(value *string) *AgentBaseUpdate {
 	if value != nil {
 		return ab.SetQ(*value)

+ 4 - 0
go.sum

@@ -472,6 +472,7 @@ github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Ky
 github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
 github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
 github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
+github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
 github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
 github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
 github.com/mattn/go-sqlite3 v1.14.8/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
@@ -510,6 +511,7 @@ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLA
 github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78=
 github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
 github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
+github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
 github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
 github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
 github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
@@ -611,6 +613,8 @@ github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkU
 github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0=
 github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
 github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo=
+github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=
+github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=
 github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
 github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
 github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=

+ 4 - 0
internal/logic/agent/create_agent_logic.go

@@ -38,6 +38,10 @@ func (l *CreateAgentLogic) CreateAgent(req *types.AgentInfo) (*types.BaseMsgResp
 		SetOrganizationID(organizationId).
 		SetNotNilBackground(req.Background).
 		SetNotNilExamples(req.Examples).
+		SetNotNilModel(req.Model).
+		SetNotNilAPIKey(req.ApiKey).
+		SetNotNilAPIBase(req.ApiBase).
+		SetNotNilType(req.Type).
 		Save(l.ctx)
 
 	if err != nil {

+ 7 - 1
internal/logic/agent/delete_agent_logic.go

@@ -3,6 +3,7 @@ package agent
 import (
 	"context"
 	"errors"
+	"wechat-api/ent/apikey"
 	"wechat-api/ent/wx"
 
 	"wechat-api/ent/agent"
@@ -40,11 +41,16 @@ func (l *DeleteAgentLogic) DeleteAgent(req *types.IDsReq) (*types.BaseMsgResp, e
 		return nil, errors.New("有账号在使用该AI角色,请取消关联后再尝试删除")
 	}
 
+	apikey_count, _ := l.svcCtx.DB.ApiKey.Query().Where(apikey.AgentIDIn(req.Ids...)).Count(l.ctx)
+	if apikey_count > 0 {
+		return nil, errors.New("有账号在使用该AI角色,请取消关联后再尝试删除")
+	}
+
 	_, err := l.svcCtx.DB.Agent.Delete().Where(agent.IDIn(req.Ids...), agent.OrganizationID(organizationId)).Exec(l.ctx)
 
 	if err != nil {
 		return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
 	}
-
+	l.svcCtx.Rds.Del(l.ctx, "COMPAPI_AUTHINFO")
 	return &types.BaseMsgResp{Msg: errormsg.DeleteSuccess}, nil
 }

+ 4 - 0
internal/logic/agent/get_agent_by_id_logic.go

@@ -53,6 +53,10 @@ func (l *GetAgentByIdLogic) GetAgentById(req *types.IDReq) (*types.AgentInfoResp
 			Examples:     &data.Examples,
 			DatasetId:    &data.DatasetID,
 			CollectionId: &data.CollectionID,
+			Model:        &data.Model,
+			ApiBase:      &data.APIBase,
+			ApiKey:       &data.APIKey,
+			Type:         &data.Type,
 		},
 	}, nil
 }

+ 4 - 0
internal/logic/agent/get_agent_list_logic.go

@@ -79,6 +79,10 @@ func (l *GetAgentListLogic) GetAgentList(req *types.AgentListReq) (*types.AgentL
 				Examples:     &v.Examples,
 				DatasetId:    &v.DatasetID,
 				CollectionId: &v.CollectionID,
+				Model:        &v.Model,
+				ApiBase:      &v.APIBase,
+				ApiKey:       &v.APIKey,
+				Type:         &v.Type,
 			})
 	}
 

+ 4 - 1
internal/logic/agent/update_agent_logic.go

@@ -56,11 +56,14 @@ func (l *UpdateAgentLogic) UpdateAgent(req *types.AgentInfo) (*types.BaseMsgResp
 		SetNotNilStatus(req.Status).
 		SetNotNilBackground(req.Background).
 		SetNotNilExamples(req.Examples).
+		SetNotNilModel(req.Model).
+		SetNotNilAPIKey(req.ApiKey).
+		SetNotNilAPIBase(req.ApiBase).
 		Exec(l.ctx)
 
 	if err != nil {
 		return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
 	}
-
+	l.svcCtx.Rds.Del(l.ctx, "COMPAPI_AUTHINFO")
 	return &types.BaseMsgResp{Msg: errormsg.UpdateSuccess}, nil
 }

+ 1 - 1
internal/logic/api_key/delete_api_key_logic.go

@@ -31,6 +31,6 @@ func (l *DeleteApiKeyLogic) DeleteApiKey(req *types.IDsReq) (resp *types.BaseMsg
 	if err != nil {
 		return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
 	}
-	l.svcCtx.Rds.Del(l.ctx, "api_key")
+	l.svcCtx.Rds.Del(l.ctx, "COMPAPI_AUTHINFO")
 	return &types.BaseMsgResp{Msg: errormsg.DeleteSuccess}, nil
 }

+ 1 - 1
internal/logic/api_key/update_api_key_logic.go

@@ -37,6 +37,6 @@ func (l *UpdateApiKeyLogic) UpdateApiKey(req *types.ApiKeyInfo) (resp *types.Bas
 	if err != nil {
 		return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
 	}
-	l.svcCtx.Rds.Del(l.ctx, "api_key")
+	l.svcCtx.Rds.Del(l.ctx, "COMPAPI_AUTHINFO")
 	return &types.BaseMsgResp{Msg: errormsg.UpdateSuccess}, nil
 }

+ 16 - 0
internal/types/types.go

@@ -472,6 +472,14 @@ type AgentInfo struct {
 	Examples     *string `json:"examples,optional"`
 	DatasetId    *string `json:"dataset_id,optional"`
 	CollectionId *string `json:"collection_id,optional"`
+	// model | model
+	Model *string `json:"model,optional"`
+	// api_base | api_base
+	ApiBase *string `json:"api_base,optional"`
+	// api_key | api_key
+	ApiKey *string `json:"api_key,optional"`
+	// type | 类型 1. 内置 2. 接入
+	Type *int `json:"type,optional"`
 }
 
 // The response data of agent list | Agent列表数据
@@ -504,6 +512,14 @@ type AgentListReq struct {
 	Status *int `json:"status,optional"`
 	// 租户id
 	OrganizationId *uint64 `json:"organizationId,optional"`
+	// model | model
+	Model *string `json:"model,optional"`
+	// api_base | api_base
+	ApiBase *string `json:"api_base,optional"`
+	// api_key | api_key
+	ApiKey *string `json:"api_key,optional"`
+	// type | 类型 1. 内置 2. 接入
+	Type *int `json:"type,optional"`
 }
 
 // Agent information response | Agent信息返回体