Browse Source

调整AI角色名称字数限制

boweniac 7 months ago
parent
commit
dbc4af1122
5 changed files with 20 additions and 4 deletions
  1. 4 0
      ent/agent/agent.go
  2. 8 0
      ent/agent_create.go
  3. 3 3
      ent/migrate/schema.go
  4. 4 0
      ent/runtime/runtime.go
  5. 1 1
      ent/schema/agent.go

+ 4 - 0
ent/agent/agent.go

@@ -92,8 +92,12 @@ var (
 	DefaultStatus int
 	// StatusValidator is a validator for the "status" field. It is called by the builders before save.
 	StatusValidator func(int) error
+	// DefaultBackground holds the default value on creation for the "background" field.
+	DefaultBackground string
 	// BackgroundValidator is a validator for the "background" field. It is called by the builders before save.
 	BackgroundValidator func(string) error
+	// DefaultExamples holds the default value on creation for the "examples" field.
+	DefaultExamples string
 	// ExamplesValidator is a validator for the "examples" field. It is called by the builders before save.
 	ExamplesValidator func(string) error
 	// OrganizationIDValidator is a validator for the "organization_id" field. It is called by the builders before save.

+ 8 - 0
ent/agent_create.go

@@ -201,6 +201,14 @@ func (ac *AgentCreate) defaults() error {
 		v := agent.DefaultStatus
 		ac.mutation.SetStatus(v)
 	}
+	if _, ok := ac.mutation.Background(); !ok {
+		v := agent.DefaultBackground
+		ac.mutation.SetBackground(v)
+	}
+	if _, ok := ac.mutation.Examples(); !ok {
+		v := agent.DefaultExamples
+		ac.mutation.SetExamples(v)
+	}
 	return nil
 }
 

+ 3 - 3
ent/migrate/schema.go

@@ -15,11 +15,11 @@ var (
 		{Name: "created_at", Type: field.TypeTime, Comment: "Create Time | 创建日期"},
 		{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: 20, Comment: "name | 角色名称"},
+		{Name: "name", Type: field.TypeString, Size: 255, Comment: "name | 角色名称"},
 		{Name: "role", Type: field.TypeString, Size: 1000, Comment: "role | 角色设定"},
 		{Name: "status", Type: field.TypeInt, Nullable: true, Comment: "status | 状态 1-正常 2-禁用", Default: 1},
-		{Name: "background", Type: field.TypeString, Nullable: true, Size: 1000, Comment: "background | 背景介绍"},
-		{Name: "examples", Type: field.TypeString, Nullable: true, Size: 5000, Comment: "examples | 对话案例"},
+		{Name: "background", Type: field.TypeString, Nullable: true, Size: 1000, Comment: "background | 背景介绍", Default: ""},
+		{Name: "examples", Type: field.TypeString, Nullable: true, Size: 5000, Comment: "examples | 对话案例", Default: ""},
 		{Name: "organization_id", Type: field.TypeUint64, Comment: "organization_id | 租户ID"},
 	}
 	// AgentTable holds the schema information for the "agent" table.

+ 4 - 0
ent/runtime/runtime.go

@@ -59,10 +59,14 @@ func init() {
 	agent.StatusValidator = agentDescStatus.Validators[0].(func(int) error)
 	// agentDescBackground is the schema descriptor for background field.
 	agentDescBackground := agentFields[3].Descriptor()
+	// agent.DefaultBackground holds the default value on creation for the background field.
+	agent.DefaultBackground = agentDescBackground.Default.(string)
 	// agent.BackgroundValidator is a validator for the "background" field. It is called by the builders before save.
 	agent.BackgroundValidator = agentDescBackground.Validators[0].(func(string) error)
 	// agentDescExamples is the schema descriptor for examples field.
 	agentDescExamples := agentFields[4].Descriptor()
+	// agent.DefaultExamples holds the default value on creation for the examples field.
+	agent.DefaultExamples = agentDescExamples.Default.(string)
 	// agent.ExamplesValidator is a validator for the "examples" field. It is called by the builders before save.
 	agent.ExamplesValidator = agentDescExamples.Validators[0].(func(string) error)
 	// agentDescOrganizationID is the schema descriptor for organization_id field.

+ 1 - 1
ent/schema/agent.go

@@ -18,7 +18,7 @@ type Agent struct {
 
 func (Agent) Fields() []ent.Field {
 	return []ent.Field{
-		field.String("name").MaxLen(20).Comment("name | 角色名称"),
+		field.String("name").MaxLen(255).Comment("name | 角色名称"),
 		field.String("role").MaxLen(1000).Comment("role | 角色设定"),
 		field.Int("status").Optional().Range(1, 2).Default(1).Comment("status | 状态 1-正常 2-禁用"),
 		field.String("background").Optional().Default("").MaxLen(1000).Comment("background | 背景介绍"),