Просмотр исходного кода

升级本地版token验证接口

宋伯文 4 месяцев назад
Родитель
Сommit
9ac2c2ffd1

+ 0 - 2
crontask/send_wx_on_timeout.go

@@ -50,8 +50,6 @@ func (l *CronTask) sendWxOnTimeout() {
 		// 查询 node 对应的 stage 记录
 		lowerBound := startTime.Add(-time.Minute * time.Duration(node.NoReplyCondition*coef+2))
 		upperBound := startTime.Add(-time.Minute * time.Duration(node.NoReplyCondition*coef))
-		l.Logger.Errorf("------------------------lowerBound--------------------------- %+v", lowerBound)
-		l.Logger.Errorf("------------------------now--------------------------- %+v", time.Now())
 		if node.ParentID == 0 {
 			messages, _ = l.svcCtx.DB.MessageRecords.Query().
 				Where(messagerecords.StatusEQ(3)).

+ 15 - 0
desc/wechat/token.api

@@ -1,4 +1,5 @@
 import "../base.api"
+import "./agent.api"
 
 type (
     // The data of token information | Token信息
@@ -71,6 +72,20 @@ type (
 
 		// Timestamp 时间戳
 		Timestamp  *int64 `json:"timestamp"`
+
+		AgentInfo *AgentInfo `json:"agent_info"`
+
+		CustomAgentBase *string `json:"custom_agent_base"`
+
+		CustomAgentKey *string `json:"custom_agent_key"`
+
+		OpenaiBase *string `json:"openai_base"`
+
+		OpenaiKey *string `json:"openai_key"`
+
+		DatasetBase *string `json:"dataset_base"`
+
+        DatasetKey *string `json:"dataset_key"`
 	}
 )
 

+ 5 - 0
ent/migrate/schema.go

@@ -640,6 +640,11 @@ var (
 		{Name: "token", Type: field.TypeString, Nullable: true, Comment: "Token", Default: ""},
 		{Name: "mac", Type: field.TypeString, Comment: "Mac地址", Default: ""},
 		{Name: "organization_id", Type: field.TypeUint64, Comment: "租户ID", Default: 0},
+		{Name: "agent_id", Type: field.TypeUint64, Comment: "智能体ID", Default: 0},
+		{Name: "custom_agent_base", Type: field.TypeString, Nullable: true, Comment: "定制agent服务地址", Default: ""},
+		{Name: "custom_agent_key", Type: field.TypeString, Nullable: true, Comment: "定制agent服务密钥", Default: ""},
+		{Name: "openai_base", Type: field.TypeString, Nullable: true, Comment: "大模型服务地址", Default: ""},
+		{Name: "openai_key", Type: field.TypeString, Nullable: true, Comment: "大模型服务密钥", Default: ""},
 	}
 	// TokenTable holds the schema information for the "token" table.
 	TokenTable = &schema.Table{

+ 380 - 1
ent/mutation.go

@@ -22212,6 +22212,12 @@ type TokenMutation struct {
 	mac                *string
 	organization_id    *uint64
 	addorganization_id *int64
+	agent_id           *uint64
+	addagent_id        *int64
+	custom_agent_base  *string
+	custom_agent_key   *string
+	openai_base        *string
+	openai_key         *string
 	clearedFields      map[string]struct{}
 	done               bool
 	oldValue           func(context.Context) (*Token, error)
@@ -22633,6 +22639,258 @@ func (m *TokenMutation) ResetOrganizationID() {
 	m.addorganization_id = nil
 }
 
+// SetAgentID sets the "agent_id" field.
+func (m *TokenMutation) SetAgentID(u uint64) {
+	m.agent_id = &u
+	m.addagent_id = nil
+}
+
+// AgentID returns the value of the "agent_id" field in the mutation.
+func (m *TokenMutation) AgentID() (r uint64, exists bool) {
+	v := m.agent_id
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldAgentID returns the old "agent_id" field's value of the Token entity.
+// If the Token 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 *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldAgentID requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
+	}
+	return oldValue.AgentID, nil
+}
+
+// AddAgentID adds u to the "agent_id" field.
+func (m *TokenMutation) AddAgentID(u int64) {
+	if m.addagent_id != nil {
+		*m.addagent_id += u
+	} else {
+		m.addagent_id = &u
+	}
+}
+
+// AddedAgentID returns the value that was added to the "agent_id" field in this mutation.
+func (m *TokenMutation) AddedAgentID() (r int64, exists bool) {
+	v := m.addagent_id
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// ResetAgentID resets all changes to the "agent_id" field.
+func (m *TokenMutation) ResetAgentID() {
+	m.agent_id = nil
+	m.addagent_id = nil
+}
+
+// SetCustomAgentBase sets the "custom_agent_base" field.
+func (m *TokenMutation) SetCustomAgentBase(s string) {
+	m.custom_agent_base = &s
+}
+
+// CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
+func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
+	v := m.custom_agent_base
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
+// If the Token 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 *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
+	}
+	return oldValue.CustomAgentBase, nil
+}
+
+// ClearCustomAgentBase clears the value of the "custom_agent_base" field.
+func (m *TokenMutation) ClearCustomAgentBase() {
+	m.custom_agent_base = nil
+	m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
+}
+
+// CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
+func (m *TokenMutation) CustomAgentBaseCleared() bool {
+	_, ok := m.clearedFields[token.FieldCustomAgentBase]
+	return ok
+}
+
+// ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
+func (m *TokenMutation) ResetCustomAgentBase() {
+	m.custom_agent_base = nil
+	delete(m.clearedFields, token.FieldCustomAgentBase)
+}
+
+// SetCustomAgentKey sets the "custom_agent_key" field.
+func (m *TokenMutation) SetCustomAgentKey(s string) {
+	m.custom_agent_key = &s
+}
+
+// CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
+func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
+	v := m.custom_agent_key
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
+// If the Token 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 *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
+	}
+	return oldValue.CustomAgentKey, nil
+}
+
+// ClearCustomAgentKey clears the value of the "custom_agent_key" field.
+func (m *TokenMutation) ClearCustomAgentKey() {
+	m.custom_agent_key = nil
+	m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
+}
+
+// CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
+func (m *TokenMutation) CustomAgentKeyCleared() bool {
+	_, ok := m.clearedFields[token.FieldCustomAgentKey]
+	return ok
+}
+
+// ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
+func (m *TokenMutation) ResetCustomAgentKey() {
+	m.custom_agent_key = nil
+	delete(m.clearedFields, token.FieldCustomAgentKey)
+}
+
+// SetOpenaiBase sets the "openai_base" field.
+func (m *TokenMutation) SetOpenaiBase(s string) {
+	m.openai_base = &s
+}
+
+// OpenaiBase returns the value of the "openai_base" field in the mutation.
+func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
+	v := m.openai_base
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
+// If the Token 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 *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
+	}
+	return oldValue.OpenaiBase, nil
+}
+
+// ClearOpenaiBase clears the value of the "openai_base" field.
+func (m *TokenMutation) ClearOpenaiBase() {
+	m.openai_base = nil
+	m.clearedFields[token.FieldOpenaiBase] = struct{}{}
+}
+
+// OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
+func (m *TokenMutation) OpenaiBaseCleared() bool {
+	_, ok := m.clearedFields[token.FieldOpenaiBase]
+	return ok
+}
+
+// ResetOpenaiBase resets all changes to the "openai_base" field.
+func (m *TokenMutation) ResetOpenaiBase() {
+	m.openai_base = nil
+	delete(m.clearedFields, token.FieldOpenaiBase)
+}
+
+// SetOpenaiKey sets the "openai_key" field.
+func (m *TokenMutation) SetOpenaiKey(s string) {
+	m.openai_key = &s
+}
+
+// OpenaiKey returns the value of the "openai_key" field in the mutation.
+func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
+	v := m.openai_key
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
+// If the Token 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 *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
+	}
+	return oldValue.OpenaiKey, nil
+}
+
+// ClearOpenaiKey clears the value of the "openai_key" field.
+func (m *TokenMutation) ClearOpenaiKey() {
+	m.openai_key = nil
+	m.clearedFields[token.FieldOpenaiKey] = struct{}{}
+}
+
+// OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
+func (m *TokenMutation) OpenaiKeyCleared() bool {
+	_, ok := m.clearedFields[token.FieldOpenaiKey]
+	return ok
+}
+
+// ResetOpenaiKey resets all changes to the "openai_key" field.
+func (m *TokenMutation) ResetOpenaiKey() {
+	m.openai_key = nil
+	delete(m.clearedFields, token.FieldOpenaiKey)
+}
+
 // Where appends a list predicates to the TokenMutation builder.
 func (m *TokenMutation) Where(ps ...predicate.Token) {
 	m.predicates = append(m.predicates, ps...)
@@ -22667,7 +22925,7 @@ func (m *TokenMutation) Type() string {
 // order to get all numeric fields that were incremented/decremented, call
 // AddedFields().
 func (m *TokenMutation) Fields() []string {
-	fields := make([]string, 0, 7)
+	fields := make([]string, 0, 12)
 	if m.created_at != nil {
 		fields = append(fields, token.FieldCreatedAt)
 	}
@@ -22689,6 +22947,21 @@ func (m *TokenMutation) Fields() []string {
 	if m.organization_id != nil {
 		fields = append(fields, token.FieldOrganizationID)
 	}
+	if m.agent_id != nil {
+		fields = append(fields, token.FieldAgentID)
+	}
+	if m.custom_agent_base != nil {
+		fields = append(fields, token.FieldCustomAgentBase)
+	}
+	if m.custom_agent_key != nil {
+		fields = append(fields, token.FieldCustomAgentKey)
+	}
+	if m.openai_base != nil {
+		fields = append(fields, token.FieldOpenaiBase)
+	}
+	if m.openai_key != nil {
+		fields = append(fields, token.FieldOpenaiKey)
+	}
 	return fields
 }
 
@@ -22711,6 +22984,16 @@ func (m *TokenMutation) Field(name string) (ent.Value, bool) {
 		return m.MAC()
 	case token.FieldOrganizationID:
 		return m.OrganizationID()
+	case token.FieldAgentID:
+		return m.AgentID()
+	case token.FieldCustomAgentBase:
+		return m.CustomAgentBase()
+	case token.FieldCustomAgentKey:
+		return m.CustomAgentKey()
+	case token.FieldOpenaiBase:
+		return m.OpenaiBase()
+	case token.FieldOpenaiKey:
+		return m.OpenaiKey()
 	}
 	return nil, false
 }
@@ -22734,6 +23017,16 @@ func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, e
 		return m.OldMAC(ctx)
 	case token.FieldOrganizationID:
 		return m.OldOrganizationID(ctx)
+	case token.FieldAgentID:
+		return m.OldAgentID(ctx)
+	case token.FieldCustomAgentBase:
+		return m.OldCustomAgentBase(ctx)
+	case token.FieldCustomAgentKey:
+		return m.OldCustomAgentKey(ctx)
+	case token.FieldOpenaiBase:
+		return m.OldOpenaiBase(ctx)
+	case token.FieldOpenaiKey:
+		return m.OldOpenaiKey(ctx)
 	}
 	return nil, fmt.Errorf("unknown Token field %s", name)
 }
@@ -22792,6 +23085,41 @@ func (m *TokenMutation) SetField(name string, value ent.Value) error {
 		}
 		m.SetOrganizationID(v)
 		return nil
+	case token.FieldAgentID:
+		v, ok := value.(uint64)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetAgentID(v)
+		return nil
+	case token.FieldCustomAgentBase:
+		v, ok := value.(string)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetCustomAgentBase(v)
+		return nil
+	case token.FieldCustomAgentKey:
+		v, ok := value.(string)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetCustomAgentKey(v)
+		return nil
+	case token.FieldOpenaiBase:
+		v, ok := value.(string)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetOpenaiBase(v)
+		return nil
+	case token.FieldOpenaiKey:
+		v, ok := value.(string)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetOpenaiKey(v)
+		return nil
 	}
 	return fmt.Errorf("unknown Token field %s", name)
 }
@@ -22803,6 +23131,9 @@ func (m *TokenMutation) AddedFields() []string {
 	if m.addorganization_id != nil {
 		fields = append(fields, token.FieldOrganizationID)
 	}
+	if m.addagent_id != nil {
+		fields = append(fields, token.FieldAgentID)
+	}
 	return fields
 }
 
@@ -22813,6 +23144,8 @@ func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
 	switch name {
 	case token.FieldOrganizationID:
 		return m.AddedOrganizationID()
+	case token.FieldAgentID:
+		return m.AddedAgentID()
 	}
 	return nil, false
 }
@@ -22829,6 +23162,13 @@ func (m *TokenMutation) AddField(name string, value ent.Value) error {
 		}
 		m.AddOrganizationID(v)
 		return nil
+	case token.FieldAgentID:
+		v, ok := value.(int64)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.AddAgentID(v)
+		return nil
 	}
 	return fmt.Errorf("unknown Token numeric field %s", name)
 }
@@ -22846,6 +23186,18 @@ func (m *TokenMutation) ClearedFields() []string {
 	if m.FieldCleared(token.FieldToken) {
 		fields = append(fields, token.FieldToken)
 	}
+	if m.FieldCleared(token.FieldCustomAgentBase) {
+		fields = append(fields, token.FieldCustomAgentBase)
+	}
+	if m.FieldCleared(token.FieldCustomAgentKey) {
+		fields = append(fields, token.FieldCustomAgentKey)
+	}
+	if m.FieldCleared(token.FieldOpenaiBase) {
+		fields = append(fields, token.FieldOpenaiBase)
+	}
+	if m.FieldCleared(token.FieldOpenaiKey) {
+		fields = append(fields, token.FieldOpenaiKey)
+	}
 	return fields
 }
 
@@ -22869,6 +23221,18 @@ func (m *TokenMutation) ClearField(name string) error {
 	case token.FieldToken:
 		m.ClearToken()
 		return nil
+	case token.FieldCustomAgentBase:
+		m.ClearCustomAgentBase()
+		return nil
+	case token.FieldCustomAgentKey:
+		m.ClearCustomAgentKey()
+		return nil
+	case token.FieldOpenaiBase:
+		m.ClearOpenaiBase()
+		return nil
+	case token.FieldOpenaiKey:
+		m.ClearOpenaiKey()
+		return nil
 	}
 	return fmt.Errorf("unknown Token nullable field %s", name)
 }
@@ -22898,6 +23262,21 @@ func (m *TokenMutation) ResetField(name string) error {
 	case token.FieldOrganizationID:
 		m.ResetOrganizationID()
 		return nil
+	case token.FieldAgentID:
+		m.ResetAgentID()
+		return nil
+	case token.FieldCustomAgentBase:
+		m.ResetCustomAgentBase()
+		return nil
+	case token.FieldCustomAgentKey:
+		m.ResetCustomAgentKey()
+		return nil
+	case token.FieldOpenaiBase:
+		m.ResetOpenaiBase()
+		return nil
+	case token.FieldOpenaiKey:
+		m.ResetOpenaiKey()
+		return nil
 	}
 	return fmt.Errorf("unknown Token field %s", name)
 }

+ 20 - 0
ent/runtime/runtime.go

@@ -851,6 +851,26 @@ func init() {
 	tokenDescOrganizationID := tokenFields[3].Descriptor()
 	// token.DefaultOrganizationID holds the default value on creation for the organization_id field.
 	token.DefaultOrganizationID = tokenDescOrganizationID.Default.(uint64)
+	// tokenDescAgentID is the schema descriptor for agent_id field.
+	tokenDescAgentID := tokenFields[4].Descriptor()
+	// token.DefaultAgentID holds the default value on creation for the agent_id field.
+	token.DefaultAgentID = tokenDescAgentID.Default.(uint64)
+	// tokenDescCustomAgentBase is the schema descriptor for custom_agent_base field.
+	tokenDescCustomAgentBase := tokenFields[5].Descriptor()
+	// token.DefaultCustomAgentBase holds the default value on creation for the custom_agent_base field.
+	token.DefaultCustomAgentBase = tokenDescCustomAgentBase.Default.(string)
+	// tokenDescCustomAgentKey is the schema descriptor for custom_agent_key field.
+	tokenDescCustomAgentKey := tokenFields[6].Descriptor()
+	// token.DefaultCustomAgentKey holds the default value on creation for the custom_agent_key field.
+	token.DefaultCustomAgentKey = tokenDescCustomAgentKey.Default.(string)
+	// tokenDescOpenaiBase is the schema descriptor for openai_base field.
+	tokenDescOpenaiBase := tokenFields[7].Descriptor()
+	// token.DefaultOpenaiBase holds the default value on creation for the openai_base field.
+	token.DefaultOpenaiBase = tokenDescOpenaiBase.Default.(string)
+	// tokenDescOpenaiKey is the schema descriptor for openai_key field.
+	tokenDescOpenaiKey := tokenFields[8].Descriptor()
+	// token.DefaultOpenaiKey holds the default value on creation for the openai_key field.
+	token.DefaultOpenaiKey = tokenDescOpenaiKey.Default.(string)
 	tutorialMixin := schema.Tutorial{}.Mixin()
 	tutorialMixinHooks1 := tutorialMixin[1].Hooks()
 	tutorial.Hooks[0] = tutorialMixinHooks1[0]

+ 5 - 0
ent/schema/token.go

@@ -21,6 +21,11 @@ func (Token) Fields() []ent.Field {
 		field.String("token").Optional().Default("").Comment("Token"),
 		field.String("mac").Default("").Comment("Mac地址"),
 		field.Uint64("organization_id").Default(0).Comment("租户ID"),
+		field.Uint64("agent_id").Default(0).Comment("智能体ID"),
+		field.String("custom_agent_base").Optional().Default("").Comment("定制agent服务地址"),
+		field.String("custom_agent_key").Optional().Default("").Comment("定制agent服务密钥"),
+		field.String("openai_base").Optional().Default("").Comment("大模型服务地址"),
+		field.String("openai_key").Optional().Default("").Comment("大模型服务密钥"),
 	}
 }
 

+ 120 - 0
ent/set_not_nil.go

@@ -4832,6 +4832,126 @@ func (t *TokenCreate) SetNotNilOrganizationID(value *uint64) *TokenCreate {
 }
 
 // set field if value's pointer is not nil.
+func (t *TokenUpdate) SetNotNilAgentID(value *uint64) *TokenUpdate {
+	if value != nil {
+		return t.SetAgentID(*value)
+	}
+	return t
+}
+
+// set field if value's pointer is not nil.
+func (t *TokenUpdateOne) SetNotNilAgentID(value *uint64) *TokenUpdateOne {
+	if value != nil {
+		return t.SetAgentID(*value)
+	}
+	return t
+}
+
+// set field if value's pointer is not nil.
+func (t *TokenCreate) SetNotNilAgentID(value *uint64) *TokenCreate {
+	if value != nil {
+		return t.SetAgentID(*value)
+	}
+	return t
+}
+
+// set field if value's pointer is not nil.
+func (t *TokenUpdate) SetNotNilCustomAgentBase(value *string) *TokenUpdate {
+	if value != nil {
+		return t.SetCustomAgentBase(*value)
+	}
+	return t
+}
+
+// set field if value's pointer is not nil.
+func (t *TokenUpdateOne) SetNotNilCustomAgentBase(value *string) *TokenUpdateOne {
+	if value != nil {
+		return t.SetCustomAgentBase(*value)
+	}
+	return t
+}
+
+// set field if value's pointer is not nil.
+func (t *TokenCreate) SetNotNilCustomAgentBase(value *string) *TokenCreate {
+	if value != nil {
+		return t.SetCustomAgentBase(*value)
+	}
+	return t
+}
+
+// set field if value's pointer is not nil.
+func (t *TokenUpdate) SetNotNilCustomAgentKey(value *string) *TokenUpdate {
+	if value != nil {
+		return t.SetCustomAgentKey(*value)
+	}
+	return t
+}
+
+// set field if value's pointer is not nil.
+func (t *TokenUpdateOne) SetNotNilCustomAgentKey(value *string) *TokenUpdateOne {
+	if value != nil {
+		return t.SetCustomAgentKey(*value)
+	}
+	return t
+}
+
+// set field if value's pointer is not nil.
+func (t *TokenCreate) SetNotNilCustomAgentKey(value *string) *TokenCreate {
+	if value != nil {
+		return t.SetCustomAgentKey(*value)
+	}
+	return t
+}
+
+// set field if value's pointer is not nil.
+func (t *TokenUpdate) SetNotNilOpenaiBase(value *string) *TokenUpdate {
+	if value != nil {
+		return t.SetOpenaiBase(*value)
+	}
+	return t
+}
+
+// set field if value's pointer is not nil.
+func (t *TokenUpdateOne) SetNotNilOpenaiBase(value *string) *TokenUpdateOne {
+	if value != nil {
+		return t.SetOpenaiBase(*value)
+	}
+	return t
+}
+
+// set field if value's pointer is not nil.
+func (t *TokenCreate) SetNotNilOpenaiBase(value *string) *TokenCreate {
+	if value != nil {
+		return t.SetOpenaiBase(*value)
+	}
+	return t
+}
+
+// set field if value's pointer is not nil.
+func (t *TokenUpdate) SetNotNilOpenaiKey(value *string) *TokenUpdate {
+	if value != nil {
+		return t.SetOpenaiKey(*value)
+	}
+	return t
+}
+
+// set field if value's pointer is not nil.
+func (t *TokenUpdateOne) SetNotNilOpenaiKey(value *string) *TokenUpdateOne {
+	if value != nil {
+		return t.SetOpenaiKey(*value)
+	}
+	return t
+}
+
+// set field if value's pointer is not nil.
+func (t *TokenCreate) SetNotNilOpenaiKey(value *string) *TokenCreate {
+	if value != nil {
+		return t.SetOpenaiKey(*value)
+	}
+	return t
+}
+
+// set field if value's pointer is not nil.
 func (t *TutorialUpdate) SetNotNilUpdatedAt(value *time.Time) *TutorialUpdate {
 	if value != nil {
 		return t.SetUpdatedAt(*value)

+ 58 - 3
ent/token.go

@@ -31,7 +31,17 @@ type Token struct {
 	MAC string `json:"mac,omitempty"`
 	// 租户ID
 	OrganizationID uint64 `json:"organization_id,omitempty"`
-	selectValues   sql.SelectValues
+	// 智能体ID
+	AgentID uint64 `json:"agent_id,omitempty"`
+	// 定制agent服务地址
+	CustomAgentBase string `json:"custom_agent_base,omitempty"`
+	// 定制agent服务密钥
+	CustomAgentKey string `json:"custom_agent_key,omitempty"`
+	// 大模型服务地址
+	OpenaiBase string `json:"openai_base,omitempty"`
+	// 大模型服务密钥
+	OpenaiKey    string `json:"openai_key,omitempty"`
+	selectValues sql.SelectValues
 }
 
 // scanValues returns the types for scanning values from sql.Rows.
@@ -39,9 +49,9 @@ func (*Token) scanValues(columns []string) ([]any, error) {
 	values := make([]any, len(columns))
 	for i := range columns {
 		switch columns[i] {
-		case token.FieldID, token.FieldOrganizationID:
+		case token.FieldID, token.FieldOrganizationID, token.FieldAgentID:
 			values[i] = new(sql.NullInt64)
-		case token.FieldToken, token.FieldMAC:
+		case token.FieldToken, token.FieldMAC, token.FieldCustomAgentBase, token.FieldCustomAgentKey, token.FieldOpenaiBase, token.FieldOpenaiKey:
 			values[i] = new(sql.NullString)
 		case token.FieldCreatedAt, token.FieldUpdatedAt, token.FieldDeletedAt, token.FieldExpireAt:
 			values[i] = new(sql.NullTime)
@@ -108,6 +118,36 @@ func (t *Token) assignValues(columns []string, values []any) error {
 			} else if value.Valid {
 				t.OrganizationID = uint64(value.Int64)
 			}
+		case token.FieldAgentID:
+			if value, ok := values[i].(*sql.NullInt64); !ok {
+				return fmt.Errorf("unexpected type %T for field agent_id", values[i])
+			} else if value.Valid {
+				t.AgentID = uint64(value.Int64)
+			}
+		case token.FieldCustomAgentBase:
+			if value, ok := values[i].(*sql.NullString); !ok {
+				return fmt.Errorf("unexpected type %T for field custom_agent_base", values[i])
+			} else if value.Valid {
+				t.CustomAgentBase = value.String
+			}
+		case token.FieldCustomAgentKey:
+			if value, ok := values[i].(*sql.NullString); !ok {
+				return fmt.Errorf("unexpected type %T for field custom_agent_key", values[i])
+			} else if value.Valid {
+				t.CustomAgentKey = value.String
+			}
+		case token.FieldOpenaiBase:
+			if value, ok := values[i].(*sql.NullString); !ok {
+				return fmt.Errorf("unexpected type %T for field openai_base", values[i])
+			} else if value.Valid {
+				t.OpenaiBase = value.String
+			}
+		case token.FieldOpenaiKey:
+			if value, ok := values[i].(*sql.NullString); !ok {
+				return fmt.Errorf("unexpected type %T for field openai_key", values[i])
+			} else if value.Valid {
+				t.OpenaiKey = value.String
+			}
 		default:
 			t.selectValues.Set(columns[i], values[i])
 		}
@@ -164,6 +204,21 @@ func (t *Token) String() string {
 	builder.WriteString(", ")
 	builder.WriteString("organization_id=")
 	builder.WriteString(fmt.Sprintf("%v", t.OrganizationID))
+	builder.WriteString(", ")
+	builder.WriteString("agent_id=")
+	builder.WriteString(fmt.Sprintf("%v", t.AgentID))
+	builder.WriteString(", ")
+	builder.WriteString("custom_agent_base=")
+	builder.WriteString(t.CustomAgentBase)
+	builder.WriteString(", ")
+	builder.WriteString("custom_agent_key=")
+	builder.WriteString(t.CustomAgentKey)
+	builder.WriteString(", ")
+	builder.WriteString("openai_base=")
+	builder.WriteString(t.OpenaiBase)
+	builder.WriteString(", ")
+	builder.WriteString("openai_key=")
+	builder.WriteString(t.OpenaiKey)
 	builder.WriteByte(')')
 	return builder.String()
 }

+ 50 - 0
ent/token/token.go

@@ -28,6 +28,16 @@ const (
 	FieldMAC = "mac"
 	// FieldOrganizationID holds the string denoting the organization_id field in the database.
 	FieldOrganizationID = "organization_id"
+	// FieldAgentID holds the string denoting the agent_id field in the database.
+	FieldAgentID = "agent_id"
+	// FieldCustomAgentBase holds the string denoting the custom_agent_base field in the database.
+	FieldCustomAgentBase = "custom_agent_base"
+	// FieldCustomAgentKey holds the string denoting the custom_agent_key field in the database.
+	FieldCustomAgentKey = "custom_agent_key"
+	// FieldOpenaiBase holds the string denoting the openai_base field in the database.
+	FieldOpenaiBase = "openai_base"
+	// FieldOpenaiKey holds the string denoting the openai_key field in the database.
+	FieldOpenaiKey = "openai_key"
 	// Table holds the table name of the token in the database.
 	Table = "token"
 )
@@ -42,6 +52,11 @@ var Columns = []string{
 	FieldToken,
 	FieldMAC,
 	FieldOrganizationID,
+	FieldAgentID,
+	FieldCustomAgentBase,
+	FieldCustomAgentKey,
+	FieldOpenaiBase,
+	FieldOpenaiKey,
 }
 
 // ValidColumn reports if the column name is valid (part of the table columns).
@@ -74,6 +89,16 @@ var (
 	DefaultMAC string
 	// DefaultOrganizationID holds the default value on creation for the "organization_id" field.
 	DefaultOrganizationID uint64
+	// DefaultAgentID holds the default value on creation for the "agent_id" field.
+	DefaultAgentID uint64
+	// DefaultCustomAgentBase holds the default value on creation for the "custom_agent_base" field.
+	DefaultCustomAgentBase string
+	// DefaultCustomAgentKey holds the default value on creation for the "custom_agent_key" field.
+	DefaultCustomAgentKey string
+	// DefaultOpenaiBase holds the default value on creation for the "openai_base" field.
+	DefaultOpenaiBase string
+	// DefaultOpenaiKey holds the default value on creation for the "openai_key" field.
+	DefaultOpenaiKey string
 )
 
 // OrderOption defines the ordering options for the Token queries.
@@ -118,3 +143,28 @@ func ByMAC(opts ...sql.OrderTermOption) OrderOption {
 func ByOrganizationID(opts ...sql.OrderTermOption) OrderOption {
 	return sql.OrderByField(FieldOrganizationID, opts...).ToFunc()
 }
+
+// ByAgentID orders the results by the agent_id field.
+func ByAgentID(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldAgentID, opts...).ToFunc()
+}
+
+// ByCustomAgentBase orders the results by the custom_agent_base field.
+func ByCustomAgentBase(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldCustomAgentBase, opts...).ToFunc()
+}
+
+// ByCustomAgentKey orders the results by the custom_agent_key field.
+func ByCustomAgentKey(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldCustomAgentKey, opts...).ToFunc()
+}
+
+// ByOpenaiBase orders the results by the openai_base field.
+func ByOpenaiBase(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldOpenaiBase, opts...).ToFunc()
+}
+
+// ByOpenaiKey orders the results by the openai_key field.
+func ByOpenaiKey(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldOpenaiKey, opts...).ToFunc()
+}

+ 365 - 0
ent/token/where.go

@@ -89,6 +89,31 @@ func OrganizationID(v uint64) predicate.Token {
 	return predicate.Token(sql.FieldEQ(FieldOrganizationID, v))
 }
 
+// AgentID applies equality check predicate on the "agent_id" field. It's identical to AgentIDEQ.
+func AgentID(v uint64) predicate.Token {
+	return predicate.Token(sql.FieldEQ(FieldAgentID, v))
+}
+
+// CustomAgentBase applies equality check predicate on the "custom_agent_base" field. It's identical to CustomAgentBaseEQ.
+func CustomAgentBase(v string) predicate.Token {
+	return predicate.Token(sql.FieldEQ(FieldCustomAgentBase, v))
+}
+
+// CustomAgentKey applies equality check predicate on the "custom_agent_key" field. It's identical to CustomAgentKeyEQ.
+func CustomAgentKey(v string) predicate.Token {
+	return predicate.Token(sql.FieldEQ(FieldCustomAgentKey, v))
+}
+
+// OpenaiBase applies equality check predicate on the "openai_base" field. It's identical to OpenaiBaseEQ.
+func OpenaiBase(v string) predicate.Token {
+	return predicate.Token(sql.FieldEQ(FieldOpenaiBase, v))
+}
+
+// OpenaiKey applies equality check predicate on the "openai_key" field. It's identical to OpenaiKeyEQ.
+func OpenaiKey(v string) predicate.Token {
+	return predicate.Token(sql.FieldEQ(FieldOpenaiKey, v))
+}
+
 // CreatedAtEQ applies the EQ predicate on the "created_at" field.
 func CreatedAtEQ(v time.Time) predicate.Token {
 	return predicate.Token(sql.FieldEQ(FieldCreatedAt, v))
@@ -449,6 +474,346 @@ func OrganizationIDLTE(v uint64) predicate.Token {
 	return predicate.Token(sql.FieldLTE(FieldOrganizationID, v))
 }
 
+// AgentIDEQ applies the EQ predicate on the "agent_id" field.
+func AgentIDEQ(v uint64) predicate.Token {
+	return predicate.Token(sql.FieldEQ(FieldAgentID, v))
+}
+
+// AgentIDNEQ applies the NEQ predicate on the "agent_id" field.
+func AgentIDNEQ(v uint64) predicate.Token {
+	return predicate.Token(sql.FieldNEQ(FieldAgentID, v))
+}
+
+// AgentIDIn applies the In predicate on the "agent_id" field.
+func AgentIDIn(vs ...uint64) predicate.Token {
+	return predicate.Token(sql.FieldIn(FieldAgentID, vs...))
+}
+
+// AgentIDNotIn applies the NotIn predicate on the "agent_id" field.
+func AgentIDNotIn(vs ...uint64) predicate.Token {
+	return predicate.Token(sql.FieldNotIn(FieldAgentID, vs...))
+}
+
+// AgentIDGT applies the GT predicate on the "agent_id" field.
+func AgentIDGT(v uint64) predicate.Token {
+	return predicate.Token(sql.FieldGT(FieldAgentID, v))
+}
+
+// AgentIDGTE applies the GTE predicate on the "agent_id" field.
+func AgentIDGTE(v uint64) predicate.Token {
+	return predicate.Token(sql.FieldGTE(FieldAgentID, v))
+}
+
+// AgentIDLT applies the LT predicate on the "agent_id" field.
+func AgentIDLT(v uint64) predicate.Token {
+	return predicate.Token(sql.FieldLT(FieldAgentID, v))
+}
+
+// AgentIDLTE applies the LTE predicate on the "agent_id" field.
+func AgentIDLTE(v uint64) predicate.Token {
+	return predicate.Token(sql.FieldLTE(FieldAgentID, v))
+}
+
+// CustomAgentBaseEQ applies the EQ predicate on the "custom_agent_base" field.
+func CustomAgentBaseEQ(v string) predicate.Token {
+	return predicate.Token(sql.FieldEQ(FieldCustomAgentBase, v))
+}
+
+// CustomAgentBaseNEQ applies the NEQ predicate on the "custom_agent_base" field.
+func CustomAgentBaseNEQ(v string) predicate.Token {
+	return predicate.Token(sql.FieldNEQ(FieldCustomAgentBase, v))
+}
+
+// CustomAgentBaseIn applies the In predicate on the "custom_agent_base" field.
+func CustomAgentBaseIn(vs ...string) predicate.Token {
+	return predicate.Token(sql.FieldIn(FieldCustomAgentBase, vs...))
+}
+
+// CustomAgentBaseNotIn applies the NotIn predicate on the "custom_agent_base" field.
+func CustomAgentBaseNotIn(vs ...string) predicate.Token {
+	return predicate.Token(sql.FieldNotIn(FieldCustomAgentBase, vs...))
+}
+
+// CustomAgentBaseGT applies the GT predicate on the "custom_agent_base" field.
+func CustomAgentBaseGT(v string) predicate.Token {
+	return predicate.Token(sql.FieldGT(FieldCustomAgentBase, v))
+}
+
+// CustomAgentBaseGTE applies the GTE predicate on the "custom_agent_base" field.
+func CustomAgentBaseGTE(v string) predicate.Token {
+	return predicate.Token(sql.FieldGTE(FieldCustomAgentBase, v))
+}
+
+// CustomAgentBaseLT applies the LT predicate on the "custom_agent_base" field.
+func CustomAgentBaseLT(v string) predicate.Token {
+	return predicate.Token(sql.FieldLT(FieldCustomAgentBase, v))
+}
+
+// CustomAgentBaseLTE applies the LTE predicate on the "custom_agent_base" field.
+func CustomAgentBaseLTE(v string) predicate.Token {
+	return predicate.Token(sql.FieldLTE(FieldCustomAgentBase, v))
+}
+
+// CustomAgentBaseContains applies the Contains predicate on the "custom_agent_base" field.
+func CustomAgentBaseContains(v string) predicate.Token {
+	return predicate.Token(sql.FieldContains(FieldCustomAgentBase, v))
+}
+
+// CustomAgentBaseHasPrefix applies the HasPrefix predicate on the "custom_agent_base" field.
+func CustomAgentBaseHasPrefix(v string) predicate.Token {
+	return predicate.Token(sql.FieldHasPrefix(FieldCustomAgentBase, v))
+}
+
+// CustomAgentBaseHasSuffix applies the HasSuffix predicate on the "custom_agent_base" field.
+func CustomAgentBaseHasSuffix(v string) predicate.Token {
+	return predicate.Token(sql.FieldHasSuffix(FieldCustomAgentBase, v))
+}
+
+// CustomAgentBaseIsNil applies the IsNil predicate on the "custom_agent_base" field.
+func CustomAgentBaseIsNil() predicate.Token {
+	return predicate.Token(sql.FieldIsNull(FieldCustomAgentBase))
+}
+
+// CustomAgentBaseNotNil applies the NotNil predicate on the "custom_agent_base" field.
+func CustomAgentBaseNotNil() predicate.Token {
+	return predicate.Token(sql.FieldNotNull(FieldCustomAgentBase))
+}
+
+// CustomAgentBaseEqualFold applies the EqualFold predicate on the "custom_agent_base" field.
+func CustomAgentBaseEqualFold(v string) predicate.Token {
+	return predicate.Token(sql.FieldEqualFold(FieldCustomAgentBase, v))
+}
+
+// CustomAgentBaseContainsFold applies the ContainsFold predicate on the "custom_agent_base" field.
+func CustomAgentBaseContainsFold(v string) predicate.Token {
+	return predicate.Token(sql.FieldContainsFold(FieldCustomAgentBase, v))
+}
+
+// CustomAgentKeyEQ applies the EQ predicate on the "custom_agent_key" field.
+func CustomAgentKeyEQ(v string) predicate.Token {
+	return predicate.Token(sql.FieldEQ(FieldCustomAgentKey, v))
+}
+
+// CustomAgentKeyNEQ applies the NEQ predicate on the "custom_agent_key" field.
+func CustomAgentKeyNEQ(v string) predicate.Token {
+	return predicate.Token(sql.FieldNEQ(FieldCustomAgentKey, v))
+}
+
+// CustomAgentKeyIn applies the In predicate on the "custom_agent_key" field.
+func CustomAgentKeyIn(vs ...string) predicate.Token {
+	return predicate.Token(sql.FieldIn(FieldCustomAgentKey, vs...))
+}
+
+// CustomAgentKeyNotIn applies the NotIn predicate on the "custom_agent_key" field.
+func CustomAgentKeyNotIn(vs ...string) predicate.Token {
+	return predicate.Token(sql.FieldNotIn(FieldCustomAgentKey, vs...))
+}
+
+// CustomAgentKeyGT applies the GT predicate on the "custom_agent_key" field.
+func CustomAgentKeyGT(v string) predicate.Token {
+	return predicate.Token(sql.FieldGT(FieldCustomAgentKey, v))
+}
+
+// CustomAgentKeyGTE applies the GTE predicate on the "custom_agent_key" field.
+func CustomAgentKeyGTE(v string) predicate.Token {
+	return predicate.Token(sql.FieldGTE(FieldCustomAgentKey, v))
+}
+
+// CustomAgentKeyLT applies the LT predicate on the "custom_agent_key" field.
+func CustomAgentKeyLT(v string) predicate.Token {
+	return predicate.Token(sql.FieldLT(FieldCustomAgentKey, v))
+}
+
+// CustomAgentKeyLTE applies the LTE predicate on the "custom_agent_key" field.
+func CustomAgentKeyLTE(v string) predicate.Token {
+	return predicate.Token(sql.FieldLTE(FieldCustomAgentKey, v))
+}
+
+// CustomAgentKeyContains applies the Contains predicate on the "custom_agent_key" field.
+func CustomAgentKeyContains(v string) predicate.Token {
+	return predicate.Token(sql.FieldContains(FieldCustomAgentKey, v))
+}
+
+// CustomAgentKeyHasPrefix applies the HasPrefix predicate on the "custom_agent_key" field.
+func CustomAgentKeyHasPrefix(v string) predicate.Token {
+	return predicate.Token(sql.FieldHasPrefix(FieldCustomAgentKey, v))
+}
+
+// CustomAgentKeyHasSuffix applies the HasSuffix predicate on the "custom_agent_key" field.
+func CustomAgentKeyHasSuffix(v string) predicate.Token {
+	return predicate.Token(sql.FieldHasSuffix(FieldCustomAgentKey, v))
+}
+
+// CustomAgentKeyIsNil applies the IsNil predicate on the "custom_agent_key" field.
+func CustomAgentKeyIsNil() predicate.Token {
+	return predicate.Token(sql.FieldIsNull(FieldCustomAgentKey))
+}
+
+// CustomAgentKeyNotNil applies the NotNil predicate on the "custom_agent_key" field.
+func CustomAgentKeyNotNil() predicate.Token {
+	return predicate.Token(sql.FieldNotNull(FieldCustomAgentKey))
+}
+
+// CustomAgentKeyEqualFold applies the EqualFold predicate on the "custom_agent_key" field.
+func CustomAgentKeyEqualFold(v string) predicate.Token {
+	return predicate.Token(sql.FieldEqualFold(FieldCustomAgentKey, v))
+}
+
+// CustomAgentKeyContainsFold applies the ContainsFold predicate on the "custom_agent_key" field.
+func CustomAgentKeyContainsFold(v string) predicate.Token {
+	return predicate.Token(sql.FieldContainsFold(FieldCustomAgentKey, v))
+}
+
+// OpenaiBaseEQ applies the EQ predicate on the "openai_base" field.
+func OpenaiBaseEQ(v string) predicate.Token {
+	return predicate.Token(sql.FieldEQ(FieldOpenaiBase, v))
+}
+
+// OpenaiBaseNEQ applies the NEQ predicate on the "openai_base" field.
+func OpenaiBaseNEQ(v string) predicate.Token {
+	return predicate.Token(sql.FieldNEQ(FieldOpenaiBase, v))
+}
+
+// OpenaiBaseIn applies the In predicate on the "openai_base" field.
+func OpenaiBaseIn(vs ...string) predicate.Token {
+	return predicate.Token(sql.FieldIn(FieldOpenaiBase, vs...))
+}
+
+// OpenaiBaseNotIn applies the NotIn predicate on the "openai_base" field.
+func OpenaiBaseNotIn(vs ...string) predicate.Token {
+	return predicate.Token(sql.FieldNotIn(FieldOpenaiBase, vs...))
+}
+
+// OpenaiBaseGT applies the GT predicate on the "openai_base" field.
+func OpenaiBaseGT(v string) predicate.Token {
+	return predicate.Token(sql.FieldGT(FieldOpenaiBase, v))
+}
+
+// OpenaiBaseGTE applies the GTE predicate on the "openai_base" field.
+func OpenaiBaseGTE(v string) predicate.Token {
+	return predicate.Token(sql.FieldGTE(FieldOpenaiBase, v))
+}
+
+// OpenaiBaseLT applies the LT predicate on the "openai_base" field.
+func OpenaiBaseLT(v string) predicate.Token {
+	return predicate.Token(sql.FieldLT(FieldOpenaiBase, v))
+}
+
+// OpenaiBaseLTE applies the LTE predicate on the "openai_base" field.
+func OpenaiBaseLTE(v string) predicate.Token {
+	return predicate.Token(sql.FieldLTE(FieldOpenaiBase, v))
+}
+
+// OpenaiBaseContains applies the Contains predicate on the "openai_base" field.
+func OpenaiBaseContains(v string) predicate.Token {
+	return predicate.Token(sql.FieldContains(FieldOpenaiBase, v))
+}
+
+// OpenaiBaseHasPrefix applies the HasPrefix predicate on the "openai_base" field.
+func OpenaiBaseHasPrefix(v string) predicate.Token {
+	return predicate.Token(sql.FieldHasPrefix(FieldOpenaiBase, v))
+}
+
+// OpenaiBaseHasSuffix applies the HasSuffix predicate on the "openai_base" field.
+func OpenaiBaseHasSuffix(v string) predicate.Token {
+	return predicate.Token(sql.FieldHasSuffix(FieldOpenaiBase, v))
+}
+
+// OpenaiBaseIsNil applies the IsNil predicate on the "openai_base" field.
+func OpenaiBaseIsNil() predicate.Token {
+	return predicate.Token(sql.FieldIsNull(FieldOpenaiBase))
+}
+
+// OpenaiBaseNotNil applies the NotNil predicate on the "openai_base" field.
+func OpenaiBaseNotNil() predicate.Token {
+	return predicate.Token(sql.FieldNotNull(FieldOpenaiBase))
+}
+
+// OpenaiBaseEqualFold applies the EqualFold predicate on the "openai_base" field.
+func OpenaiBaseEqualFold(v string) predicate.Token {
+	return predicate.Token(sql.FieldEqualFold(FieldOpenaiBase, v))
+}
+
+// OpenaiBaseContainsFold applies the ContainsFold predicate on the "openai_base" field.
+func OpenaiBaseContainsFold(v string) predicate.Token {
+	return predicate.Token(sql.FieldContainsFold(FieldOpenaiBase, v))
+}
+
+// OpenaiKeyEQ applies the EQ predicate on the "openai_key" field.
+func OpenaiKeyEQ(v string) predicate.Token {
+	return predicate.Token(sql.FieldEQ(FieldOpenaiKey, v))
+}
+
+// OpenaiKeyNEQ applies the NEQ predicate on the "openai_key" field.
+func OpenaiKeyNEQ(v string) predicate.Token {
+	return predicate.Token(sql.FieldNEQ(FieldOpenaiKey, v))
+}
+
+// OpenaiKeyIn applies the In predicate on the "openai_key" field.
+func OpenaiKeyIn(vs ...string) predicate.Token {
+	return predicate.Token(sql.FieldIn(FieldOpenaiKey, vs...))
+}
+
+// OpenaiKeyNotIn applies the NotIn predicate on the "openai_key" field.
+func OpenaiKeyNotIn(vs ...string) predicate.Token {
+	return predicate.Token(sql.FieldNotIn(FieldOpenaiKey, vs...))
+}
+
+// OpenaiKeyGT applies the GT predicate on the "openai_key" field.
+func OpenaiKeyGT(v string) predicate.Token {
+	return predicate.Token(sql.FieldGT(FieldOpenaiKey, v))
+}
+
+// OpenaiKeyGTE applies the GTE predicate on the "openai_key" field.
+func OpenaiKeyGTE(v string) predicate.Token {
+	return predicate.Token(sql.FieldGTE(FieldOpenaiKey, v))
+}
+
+// OpenaiKeyLT applies the LT predicate on the "openai_key" field.
+func OpenaiKeyLT(v string) predicate.Token {
+	return predicate.Token(sql.FieldLT(FieldOpenaiKey, v))
+}
+
+// OpenaiKeyLTE applies the LTE predicate on the "openai_key" field.
+func OpenaiKeyLTE(v string) predicate.Token {
+	return predicate.Token(sql.FieldLTE(FieldOpenaiKey, v))
+}
+
+// OpenaiKeyContains applies the Contains predicate on the "openai_key" field.
+func OpenaiKeyContains(v string) predicate.Token {
+	return predicate.Token(sql.FieldContains(FieldOpenaiKey, v))
+}
+
+// OpenaiKeyHasPrefix applies the HasPrefix predicate on the "openai_key" field.
+func OpenaiKeyHasPrefix(v string) predicate.Token {
+	return predicate.Token(sql.FieldHasPrefix(FieldOpenaiKey, v))
+}
+
+// OpenaiKeyHasSuffix applies the HasSuffix predicate on the "openai_key" field.
+func OpenaiKeyHasSuffix(v string) predicate.Token {
+	return predicate.Token(sql.FieldHasSuffix(FieldOpenaiKey, v))
+}
+
+// OpenaiKeyIsNil applies the IsNil predicate on the "openai_key" field.
+func OpenaiKeyIsNil() predicate.Token {
+	return predicate.Token(sql.FieldIsNull(FieldOpenaiKey))
+}
+
+// OpenaiKeyNotNil applies the NotNil predicate on the "openai_key" field.
+func OpenaiKeyNotNil() predicate.Token {
+	return predicate.Token(sql.FieldNotNull(FieldOpenaiKey))
+}
+
+// OpenaiKeyEqualFold applies the EqualFold predicate on the "openai_key" field.
+func OpenaiKeyEqualFold(v string) predicate.Token {
+	return predicate.Token(sql.FieldEqualFold(FieldOpenaiKey, v))
+}
+
+// OpenaiKeyContainsFold applies the ContainsFold predicate on the "openai_key" field.
+func OpenaiKeyContainsFold(v string) predicate.Token {
+	return predicate.Token(sql.FieldContainsFold(FieldOpenaiKey, v))
+}
+
 // And groups predicates with the AND operator between them.
 func And(predicates ...predicate.Token) predicate.Token {
 	return predicate.Token(sql.AndPredicates(predicates...))

+ 413 - 0
ent/token_create.go

@@ -120,6 +120,76 @@ func (tc *TokenCreate) SetNillableOrganizationID(u *uint64) *TokenCreate {
 	return tc
 }
 
+// SetAgentID sets the "agent_id" field.
+func (tc *TokenCreate) SetAgentID(u uint64) *TokenCreate {
+	tc.mutation.SetAgentID(u)
+	return tc
+}
+
+// SetNillableAgentID sets the "agent_id" field if the given value is not nil.
+func (tc *TokenCreate) SetNillableAgentID(u *uint64) *TokenCreate {
+	if u != nil {
+		tc.SetAgentID(*u)
+	}
+	return tc
+}
+
+// SetCustomAgentBase sets the "custom_agent_base" field.
+func (tc *TokenCreate) SetCustomAgentBase(s string) *TokenCreate {
+	tc.mutation.SetCustomAgentBase(s)
+	return tc
+}
+
+// SetNillableCustomAgentBase sets the "custom_agent_base" field if the given value is not nil.
+func (tc *TokenCreate) SetNillableCustomAgentBase(s *string) *TokenCreate {
+	if s != nil {
+		tc.SetCustomAgentBase(*s)
+	}
+	return tc
+}
+
+// SetCustomAgentKey sets the "custom_agent_key" field.
+func (tc *TokenCreate) SetCustomAgentKey(s string) *TokenCreate {
+	tc.mutation.SetCustomAgentKey(s)
+	return tc
+}
+
+// SetNillableCustomAgentKey sets the "custom_agent_key" field if the given value is not nil.
+func (tc *TokenCreate) SetNillableCustomAgentKey(s *string) *TokenCreate {
+	if s != nil {
+		tc.SetCustomAgentKey(*s)
+	}
+	return tc
+}
+
+// SetOpenaiBase sets the "openai_base" field.
+func (tc *TokenCreate) SetOpenaiBase(s string) *TokenCreate {
+	tc.mutation.SetOpenaiBase(s)
+	return tc
+}
+
+// SetNillableOpenaiBase sets the "openai_base" field if the given value is not nil.
+func (tc *TokenCreate) SetNillableOpenaiBase(s *string) *TokenCreate {
+	if s != nil {
+		tc.SetOpenaiBase(*s)
+	}
+	return tc
+}
+
+// SetOpenaiKey sets the "openai_key" field.
+func (tc *TokenCreate) SetOpenaiKey(s string) *TokenCreate {
+	tc.mutation.SetOpenaiKey(s)
+	return tc
+}
+
+// SetNillableOpenaiKey sets the "openai_key" field if the given value is not nil.
+func (tc *TokenCreate) SetNillableOpenaiKey(s *string) *TokenCreate {
+	if s != nil {
+		tc.SetOpenaiKey(*s)
+	}
+	return tc
+}
+
 // SetID sets the "id" field.
 func (tc *TokenCreate) SetID(u uint64) *TokenCreate {
 	tc.mutation.SetID(u)
@@ -189,6 +259,26 @@ func (tc *TokenCreate) defaults() error {
 		v := token.DefaultOrganizationID
 		tc.mutation.SetOrganizationID(v)
 	}
+	if _, ok := tc.mutation.AgentID(); !ok {
+		v := token.DefaultAgentID
+		tc.mutation.SetAgentID(v)
+	}
+	if _, ok := tc.mutation.CustomAgentBase(); !ok {
+		v := token.DefaultCustomAgentBase
+		tc.mutation.SetCustomAgentBase(v)
+	}
+	if _, ok := tc.mutation.CustomAgentKey(); !ok {
+		v := token.DefaultCustomAgentKey
+		tc.mutation.SetCustomAgentKey(v)
+	}
+	if _, ok := tc.mutation.OpenaiBase(); !ok {
+		v := token.DefaultOpenaiBase
+		tc.mutation.SetOpenaiBase(v)
+	}
+	if _, ok := tc.mutation.OpenaiKey(); !ok {
+		v := token.DefaultOpenaiKey
+		tc.mutation.SetOpenaiKey(v)
+	}
 	return nil
 }
 
@@ -206,6 +296,9 @@ func (tc *TokenCreate) check() error {
 	if _, ok := tc.mutation.OrganizationID(); !ok {
 		return &ValidationError{Name: "organization_id", err: errors.New(`ent: missing required field "Token.organization_id"`)}
 	}
+	if _, ok := tc.mutation.AgentID(); !ok {
+		return &ValidationError{Name: "agent_id", err: errors.New(`ent: missing required field "Token.agent_id"`)}
+	}
 	return nil
 }
 
@@ -267,6 +360,26 @@ func (tc *TokenCreate) createSpec() (*Token, *sqlgraph.CreateSpec) {
 		_spec.SetField(token.FieldOrganizationID, field.TypeUint64, value)
 		_node.OrganizationID = value
 	}
+	if value, ok := tc.mutation.AgentID(); ok {
+		_spec.SetField(token.FieldAgentID, field.TypeUint64, value)
+		_node.AgentID = value
+	}
+	if value, ok := tc.mutation.CustomAgentBase(); ok {
+		_spec.SetField(token.FieldCustomAgentBase, field.TypeString, value)
+		_node.CustomAgentBase = value
+	}
+	if value, ok := tc.mutation.CustomAgentKey(); ok {
+		_spec.SetField(token.FieldCustomAgentKey, field.TypeString, value)
+		_node.CustomAgentKey = value
+	}
+	if value, ok := tc.mutation.OpenaiBase(); ok {
+		_spec.SetField(token.FieldOpenaiBase, field.TypeString, value)
+		_node.OpenaiBase = value
+	}
+	if value, ok := tc.mutation.OpenaiKey(); ok {
+		_spec.SetField(token.FieldOpenaiKey, field.TypeString, value)
+		_node.OpenaiKey = value
+	}
 	return _node, _spec
 }
 
@@ -415,6 +528,96 @@ func (u *TokenUpsert) AddOrganizationID(v uint64) *TokenUpsert {
 	return u
 }
 
+// SetAgentID sets the "agent_id" field.
+func (u *TokenUpsert) SetAgentID(v uint64) *TokenUpsert {
+	u.Set(token.FieldAgentID, v)
+	return u
+}
+
+// UpdateAgentID sets the "agent_id" field to the value that was provided on create.
+func (u *TokenUpsert) UpdateAgentID() *TokenUpsert {
+	u.SetExcluded(token.FieldAgentID)
+	return u
+}
+
+// AddAgentID adds v to the "agent_id" field.
+func (u *TokenUpsert) AddAgentID(v uint64) *TokenUpsert {
+	u.Add(token.FieldAgentID, v)
+	return u
+}
+
+// SetCustomAgentBase sets the "custom_agent_base" field.
+func (u *TokenUpsert) SetCustomAgentBase(v string) *TokenUpsert {
+	u.Set(token.FieldCustomAgentBase, v)
+	return u
+}
+
+// UpdateCustomAgentBase sets the "custom_agent_base" field to the value that was provided on create.
+func (u *TokenUpsert) UpdateCustomAgentBase() *TokenUpsert {
+	u.SetExcluded(token.FieldCustomAgentBase)
+	return u
+}
+
+// ClearCustomAgentBase clears the value of the "custom_agent_base" field.
+func (u *TokenUpsert) ClearCustomAgentBase() *TokenUpsert {
+	u.SetNull(token.FieldCustomAgentBase)
+	return u
+}
+
+// SetCustomAgentKey sets the "custom_agent_key" field.
+func (u *TokenUpsert) SetCustomAgentKey(v string) *TokenUpsert {
+	u.Set(token.FieldCustomAgentKey, v)
+	return u
+}
+
+// UpdateCustomAgentKey sets the "custom_agent_key" field to the value that was provided on create.
+func (u *TokenUpsert) UpdateCustomAgentKey() *TokenUpsert {
+	u.SetExcluded(token.FieldCustomAgentKey)
+	return u
+}
+
+// ClearCustomAgentKey clears the value of the "custom_agent_key" field.
+func (u *TokenUpsert) ClearCustomAgentKey() *TokenUpsert {
+	u.SetNull(token.FieldCustomAgentKey)
+	return u
+}
+
+// SetOpenaiBase sets the "openai_base" field.
+func (u *TokenUpsert) SetOpenaiBase(v string) *TokenUpsert {
+	u.Set(token.FieldOpenaiBase, v)
+	return u
+}
+
+// UpdateOpenaiBase sets the "openai_base" field to the value that was provided on create.
+func (u *TokenUpsert) UpdateOpenaiBase() *TokenUpsert {
+	u.SetExcluded(token.FieldOpenaiBase)
+	return u
+}
+
+// ClearOpenaiBase clears the value of the "openai_base" field.
+func (u *TokenUpsert) ClearOpenaiBase() *TokenUpsert {
+	u.SetNull(token.FieldOpenaiBase)
+	return u
+}
+
+// SetOpenaiKey sets the "openai_key" field.
+func (u *TokenUpsert) SetOpenaiKey(v string) *TokenUpsert {
+	u.Set(token.FieldOpenaiKey, v)
+	return u
+}
+
+// UpdateOpenaiKey sets the "openai_key" field to the value that was provided on create.
+func (u *TokenUpsert) UpdateOpenaiKey() *TokenUpsert {
+	u.SetExcluded(token.FieldOpenaiKey)
+	return u
+}
+
+// ClearOpenaiKey clears the value of the "openai_key" field.
+func (u *TokenUpsert) ClearOpenaiKey() *TokenUpsert {
+	u.SetNull(token.FieldOpenaiKey)
+	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:
 //
@@ -578,6 +781,111 @@ func (u *TokenUpsertOne) UpdateOrganizationID() *TokenUpsertOne {
 	})
 }
 
+// SetAgentID sets the "agent_id" field.
+func (u *TokenUpsertOne) SetAgentID(v uint64) *TokenUpsertOne {
+	return u.Update(func(s *TokenUpsert) {
+		s.SetAgentID(v)
+	})
+}
+
+// AddAgentID adds v to the "agent_id" field.
+func (u *TokenUpsertOne) AddAgentID(v uint64) *TokenUpsertOne {
+	return u.Update(func(s *TokenUpsert) {
+		s.AddAgentID(v)
+	})
+}
+
+// UpdateAgentID sets the "agent_id" field to the value that was provided on create.
+func (u *TokenUpsertOne) UpdateAgentID() *TokenUpsertOne {
+	return u.Update(func(s *TokenUpsert) {
+		s.UpdateAgentID()
+	})
+}
+
+// SetCustomAgentBase sets the "custom_agent_base" field.
+func (u *TokenUpsertOne) SetCustomAgentBase(v string) *TokenUpsertOne {
+	return u.Update(func(s *TokenUpsert) {
+		s.SetCustomAgentBase(v)
+	})
+}
+
+// UpdateCustomAgentBase sets the "custom_agent_base" field to the value that was provided on create.
+func (u *TokenUpsertOne) UpdateCustomAgentBase() *TokenUpsertOne {
+	return u.Update(func(s *TokenUpsert) {
+		s.UpdateCustomAgentBase()
+	})
+}
+
+// ClearCustomAgentBase clears the value of the "custom_agent_base" field.
+func (u *TokenUpsertOne) ClearCustomAgentBase() *TokenUpsertOne {
+	return u.Update(func(s *TokenUpsert) {
+		s.ClearCustomAgentBase()
+	})
+}
+
+// SetCustomAgentKey sets the "custom_agent_key" field.
+func (u *TokenUpsertOne) SetCustomAgentKey(v string) *TokenUpsertOne {
+	return u.Update(func(s *TokenUpsert) {
+		s.SetCustomAgentKey(v)
+	})
+}
+
+// UpdateCustomAgentKey sets the "custom_agent_key" field to the value that was provided on create.
+func (u *TokenUpsertOne) UpdateCustomAgentKey() *TokenUpsertOne {
+	return u.Update(func(s *TokenUpsert) {
+		s.UpdateCustomAgentKey()
+	})
+}
+
+// ClearCustomAgentKey clears the value of the "custom_agent_key" field.
+func (u *TokenUpsertOne) ClearCustomAgentKey() *TokenUpsertOne {
+	return u.Update(func(s *TokenUpsert) {
+		s.ClearCustomAgentKey()
+	})
+}
+
+// SetOpenaiBase sets the "openai_base" field.
+func (u *TokenUpsertOne) SetOpenaiBase(v string) *TokenUpsertOne {
+	return u.Update(func(s *TokenUpsert) {
+		s.SetOpenaiBase(v)
+	})
+}
+
+// UpdateOpenaiBase sets the "openai_base" field to the value that was provided on create.
+func (u *TokenUpsertOne) UpdateOpenaiBase() *TokenUpsertOne {
+	return u.Update(func(s *TokenUpsert) {
+		s.UpdateOpenaiBase()
+	})
+}
+
+// ClearOpenaiBase clears the value of the "openai_base" field.
+func (u *TokenUpsertOne) ClearOpenaiBase() *TokenUpsertOne {
+	return u.Update(func(s *TokenUpsert) {
+		s.ClearOpenaiBase()
+	})
+}
+
+// SetOpenaiKey sets the "openai_key" field.
+func (u *TokenUpsertOne) SetOpenaiKey(v string) *TokenUpsertOne {
+	return u.Update(func(s *TokenUpsert) {
+		s.SetOpenaiKey(v)
+	})
+}
+
+// UpdateOpenaiKey sets the "openai_key" field to the value that was provided on create.
+func (u *TokenUpsertOne) UpdateOpenaiKey() *TokenUpsertOne {
+	return u.Update(func(s *TokenUpsert) {
+		s.UpdateOpenaiKey()
+	})
+}
+
+// ClearOpenaiKey clears the value of the "openai_key" field.
+func (u *TokenUpsertOne) ClearOpenaiKey() *TokenUpsertOne {
+	return u.Update(func(s *TokenUpsert) {
+		s.ClearOpenaiKey()
+	})
+}
+
 // Exec executes the query.
 func (u *TokenUpsertOne) Exec(ctx context.Context) error {
 	if len(u.create.conflict) == 0 {
@@ -907,6 +1215,111 @@ func (u *TokenUpsertBulk) UpdateOrganizationID() *TokenUpsertBulk {
 	})
 }
 
+// SetAgentID sets the "agent_id" field.
+func (u *TokenUpsertBulk) SetAgentID(v uint64) *TokenUpsertBulk {
+	return u.Update(func(s *TokenUpsert) {
+		s.SetAgentID(v)
+	})
+}
+
+// AddAgentID adds v to the "agent_id" field.
+func (u *TokenUpsertBulk) AddAgentID(v uint64) *TokenUpsertBulk {
+	return u.Update(func(s *TokenUpsert) {
+		s.AddAgentID(v)
+	})
+}
+
+// UpdateAgentID sets the "agent_id" field to the value that was provided on create.
+func (u *TokenUpsertBulk) UpdateAgentID() *TokenUpsertBulk {
+	return u.Update(func(s *TokenUpsert) {
+		s.UpdateAgentID()
+	})
+}
+
+// SetCustomAgentBase sets the "custom_agent_base" field.
+func (u *TokenUpsertBulk) SetCustomAgentBase(v string) *TokenUpsertBulk {
+	return u.Update(func(s *TokenUpsert) {
+		s.SetCustomAgentBase(v)
+	})
+}
+
+// UpdateCustomAgentBase sets the "custom_agent_base" field to the value that was provided on create.
+func (u *TokenUpsertBulk) UpdateCustomAgentBase() *TokenUpsertBulk {
+	return u.Update(func(s *TokenUpsert) {
+		s.UpdateCustomAgentBase()
+	})
+}
+
+// ClearCustomAgentBase clears the value of the "custom_agent_base" field.
+func (u *TokenUpsertBulk) ClearCustomAgentBase() *TokenUpsertBulk {
+	return u.Update(func(s *TokenUpsert) {
+		s.ClearCustomAgentBase()
+	})
+}
+
+// SetCustomAgentKey sets the "custom_agent_key" field.
+func (u *TokenUpsertBulk) SetCustomAgentKey(v string) *TokenUpsertBulk {
+	return u.Update(func(s *TokenUpsert) {
+		s.SetCustomAgentKey(v)
+	})
+}
+
+// UpdateCustomAgentKey sets the "custom_agent_key" field to the value that was provided on create.
+func (u *TokenUpsertBulk) UpdateCustomAgentKey() *TokenUpsertBulk {
+	return u.Update(func(s *TokenUpsert) {
+		s.UpdateCustomAgentKey()
+	})
+}
+
+// ClearCustomAgentKey clears the value of the "custom_agent_key" field.
+func (u *TokenUpsertBulk) ClearCustomAgentKey() *TokenUpsertBulk {
+	return u.Update(func(s *TokenUpsert) {
+		s.ClearCustomAgentKey()
+	})
+}
+
+// SetOpenaiBase sets the "openai_base" field.
+func (u *TokenUpsertBulk) SetOpenaiBase(v string) *TokenUpsertBulk {
+	return u.Update(func(s *TokenUpsert) {
+		s.SetOpenaiBase(v)
+	})
+}
+
+// UpdateOpenaiBase sets the "openai_base" field to the value that was provided on create.
+func (u *TokenUpsertBulk) UpdateOpenaiBase() *TokenUpsertBulk {
+	return u.Update(func(s *TokenUpsert) {
+		s.UpdateOpenaiBase()
+	})
+}
+
+// ClearOpenaiBase clears the value of the "openai_base" field.
+func (u *TokenUpsertBulk) ClearOpenaiBase() *TokenUpsertBulk {
+	return u.Update(func(s *TokenUpsert) {
+		s.ClearOpenaiBase()
+	})
+}
+
+// SetOpenaiKey sets the "openai_key" field.
+func (u *TokenUpsertBulk) SetOpenaiKey(v string) *TokenUpsertBulk {
+	return u.Update(func(s *TokenUpsert) {
+		s.SetOpenaiKey(v)
+	})
+}
+
+// UpdateOpenaiKey sets the "openai_key" field to the value that was provided on create.
+func (u *TokenUpsertBulk) UpdateOpenaiKey() *TokenUpsertBulk {
+	return u.Update(func(s *TokenUpsert) {
+		s.UpdateOpenaiKey()
+	})
+}
+
+// ClearOpenaiKey clears the value of the "openai_key" field.
+func (u *TokenUpsertBulk) ClearOpenaiKey() *TokenUpsertBulk {
+	return u.Update(func(s *TokenUpsert) {
+		s.ClearOpenaiKey()
+	})
+}
+
 // Exec executes the query.
 func (u *TokenUpsertBulk) Exec(ctx context.Context) error {
 	if u.create.err != nil {

+ 262 - 0
ent/token_update.go

@@ -129,6 +129,107 @@ func (tu *TokenUpdate) AddOrganizationID(u int64) *TokenUpdate {
 	return tu
 }
 
+// SetAgentID sets the "agent_id" field.
+func (tu *TokenUpdate) SetAgentID(u uint64) *TokenUpdate {
+	tu.mutation.ResetAgentID()
+	tu.mutation.SetAgentID(u)
+	return tu
+}
+
+// SetNillableAgentID sets the "agent_id" field if the given value is not nil.
+func (tu *TokenUpdate) SetNillableAgentID(u *uint64) *TokenUpdate {
+	if u != nil {
+		tu.SetAgentID(*u)
+	}
+	return tu
+}
+
+// AddAgentID adds u to the "agent_id" field.
+func (tu *TokenUpdate) AddAgentID(u int64) *TokenUpdate {
+	tu.mutation.AddAgentID(u)
+	return tu
+}
+
+// SetCustomAgentBase sets the "custom_agent_base" field.
+func (tu *TokenUpdate) SetCustomAgentBase(s string) *TokenUpdate {
+	tu.mutation.SetCustomAgentBase(s)
+	return tu
+}
+
+// SetNillableCustomAgentBase sets the "custom_agent_base" field if the given value is not nil.
+func (tu *TokenUpdate) SetNillableCustomAgentBase(s *string) *TokenUpdate {
+	if s != nil {
+		tu.SetCustomAgentBase(*s)
+	}
+	return tu
+}
+
+// ClearCustomAgentBase clears the value of the "custom_agent_base" field.
+func (tu *TokenUpdate) ClearCustomAgentBase() *TokenUpdate {
+	tu.mutation.ClearCustomAgentBase()
+	return tu
+}
+
+// SetCustomAgentKey sets the "custom_agent_key" field.
+func (tu *TokenUpdate) SetCustomAgentKey(s string) *TokenUpdate {
+	tu.mutation.SetCustomAgentKey(s)
+	return tu
+}
+
+// SetNillableCustomAgentKey sets the "custom_agent_key" field if the given value is not nil.
+func (tu *TokenUpdate) SetNillableCustomAgentKey(s *string) *TokenUpdate {
+	if s != nil {
+		tu.SetCustomAgentKey(*s)
+	}
+	return tu
+}
+
+// ClearCustomAgentKey clears the value of the "custom_agent_key" field.
+func (tu *TokenUpdate) ClearCustomAgentKey() *TokenUpdate {
+	tu.mutation.ClearCustomAgentKey()
+	return tu
+}
+
+// SetOpenaiBase sets the "openai_base" field.
+func (tu *TokenUpdate) SetOpenaiBase(s string) *TokenUpdate {
+	tu.mutation.SetOpenaiBase(s)
+	return tu
+}
+
+// SetNillableOpenaiBase sets the "openai_base" field if the given value is not nil.
+func (tu *TokenUpdate) SetNillableOpenaiBase(s *string) *TokenUpdate {
+	if s != nil {
+		tu.SetOpenaiBase(*s)
+	}
+	return tu
+}
+
+// ClearOpenaiBase clears the value of the "openai_base" field.
+func (tu *TokenUpdate) ClearOpenaiBase() *TokenUpdate {
+	tu.mutation.ClearOpenaiBase()
+	return tu
+}
+
+// SetOpenaiKey sets the "openai_key" field.
+func (tu *TokenUpdate) SetOpenaiKey(s string) *TokenUpdate {
+	tu.mutation.SetOpenaiKey(s)
+	return tu
+}
+
+// SetNillableOpenaiKey sets the "openai_key" field if the given value is not nil.
+func (tu *TokenUpdate) SetNillableOpenaiKey(s *string) *TokenUpdate {
+	if s != nil {
+		tu.SetOpenaiKey(*s)
+	}
+	return tu
+}
+
+// ClearOpenaiKey clears the value of the "openai_key" field.
+func (tu *TokenUpdate) ClearOpenaiKey() *TokenUpdate {
+	tu.mutation.ClearOpenaiKey()
+	return tu
+}
+
 // Mutation returns the TokenMutation object of the builder.
 func (tu *TokenUpdate) Mutation() *TokenMutation {
 	return tu.mutation
@@ -215,6 +316,36 @@ func (tu *TokenUpdate) sqlSave(ctx context.Context) (n int, err error) {
 	if value, ok := tu.mutation.AddedOrganizationID(); ok {
 		_spec.AddField(token.FieldOrganizationID, field.TypeUint64, value)
 	}
+	if value, ok := tu.mutation.AgentID(); ok {
+		_spec.SetField(token.FieldAgentID, field.TypeUint64, value)
+	}
+	if value, ok := tu.mutation.AddedAgentID(); ok {
+		_spec.AddField(token.FieldAgentID, field.TypeUint64, value)
+	}
+	if value, ok := tu.mutation.CustomAgentBase(); ok {
+		_spec.SetField(token.FieldCustomAgentBase, field.TypeString, value)
+	}
+	if tu.mutation.CustomAgentBaseCleared() {
+		_spec.ClearField(token.FieldCustomAgentBase, field.TypeString)
+	}
+	if value, ok := tu.mutation.CustomAgentKey(); ok {
+		_spec.SetField(token.FieldCustomAgentKey, field.TypeString, value)
+	}
+	if tu.mutation.CustomAgentKeyCleared() {
+		_spec.ClearField(token.FieldCustomAgentKey, field.TypeString)
+	}
+	if value, ok := tu.mutation.OpenaiBase(); ok {
+		_spec.SetField(token.FieldOpenaiBase, field.TypeString, value)
+	}
+	if tu.mutation.OpenaiBaseCleared() {
+		_spec.ClearField(token.FieldOpenaiBase, field.TypeString)
+	}
+	if value, ok := tu.mutation.OpenaiKey(); ok {
+		_spec.SetField(token.FieldOpenaiKey, field.TypeString, value)
+	}
+	if tu.mutation.OpenaiKeyCleared() {
+		_spec.ClearField(token.FieldOpenaiKey, field.TypeString)
+	}
 	if n, err = sqlgraph.UpdateNodes(ctx, tu.driver, _spec); err != nil {
 		if _, ok := err.(*sqlgraph.NotFoundError); ok {
 			err = &NotFoundError{token.Label}
@@ -336,6 +467,107 @@ func (tuo *TokenUpdateOne) AddOrganizationID(u int64) *TokenUpdateOne {
 	return tuo
 }
 
+// SetAgentID sets the "agent_id" field.
+func (tuo *TokenUpdateOne) SetAgentID(u uint64) *TokenUpdateOne {
+	tuo.mutation.ResetAgentID()
+	tuo.mutation.SetAgentID(u)
+	return tuo
+}
+
+// SetNillableAgentID sets the "agent_id" field if the given value is not nil.
+func (tuo *TokenUpdateOne) SetNillableAgentID(u *uint64) *TokenUpdateOne {
+	if u != nil {
+		tuo.SetAgentID(*u)
+	}
+	return tuo
+}
+
+// AddAgentID adds u to the "agent_id" field.
+func (tuo *TokenUpdateOne) AddAgentID(u int64) *TokenUpdateOne {
+	tuo.mutation.AddAgentID(u)
+	return tuo
+}
+
+// SetCustomAgentBase sets the "custom_agent_base" field.
+func (tuo *TokenUpdateOne) SetCustomAgentBase(s string) *TokenUpdateOne {
+	tuo.mutation.SetCustomAgentBase(s)
+	return tuo
+}
+
+// SetNillableCustomAgentBase sets the "custom_agent_base" field if the given value is not nil.
+func (tuo *TokenUpdateOne) SetNillableCustomAgentBase(s *string) *TokenUpdateOne {
+	if s != nil {
+		tuo.SetCustomAgentBase(*s)
+	}
+	return tuo
+}
+
+// ClearCustomAgentBase clears the value of the "custom_agent_base" field.
+func (tuo *TokenUpdateOne) ClearCustomAgentBase() *TokenUpdateOne {
+	tuo.mutation.ClearCustomAgentBase()
+	return tuo
+}
+
+// SetCustomAgentKey sets the "custom_agent_key" field.
+func (tuo *TokenUpdateOne) SetCustomAgentKey(s string) *TokenUpdateOne {
+	tuo.mutation.SetCustomAgentKey(s)
+	return tuo
+}
+
+// SetNillableCustomAgentKey sets the "custom_agent_key" field if the given value is not nil.
+func (tuo *TokenUpdateOne) SetNillableCustomAgentKey(s *string) *TokenUpdateOne {
+	if s != nil {
+		tuo.SetCustomAgentKey(*s)
+	}
+	return tuo
+}
+
+// ClearCustomAgentKey clears the value of the "custom_agent_key" field.
+func (tuo *TokenUpdateOne) ClearCustomAgentKey() *TokenUpdateOne {
+	tuo.mutation.ClearCustomAgentKey()
+	return tuo
+}
+
+// SetOpenaiBase sets the "openai_base" field.
+func (tuo *TokenUpdateOne) SetOpenaiBase(s string) *TokenUpdateOne {
+	tuo.mutation.SetOpenaiBase(s)
+	return tuo
+}
+
+// SetNillableOpenaiBase sets the "openai_base" field if the given value is not nil.
+func (tuo *TokenUpdateOne) SetNillableOpenaiBase(s *string) *TokenUpdateOne {
+	if s != nil {
+		tuo.SetOpenaiBase(*s)
+	}
+	return tuo
+}
+
+// ClearOpenaiBase clears the value of the "openai_base" field.
+func (tuo *TokenUpdateOne) ClearOpenaiBase() *TokenUpdateOne {
+	tuo.mutation.ClearOpenaiBase()
+	return tuo
+}
+
+// SetOpenaiKey sets the "openai_key" field.
+func (tuo *TokenUpdateOne) SetOpenaiKey(s string) *TokenUpdateOne {
+	tuo.mutation.SetOpenaiKey(s)
+	return tuo
+}
+
+// SetNillableOpenaiKey sets the "openai_key" field if the given value is not nil.
+func (tuo *TokenUpdateOne) SetNillableOpenaiKey(s *string) *TokenUpdateOne {
+	if s != nil {
+		tuo.SetOpenaiKey(*s)
+	}
+	return tuo
+}
+
+// ClearOpenaiKey clears the value of the "openai_key" field.
+func (tuo *TokenUpdateOne) ClearOpenaiKey() *TokenUpdateOne {
+	tuo.mutation.ClearOpenaiKey()
+	return tuo
+}
+
 // Mutation returns the TokenMutation object of the builder.
 func (tuo *TokenUpdateOne) Mutation() *TokenMutation {
 	return tuo.mutation
@@ -452,6 +684,36 @@ func (tuo *TokenUpdateOne) sqlSave(ctx context.Context) (_node *Token, err error
 	if value, ok := tuo.mutation.AddedOrganizationID(); ok {
 		_spec.AddField(token.FieldOrganizationID, field.TypeUint64, value)
 	}
+	if value, ok := tuo.mutation.AgentID(); ok {
+		_spec.SetField(token.FieldAgentID, field.TypeUint64, value)
+	}
+	if value, ok := tuo.mutation.AddedAgentID(); ok {
+		_spec.AddField(token.FieldAgentID, field.TypeUint64, value)
+	}
+	if value, ok := tuo.mutation.CustomAgentBase(); ok {
+		_spec.SetField(token.FieldCustomAgentBase, field.TypeString, value)
+	}
+	if tuo.mutation.CustomAgentBaseCleared() {
+		_spec.ClearField(token.FieldCustomAgentBase, field.TypeString)
+	}
+	if value, ok := tuo.mutation.CustomAgentKey(); ok {
+		_spec.SetField(token.FieldCustomAgentKey, field.TypeString, value)
+	}
+	if tuo.mutation.CustomAgentKeyCleared() {
+		_spec.ClearField(token.FieldCustomAgentKey, field.TypeString)
+	}
+	if value, ok := tuo.mutation.OpenaiBase(); ok {
+		_spec.SetField(token.FieldOpenaiBase, field.TypeString, value)
+	}
+	if tuo.mutation.OpenaiBaseCleared() {
+		_spec.ClearField(token.FieldOpenaiBase, field.TypeString)
+	}
+	if value, ok := tuo.mutation.OpenaiKey(); ok {
+		_spec.SetField(token.FieldOpenaiKey, field.TypeString, value)
+	}
+	if tuo.mutation.OpenaiKeyCleared() {
+		_spec.ClearField(token.FieldOpenaiKey, field.TypeString)
+	}
 	_node = &Token{config: tuo.config}
 	_spec.Assign = _node.assignValues
 	_spec.ScanValues = _node.scanValues

+ 15 - 4
etc/wechat-docker.yaml

@@ -6,7 +6,7 @@ Timeout: 30000
 Mode: "dev"
 
 Auth:
-  AccessSecret: jS6VKDtsJf3z1n2VKDtsJf3z1n2
+  AccessSecret: LnQD46hBde0AgFXBer8ZZZe3FgC
   AccessExpire: 259200
 
 CROSConf:
@@ -25,7 +25,7 @@ Log:
 
 DatabaseConf:
   Type: mysql
-  Host: mysql-server
+  Host: scrm-mysql
   Port: 3306
   DBName: wechat
   Username: root
@@ -41,11 +41,11 @@ CoreRpc:
   Enabled: true
 
 RedisConf:
-  Host: redis-server:6379
+  Host: scrm-redis:6379
 
 CasbinDatabaseConf:
   Type: mysql
-  Host: mysql-server
+  Host: scrm-mysql
   Port: 3306
   DBName: wechat-admin
   Username: root
@@ -66,3 +66,14 @@ CasbinConf:
     e = some(where (p.eft == allow))
     [matchers]
     m = r.sub == p.sub && keyMatch2(r.obj,p.obj) && r.act == p.act
+
+Miniprogram:
+  Appid: wx1452f34bba8fe718
+  Secret: 171fdab212fdde0d51b59fa59c9ee070
+  redisaddr: scrm-redis:6379
+
+Aliyun:
+  ACCESS_KEY_ID: LTAI5tSJwCQyuaxXR3UxfnWw
+  ACCESS_KEY_SECRET: 0pv4xhSPJv9IPSxrkB52FspJk27W7V
+  OSS_ENDPOINT: sts.cn-beijing.aliyuncs.com
+  OSS_ROLEARN: acs:ram::1317798064750399:role/ramoss

+ 1 - 1
etc/wechat.yaml

@@ -6,7 +6,7 @@ Timeout: 30000
 Mode: "dev"
 
 Auth:
-  AccessSecret: jS6VKDtsJf3z1n2VKDtsJf3z1n2
+  AccessSecret: LnQD46hBde0AgFXBer8ZZZe3FgC
   AccessExpire: 259200
 
 CROSConf:

+ 47 - 3
internal/logic/token/check_token_logic.go

@@ -8,6 +8,7 @@ import (
 	"strconv"
 	"time"
 	"wechat-api/ent"
+	"wechat-api/ent/agent"
 	"wechat-api/ent/token"
 	"wechat-api/internal/utils/dberrorhandler"
 
@@ -42,6 +43,11 @@ func (l *CheckTokenLogic) CheckToken(req *types.CheckTokenReq) (resp *types.Chec
 		return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
 	}
 
+	var agentInfo types.AgentInfo
+	var customAgentBase string
+	var customAgentKey string
+	var openaiBase string
+	var openaiKey string
 	if tokenItem == nil { // 判断Token是否存在
 		valid = false
 	} else if tokenItem.ExpireAt.Unix() > timestamp { // 判断Token是否过期
@@ -62,10 +68,48 @@ func (l *CheckTokenLogic) CheckToken(req *types.CheckTokenReq) (resp *types.Chec
 		}
 	}
 
+	if valid {
+		customAgentBase = tokenItem.CustomAgentBase
+		customAgentKey = tokenItem.CustomAgentKey
+		openaiBase = tokenItem.OpenaiBase
+		openaiKey = tokenItem.OpenaiKey
+		if tokenItem.AgentID == 0 {
+			agentInfo = types.AgentInfo{
+				BaseIDInfo: types.BaseIDInfo{
+					Id: &tokenItem.AgentID,
+				},
+			}
+		} else {
+			data, _ := l.svcCtx.DB.Agent.Query().Where(agent.ID(tokenItem.AgentID), agent.OrganizationID(tokenItem.OrganizationID)).First(l.ctx)
+			if data != nil {
+				agentInfo = types.AgentInfo{
+					BaseIDInfo: types.BaseIDInfo{
+						Id: &data.ID,
+					},
+					Name:         &data.Name,
+					Role:         &data.Role,
+					Background:   &data.Background,
+					Examples:     &data.Examples,
+					DatasetId:    &data.DatasetID,
+					CollectionId: &data.CollectionID,
+				}
+			}
+		}
+
+	}
+	datasetBase := "https://fastgpt.gkscrm.com/api/core/dataset/searchTest"
+	datasetKey := "fastgpt-czbAiqKKse65hwwviZhwkgvyDEKE3aeB31Fx18oUsAGojyWQ672HdsWZi1E1C"
 	return &types.CheckTokenResp{
-		Valid:     &valid,
-		Sign:      &sign,
-		Timestamp: &timestamp,
+		Valid:           &valid,
+		Sign:            &sign,
+		Timestamp:       &timestamp,
+		AgentInfo:       &agentInfo,
+		CustomAgentBase: &customAgentBase,
+		CustomAgentKey:  &customAgentKey,
+		OpenaiBase:      &openaiBase,
+		OpenaiKey:       &openaiKey,
+		DatasetBase:     &datasetBase,
+		DatasetKey:      &datasetKey,
 	}, nil
 }
 

+ 8 - 1
internal/types/types.go

@@ -2067,7 +2067,14 @@ type CheckTokenResp struct {
 	// Sign 签名内容
 	Sign *string `json:"sign"`
 	// Timestamp 时间戳
-	Timestamp *int64 `json:"timestamp"`
+	Timestamp       *int64     `json:"timestamp"`
+	AgentInfo       *AgentInfo `json:"agent_info"`
+	CustomAgentBase *string    `json:"custom_agent_base"`
+	CustomAgentKey  *string    `json:"custom_agent_key"`
+	OpenaiBase      *string    `json:"openai_base"`
+	OpenaiKey       *string    `json:"openai_key"`
+	DatasetBase     *string    `json:"dataset_base"`
+	DatasetKey      *string    `json:"dataset_key"`
 }
 
 // The data of category information | Category信息