Explorar o código

1.全流程去掉workId 2.解决访问fastgpt api出错但err依然为nil的问题,通过api返回值结构增加新成员来捕获 3.API请求的异步模式全流程实现(下任务及cron中并发处理

liwei hai 1 mes
pai
achega
c44e1029d3

+ 411 - 0
crontask/compapi_callback.go

@@ -0,0 +1,411 @@
+package crontask
+
+import (
+	"bytes"
+	"encoding/json"
+	"errors"
+	"fmt"
+	"hash/fnv"
+	"runtime"
+	"strconv"
+	"sync"
+	"sync/atomic"
+	"time"
+	"wechat-api/ent"
+	"wechat-api/ent/compapiasynctask"
+	"wechat-api/ent/predicate"
+	"wechat-api/internal/types"
+	"wechat-api/internal/utils/compapi"
+
+	"github.com/openai/openai-go/option"
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+const (
+	Task_Ready    = 10 //任务就绪
+	ReqApi_Done   = 20 //请求API完成
+	Callback_Done = 30 //请求回调完成
+	All_Done      = 30 //全部完成
+	Task_Suspend  = 60 //任务暂停
+	Task_Fail     = 70 //任务失败
+
+	//MaxWorker   = 5    //最大并发worker数量
+	MaxLoadTask = 1000 //一次最大获取任务数量
+
+	LoopTryCount    = 3 //循环体内重试次数
+	ErrTaskTryCount = 3 //最大允许错误任务重试次数
+
+	DefaultChatId = "FOO001"
+)
+
+type Task struct {
+	Data *ent.CompapiAsynctask
+	Idx  int
+	Code int
+}
+
+// 带会话管理的任务通道组
+type TaskDispatcher struct {
+	mu        sync.Mutex
+	workerChs []chan Task // 每个worker独立通道
+}
+
+func NewTaskDispatcher(workerCount int) *TaskDispatcher {
+	td := &TaskDispatcher{
+		workerChs: make([]chan Task, workerCount),
+	}
+
+	// 初始化worker通道
+	for i := range td.workerChs {
+		td.workerChs[i] = make(chan Task, 100) // 每个worker带缓冲
+		//fmt.Printf("make worker chan:%d\n", i+1)
+	}
+	return td
+}
+
+// 哈希分片算法(确保相同chatid路由到同一个worker)
+func (td *TaskDispatcher) getWorkerChannel(chatId string) (int, chan Task) {
+	if len(chatId) == 0 {
+		chatId = DefaultChatId
+	}
+	h := fnv.New32a()
+	h.Write([]byte(chatId))
+	idx := int(h.Sum32()) % len(td.workerChs)
+	return idx, td.workerChs[idx]
+}
+
+// 分配任务到对应的消费channel
+func (td *TaskDispatcher) Dispatch(task Task) {
+	td.mu.Lock()
+	defer td.mu.Unlock()
+
+	// 根据chatId哈希获得其对应的workerChan
+	workerChId, workerCh := td.getWorkerChannel(task.Data.ChatID)
+	// 将任务送入该chatid的workerChan
+	workerCh <- task
+	logx.Debugf("producer:ChatId:[%s] Task Push to WorkerChan:%d", task.Data.ChatID, workerChId+1)
+}
+
+func getGoroutineId() (int64, error) {
+	// 堆栈结果中需要消除的前缀符
+	var goroutineSpace = []byte("goroutine ")
+
+	bs := make([]byte, 128)
+	bs = bs[:runtime.Stack(bs, false)]
+	bs = bytes.TrimPrefix(bs, goroutineSpace)
+	i := bytes.IndexByte(bs, ' ')
+	if i < 0 {
+		return -1, errors.New("get current goroutine id failed")
+	}
+	return strconv.ParseInt(string(bs[:i]), 10, 64)
+}
+
+func (l *CronTask) compApiCallback(MaxWorker int) {
+
+	var (
+		wg       sync.WaitGroup
+		produced int64 //生产数量(原子计数器)
+		consumed int64 //消费数量(原子计数器)
+	)
+
+	//创建任务分发器
+	if MaxWorker <= 0 {
+		MaxWorker = 2
+	}
+	dispatcher := NewTaskDispatcher(MaxWorker)
+
+	//启动消费者
+	for i, ch := range dispatcher.workerChs {
+
+		wg.Add(1)
+		go func(workerID int, taskCh chan Task) {
+			defer wg.Done()
+			workerId, _ := getGoroutineId()
+			logx.Infof("Consumer Goroutine:%d start......\n", workerId)
+			for task := range taskCh {
+				l.processTask(workerID, task)
+
+				atomic.AddInt64(&consumed, 1)
+			}
+		}(i+1, ch)
+	}
+
+	// 生产者
+	wg.Add(1)
+	go func() {
+		defer wg.Done()
+		workerId, _ := getGoroutineId()
+		logx.Infof("Producer Goroutine:%d start......\n", workerId)
+		//获得待处理异步任务列表
+		tasks, err := l.getAsyncReqTaskList()
+		if err != nil {
+			logx.Errorf("getAsyncReqTaskList err:%s", err)
+			return
+		}
+
+		// 分发任务
+		for _, task := range tasks {
+			dispatcher.Dispatch(task)
+			atomic.AddInt64(&produced, 1)
+		}
+
+		logx.Infof("📦Producer Goroutine:%d 此批次共创建任务%d件", workerId, len(tasks))
+
+		// 关闭所有会话通道
+		dispatcher.mu.Lock()
+		for _, ch := range dispatcher.workerChs {
+			_ = ch
+			close(ch)
+		}
+		dispatcher.mu.Unlock()
+	}()
+
+	wg.Wait()
+	if atomic.LoadInt64(&produced) > 0 {
+		logx.Infof("🏁本次任务完成度统计: Producer:1,Consumer:%d (%d/%d)*100=%d%%", MaxWorker, atomic.LoadInt64(&consumed), atomic.LoadInt64(&produced),
+			(atomic.LoadInt64(&consumed)/atomic.LoadInt64(&produced))*100)
+	}
+}
+
+func (l *CronTask) getAsyncReqTaskList() ([]Task, error) {
+	var predicates []predicate.CompapiAsynctask
+	predicates = append(predicates, compapiasynctask.TaskStatusLT(All_Done))
+
+	var tasks []Task
+	res, err := l.svcCtx.DB.CompapiAsynctask.Query().Where(predicates...).
+		Order(ent.Asc(compapiasynctask.FieldID)).
+		Limit(MaxLoadTask).
+		All(l.ctx)
+	if err == nil {
+		for idx, val := range res {
+			tasks = append(tasks, Task{Data: val, Idx: idx})
+		}
+	}
+	return tasks, err
+}
+
+func (l *CronTask) processTask(workerID int, task Task) {
+	//fmt.Printf("In processTask,Consumer(%d) dealing\n", workerID)
+	//fmt.Printf("Task Detail: User(%s/%s) Async Call %s\n", task.Data.ChatID, task.Data.AuthToken, task.Data.OpenaiBase)
+	_ = workerID
+	var err error
+	rt := 0
+	for {
+		if task.Data.TaskStatus >= All_Done {
+			break
+		}
+		switch task.Data.TaskStatus {
+		case Task_Ready:
+			//请求API平台
+			//	succ: taskStatus Task_Ready => ReqApi_Done
+			//  fail: taskStatus保持当前不变或Task_Fail
+			rt, err = l.requestAPI(task.Data)
+		case ReqApi_Done:
+			//结果回调
+			// succ: taskStatus ReqApi_Done => Callback_Done(All_Done)
+			// fail: taskStatus保持当前不变或Task_Fail
+			rt, err = l.requestCallback(task.Data)
+		}
+		if err != nil {
+			//收集错误
+			if rt == 0 {
+				//不可恢复错误处理....
+			}
+			//fmt.Println("===>ERROR:", err, ",Task Ignore...")
+			return //先暂时忽略处理,也许应按错误类型分别对待
+		}
+	}
+}
+
+func (l *CronTask) requestCallback(taskData *ent.CompapiAsynctask) (int, error) {
+	workerId, _ := getGoroutineId()
+	logx.Debugf("Worker:%d INTO requestCallback for task status:%d", workerId, taskData.TaskStatus)
+
+	if needStop, _ := l.checkErrRetry(taskData); needStop { //重试次数检测,如果超过直接标为永久失败而不再处理
+		return 1, errors.New("too many err retry")
+	}
+	if taskData.TaskStatus != ReqApi_Done {
+		return 0, fmt.Errorf("invalid task run order for status:%d", taskData.TaskStatus)
+	}
+	req := types.CompOpenApiResp{}
+	if len(taskData.ResponseRaw) == 0 {
+		return 0, errors.New("call api response empty")
+	}
+	if len(taskData.CallbackURL) == 0 {
+		return 0, errors.New("callback url empty")
+	}
+	if err := json.Unmarshal([]byte(taskData.ResponseRaw), &req); err != nil {
+		return 0, err
+	}
+
+	//先开启事务更新任务状态 => Callback_Done(回调完成)
+	tx, err := l.updateTaskStatusByTx(taskData.ID, Callback_Done)
+	if err != nil {
+		return 0, err
+	}
+
+	//请求预先给定的callback_url
+	client := compapi.NewAiClient("", taskData.CallbackURL)
+	//emptyParams := openai.ChatCompletionNewParams{}
+	customResp := types.BaseDataInfo{}
+	opts := []option.RequestOption{option.WithResponseBodyInto(&customResp)}
+	opts = append(opts, option.WithRequestBody("application/json", []byte(taskData.ResponseRaw)))
+	for i := range LoopTryCount { //重试机制
+
+		err = client.Post(l.ctx, taskData.CallbackURL, nil, nil, opts...)
+		//_, err = client.Chat.Completions.New(l.ctx, emptyParams, opts...)
+		if err == nil {
+			//call succ
+			break
+		}
+		logx.Infof("Worker:%d call '%s' fail: '%s',sleep %d Second for next(%d/%d/%d)", workerId,
+			taskData.CallbackURL, err, 1+i*5, i+1, LoopTryCount, taskData.RetryCount)
+		time.Sleep(time.Duration(1+i*5) * time.Second)
+	}
+
+	if err != nil {
+		_ = tx.Rollback() //回滚之前更新状态
+		//fmt.Printf("Worker:%d client.Chat.Completions.New Fail,Rollback......\n", workerId)
+		err1 := l.dealErrorTask(taskData, err) //错误任务处理
+		et := 1
+		if err1 != nil {
+			et = 0
+		}
+		return et, err
+	}
+
+	err = tx.Commit() //事务提交
+	//fmt.Printf("Worker:%d requestCallback事务提交\n", workerId)
+	if err != nil {
+		return 0, err
+	}
+	taskData.TaskStatus = Callback_Done //状态迁移
+	return 1, nil
+}
+
+func (l *CronTask) requestAPI(taskData *ent.CompapiAsynctask) (int, error) {
+	workerId, _ := getGoroutineId()
+	logx.Debugf("Worker:%d INTO requestAPI for task status:%d", workerId, taskData.TaskStatus)
+
+	if needStop, _ := l.checkErrRetry(taskData); needStop { //重试次数检测,如果超过直接标为永久失败而不再处理
+		return 1, errors.New("too many err retry")
+	}
+
+	if taskData.TaskStatus != Task_Ready {
+		return 0, fmt.Errorf("invalid task run order for status:%d", taskData.TaskStatus)
+	}
+	if taskData.EventType != "fastgpt" {
+		return 0, fmt.Errorf("event type :'%s' not support", taskData.EventType)
+	}
+	var (
+		err     error
+		apiResp *types.CompOpenApiResp
+		tx      *ent.Tx
+	)
+	req := types.CompApiReq{}
+	if err = json.Unmarshal([]byte(taskData.RequestRaw), &req); err != nil {
+		return 0, err
+	}
+	//先开启事务更新任务状态 => ReqApi_Done(请求API完成)
+	tx, err = l.updateTaskStatusByTx(taskData.ID, ReqApi_Done)
+	if err != nil {
+		return 0, err
+	}
+
+	for i := range LoopTryCount { //重试机制
+
+		apiResp, err = compapi.NewFastgptChatCompletions(l.ctx,
+			taskData.OpenaiKey, taskData.OpenaiBase, &req)
+		if err == nil && apiResp != nil && len(apiResp.Choices) > 0 {
+			//call succ
+			break
+		} else if apiResp != nil && len(apiResp.Choices) == 0 {
+			err = errors.New("返回结果缺失,请检查访问权限")
+		}
+		logx.Infof("Worker:%d call '%s' fail: '%s',sleep %d Second for next(%d/%d/%d)", workerId,
+			taskData.CallbackURL, err, 1+i*5, i+1, LoopTryCount, taskData.RetryCount)
+		time.Sleep(time.Duration(1+i*5) * time.Second)
+	}
+
+	if err != nil || apiResp == nil {
+		if apiResp == nil && err == nil {
+			err = errors.New("resp is null")
+		}
+		_ = tx.Rollback() //回滚之前更新状态
+		//fmt.Printf("Worker:%d NewFastgptChatCompletions Fail,Rollback......\n", workerId)
+		err1 := l.dealErrorTask(taskData, err) //错误任务处理
+		et := 1
+		if err1 != nil {
+			et = 0
+		}
+		return et, err
+	}
+
+	respBs, err := json.Marshal(*apiResp)
+	if err != nil {
+		_ = tx.Rollback() //回滚之前更新状态
+		return 0, err
+	}
+	taskData.ResponseRaw = string(respBs)
+
+	_, err = tx.CompapiAsynctask.UpdateOneID(taskData.ID).
+		SetResponseRaw(taskData.ResponseRaw).
+		Save(l.ctx)
+	if err != nil {
+		_ = tx.Rollback() //回滚之前更新状态
+		return 0, err
+	}
+	err = tx.Commit() //事务提交
+	//fmt.Printf("Worker:%d requestAPI事务提交\n", workerId)
+	if err != nil {
+		return 0, err
+	}
+	taskData.TaskStatus = ReqApi_Done //状态迁移
+	return 1, nil
+}
+
+// 更新任务状态事务版
+func (l *CronTask) updateTaskStatusByTx(Id uint64, status int) (*ent.Tx, error) {
+	//开启Mysql事务
+	tx, _ := l.svcCtx.DB.Tx(l.ctx)
+	_, err := tx.CompapiAsynctask.UpdateOneID(Id).
+		SetTaskStatus(int8(status)).
+		SetUpdatedAt(time.Now()).
+		Save(l.ctx)
+	if err != nil {
+		return nil, err
+	}
+	return tx, nil
+}
+
+func (l *CronTask) checkErrRetry(taskData *ent.CompapiAsynctask) (bool, error) {
+	var err error
+	var needStop = false
+	if taskData.RetryCount >= ErrTaskTryCount { //错误任务尝试次数超过约定则将任务状态永久设为失败
+		_, err = l.svcCtx.DB.CompapiAsynctask.UpdateOneID(taskData.ID).
+			SetUpdatedAt(time.Now()).
+			SetTaskStatus(int8(Task_Fail)).
+			Save(l.ctx)
+		if err == nil {
+			needStop = true
+			taskData.TaskStatus = Task_Fail
+		}
+	}
+	return needStop, err
+}
+
+// 错误任务处理
+func (l *CronTask) dealErrorTask(taskData *ent.CompapiAsynctask, lasterr error) error {
+	logx.Debug("多次循环之后依然失败,进入错误任务处理环节")
+	cauo := l.svcCtx.DB.CompapiAsynctask.UpdateOneID(taskData.ID).
+		SetUpdatedAt(time.Now())
+	if taskData.RetryCount >= ErrTaskTryCount { //错误任务尝试次数超过约定则将任务状态永久设为失败
+		taskData.TaskStatus = Task_Fail
+		cauo = cauo.SetTaskStatus(int8(Task_Fail))
+	} else {
+		cauo = cauo.SetRetryCount(taskData.RetryCount + 1).
+			SetLastError(lasterr.Error())
+	}
+	_, err := cauo.Save(l.ctx)
+	return err
+}

+ 7 - 0
crontask/init.go

@@ -23,6 +23,7 @@ func NewCronTask(ctx context.Context, svcCtx *svc.ServiceContext) *CronTask {
 }
 
 func ScheduleRun(c *cron.Cron, serverCtx *svc.ServiceContext) {
+
 	l := NewCronTask(context.Background(), serverCtx)
 	c.AddFunc("* * * * *", func() {
 		l.sendMsg()
@@ -42,4 +43,10 @@ func ScheduleRun(c *cron.Cron, serverCtx *svc.ServiceContext) {
 	c.AddFunc("0 * * * *", func() {
 		computeStatistic.computeStatistic()
 	})
+
+	l = NewCronTask(context.Background(), serverCtx)
+	c.AddFunc("* * * * *", func() {
+		MaxWorker := 6
+		l.compApiCallback(MaxWorker)
+	})
 }

+ 26 - 8
desc/openapi/chat.api

@@ -31,36 +31,38 @@ type (
 		//EventType事件类型
         EventType string `json:"event_type,default=fastgpt"`
         //WorkId工作流ID
-        WorkId string `json:"work_id"`
+        WorkId string `json:"work_id,optional,omitempty"`
 		//IsBatch 是同步还是异步,默认及取值false表明同步
         IsBatch bool `json:"is_batch,default=false"`
         //异步回调地址
-        Callback string `json:"callback,optional"`
+        Callback string `json:"callback,optional,omitempty"`
 	}
 
 	FastGptSpecReq {
         //ChatId
-        ChatId string `json:"chat_id,optional"`
+        ChatId string `json:"chat_id,optional,omitempty"`
 		//FastgptChatId
-		FastgptChatId string `json:"chatId,optional"`
+		FastgptChatId string `json:"chatId,optional,omitempty"`
         //ResponseChatItemId
-        ResponseChatItemId string `json:"response_chat_item_id,optional"`
+        ResponseChatItemId string `json:"response_chat_item_id,optional,omitempty"`
         //Detail 详情开关
         Detail bool `json:"detail,default=false"`
         //Variables
-        Variables map[string]string `json:"variables,optional"`
+        Variables map[string]string `json:"variables,optional,omitempty"`
 	}
 	
 	StdCompMessage {
         Role string `json:"role"`
-        Content interface{} `json:"content"`
+		Content interface{} `json:"content"`
+        //Content string `json:"content"`
     }
 
     //以下是API响应类型
 	CompOpenApiResp {
         StdCompApiResp
 		FastgptSpecResp
-    }
+		FastgptErrResp
+	}
 
 	StdCompApiResp {
         // A unique identifier for the chat completion.
@@ -89,6 +91,22 @@ type (
 		ResponseData []map[string]interface{} `json:"responseData,omitempty"`
 		NewVariables map[string]interface{} `json:"newVariables,omitempty"`
 	}
+
+	FastgptErrResp {
+		FgtErrCode *int `json:"code,omitempty"`
+		FgtErrStatusTxt *string `json:"statusText,omitempty"`
+		FgtErrMessage *string `json:"message,omitempty"`
+	}
+	
+	DeepseekErrResp {
+		DSErr DeepseekErrInfo `json:"error,omitempty"`
+	}
+	DeepseekErrInfo {
+		Message string `json:"message,omitempty"`
+		Type string `json:"type,omitempty"`
+		Code string `json:"code,omitempty"`
+		Param interface{} `json:"param,omitempty"`
+	}
 	
 	ChatCompletionAudio {
 	    // Unique identifier for this audio response.

+ 77 - 77
ent/client.go

@@ -20,7 +20,7 @@ import (
 	"wechat-api/ent/category"
 	"wechat-api/ent/chatrecords"
 	"wechat-api/ent/chatsession"
-	"wechat-api/ent/compapijob"
+	"wechat-api/ent/compapiasynctask"
 	"wechat-api/ent/contact"
 	"wechat-api/ent/creditbalance"
 	"wechat-api/ent/creditusage"
@@ -85,8 +85,8 @@ type Client struct {
 	ChatRecords *ChatRecordsClient
 	// ChatSession is the client for interacting with the ChatSession builders.
 	ChatSession *ChatSessionClient
-	// CompapiJob is the client for interacting with the CompapiJob builders.
-	CompapiJob *CompapiJobClient
+	// CompapiAsynctask is the client for interacting with the CompapiAsynctask builders.
+	CompapiAsynctask *CompapiAsynctaskClient
 	// Contact is the client for interacting with the Contact builders.
 	Contact *ContactClient
 	// CreditBalance is the client for interacting with the CreditBalance builders.
@@ -171,7 +171,7 @@ func (c *Client) init() {
 	c.Category = NewCategoryClient(c.config)
 	c.ChatRecords = NewChatRecordsClient(c.config)
 	c.ChatSession = NewChatSessionClient(c.config)
-	c.CompapiJob = NewCompapiJobClient(c.config)
+	c.CompapiAsynctask = NewCompapiAsynctaskClient(c.config)
 	c.Contact = NewContactClient(c.config)
 	c.CreditBalance = NewCreditBalanceClient(c.config)
 	c.CreditUsage = NewCreditUsageClient(c.config)
@@ -305,7 +305,7 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) {
 		Category:            NewCategoryClient(cfg),
 		ChatRecords:         NewChatRecordsClient(cfg),
 		ChatSession:         NewChatSessionClient(cfg),
-		CompapiJob:          NewCompapiJobClient(cfg),
+		CompapiAsynctask:    NewCompapiAsynctaskClient(cfg),
 		Contact:             NewContactClient(cfg),
 		CreditBalance:       NewCreditBalanceClient(cfg),
 		CreditUsage:         NewCreditUsageClient(cfg),
@@ -366,7 +366,7 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
 		Category:            NewCategoryClient(cfg),
 		ChatRecords:         NewChatRecordsClient(cfg),
 		ChatSession:         NewChatSessionClient(cfg),
-		CompapiJob:          NewCompapiJobClient(cfg),
+		CompapiAsynctask:    NewCompapiAsynctaskClient(cfg),
 		Contact:             NewContactClient(cfg),
 		CreditBalance:       NewCreditBalanceClient(cfg),
 		CreditUsage:         NewCreditUsageClient(cfg),
@@ -429,7 +429,7 @@ func (c *Client) Close() error {
 func (c *Client) Use(hooks ...Hook) {
 	for _, n := range []interface{ Use(...Hook) }{
 		c.Agent, c.AgentBase, c.AliyunAvatar, c.AllocAgent, c.ApiKey, c.BatchMsg,
-		c.Category, c.ChatRecords, c.ChatSession, c.CompapiJob, c.Contact,
+		c.Category, c.ChatRecords, c.ChatSession, c.CompapiAsynctask, c.Contact,
 		c.CreditBalance, c.CreditUsage, c.Employee, c.EmployeeConfig, c.Label,
 		c.LabelRelationship, c.LabelTagging, c.Message, c.MessageRecords, c.Msg,
 		c.PayRecharge, c.Server, c.SopNode, c.SopStage, c.SopTask, c.Token, c.Tutorial,
@@ -447,7 +447,7 @@ func (c *Client) Use(hooks ...Hook) {
 func (c *Client) Intercept(interceptors ...Interceptor) {
 	for _, n := range []interface{ Intercept(...Interceptor) }{
 		c.Agent, c.AgentBase, c.AliyunAvatar, c.AllocAgent, c.ApiKey, c.BatchMsg,
-		c.Category, c.ChatRecords, c.ChatSession, c.CompapiJob, c.Contact,
+		c.Category, c.ChatRecords, c.ChatSession, c.CompapiAsynctask, c.Contact,
 		c.CreditBalance, c.CreditUsage, c.Employee, c.EmployeeConfig, c.Label,
 		c.LabelRelationship, c.LabelTagging, c.Message, c.MessageRecords, c.Msg,
 		c.PayRecharge, c.Server, c.SopNode, c.SopStage, c.SopTask, c.Token, c.Tutorial,
@@ -481,8 +481,8 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
 		return c.ChatRecords.mutate(ctx, m)
 	case *ChatSessionMutation:
 		return c.ChatSession.mutate(ctx, m)
-	case *CompapiJobMutation:
-		return c.CompapiJob.mutate(ctx, m)
+	case *CompapiAsynctaskMutation:
+		return c.CompapiAsynctask.mutate(ctx, m)
 	case *ContactMutation:
 		return c.Contact.mutate(ctx, m)
 	case *CreditBalanceMutation:
@@ -1861,107 +1861,107 @@ func (c *ChatSessionClient) mutate(ctx context.Context, m *ChatSessionMutation)
 	}
 }
 
-// CompapiJobClient is a client for the CompapiJob schema.
-type CompapiJobClient struct {
+// CompapiAsynctaskClient is a client for the CompapiAsynctask schema.
+type CompapiAsynctaskClient struct {
 	config
 }
 
-// NewCompapiJobClient returns a client for the CompapiJob from the given config.
-func NewCompapiJobClient(c config) *CompapiJobClient {
-	return &CompapiJobClient{config: c}
+// NewCompapiAsynctaskClient returns a client for the CompapiAsynctask from the given config.
+func NewCompapiAsynctaskClient(c config) *CompapiAsynctaskClient {
+	return &CompapiAsynctaskClient{config: c}
 }
 
 // Use adds a list of mutation hooks to the hooks stack.
-// A call to `Use(f, g, h)` equals to `compapijob.Hooks(f(g(h())))`.
-func (c *CompapiJobClient) Use(hooks ...Hook) {
-	c.hooks.CompapiJob = append(c.hooks.CompapiJob, hooks...)
+// A call to `Use(f, g, h)` equals to `compapiasynctask.Hooks(f(g(h())))`.
+func (c *CompapiAsynctaskClient) Use(hooks ...Hook) {
+	c.hooks.CompapiAsynctask = append(c.hooks.CompapiAsynctask, hooks...)
 }
 
 // Intercept adds a list of query interceptors to the interceptors stack.
-// A call to `Intercept(f, g, h)` equals to `compapijob.Intercept(f(g(h())))`.
-func (c *CompapiJobClient) Intercept(interceptors ...Interceptor) {
-	c.inters.CompapiJob = append(c.inters.CompapiJob, interceptors...)
+// A call to `Intercept(f, g, h)` equals to `compapiasynctask.Intercept(f(g(h())))`.
+func (c *CompapiAsynctaskClient) Intercept(interceptors ...Interceptor) {
+	c.inters.CompapiAsynctask = append(c.inters.CompapiAsynctask, interceptors...)
 }
 
-// Create returns a builder for creating a CompapiJob entity.
-func (c *CompapiJobClient) Create() *CompapiJobCreate {
-	mutation := newCompapiJobMutation(c.config, OpCreate)
-	return &CompapiJobCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
+// Create returns a builder for creating a CompapiAsynctask entity.
+func (c *CompapiAsynctaskClient) Create() *CompapiAsynctaskCreate {
+	mutation := newCompapiAsynctaskMutation(c.config, OpCreate)
+	return &CompapiAsynctaskCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
 }
 
-// CreateBulk returns a builder for creating a bulk of CompapiJob entities.
-func (c *CompapiJobClient) CreateBulk(builders ...*CompapiJobCreate) *CompapiJobCreateBulk {
-	return &CompapiJobCreateBulk{config: c.config, builders: builders}
+// CreateBulk returns a builder for creating a bulk of CompapiAsynctask entities.
+func (c *CompapiAsynctaskClient) CreateBulk(builders ...*CompapiAsynctaskCreate) *CompapiAsynctaskCreateBulk {
+	return &CompapiAsynctaskCreateBulk{config: c.config, builders: builders}
 }
 
 // MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
 // a builder and applies setFunc on it.
-func (c *CompapiJobClient) MapCreateBulk(slice any, setFunc func(*CompapiJobCreate, int)) *CompapiJobCreateBulk {
+func (c *CompapiAsynctaskClient) MapCreateBulk(slice any, setFunc func(*CompapiAsynctaskCreate, int)) *CompapiAsynctaskCreateBulk {
 	rv := reflect.ValueOf(slice)
 	if rv.Kind() != reflect.Slice {
-		return &CompapiJobCreateBulk{err: fmt.Errorf("calling to CompapiJobClient.MapCreateBulk with wrong type %T, need slice", slice)}
+		return &CompapiAsynctaskCreateBulk{err: fmt.Errorf("calling to CompapiAsynctaskClient.MapCreateBulk with wrong type %T, need slice", slice)}
 	}
-	builders := make([]*CompapiJobCreate, rv.Len())
+	builders := make([]*CompapiAsynctaskCreate, rv.Len())
 	for i := 0; i < rv.Len(); i++ {
 		builders[i] = c.Create()
 		setFunc(builders[i], i)
 	}
-	return &CompapiJobCreateBulk{config: c.config, builders: builders}
+	return &CompapiAsynctaskCreateBulk{config: c.config, builders: builders}
 }
 
-// Update returns an update builder for CompapiJob.
-func (c *CompapiJobClient) Update() *CompapiJobUpdate {
-	mutation := newCompapiJobMutation(c.config, OpUpdate)
-	return &CompapiJobUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
+// Update returns an update builder for CompapiAsynctask.
+func (c *CompapiAsynctaskClient) Update() *CompapiAsynctaskUpdate {
+	mutation := newCompapiAsynctaskMutation(c.config, OpUpdate)
+	return &CompapiAsynctaskUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
 }
 
 // UpdateOne returns an update builder for the given entity.
-func (c *CompapiJobClient) UpdateOne(cj *CompapiJob) *CompapiJobUpdateOne {
-	mutation := newCompapiJobMutation(c.config, OpUpdateOne, withCompapiJob(cj))
-	return &CompapiJobUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
+func (c *CompapiAsynctaskClient) UpdateOne(ca *CompapiAsynctask) *CompapiAsynctaskUpdateOne {
+	mutation := newCompapiAsynctaskMutation(c.config, OpUpdateOne, withCompapiAsynctask(ca))
+	return &CompapiAsynctaskUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
 }
 
 // UpdateOneID returns an update builder for the given id.
-func (c *CompapiJobClient) UpdateOneID(id uint64) *CompapiJobUpdateOne {
-	mutation := newCompapiJobMutation(c.config, OpUpdateOne, withCompapiJobID(id))
-	return &CompapiJobUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
+func (c *CompapiAsynctaskClient) UpdateOneID(id uint64) *CompapiAsynctaskUpdateOne {
+	mutation := newCompapiAsynctaskMutation(c.config, OpUpdateOne, withCompapiAsynctaskID(id))
+	return &CompapiAsynctaskUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
 }
 
-// Delete returns a delete builder for CompapiJob.
-func (c *CompapiJobClient) Delete() *CompapiJobDelete {
-	mutation := newCompapiJobMutation(c.config, OpDelete)
-	return &CompapiJobDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
+// Delete returns a delete builder for CompapiAsynctask.
+func (c *CompapiAsynctaskClient) Delete() *CompapiAsynctaskDelete {
+	mutation := newCompapiAsynctaskMutation(c.config, OpDelete)
+	return &CompapiAsynctaskDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
 }
 
 // DeleteOne returns a builder for deleting the given entity.
-func (c *CompapiJobClient) DeleteOne(cj *CompapiJob) *CompapiJobDeleteOne {
-	return c.DeleteOneID(cj.ID)
+func (c *CompapiAsynctaskClient) DeleteOne(ca *CompapiAsynctask) *CompapiAsynctaskDeleteOne {
+	return c.DeleteOneID(ca.ID)
 }
 
 // DeleteOneID returns a builder for deleting the given entity by its id.
-func (c *CompapiJobClient) DeleteOneID(id uint64) *CompapiJobDeleteOne {
-	builder := c.Delete().Where(compapijob.ID(id))
+func (c *CompapiAsynctaskClient) DeleteOneID(id uint64) *CompapiAsynctaskDeleteOne {
+	builder := c.Delete().Where(compapiasynctask.ID(id))
 	builder.mutation.id = &id
 	builder.mutation.op = OpDeleteOne
-	return &CompapiJobDeleteOne{builder}
+	return &CompapiAsynctaskDeleteOne{builder}
 }
 
-// Query returns a query builder for CompapiJob.
-func (c *CompapiJobClient) Query() *CompapiJobQuery {
-	return &CompapiJobQuery{
+// Query returns a query builder for CompapiAsynctask.
+func (c *CompapiAsynctaskClient) Query() *CompapiAsynctaskQuery {
+	return &CompapiAsynctaskQuery{
 		config: c.config,
-		ctx:    &QueryContext{Type: TypeCompapiJob},
+		ctx:    &QueryContext{Type: TypeCompapiAsynctask},
 		inters: c.Interceptors(),
 	}
 }
 
-// Get returns a CompapiJob entity by its id.
-func (c *CompapiJobClient) Get(ctx context.Context, id uint64) (*CompapiJob, error) {
-	return c.Query().Where(compapijob.ID(id)).Only(ctx)
+// Get returns a CompapiAsynctask entity by its id.
+func (c *CompapiAsynctaskClient) Get(ctx context.Context, id uint64) (*CompapiAsynctask, error) {
+	return c.Query().Where(compapiasynctask.ID(id)).Only(ctx)
 }
 
 // GetX is like Get, but panics if an error occurs.
-func (c *CompapiJobClient) GetX(ctx context.Context, id uint64) *CompapiJob {
+func (c *CompapiAsynctaskClient) GetX(ctx context.Context, id uint64) *CompapiAsynctask {
 	obj, err := c.Get(ctx, id)
 	if err != nil {
 		panic(err)
@@ -1970,27 +1970,27 @@ func (c *CompapiJobClient) GetX(ctx context.Context, id uint64) *CompapiJob {
 }
 
 // Hooks returns the client hooks.
-func (c *CompapiJobClient) Hooks() []Hook {
-	return c.hooks.CompapiJob
+func (c *CompapiAsynctaskClient) Hooks() []Hook {
+	return c.hooks.CompapiAsynctask
 }
 
 // Interceptors returns the client interceptors.
-func (c *CompapiJobClient) Interceptors() []Interceptor {
-	return c.inters.CompapiJob
+func (c *CompapiAsynctaskClient) Interceptors() []Interceptor {
+	return c.inters.CompapiAsynctask
 }
 
-func (c *CompapiJobClient) mutate(ctx context.Context, m *CompapiJobMutation) (Value, error) {
+func (c *CompapiAsynctaskClient) mutate(ctx context.Context, m *CompapiAsynctaskMutation) (Value, error) {
 	switch m.Op() {
 	case OpCreate:
-		return (&CompapiJobCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
+		return (&CompapiAsynctaskCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
 	case OpUpdate:
-		return (&CompapiJobUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
+		return (&CompapiAsynctaskUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
 	case OpUpdateOne:
-		return (&CompapiJobUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
+		return (&CompapiAsynctaskUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
 	case OpDelete, OpDeleteOne:
-		return (&CompapiJobDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
+		return (&CompapiAsynctaskDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
 	default:
-		return nil, fmt.Errorf("ent: unknown CompapiJob mutation op: %q", m.Op())
+		return nil, fmt.Errorf("ent: unknown CompapiAsynctask mutation op: %q", m.Op())
 	}
 }
 
@@ -6670,19 +6670,19 @@ func (c *WxCardVisitClient) mutate(ctx context.Context, m *WxCardVisitMutation)
 type (
 	hooks struct {
 		Agent, AgentBase, AliyunAvatar, AllocAgent, ApiKey, BatchMsg, Category,
-		ChatRecords, ChatSession, CompapiJob, Contact, CreditBalance, CreditUsage,
-		Employee, EmployeeConfig, Label, LabelRelationship, LabelTagging, Message,
-		MessageRecords, Msg, PayRecharge, Server, SopNode, SopStage, SopTask, Token,
-		Tutorial, UsageDetail, UsageStatisticDay, UsageStatisticHour,
+		ChatRecords, ChatSession, CompapiAsynctask, Contact, CreditBalance,
+		CreditUsage, Employee, EmployeeConfig, Label, LabelRelationship, LabelTagging,
+		Message, MessageRecords, Msg, PayRecharge, Server, SopNode, SopStage, SopTask,
+		Token, Tutorial, UsageDetail, UsageStatisticDay, UsageStatisticHour,
 		UsageStatisticMonth, UsageTotal, Whatsapp, WhatsappChannel, WorkExperience,
 		WpChatroom, WpChatroomMember, Wx, WxCard, WxCardUser, WxCardVisit []ent.Hook
 	}
 	inters struct {
 		Agent, AgentBase, AliyunAvatar, AllocAgent, ApiKey, BatchMsg, Category,
-		ChatRecords, ChatSession, CompapiJob, Contact, CreditBalance, CreditUsage,
-		Employee, EmployeeConfig, Label, LabelRelationship, LabelTagging, Message,
-		MessageRecords, Msg, PayRecharge, Server, SopNode, SopStage, SopTask, Token,
-		Tutorial, UsageDetail, UsageStatisticDay, UsageStatisticHour,
+		ChatRecords, ChatSession, CompapiAsynctask, Contact, CreditBalance,
+		CreditUsage, Employee, EmployeeConfig, Label, LabelRelationship, LabelTagging,
+		Message, MessageRecords, Msg, PayRecharge, Server, SopNode, SopStage, SopTask,
+		Token, Tutorial, UsageDetail, UsageStatisticDay, UsageStatisticHour,
 		UsageStatisticMonth, UsageTotal, Whatsapp, WhatsappChannel, WorkExperience,
 		WpChatroom, WpChatroomMember, Wx, WxCard, WxCardUser,
 		WxCardVisit []ent.Interceptor

+ 249 - 0
ent/compapiasynctask.go

@@ -0,0 +1,249 @@
+// Code generated by ent, DO NOT EDIT.
+
+package ent
+
+import (
+	"fmt"
+	"strings"
+	"time"
+	"wechat-api/ent/compapiasynctask"
+
+	"entgo.io/ent"
+	"entgo.io/ent/dialect/sql"
+)
+
+// CompapiAsynctask is the model entity for the CompapiAsynctask schema.
+type CompapiAsynctask struct {
+	config `json:"-"`
+	// ID of the ent.
+	ID uint64 `json:"id,omitempty"`
+	// Create Time | 创建日期
+	CreatedAt time.Time `json:"created_at,omitempty"`
+	// Update Time | 修改日期
+	UpdatedAt time.Time `json:"updated_at,omitempty"`
+	// 发起请求者的授权token
+	AuthToken string `json:"auth_token,omitempty"`
+	// 请求目标类型
+	EventType string `json:"event_type,omitempty"`
+	// 会话ID
+	ChatID string `json:"chat_id,omitempty"`
+	// workId在字典中的索引值
+	WorkidIdx int8 `json:"workid_idx,omitempty"`
+	// 待请求的大模型服务地址
+	OpenaiBase string `json:"openai_base,omitempty"`
+	// 待请求的大模型服务密钥授权token
+	OpenaiKey string `json:"openai_key,omitempty"`
+	// 请求参数结构字符串
+	RequestRaw string `json:"request_raw,omitempty"`
+	// 请求响应结构字符串
+	ResponseRaw string `json:"response_raw,omitempty"`
+	// 异步执行回调地址
+	CallbackURL string `json:"callback_url,omitempty"`
+	// callback_status | 任务完成状态 10 任务就绪 20 请求API完成 30 请求回调完成 60 任务暂停 70 任务失败
+	TaskStatus int8 `json:"task_status,omitempty"`
+	// retry count | 重试次数
+	RetryCount int8 `json:"retry_count,omitempty"`
+	// 最后一次出错信息
+	LastError    string `json:"last_error,omitempty"`
+	selectValues sql.SelectValues
+}
+
+// scanValues returns the types for scanning values from sql.Rows.
+func (*CompapiAsynctask) scanValues(columns []string) ([]any, error) {
+	values := make([]any, len(columns))
+	for i := range columns {
+		switch columns[i] {
+		case compapiasynctask.FieldID, compapiasynctask.FieldWorkidIdx, compapiasynctask.FieldTaskStatus, compapiasynctask.FieldRetryCount:
+			values[i] = new(sql.NullInt64)
+		case compapiasynctask.FieldAuthToken, compapiasynctask.FieldEventType, compapiasynctask.FieldChatID, compapiasynctask.FieldOpenaiBase, compapiasynctask.FieldOpenaiKey, compapiasynctask.FieldRequestRaw, compapiasynctask.FieldResponseRaw, compapiasynctask.FieldCallbackURL, compapiasynctask.FieldLastError:
+			values[i] = new(sql.NullString)
+		case compapiasynctask.FieldCreatedAt, compapiasynctask.FieldUpdatedAt:
+			values[i] = new(sql.NullTime)
+		default:
+			values[i] = new(sql.UnknownType)
+		}
+	}
+	return values, nil
+}
+
+// assignValues assigns the values that were returned from sql.Rows (after scanning)
+// to the CompapiAsynctask fields.
+func (ca *CompapiAsynctask) assignValues(columns []string, values []any) error {
+	if m, n := len(values), len(columns); m < n {
+		return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
+	}
+	for i := range columns {
+		switch columns[i] {
+		case compapiasynctask.FieldID:
+			value, ok := values[i].(*sql.NullInt64)
+			if !ok {
+				return fmt.Errorf("unexpected type %T for field id", value)
+			}
+			ca.ID = uint64(value.Int64)
+		case compapiasynctask.FieldCreatedAt:
+			if value, ok := values[i].(*sql.NullTime); !ok {
+				return fmt.Errorf("unexpected type %T for field created_at", values[i])
+			} else if value.Valid {
+				ca.CreatedAt = value.Time
+			}
+		case compapiasynctask.FieldUpdatedAt:
+			if value, ok := values[i].(*sql.NullTime); !ok {
+				return fmt.Errorf("unexpected type %T for field updated_at", values[i])
+			} else if value.Valid {
+				ca.UpdatedAt = value.Time
+			}
+		case compapiasynctask.FieldAuthToken:
+			if value, ok := values[i].(*sql.NullString); !ok {
+				return fmt.Errorf("unexpected type %T for field auth_token", values[i])
+			} else if value.Valid {
+				ca.AuthToken = value.String
+			}
+		case compapiasynctask.FieldEventType:
+			if value, ok := values[i].(*sql.NullString); !ok {
+				return fmt.Errorf("unexpected type %T for field event_type", values[i])
+			} else if value.Valid {
+				ca.EventType = value.String
+			}
+		case compapiasynctask.FieldChatID:
+			if value, ok := values[i].(*sql.NullString); !ok {
+				return fmt.Errorf("unexpected type %T for field chat_id", values[i])
+			} else if value.Valid {
+				ca.ChatID = value.String
+			}
+		case compapiasynctask.FieldWorkidIdx:
+			if value, ok := values[i].(*sql.NullInt64); !ok {
+				return fmt.Errorf("unexpected type %T for field workid_idx", values[i])
+			} else if value.Valid {
+				ca.WorkidIdx = int8(value.Int64)
+			}
+		case compapiasynctask.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 {
+				ca.OpenaiBase = value.String
+			}
+		case compapiasynctask.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 {
+				ca.OpenaiKey = value.String
+			}
+		case compapiasynctask.FieldRequestRaw:
+			if value, ok := values[i].(*sql.NullString); !ok {
+				return fmt.Errorf("unexpected type %T for field request_raw", values[i])
+			} else if value.Valid {
+				ca.RequestRaw = value.String
+			}
+		case compapiasynctask.FieldResponseRaw:
+			if value, ok := values[i].(*sql.NullString); !ok {
+				return fmt.Errorf("unexpected type %T for field response_raw", values[i])
+			} else if value.Valid {
+				ca.ResponseRaw = value.String
+			}
+		case compapiasynctask.FieldCallbackURL:
+			if value, ok := values[i].(*sql.NullString); !ok {
+				return fmt.Errorf("unexpected type %T for field callback_url", values[i])
+			} else if value.Valid {
+				ca.CallbackURL = value.String
+			}
+		case compapiasynctask.FieldTaskStatus:
+			if value, ok := values[i].(*sql.NullInt64); !ok {
+				return fmt.Errorf("unexpected type %T for field task_status", values[i])
+			} else if value.Valid {
+				ca.TaskStatus = int8(value.Int64)
+			}
+		case compapiasynctask.FieldRetryCount:
+			if value, ok := values[i].(*sql.NullInt64); !ok {
+				return fmt.Errorf("unexpected type %T for field retry_count", values[i])
+			} else if value.Valid {
+				ca.RetryCount = int8(value.Int64)
+			}
+		case compapiasynctask.FieldLastError:
+			if value, ok := values[i].(*sql.NullString); !ok {
+				return fmt.Errorf("unexpected type %T for field last_error", values[i])
+			} else if value.Valid {
+				ca.LastError = value.String
+			}
+		default:
+			ca.selectValues.Set(columns[i], values[i])
+		}
+	}
+	return nil
+}
+
+// Value returns the ent.Value that was dynamically selected and assigned to the CompapiAsynctask.
+// This includes values selected through modifiers, order, etc.
+func (ca *CompapiAsynctask) Value(name string) (ent.Value, error) {
+	return ca.selectValues.Get(name)
+}
+
+// Update returns a builder for updating this CompapiAsynctask.
+// Note that you need to call CompapiAsynctask.Unwrap() before calling this method if this CompapiAsynctask
+// was returned from a transaction, and the transaction was committed or rolled back.
+func (ca *CompapiAsynctask) Update() *CompapiAsynctaskUpdateOne {
+	return NewCompapiAsynctaskClient(ca.config).UpdateOne(ca)
+}
+
+// Unwrap unwraps the CompapiAsynctask entity that was returned from a transaction after it was closed,
+// so that all future queries will be executed through the driver which created the transaction.
+func (ca *CompapiAsynctask) Unwrap() *CompapiAsynctask {
+	_tx, ok := ca.config.driver.(*txDriver)
+	if !ok {
+		panic("ent: CompapiAsynctask is not a transactional entity")
+	}
+	ca.config.driver = _tx.drv
+	return ca
+}
+
+// String implements the fmt.Stringer.
+func (ca *CompapiAsynctask) String() string {
+	var builder strings.Builder
+	builder.WriteString("CompapiAsynctask(")
+	builder.WriteString(fmt.Sprintf("id=%v, ", ca.ID))
+	builder.WriteString("created_at=")
+	builder.WriteString(ca.CreatedAt.Format(time.ANSIC))
+	builder.WriteString(", ")
+	builder.WriteString("updated_at=")
+	builder.WriteString(ca.UpdatedAt.Format(time.ANSIC))
+	builder.WriteString(", ")
+	builder.WriteString("auth_token=")
+	builder.WriteString(ca.AuthToken)
+	builder.WriteString(", ")
+	builder.WriteString("event_type=")
+	builder.WriteString(ca.EventType)
+	builder.WriteString(", ")
+	builder.WriteString("chat_id=")
+	builder.WriteString(ca.ChatID)
+	builder.WriteString(", ")
+	builder.WriteString("workid_idx=")
+	builder.WriteString(fmt.Sprintf("%v", ca.WorkidIdx))
+	builder.WriteString(", ")
+	builder.WriteString("openai_base=")
+	builder.WriteString(ca.OpenaiBase)
+	builder.WriteString(", ")
+	builder.WriteString("openai_key=")
+	builder.WriteString(ca.OpenaiKey)
+	builder.WriteString(", ")
+	builder.WriteString("request_raw=")
+	builder.WriteString(ca.RequestRaw)
+	builder.WriteString(", ")
+	builder.WriteString("response_raw=")
+	builder.WriteString(ca.ResponseRaw)
+	builder.WriteString(", ")
+	builder.WriteString("callback_url=")
+	builder.WriteString(ca.CallbackURL)
+	builder.WriteString(", ")
+	builder.WriteString("task_status=")
+	builder.WriteString(fmt.Sprintf("%v", ca.TaskStatus))
+	builder.WriteString(", ")
+	builder.WriteString("retry_count=")
+	builder.WriteString(fmt.Sprintf("%v", ca.RetryCount))
+	builder.WriteString(", ")
+	builder.WriteString("last_error=")
+	builder.WriteString(ca.LastError)
+	builder.WriteByte(')')
+	return builder.String()
+}
+
+// CompapiAsynctasks is a parsable slice of CompapiAsynctask.
+type CompapiAsynctasks []*CompapiAsynctask

+ 178 - 0
ent/compapiasynctask/compapiasynctask.go

@@ -0,0 +1,178 @@
+// Code generated by ent, DO NOT EDIT.
+
+package compapiasynctask
+
+import (
+	"time"
+
+	"entgo.io/ent/dialect/sql"
+)
+
+const (
+	// Label holds the string label denoting the compapiasynctask type in the database.
+	Label = "compapi_asynctask"
+	// FieldID holds the string denoting the id field in the database.
+	FieldID = "id"
+	// FieldCreatedAt holds the string denoting the created_at field in the database.
+	FieldCreatedAt = "created_at"
+	// FieldUpdatedAt holds the string denoting the updated_at field in the database.
+	FieldUpdatedAt = "updated_at"
+	// FieldAuthToken holds the string denoting the auth_token field in the database.
+	FieldAuthToken = "auth_token"
+	// FieldEventType holds the string denoting the event_type field in the database.
+	FieldEventType = "event_type"
+	// FieldChatID holds the string denoting the chat_id field in the database.
+	FieldChatID = "chat_id"
+	// FieldWorkidIdx holds the string denoting the workid_idx field in the database.
+	FieldWorkidIdx = "workid_idx"
+	// 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"
+	// FieldRequestRaw holds the string denoting the request_raw field in the database.
+	FieldRequestRaw = "request_raw"
+	// FieldResponseRaw holds the string denoting the response_raw field in the database.
+	FieldResponseRaw = "response_raw"
+	// FieldCallbackURL holds the string denoting the callback_url field in the database.
+	FieldCallbackURL = "callback_url"
+	// FieldTaskStatus holds the string denoting the task_status field in the database.
+	FieldTaskStatus = "task_status"
+	// FieldRetryCount holds the string denoting the retry_count field in the database.
+	FieldRetryCount = "retry_count"
+	// FieldLastError holds the string denoting the last_error field in the database.
+	FieldLastError = "last_error"
+	// Table holds the table name of the compapiasynctask in the database.
+	Table = "compapi_asynctask"
+)
+
+// Columns holds all SQL columns for compapiasynctask fields.
+var Columns = []string{
+	FieldID,
+	FieldCreatedAt,
+	FieldUpdatedAt,
+	FieldAuthToken,
+	FieldEventType,
+	FieldChatID,
+	FieldWorkidIdx,
+	FieldOpenaiBase,
+	FieldOpenaiKey,
+	FieldRequestRaw,
+	FieldResponseRaw,
+	FieldCallbackURL,
+	FieldTaskStatus,
+	FieldRetryCount,
+	FieldLastError,
+}
+
+// ValidColumn reports if the column name is valid (part of the table columns).
+func ValidColumn(column string) bool {
+	for i := range Columns {
+		if column == Columns[i] {
+			return true
+		}
+	}
+	return false
+}
+
+var (
+	// DefaultCreatedAt holds the default value on creation for the "created_at" field.
+	DefaultCreatedAt func() time.Time
+	// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
+	DefaultUpdatedAt func() time.Time
+	// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
+	UpdateDefaultUpdatedAt func() time.Time
+	// DefaultEventType holds the default value on creation for the "event_type" field.
+	DefaultEventType string
+	// DefaultChatID holds the default value on creation for the "chat_id" field.
+	DefaultChatID string
+	// DefaultWorkidIdx holds the default value on creation for the "workid_idx" field.
+	DefaultWorkidIdx int8
+	// DefaultResponseRaw holds the default value on creation for the "response_raw" field.
+	DefaultResponseRaw string
+	// CallbackURLValidator is a validator for the "callback_url" field. It is called by the builders before save.
+	CallbackURLValidator func(string) error
+	// DefaultTaskStatus holds the default value on creation for the "task_status" field.
+	DefaultTaskStatus int8
+	// DefaultRetryCount holds the default value on creation for the "retry_count" field.
+	DefaultRetryCount int8
+	// DefaultLastError holds the default value on creation for the "last_error" field.
+	DefaultLastError string
+)
+
+// OrderOption defines the ordering options for the CompapiAsynctask queries.
+type OrderOption func(*sql.Selector)
+
+// ByID orders the results by the id field.
+func ByID(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldID, opts...).ToFunc()
+}
+
+// ByCreatedAt orders the results by the created_at field.
+func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
+}
+
+// ByUpdatedAt orders the results by the updated_at field.
+func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
+}
+
+// ByAuthToken orders the results by the auth_token field.
+func ByAuthToken(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldAuthToken, opts...).ToFunc()
+}
+
+// ByEventType orders the results by the event_type field.
+func ByEventType(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldEventType, opts...).ToFunc()
+}
+
+// ByChatID orders the results by the chat_id field.
+func ByChatID(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldChatID, opts...).ToFunc()
+}
+
+// ByWorkidIdx orders the results by the workid_idx field.
+func ByWorkidIdx(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldWorkidIdx, 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()
+}
+
+// ByRequestRaw orders the results by the request_raw field.
+func ByRequestRaw(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldRequestRaw, opts...).ToFunc()
+}
+
+// ByResponseRaw orders the results by the response_raw field.
+func ByResponseRaw(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldResponseRaw, opts...).ToFunc()
+}
+
+// ByCallbackURL orders the results by the callback_url field.
+func ByCallbackURL(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldCallbackURL, opts...).ToFunc()
+}
+
+// ByTaskStatus orders the results by the task_status field.
+func ByTaskStatus(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldTaskStatus, opts...).ToFunc()
+}
+
+// ByRetryCount orders the results by the retry_count field.
+func ByRetryCount(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldRetryCount, opts...).ToFunc()
+}
+
+// ByLastError orders the results by the last_error field.
+func ByLastError(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldLastError, opts...).ToFunc()
+}

+ 985 - 0
ent/compapiasynctask/where.go

@@ -0,0 +1,985 @@
+// Code generated by ent, DO NOT EDIT.
+
+package compapiasynctask
+
+import (
+	"time"
+	"wechat-api/ent/predicate"
+
+	"entgo.io/ent/dialect/sql"
+)
+
+// ID filters vertices based on their ID field.
+func ID(id uint64) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldEQ(FieldID, id))
+}
+
+// IDEQ applies the EQ predicate on the ID field.
+func IDEQ(id uint64) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldEQ(FieldID, id))
+}
+
+// IDNEQ applies the NEQ predicate on the ID field.
+func IDNEQ(id uint64) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldNEQ(FieldID, id))
+}
+
+// IDIn applies the In predicate on the ID field.
+func IDIn(ids ...uint64) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldIn(FieldID, ids...))
+}
+
+// IDNotIn applies the NotIn predicate on the ID field.
+func IDNotIn(ids ...uint64) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldNotIn(FieldID, ids...))
+}
+
+// IDGT applies the GT predicate on the ID field.
+func IDGT(id uint64) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldGT(FieldID, id))
+}
+
+// IDGTE applies the GTE predicate on the ID field.
+func IDGTE(id uint64) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldGTE(FieldID, id))
+}
+
+// IDLT applies the LT predicate on the ID field.
+func IDLT(id uint64) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldLT(FieldID, id))
+}
+
+// IDLTE applies the LTE predicate on the ID field.
+func IDLTE(id uint64) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldLTE(FieldID, id))
+}
+
+// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
+func CreatedAt(v time.Time) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldEQ(FieldCreatedAt, v))
+}
+
+// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
+func UpdatedAt(v time.Time) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldEQ(FieldUpdatedAt, v))
+}
+
+// AuthToken applies equality check predicate on the "auth_token" field. It's identical to AuthTokenEQ.
+func AuthToken(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldEQ(FieldAuthToken, v))
+}
+
+// EventType applies equality check predicate on the "event_type" field. It's identical to EventTypeEQ.
+func EventType(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldEQ(FieldEventType, v))
+}
+
+// ChatID applies equality check predicate on the "chat_id" field. It's identical to ChatIDEQ.
+func ChatID(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldEQ(FieldChatID, v))
+}
+
+// WorkidIdx applies equality check predicate on the "workid_idx" field. It's identical to WorkidIdxEQ.
+func WorkidIdx(v int8) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldEQ(FieldWorkidIdx, v))
+}
+
+// OpenaiBase applies equality check predicate on the "openai_base" field. It's identical to OpenaiBaseEQ.
+func OpenaiBase(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldEQ(FieldOpenaiBase, v))
+}
+
+// OpenaiKey applies equality check predicate on the "openai_key" field. It's identical to OpenaiKeyEQ.
+func OpenaiKey(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldEQ(FieldOpenaiKey, v))
+}
+
+// RequestRaw applies equality check predicate on the "request_raw" field. It's identical to RequestRawEQ.
+func RequestRaw(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldEQ(FieldRequestRaw, v))
+}
+
+// ResponseRaw applies equality check predicate on the "response_raw" field. It's identical to ResponseRawEQ.
+func ResponseRaw(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldEQ(FieldResponseRaw, v))
+}
+
+// CallbackURL applies equality check predicate on the "callback_url" field. It's identical to CallbackURLEQ.
+func CallbackURL(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldEQ(FieldCallbackURL, v))
+}
+
+// TaskStatus applies equality check predicate on the "task_status" field. It's identical to TaskStatusEQ.
+func TaskStatus(v int8) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldEQ(FieldTaskStatus, v))
+}
+
+// RetryCount applies equality check predicate on the "retry_count" field. It's identical to RetryCountEQ.
+func RetryCount(v int8) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldEQ(FieldRetryCount, v))
+}
+
+// LastError applies equality check predicate on the "last_error" field. It's identical to LastErrorEQ.
+func LastError(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldEQ(FieldLastError, v))
+}
+
+// CreatedAtEQ applies the EQ predicate on the "created_at" field.
+func CreatedAtEQ(v time.Time) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldEQ(FieldCreatedAt, v))
+}
+
+// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
+func CreatedAtNEQ(v time.Time) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldNEQ(FieldCreatedAt, v))
+}
+
+// CreatedAtIn applies the In predicate on the "created_at" field.
+func CreatedAtIn(vs ...time.Time) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldIn(FieldCreatedAt, vs...))
+}
+
+// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
+func CreatedAtNotIn(vs ...time.Time) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldNotIn(FieldCreatedAt, vs...))
+}
+
+// CreatedAtGT applies the GT predicate on the "created_at" field.
+func CreatedAtGT(v time.Time) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldGT(FieldCreatedAt, v))
+}
+
+// CreatedAtGTE applies the GTE predicate on the "created_at" field.
+func CreatedAtGTE(v time.Time) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldGTE(FieldCreatedAt, v))
+}
+
+// CreatedAtLT applies the LT predicate on the "created_at" field.
+func CreatedAtLT(v time.Time) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldLT(FieldCreatedAt, v))
+}
+
+// CreatedAtLTE applies the LTE predicate on the "created_at" field.
+func CreatedAtLTE(v time.Time) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldLTE(FieldCreatedAt, v))
+}
+
+// UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
+func UpdatedAtEQ(v time.Time) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldEQ(FieldUpdatedAt, v))
+}
+
+// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
+func UpdatedAtNEQ(v time.Time) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldNEQ(FieldUpdatedAt, v))
+}
+
+// UpdatedAtIn applies the In predicate on the "updated_at" field.
+func UpdatedAtIn(vs ...time.Time) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldIn(FieldUpdatedAt, vs...))
+}
+
+// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
+func UpdatedAtNotIn(vs ...time.Time) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldNotIn(FieldUpdatedAt, vs...))
+}
+
+// UpdatedAtGT applies the GT predicate on the "updated_at" field.
+func UpdatedAtGT(v time.Time) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldGT(FieldUpdatedAt, v))
+}
+
+// UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
+func UpdatedAtGTE(v time.Time) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldGTE(FieldUpdatedAt, v))
+}
+
+// UpdatedAtLT applies the LT predicate on the "updated_at" field.
+func UpdatedAtLT(v time.Time) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldLT(FieldUpdatedAt, v))
+}
+
+// UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
+func UpdatedAtLTE(v time.Time) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldLTE(FieldUpdatedAt, v))
+}
+
+// AuthTokenEQ applies the EQ predicate on the "auth_token" field.
+func AuthTokenEQ(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldEQ(FieldAuthToken, v))
+}
+
+// AuthTokenNEQ applies the NEQ predicate on the "auth_token" field.
+func AuthTokenNEQ(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldNEQ(FieldAuthToken, v))
+}
+
+// AuthTokenIn applies the In predicate on the "auth_token" field.
+func AuthTokenIn(vs ...string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldIn(FieldAuthToken, vs...))
+}
+
+// AuthTokenNotIn applies the NotIn predicate on the "auth_token" field.
+func AuthTokenNotIn(vs ...string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldNotIn(FieldAuthToken, vs...))
+}
+
+// AuthTokenGT applies the GT predicate on the "auth_token" field.
+func AuthTokenGT(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldGT(FieldAuthToken, v))
+}
+
+// AuthTokenGTE applies the GTE predicate on the "auth_token" field.
+func AuthTokenGTE(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldGTE(FieldAuthToken, v))
+}
+
+// AuthTokenLT applies the LT predicate on the "auth_token" field.
+func AuthTokenLT(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldLT(FieldAuthToken, v))
+}
+
+// AuthTokenLTE applies the LTE predicate on the "auth_token" field.
+func AuthTokenLTE(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldLTE(FieldAuthToken, v))
+}
+
+// AuthTokenContains applies the Contains predicate on the "auth_token" field.
+func AuthTokenContains(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldContains(FieldAuthToken, v))
+}
+
+// AuthTokenHasPrefix applies the HasPrefix predicate on the "auth_token" field.
+func AuthTokenHasPrefix(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldHasPrefix(FieldAuthToken, v))
+}
+
+// AuthTokenHasSuffix applies the HasSuffix predicate on the "auth_token" field.
+func AuthTokenHasSuffix(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldHasSuffix(FieldAuthToken, v))
+}
+
+// AuthTokenEqualFold applies the EqualFold predicate on the "auth_token" field.
+func AuthTokenEqualFold(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldEqualFold(FieldAuthToken, v))
+}
+
+// AuthTokenContainsFold applies the ContainsFold predicate on the "auth_token" field.
+func AuthTokenContainsFold(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldContainsFold(FieldAuthToken, v))
+}
+
+// EventTypeEQ applies the EQ predicate on the "event_type" field.
+func EventTypeEQ(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldEQ(FieldEventType, v))
+}
+
+// EventTypeNEQ applies the NEQ predicate on the "event_type" field.
+func EventTypeNEQ(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldNEQ(FieldEventType, v))
+}
+
+// EventTypeIn applies the In predicate on the "event_type" field.
+func EventTypeIn(vs ...string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldIn(FieldEventType, vs...))
+}
+
+// EventTypeNotIn applies the NotIn predicate on the "event_type" field.
+func EventTypeNotIn(vs ...string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldNotIn(FieldEventType, vs...))
+}
+
+// EventTypeGT applies the GT predicate on the "event_type" field.
+func EventTypeGT(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldGT(FieldEventType, v))
+}
+
+// EventTypeGTE applies the GTE predicate on the "event_type" field.
+func EventTypeGTE(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldGTE(FieldEventType, v))
+}
+
+// EventTypeLT applies the LT predicate on the "event_type" field.
+func EventTypeLT(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldLT(FieldEventType, v))
+}
+
+// EventTypeLTE applies the LTE predicate on the "event_type" field.
+func EventTypeLTE(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldLTE(FieldEventType, v))
+}
+
+// EventTypeContains applies the Contains predicate on the "event_type" field.
+func EventTypeContains(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldContains(FieldEventType, v))
+}
+
+// EventTypeHasPrefix applies the HasPrefix predicate on the "event_type" field.
+func EventTypeHasPrefix(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldHasPrefix(FieldEventType, v))
+}
+
+// EventTypeHasSuffix applies the HasSuffix predicate on the "event_type" field.
+func EventTypeHasSuffix(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldHasSuffix(FieldEventType, v))
+}
+
+// EventTypeEqualFold applies the EqualFold predicate on the "event_type" field.
+func EventTypeEqualFold(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldEqualFold(FieldEventType, v))
+}
+
+// EventTypeContainsFold applies the ContainsFold predicate on the "event_type" field.
+func EventTypeContainsFold(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldContainsFold(FieldEventType, v))
+}
+
+// ChatIDEQ applies the EQ predicate on the "chat_id" field.
+func ChatIDEQ(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldEQ(FieldChatID, v))
+}
+
+// ChatIDNEQ applies the NEQ predicate on the "chat_id" field.
+func ChatIDNEQ(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldNEQ(FieldChatID, v))
+}
+
+// ChatIDIn applies the In predicate on the "chat_id" field.
+func ChatIDIn(vs ...string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldIn(FieldChatID, vs...))
+}
+
+// ChatIDNotIn applies the NotIn predicate on the "chat_id" field.
+func ChatIDNotIn(vs ...string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldNotIn(FieldChatID, vs...))
+}
+
+// ChatIDGT applies the GT predicate on the "chat_id" field.
+func ChatIDGT(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldGT(FieldChatID, v))
+}
+
+// ChatIDGTE applies the GTE predicate on the "chat_id" field.
+func ChatIDGTE(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldGTE(FieldChatID, v))
+}
+
+// ChatIDLT applies the LT predicate on the "chat_id" field.
+func ChatIDLT(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldLT(FieldChatID, v))
+}
+
+// ChatIDLTE applies the LTE predicate on the "chat_id" field.
+func ChatIDLTE(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldLTE(FieldChatID, v))
+}
+
+// ChatIDContains applies the Contains predicate on the "chat_id" field.
+func ChatIDContains(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldContains(FieldChatID, v))
+}
+
+// ChatIDHasPrefix applies the HasPrefix predicate on the "chat_id" field.
+func ChatIDHasPrefix(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldHasPrefix(FieldChatID, v))
+}
+
+// ChatIDHasSuffix applies the HasSuffix predicate on the "chat_id" field.
+func ChatIDHasSuffix(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldHasSuffix(FieldChatID, v))
+}
+
+// ChatIDIsNil applies the IsNil predicate on the "chat_id" field.
+func ChatIDIsNil() predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldIsNull(FieldChatID))
+}
+
+// ChatIDNotNil applies the NotNil predicate on the "chat_id" field.
+func ChatIDNotNil() predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldNotNull(FieldChatID))
+}
+
+// ChatIDEqualFold applies the EqualFold predicate on the "chat_id" field.
+func ChatIDEqualFold(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldEqualFold(FieldChatID, v))
+}
+
+// ChatIDContainsFold applies the ContainsFold predicate on the "chat_id" field.
+func ChatIDContainsFold(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldContainsFold(FieldChatID, v))
+}
+
+// WorkidIdxEQ applies the EQ predicate on the "workid_idx" field.
+func WorkidIdxEQ(v int8) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldEQ(FieldWorkidIdx, v))
+}
+
+// WorkidIdxNEQ applies the NEQ predicate on the "workid_idx" field.
+func WorkidIdxNEQ(v int8) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldNEQ(FieldWorkidIdx, v))
+}
+
+// WorkidIdxIn applies the In predicate on the "workid_idx" field.
+func WorkidIdxIn(vs ...int8) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldIn(FieldWorkidIdx, vs...))
+}
+
+// WorkidIdxNotIn applies the NotIn predicate on the "workid_idx" field.
+func WorkidIdxNotIn(vs ...int8) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldNotIn(FieldWorkidIdx, vs...))
+}
+
+// WorkidIdxGT applies the GT predicate on the "workid_idx" field.
+func WorkidIdxGT(v int8) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldGT(FieldWorkidIdx, v))
+}
+
+// WorkidIdxGTE applies the GTE predicate on the "workid_idx" field.
+func WorkidIdxGTE(v int8) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldGTE(FieldWorkidIdx, v))
+}
+
+// WorkidIdxLT applies the LT predicate on the "workid_idx" field.
+func WorkidIdxLT(v int8) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldLT(FieldWorkidIdx, v))
+}
+
+// WorkidIdxLTE applies the LTE predicate on the "workid_idx" field.
+func WorkidIdxLTE(v int8) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldLTE(FieldWorkidIdx, v))
+}
+
+// WorkidIdxIsNil applies the IsNil predicate on the "workid_idx" field.
+func WorkidIdxIsNil() predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldIsNull(FieldWorkidIdx))
+}
+
+// WorkidIdxNotNil applies the NotNil predicate on the "workid_idx" field.
+func WorkidIdxNotNil() predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldNotNull(FieldWorkidIdx))
+}
+
+// OpenaiBaseEQ applies the EQ predicate on the "openai_base" field.
+func OpenaiBaseEQ(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldEQ(FieldOpenaiBase, v))
+}
+
+// OpenaiBaseNEQ applies the NEQ predicate on the "openai_base" field.
+func OpenaiBaseNEQ(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldNEQ(FieldOpenaiBase, v))
+}
+
+// OpenaiBaseIn applies the In predicate on the "openai_base" field.
+func OpenaiBaseIn(vs ...string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldIn(FieldOpenaiBase, vs...))
+}
+
+// OpenaiBaseNotIn applies the NotIn predicate on the "openai_base" field.
+func OpenaiBaseNotIn(vs ...string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldNotIn(FieldOpenaiBase, vs...))
+}
+
+// OpenaiBaseGT applies the GT predicate on the "openai_base" field.
+func OpenaiBaseGT(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldGT(FieldOpenaiBase, v))
+}
+
+// OpenaiBaseGTE applies the GTE predicate on the "openai_base" field.
+func OpenaiBaseGTE(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldGTE(FieldOpenaiBase, v))
+}
+
+// OpenaiBaseLT applies the LT predicate on the "openai_base" field.
+func OpenaiBaseLT(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldLT(FieldOpenaiBase, v))
+}
+
+// OpenaiBaseLTE applies the LTE predicate on the "openai_base" field.
+func OpenaiBaseLTE(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldLTE(FieldOpenaiBase, v))
+}
+
+// OpenaiBaseContains applies the Contains predicate on the "openai_base" field.
+func OpenaiBaseContains(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldContains(FieldOpenaiBase, v))
+}
+
+// OpenaiBaseHasPrefix applies the HasPrefix predicate on the "openai_base" field.
+func OpenaiBaseHasPrefix(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldHasPrefix(FieldOpenaiBase, v))
+}
+
+// OpenaiBaseHasSuffix applies the HasSuffix predicate on the "openai_base" field.
+func OpenaiBaseHasSuffix(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldHasSuffix(FieldOpenaiBase, v))
+}
+
+// OpenaiBaseEqualFold applies the EqualFold predicate on the "openai_base" field.
+func OpenaiBaseEqualFold(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldEqualFold(FieldOpenaiBase, v))
+}
+
+// OpenaiBaseContainsFold applies the ContainsFold predicate on the "openai_base" field.
+func OpenaiBaseContainsFold(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldContainsFold(FieldOpenaiBase, v))
+}
+
+// OpenaiKeyEQ applies the EQ predicate on the "openai_key" field.
+func OpenaiKeyEQ(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldEQ(FieldOpenaiKey, v))
+}
+
+// OpenaiKeyNEQ applies the NEQ predicate on the "openai_key" field.
+func OpenaiKeyNEQ(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldNEQ(FieldOpenaiKey, v))
+}
+
+// OpenaiKeyIn applies the In predicate on the "openai_key" field.
+func OpenaiKeyIn(vs ...string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldIn(FieldOpenaiKey, vs...))
+}
+
+// OpenaiKeyNotIn applies the NotIn predicate on the "openai_key" field.
+func OpenaiKeyNotIn(vs ...string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldNotIn(FieldOpenaiKey, vs...))
+}
+
+// OpenaiKeyGT applies the GT predicate on the "openai_key" field.
+func OpenaiKeyGT(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldGT(FieldOpenaiKey, v))
+}
+
+// OpenaiKeyGTE applies the GTE predicate on the "openai_key" field.
+func OpenaiKeyGTE(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldGTE(FieldOpenaiKey, v))
+}
+
+// OpenaiKeyLT applies the LT predicate on the "openai_key" field.
+func OpenaiKeyLT(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldLT(FieldOpenaiKey, v))
+}
+
+// OpenaiKeyLTE applies the LTE predicate on the "openai_key" field.
+func OpenaiKeyLTE(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldLTE(FieldOpenaiKey, v))
+}
+
+// OpenaiKeyContains applies the Contains predicate on the "openai_key" field.
+func OpenaiKeyContains(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldContains(FieldOpenaiKey, v))
+}
+
+// OpenaiKeyHasPrefix applies the HasPrefix predicate on the "openai_key" field.
+func OpenaiKeyHasPrefix(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldHasPrefix(FieldOpenaiKey, v))
+}
+
+// OpenaiKeyHasSuffix applies the HasSuffix predicate on the "openai_key" field.
+func OpenaiKeyHasSuffix(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldHasSuffix(FieldOpenaiKey, v))
+}
+
+// OpenaiKeyEqualFold applies the EqualFold predicate on the "openai_key" field.
+func OpenaiKeyEqualFold(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldEqualFold(FieldOpenaiKey, v))
+}
+
+// OpenaiKeyContainsFold applies the ContainsFold predicate on the "openai_key" field.
+func OpenaiKeyContainsFold(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldContainsFold(FieldOpenaiKey, v))
+}
+
+// RequestRawEQ applies the EQ predicate on the "request_raw" field.
+func RequestRawEQ(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldEQ(FieldRequestRaw, v))
+}
+
+// RequestRawNEQ applies the NEQ predicate on the "request_raw" field.
+func RequestRawNEQ(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldNEQ(FieldRequestRaw, v))
+}
+
+// RequestRawIn applies the In predicate on the "request_raw" field.
+func RequestRawIn(vs ...string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldIn(FieldRequestRaw, vs...))
+}
+
+// RequestRawNotIn applies the NotIn predicate on the "request_raw" field.
+func RequestRawNotIn(vs ...string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldNotIn(FieldRequestRaw, vs...))
+}
+
+// RequestRawGT applies the GT predicate on the "request_raw" field.
+func RequestRawGT(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldGT(FieldRequestRaw, v))
+}
+
+// RequestRawGTE applies the GTE predicate on the "request_raw" field.
+func RequestRawGTE(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldGTE(FieldRequestRaw, v))
+}
+
+// RequestRawLT applies the LT predicate on the "request_raw" field.
+func RequestRawLT(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldLT(FieldRequestRaw, v))
+}
+
+// RequestRawLTE applies the LTE predicate on the "request_raw" field.
+func RequestRawLTE(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldLTE(FieldRequestRaw, v))
+}
+
+// RequestRawContains applies the Contains predicate on the "request_raw" field.
+func RequestRawContains(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldContains(FieldRequestRaw, v))
+}
+
+// RequestRawHasPrefix applies the HasPrefix predicate on the "request_raw" field.
+func RequestRawHasPrefix(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldHasPrefix(FieldRequestRaw, v))
+}
+
+// RequestRawHasSuffix applies the HasSuffix predicate on the "request_raw" field.
+func RequestRawHasSuffix(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldHasSuffix(FieldRequestRaw, v))
+}
+
+// RequestRawEqualFold applies the EqualFold predicate on the "request_raw" field.
+func RequestRawEqualFold(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldEqualFold(FieldRequestRaw, v))
+}
+
+// RequestRawContainsFold applies the ContainsFold predicate on the "request_raw" field.
+func RequestRawContainsFold(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldContainsFold(FieldRequestRaw, v))
+}
+
+// ResponseRawEQ applies the EQ predicate on the "response_raw" field.
+func ResponseRawEQ(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldEQ(FieldResponseRaw, v))
+}
+
+// ResponseRawNEQ applies the NEQ predicate on the "response_raw" field.
+func ResponseRawNEQ(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldNEQ(FieldResponseRaw, v))
+}
+
+// ResponseRawIn applies the In predicate on the "response_raw" field.
+func ResponseRawIn(vs ...string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldIn(FieldResponseRaw, vs...))
+}
+
+// ResponseRawNotIn applies the NotIn predicate on the "response_raw" field.
+func ResponseRawNotIn(vs ...string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldNotIn(FieldResponseRaw, vs...))
+}
+
+// ResponseRawGT applies the GT predicate on the "response_raw" field.
+func ResponseRawGT(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldGT(FieldResponseRaw, v))
+}
+
+// ResponseRawGTE applies the GTE predicate on the "response_raw" field.
+func ResponseRawGTE(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldGTE(FieldResponseRaw, v))
+}
+
+// ResponseRawLT applies the LT predicate on the "response_raw" field.
+func ResponseRawLT(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldLT(FieldResponseRaw, v))
+}
+
+// ResponseRawLTE applies the LTE predicate on the "response_raw" field.
+func ResponseRawLTE(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldLTE(FieldResponseRaw, v))
+}
+
+// ResponseRawContains applies the Contains predicate on the "response_raw" field.
+func ResponseRawContains(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldContains(FieldResponseRaw, v))
+}
+
+// ResponseRawHasPrefix applies the HasPrefix predicate on the "response_raw" field.
+func ResponseRawHasPrefix(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldHasPrefix(FieldResponseRaw, v))
+}
+
+// ResponseRawHasSuffix applies the HasSuffix predicate on the "response_raw" field.
+func ResponseRawHasSuffix(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldHasSuffix(FieldResponseRaw, v))
+}
+
+// ResponseRawIsNil applies the IsNil predicate on the "response_raw" field.
+func ResponseRawIsNil() predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldIsNull(FieldResponseRaw))
+}
+
+// ResponseRawNotNil applies the NotNil predicate on the "response_raw" field.
+func ResponseRawNotNil() predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldNotNull(FieldResponseRaw))
+}
+
+// ResponseRawEqualFold applies the EqualFold predicate on the "response_raw" field.
+func ResponseRawEqualFold(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldEqualFold(FieldResponseRaw, v))
+}
+
+// ResponseRawContainsFold applies the ContainsFold predicate on the "response_raw" field.
+func ResponseRawContainsFold(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldContainsFold(FieldResponseRaw, v))
+}
+
+// CallbackURLEQ applies the EQ predicate on the "callback_url" field.
+func CallbackURLEQ(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldEQ(FieldCallbackURL, v))
+}
+
+// CallbackURLNEQ applies the NEQ predicate on the "callback_url" field.
+func CallbackURLNEQ(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldNEQ(FieldCallbackURL, v))
+}
+
+// CallbackURLIn applies the In predicate on the "callback_url" field.
+func CallbackURLIn(vs ...string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldIn(FieldCallbackURL, vs...))
+}
+
+// CallbackURLNotIn applies the NotIn predicate on the "callback_url" field.
+func CallbackURLNotIn(vs ...string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldNotIn(FieldCallbackURL, vs...))
+}
+
+// CallbackURLGT applies the GT predicate on the "callback_url" field.
+func CallbackURLGT(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldGT(FieldCallbackURL, v))
+}
+
+// CallbackURLGTE applies the GTE predicate on the "callback_url" field.
+func CallbackURLGTE(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldGTE(FieldCallbackURL, v))
+}
+
+// CallbackURLLT applies the LT predicate on the "callback_url" field.
+func CallbackURLLT(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldLT(FieldCallbackURL, v))
+}
+
+// CallbackURLLTE applies the LTE predicate on the "callback_url" field.
+func CallbackURLLTE(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldLTE(FieldCallbackURL, v))
+}
+
+// CallbackURLContains applies the Contains predicate on the "callback_url" field.
+func CallbackURLContains(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldContains(FieldCallbackURL, v))
+}
+
+// CallbackURLHasPrefix applies the HasPrefix predicate on the "callback_url" field.
+func CallbackURLHasPrefix(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldHasPrefix(FieldCallbackURL, v))
+}
+
+// CallbackURLHasSuffix applies the HasSuffix predicate on the "callback_url" field.
+func CallbackURLHasSuffix(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldHasSuffix(FieldCallbackURL, v))
+}
+
+// CallbackURLEqualFold applies the EqualFold predicate on the "callback_url" field.
+func CallbackURLEqualFold(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldEqualFold(FieldCallbackURL, v))
+}
+
+// CallbackURLContainsFold applies the ContainsFold predicate on the "callback_url" field.
+func CallbackURLContainsFold(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldContainsFold(FieldCallbackURL, v))
+}
+
+// TaskStatusEQ applies the EQ predicate on the "task_status" field.
+func TaskStatusEQ(v int8) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldEQ(FieldTaskStatus, v))
+}
+
+// TaskStatusNEQ applies the NEQ predicate on the "task_status" field.
+func TaskStatusNEQ(v int8) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldNEQ(FieldTaskStatus, v))
+}
+
+// TaskStatusIn applies the In predicate on the "task_status" field.
+func TaskStatusIn(vs ...int8) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldIn(FieldTaskStatus, vs...))
+}
+
+// TaskStatusNotIn applies the NotIn predicate on the "task_status" field.
+func TaskStatusNotIn(vs ...int8) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldNotIn(FieldTaskStatus, vs...))
+}
+
+// TaskStatusGT applies the GT predicate on the "task_status" field.
+func TaskStatusGT(v int8) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldGT(FieldTaskStatus, v))
+}
+
+// TaskStatusGTE applies the GTE predicate on the "task_status" field.
+func TaskStatusGTE(v int8) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldGTE(FieldTaskStatus, v))
+}
+
+// TaskStatusLT applies the LT predicate on the "task_status" field.
+func TaskStatusLT(v int8) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldLT(FieldTaskStatus, v))
+}
+
+// TaskStatusLTE applies the LTE predicate on the "task_status" field.
+func TaskStatusLTE(v int8) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldLTE(FieldTaskStatus, v))
+}
+
+// TaskStatusIsNil applies the IsNil predicate on the "task_status" field.
+func TaskStatusIsNil() predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldIsNull(FieldTaskStatus))
+}
+
+// TaskStatusNotNil applies the NotNil predicate on the "task_status" field.
+func TaskStatusNotNil() predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldNotNull(FieldTaskStatus))
+}
+
+// RetryCountEQ applies the EQ predicate on the "retry_count" field.
+func RetryCountEQ(v int8) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldEQ(FieldRetryCount, v))
+}
+
+// RetryCountNEQ applies the NEQ predicate on the "retry_count" field.
+func RetryCountNEQ(v int8) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldNEQ(FieldRetryCount, v))
+}
+
+// RetryCountIn applies the In predicate on the "retry_count" field.
+func RetryCountIn(vs ...int8) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldIn(FieldRetryCount, vs...))
+}
+
+// RetryCountNotIn applies the NotIn predicate on the "retry_count" field.
+func RetryCountNotIn(vs ...int8) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldNotIn(FieldRetryCount, vs...))
+}
+
+// RetryCountGT applies the GT predicate on the "retry_count" field.
+func RetryCountGT(v int8) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldGT(FieldRetryCount, v))
+}
+
+// RetryCountGTE applies the GTE predicate on the "retry_count" field.
+func RetryCountGTE(v int8) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldGTE(FieldRetryCount, v))
+}
+
+// RetryCountLT applies the LT predicate on the "retry_count" field.
+func RetryCountLT(v int8) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldLT(FieldRetryCount, v))
+}
+
+// RetryCountLTE applies the LTE predicate on the "retry_count" field.
+func RetryCountLTE(v int8) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldLTE(FieldRetryCount, v))
+}
+
+// RetryCountIsNil applies the IsNil predicate on the "retry_count" field.
+func RetryCountIsNil() predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldIsNull(FieldRetryCount))
+}
+
+// RetryCountNotNil applies the NotNil predicate on the "retry_count" field.
+func RetryCountNotNil() predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldNotNull(FieldRetryCount))
+}
+
+// LastErrorEQ applies the EQ predicate on the "last_error" field.
+func LastErrorEQ(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldEQ(FieldLastError, v))
+}
+
+// LastErrorNEQ applies the NEQ predicate on the "last_error" field.
+func LastErrorNEQ(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldNEQ(FieldLastError, v))
+}
+
+// LastErrorIn applies the In predicate on the "last_error" field.
+func LastErrorIn(vs ...string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldIn(FieldLastError, vs...))
+}
+
+// LastErrorNotIn applies the NotIn predicate on the "last_error" field.
+func LastErrorNotIn(vs ...string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldNotIn(FieldLastError, vs...))
+}
+
+// LastErrorGT applies the GT predicate on the "last_error" field.
+func LastErrorGT(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldGT(FieldLastError, v))
+}
+
+// LastErrorGTE applies the GTE predicate on the "last_error" field.
+func LastErrorGTE(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldGTE(FieldLastError, v))
+}
+
+// LastErrorLT applies the LT predicate on the "last_error" field.
+func LastErrorLT(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldLT(FieldLastError, v))
+}
+
+// LastErrorLTE applies the LTE predicate on the "last_error" field.
+func LastErrorLTE(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldLTE(FieldLastError, v))
+}
+
+// LastErrorContains applies the Contains predicate on the "last_error" field.
+func LastErrorContains(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldContains(FieldLastError, v))
+}
+
+// LastErrorHasPrefix applies the HasPrefix predicate on the "last_error" field.
+func LastErrorHasPrefix(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldHasPrefix(FieldLastError, v))
+}
+
+// LastErrorHasSuffix applies the HasSuffix predicate on the "last_error" field.
+func LastErrorHasSuffix(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldHasSuffix(FieldLastError, v))
+}
+
+// LastErrorIsNil applies the IsNil predicate on the "last_error" field.
+func LastErrorIsNil() predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldIsNull(FieldLastError))
+}
+
+// LastErrorNotNil applies the NotNil predicate on the "last_error" field.
+func LastErrorNotNil() predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldNotNull(FieldLastError))
+}
+
+// LastErrorEqualFold applies the EqualFold predicate on the "last_error" field.
+func LastErrorEqualFold(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldEqualFold(FieldLastError, v))
+}
+
+// LastErrorContainsFold applies the ContainsFold predicate on the "last_error" field.
+func LastErrorContainsFold(v string) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.FieldContainsFold(FieldLastError, v))
+}
+
+// And groups predicates with the AND operator between them.
+func And(predicates ...predicate.CompapiAsynctask) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.AndPredicates(predicates...))
+}
+
+// Or groups predicates with the OR operator between them.
+func Or(predicates ...predicate.CompapiAsynctask) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.OrPredicates(predicates...))
+}
+
+// Not applies the not operator on the given predicate.
+func Not(p predicate.CompapiAsynctask) predicate.CompapiAsynctask {
+	return predicate.CompapiAsynctask(sql.NotPredicates(p))
+}

+ 1421 - 0
ent/compapiasynctask_create.go

@@ -0,0 +1,1421 @@
+// Code generated by ent, DO NOT EDIT.
+
+package ent
+
+import (
+	"context"
+	"errors"
+	"fmt"
+	"time"
+	"wechat-api/ent/compapiasynctask"
+
+	"entgo.io/ent/dialect/sql"
+	"entgo.io/ent/dialect/sql/sqlgraph"
+	"entgo.io/ent/schema/field"
+)
+
+// CompapiAsynctaskCreate is the builder for creating a CompapiAsynctask entity.
+type CompapiAsynctaskCreate struct {
+	config
+	mutation *CompapiAsynctaskMutation
+	hooks    []Hook
+	conflict []sql.ConflictOption
+}
+
+// SetCreatedAt sets the "created_at" field.
+func (cac *CompapiAsynctaskCreate) SetCreatedAt(t time.Time) *CompapiAsynctaskCreate {
+	cac.mutation.SetCreatedAt(t)
+	return cac
+}
+
+// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
+func (cac *CompapiAsynctaskCreate) SetNillableCreatedAt(t *time.Time) *CompapiAsynctaskCreate {
+	if t != nil {
+		cac.SetCreatedAt(*t)
+	}
+	return cac
+}
+
+// SetUpdatedAt sets the "updated_at" field.
+func (cac *CompapiAsynctaskCreate) SetUpdatedAt(t time.Time) *CompapiAsynctaskCreate {
+	cac.mutation.SetUpdatedAt(t)
+	return cac
+}
+
+// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
+func (cac *CompapiAsynctaskCreate) SetNillableUpdatedAt(t *time.Time) *CompapiAsynctaskCreate {
+	if t != nil {
+		cac.SetUpdatedAt(*t)
+	}
+	return cac
+}
+
+// SetAuthToken sets the "auth_token" field.
+func (cac *CompapiAsynctaskCreate) SetAuthToken(s string) *CompapiAsynctaskCreate {
+	cac.mutation.SetAuthToken(s)
+	return cac
+}
+
+// SetEventType sets the "event_type" field.
+func (cac *CompapiAsynctaskCreate) SetEventType(s string) *CompapiAsynctaskCreate {
+	cac.mutation.SetEventType(s)
+	return cac
+}
+
+// SetNillableEventType sets the "event_type" field if the given value is not nil.
+func (cac *CompapiAsynctaskCreate) SetNillableEventType(s *string) *CompapiAsynctaskCreate {
+	if s != nil {
+		cac.SetEventType(*s)
+	}
+	return cac
+}
+
+// SetChatID sets the "chat_id" field.
+func (cac *CompapiAsynctaskCreate) SetChatID(s string) *CompapiAsynctaskCreate {
+	cac.mutation.SetChatID(s)
+	return cac
+}
+
+// SetNillableChatID sets the "chat_id" field if the given value is not nil.
+func (cac *CompapiAsynctaskCreate) SetNillableChatID(s *string) *CompapiAsynctaskCreate {
+	if s != nil {
+		cac.SetChatID(*s)
+	}
+	return cac
+}
+
+// SetWorkidIdx sets the "workid_idx" field.
+func (cac *CompapiAsynctaskCreate) SetWorkidIdx(i int8) *CompapiAsynctaskCreate {
+	cac.mutation.SetWorkidIdx(i)
+	return cac
+}
+
+// SetNillableWorkidIdx sets the "workid_idx" field if the given value is not nil.
+func (cac *CompapiAsynctaskCreate) SetNillableWorkidIdx(i *int8) *CompapiAsynctaskCreate {
+	if i != nil {
+		cac.SetWorkidIdx(*i)
+	}
+	return cac
+}
+
+// SetOpenaiBase sets the "openai_base" field.
+func (cac *CompapiAsynctaskCreate) SetOpenaiBase(s string) *CompapiAsynctaskCreate {
+	cac.mutation.SetOpenaiBase(s)
+	return cac
+}
+
+// SetOpenaiKey sets the "openai_key" field.
+func (cac *CompapiAsynctaskCreate) SetOpenaiKey(s string) *CompapiAsynctaskCreate {
+	cac.mutation.SetOpenaiKey(s)
+	return cac
+}
+
+// SetRequestRaw sets the "request_raw" field.
+func (cac *CompapiAsynctaskCreate) SetRequestRaw(s string) *CompapiAsynctaskCreate {
+	cac.mutation.SetRequestRaw(s)
+	return cac
+}
+
+// SetResponseRaw sets the "response_raw" field.
+func (cac *CompapiAsynctaskCreate) SetResponseRaw(s string) *CompapiAsynctaskCreate {
+	cac.mutation.SetResponseRaw(s)
+	return cac
+}
+
+// SetNillableResponseRaw sets the "response_raw" field if the given value is not nil.
+func (cac *CompapiAsynctaskCreate) SetNillableResponseRaw(s *string) *CompapiAsynctaskCreate {
+	if s != nil {
+		cac.SetResponseRaw(*s)
+	}
+	return cac
+}
+
+// SetCallbackURL sets the "callback_url" field.
+func (cac *CompapiAsynctaskCreate) SetCallbackURL(s string) *CompapiAsynctaskCreate {
+	cac.mutation.SetCallbackURL(s)
+	return cac
+}
+
+// SetTaskStatus sets the "task_status" field.
+func (cac *CompapiAsynctaskCreate) SetTaskStatus(i int8) *CompapiAsynctaskCreate {
+	cac.mutation.SetTaskStatus(i)
+	return cac
+}
+
+// SetNillableTaskStatus sets the "task_status" field if the given value is not nil.
+func (cac *CompapiAsynctaskCreate) SetNillableTaskStatus(i *int8) *CompapiAsynctaskCreate {
+	if i != nil {
+		cac.SetTaskStatus(*i)
+	}
+	return cac
+}
+
+// SetRetryCount sets the "retry_count" field.
+func (cac *CompapiAsynctaskCreate) SetRetryCount(i int8) *CompapiAsynctaskCreate {
+	cac.mutation.SetRetryCount(i)
+	return cac
+}
+
+// SetNillableRetryCount sets the "retry_count" field if the given value is not nil.
+func (cac *CompapiAsynctaskCreate) SetNillableRetryCount(i *int8) *CompapiAsynctaskCreate {
+	if i != nil {
+		cac.SetRetryCount(*i)
+	}
+	return cac
+}
+
+// SetLastError sets the "last_error" field.
+func (cac *CompapiAsynctaskCreate) SetLastError(s string) *CompapiAsynctaskCreate {
+	cac.mutation.SetLastError(s)
+	return cac
+}
+
+// SetNillableLastError sets the "last_error" field if the given value is not nil.
+func (cac *CompapiAsynctaskCreate) SetNillableLastError(s *string) *CompapiAsynctaskCreate {
+	if s != nil {
+		cac.SetLastError(*s)
+	}
+	return cac
+}
+
+// SetID sets the "id" field.
+func (cac *CompapiAsynctaskCreate) SetID(u uint64) *CompapiAsynctaskCreate {
+	cac.mutation.SetID(u)
+	return cac
+}
+
+// Mutation returns the CompapiAsynctaskMutation object of the builder.
+func (cac *CompapiAsynctaskCreate) Mutation() *CompapiAsynctaskMutation {
+	return cac.mutation
+}
+
+// Save creates the CompapiAsynctask in the database.
+func (cac *CompapiAsynctaskCreate) Save(ctx context.Context) (*CompapiAsynctask, error) {
+	cac.defaults()
+	return withHooks(ctx, cac.sqlSave, cac.mutation, cac.hooks)
+}
+
+// SaveX calls Save and panics if Save returns an error.
+func (cac *CompapiAsynctaskCreate) SaveX(ctx context.Context) *CompapiAsynctask {
+	v, err := cac.Save(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return v
+}
+
+// Exec executes the query.
+func (cac *CompapiAsynctaskCreate) Exec(ctx context.Context) error {
+	_, err := cac.Save(ctx)
+	return err
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (cac *CompapiAsynctaskCreate) ExecX(ctx context.Context) {
+	if err := cac.Exec(ctx); err != nil {
+		panic(err)
+	}
+}
+
+// defaults sets the default values of the builder before save.
+func (cac *CompapiAsynctaskCreate) defaults() {
+	if _, ok := cac.mutation.CreatedAt(); !ok {
+		v := compapiasynctask.DefaultCreatedAt()
+		cac.mutation.SetCreatedAt(v)
+	}
+	if _, ok := cac.mutation.UpdatedAt(); !ok {
+		v := compapiasynctask.DefaultUpdatedAt()
+		cac.mutation.SetUpdatedAt(v)
+	}
+	if _, ok := cac.mutation.EventType(); !ok {
+		v := compapiasynctask.DefaultEventType
+		cac.mutation.SetEventType(v)
+	}
+	if _, ok := cac.mutation.ChatID(); !ok {
+		v := compapiasynctask.DefaultChatID
+		cac.mutation.SetChatID(v)
+	}
+	if _, ok := cac.mutation.WorkidIdx(); !ok {
+		v := compapiasynctask.DefaultWorkidIdx
+		cac.mutation.SetWorkidIdx(v)
+	}
+	if _, ok := cac.mutation.ResponseRaw(); !ok {
+		v := compapiasynctask.DefaultResponseRaw
+		cac.mutation.SetResponseRaw(v)
+	}
+	if _, ok := cac.mutation.TaskStatus(); !ok {
+		v := compapiasynctask.DefaultTaskStatus
+		cac.mutation.SetTaskStatus(v)
+	}
+	if _, ok := cac.mutation.RetryCount(); !ok {
+		v := compapiasynctask.DefaultRetryCount
+		cac.mutation.SetRetryCount(v)
+	}
+	if _, ok := cac.mutation.LastError(); !ok {
+		v := compapiasynctask.DefaultLastError
+		cac.mutation.SetLastError(v)
+	}
+}
+
+// check runs all checks and user-defined validators on the builder.
+func (cac *CompapiAsynctaskCreate) check() error {
+	if _, ok := cac.mutation.CreatedAt(); !ok {
+		return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "CompapiAsynctask.created_at"`)}
+	}
+	if _, ok := cac.mutation.UpdatedAt(); !ok {
+		return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "CompapiAsynctask.updated_at"`)}
+	}
+	if _, ok := cac.mutation.AuthToken(); !ok {
+		return &ValidationError{Name: "auth_token", err: errors.New(`ent: missing required field "CompapiAsynctask.auth_token"`)}
+	}
+	if _, ok := cac.mutation.EventType(); !ok {
+		return &ValidationError{Name: "event_type", err: errors.New(`ent: missing required field "CompapiAsynctask.event_type"`)}
+	}
+	if _, ok := cac.mutation.OpenaiBase(); !ok {
+		return &ValidationError{Name: "openai_base", err: errors.New(`ent: missing required field "CompapiAsynctask.openai_base"`)}
+	}
+	if _, ok := cac.mutation.OpenaiKey(); !ok {
+		return &ValidationError{Name: "openai_key", err: errors.New(`ent: missing required field "CompapiAsynctask.openai_key"`)}
+	}
+	if _, ok := cac.mutation.RequestRaw(); !ok {
+		return &ValidationError{Name: "request_raw", err: errors.New(`ent: missing required field "CompapiAsynctask.request_raw"`)}
+	}
+	if _, ok := cac.mutation.CallbackURL(); !ok {
+		return &ValidationError{Name: "callback_url", err: errors.New(`ent: missing required field "CompapiAsynctask.callback_url"`)}
+	}
+	if v, ok := cac.mutation.CallbackURL(); ok {
+		if err := compapiasynctask.CallbackURLValidator(v); err != nil {
+			return &ValidationError{Name: "callback_url", err: fmt.Errorf(`ent: validator failed for field "CompapiAsynctask.callback_url": %w`, err)}
+		}
+	}
+	return nil
+}
+
+func (cac *CompapiAsynctaskCreate) sqlSave(ctx context.Context) (*CompapiAsynctask, error) {
+	if err := cac.check(); err != nil {
+		return nil, err
+	}
+	_node, _spec := cac.createSpec()
+	if err := sqlgraph.CreateNode(ctx, cac.driver, _spec); err != nil {
+		if sqlgraph.IsConstraintError(err) {
+			err = &ConstraintError{msg: err.Error(), wrap: err}
+		}
+		return nil, err
+	}
+	if _spec.ID.Value != _node.ID {
+		id := _spec.ID.Value.(int64)
+		_node.ID = uint64(id)
+	}
+	cac.mutation.id = &_node.ID
+	cac.mutation.done = true
+	return _node, nil
+}
+
+func (cac *CompapiAsynctaskCreate) createSpec() (*CompapiAsynctask, *sqlgraph.CreateSpec) {
+	var (
+		_node = &CompapiAsynctask{config: cac.config}
+		_spec = sqlgraph.NewCreateSpec(compapiasynctask.Table, sqlgraph.NewFieldSpec(compapiasynctask.FieldID, field.TypeUint64))
+	)
+	_spec.OnConflict = cac.conflict
+	if id, ok := cac.mutation.ID(); ok {
+		_node.ID = id
+		_spec.ID.Value = id
+	}
+	if value, ok := cac.mutation.CreatedAt(); ok {
+		_spec.SetField(compapiasynctask.FieldCreatedAt, field.TypeTime, value)
+		_node.CreatedAt = value
+	}
+	if value, ok := cac.mutation.UpdatedAt(); ok {
+		_spec.SetField(compapiasynctask.FieldUpdatedAt, field.TypeTime, value)
+		_node.UpdatedAt = value
+	}
+	if value, ok := cac.mutation.AuthToken(); ok {
+		_spec.SetField(compapiasynctask.FieldAuthToken, field.TypeString, value)
+		_node.AuthToken = value
+	}
+	if value, ok := cac.mutation.EventType(); ok {
+		_spec.SetField(compapiasynctask.FieldEventType, field.TypeString, value)
+		_node.EventType = value
+	}
+	if value, ok := cac.mutation.ChatID(); ok {
+		_spec.SetField(compapiasynctask.FieldChatID, field.TypeString, value)
+		_node.ChatID = value
+	}
+	if value, ok := cac.mutation.WorkidIdx(); ok {
+		_spec.SetField(compapiasynctask.FieldWorkidIdx, field.TypeInt8, value)
+		_node.WorkidIdx = value
+	}
+	if value, ok := cac.mutation.OpenaiBase(); ok {
+		_spec.SetField(compapiasynctask.FieldOpenaiBase, field.TypeString, value)
+		_node.OpenaiBase = value
+	}
+	if value, ok := cac.mutation.OpenaiKey(); ok {
+		_spec.SetField(compapiasynctask.FieldOpenaiKey, field.TypeString, value)
+		_node.OpenaiKey = value
+	}
+	if value, ok := cac.mutation.RequestRaw(); ok {
+		_spec.SetField(compapiasynctask.FieldRequestRaw, field.TypeString, value)
+		_node.RequestRaw = value
+	}
+	if value, ok := cac.mutation.ResponseRaw(); ok {
+		_spec.SetField(compapiasynctask.FieldResponseRaw, field.TypeString, value)
+		_node.ResponseRaw = value
+	}
+	if value, ok := cac.mutation.CallbackURL(); ok {
+		_spec.SetField(compapiasynctask.FieldCallbackURL, field.TypeString, value)
+		_node.CallbackURL = value
+	}
+	if value, ok := cac.mutation.TaskStatus(); ok {
+		_spec.SetField(compapiasynctask.FieldTaskStatus, field.TypeInt8, value)
+		_node.TaskStatus = value
+	}
+	if value, ok := cac.mutation.RetryCount(); ok {
+		_spec.SetField(compapiasynctask.FieldRetryCount, field.TypeInt8, value)
+		_node.RetryCount = value
+	}
+	if value, ok := cac.mutation.LastError(); ok {
+		_spec.SetField(compapiasynctask.FieldLastError, field.TypeString, value)
+		_node.LastError = value
+	}
+	return _node, _spec
+}
+
+// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
+// of the `INSERT` statement. For example:
+//
+//	client.CompapiAsynctask.Create().
+//		SetCreatedAt(v).
+//		OnConflict(
+//			// Update the row with the new values
+//			// the was proposed for insertion.
+//			sql.ResolveWithNewValues(),
+//		).
+//		// Override some of the fields with custom
+//		// update values.
+//		Update(func(u *ent.CompapiAsynctaskUpsert) {
+//			SetCreatedAt(v+v).
+//		}).
+//		Exec(ctx)
+func (cac *CompapiAsynctaskCreate) OnConflict(opts ...sql.ConflictOption) *CompapiAsynctaskUpsertOne {
+	cac.conflict = opts
+	return &CompapiAsynctaskUpsertOne{
+		create: cac,
+	}
+}
+
+// OnConflictColumns calls `OnConflict` and configures the columns
+// as conflict target. Using this option is equivalent to using:
+//
+//	client.CompapiAsynctask.Create().
+//		OnConflict(sql.ConflictColumns(columns...)).
+//		Exec(ctx)
+func (cac *CompapiAsynctaskCreate) OnConflictColumns(columns ...string) *CompapiAsynctaskUpsertOne {
+	cac.conflict = append(cac.conflict, sql.ConflictColumns(columns...))
+	return &CompapiAsynctaskUpsertOne{
+		create: cac,
+	}
+}
+
+type (
+	// CompapiAsynctaskUpsertOne is the builder for "upsert"-ing
+	//  one CompapiAsynctask node.
+	CompapiAsynctaskUpsertOne struct {
+		create *CompapiAsynctaskCreate
+	}
+
+	// CompapiAsynctaskUpsert is the "OnConflict" setter.
+	CompapiAsynctaskUpsert struct {
+		*sql.UpdateSet
+	}
+)
+
+// SetUpdatedAt sets the "updated_at" field.
+func (u *CompapiAsynctaskUpsert) SetUpdatedAt(v time.Time) *CompapiAsynctaskUpsert {
+	u.Set(compapiasynctask.FieldUpdatedAt, v)
+	return u
+}
+
+// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
+func (u *CompapiAsynctaskUpsert) UpdateUpdatedAt() *CompapiAsynctaskUpsert {
+	u.SetExcluded(compapiasynctask.FieldUpdatedAt)
+	return u
+}
+
+// SetAuthToken sets the "auth_token" field.
+func (u *CompapiAsynctaskUpsert) SetAuthToken(v string) *CompapiAsynctaskUpsert {
+	u.Set(compapiasynctask.FieldAuthToken, v)
+	return u
+}
+
+// UpdateAuthToken sets the "auth_token" field to the value that was provided on create.
+func (u *CompapiAsynctaskUpsert) UpdateAuthToken() *CompapiAsynctaskUpsert {
+	u.SetExcluded(compapiasynctask.FieldAuthToken)
+	return u
+}
+
+// SetEventType sets the "event_type" field.
+func (u *CompapiAsynctaskUpsert) SetEventType(v string) *CompapiAsynctaskUpsert {
+	u.Set(compapiasynctask.FieldEventType, v)
+	return u
+}
+
+// UpdateEventType sets the "event_type" field to the value that was provided on create.
+func (u *CompapiAsynctaskUpsert) UpdateEventType() *CompapiAsynctaskUpsert {
+	u.SetExcluded(compapiasynctask.FieldEventType)
+	return u
+}
+
+// SetChatID sets the "chat_id" field.
+func (u *CompapiAsynctaskUpsert) SetChatID(v string) *CompapiAsynctaskUpsert {
+	u.Set(compapiasynctask.FieldChatID, v)
+	return u
+}
+
+// UpdateChatID sets the "chat_id" field to the value that was provided on create.
+func (u *CompapiAsynctaskUpsert) UpdateChatID() *CompapiAsynctaskUpsert {
+	u.SetExcluded(compapiasynctask.FieldChatID)
+	return u
+}
+
+// ClearChatID clears the value of the "chat_id" field.
+func (u *CompapiAsynctaskUpsert) ClearChatID() *CompapiAsynctaskUpsert {
+	u.SetNull(compapiasynctask.FieldChatID)
+	return u
+}
+
+// SetWorkidIdx sets the "workid_idx" field.
+func (u *CompapiAsynctaskUpsert) SetWorkidIdx(v int8) *CompapiAsynctaskUpsert {
+	u.Set(compapiasynctask.FieldWorkidIdx, v)
+	return u
+}
+
+// UpdateWorkidIdx sets the "workid_idx" field to the value that was provided on create.
+func (u *CompapiAsynctaskUpsert) UpdateWorkidIdx() *CompapiAsynctaskUpsert {
+	u.SetExcluded(compapiasynctask.FieldWorkidIdx)
+	return u
+}
+
+// AddWorkidIdx adds v to the "workid_idx" field.
+func (u *CompapiAsynctaskUpsert) AddWorkidIdx(v int8) *CompapiAsynctaskUpsert {
+	u.Add(compapiasynctask.FieldWorkidIdx, v)
+	return u
+}
+
+// ClearWorkidIdx clears the value of the "workid_idx" field.
+func (u *CompapiAsynctaskUpsert) ClearWorkidIdx() *CompapiAsynctaskUpsert {
+	u.SetNull(compapiasynctask.FieldWorkidIdx)
+	return u
+}
+
+// SetOpenaiBase sets the "openai_base" field.
+func (u *CompapiAsynctaskUpsert) SetOpenaiBase(v string) *CompapiAsynctaskUpsert {
+	u.Set(compapiasynctask.FieldOpenaiBase, v)
+	return u
+}
+
+// UpdateOpenaiBase sets the "openai_base" field to the value that was provided on create.
+func (u *CompapiAsynctaskUpsert) UpdateOpenaiBase() *CompapiAsynctaskUpsert {
+	u.SetExcluded(compapiasynctask.FieldOpenaiBase)
+	return u
+}
+
+// SetOpenaiKey sets the "openai_key" field.
+func (u *CompapiAsynctaskUpsert) SetOpenaiKey(v string) *CompapiAsynctaskUpsert {
+	u.Set(compapiasynctask.FieldOpenaiKey, v)
+	return u
+}
+
+// UpdateOpenaiKey sets the "openai_key" field to the value that was provided on create.
+func (u *CompapiAsynctaskUpsert) UpdateOpenaiKey() *CompapiAsynctaskUpsert {
+	u.SetExcluded(compapiasynctask.FieldOpenaiKey)
+	return u
+}
+
+// SetRequestRaw sets the "request_raw" field.
+func (u *CompapiAsynctaskUpsert) SetRequestRaw(v string) *CompapiAsynctaskUpsert {
+	u.Set(compapiasynctask.FieldRequestRaw, v)
+	return u
+}
+
+// UpdateRequestRaw sets the "request_raw" field to the value that was provided on create.
+func (u *CompapiAsynctaskUpsert) UpdateRequestRaw() *CompapiAsynctaskUpsert {
+	u.SetExcluded(compapiasynctask.FieldRequestRaw)
+	return u
+}
+
+// SetResponseRaw sets the "response_raw" field.
+func (u *CompapiAsynctaskUpsert) SetResponseRaw(v string) *CompapiAsynctaskUpsert {
+	u.Set(compapiasynctask.FieldResponseRaw, v)
+	return u
+}
+
+// UpdateResponseRaw sets the "response_raw" field to the value that was provided on create.
+func (u *CompapiAsynctaskUpsert) UpdateResponseRaw() *CompapiAsynctaskUpsert {
+	u.SetExcluded(compapiasynctask.FieldResponseRaw)
+	return u
+}
+
+// ClearResponseRaw clears the value of the "response_raw" field.
+func (u *CompapiAsynctaskUpsert) ClearResponseRaw() *CompapiAsynctaskUpsert {
+	u.SetNull(compapiasynctask.FieldResponseRaw)
+	return u
+}
+
+// SetCallbackURL sets the "callback_url" field.
+func (u *CompapiAsynctaskUpsert) SetCallbackURL(v string) *CompapiAsynctaskUpsert {
+	u.Set(compapiasynctask.FieldCallbackURL, v)
+	return u
+}
+
+// UpdateCallbackURL sets the "callback_url" field to the value that was provided on create.
+func (u *CompapiAsynctaskUpsert) UpdateCallbackURL() *CompapiAsynctaskUpsert {
+	u.SetExcluded(compapiasynctask.FieldCallbackURL)
+	return u
+}
+
+// SetTaskStatus sets the "task_status" field.
+func (u *CompapiAsynctaskUpsert) SetTaskStatus(v int8) *CompapiAsynctaskUpsert {
+	u.Set(compapiasynctask.FieldTaskStatus, v)
+	return u
+}
+
+// UpdateTaskStatus sets the "task_status" field to the value that was provided on create.
+func (u *CompapiAsynctaskUpsert) UpdateTaskStatus() *CompapiAsynctaskUpsert {
+	u.SetExcluded(compapiasynctask.FieldTaskStatus)
+	return u
+}
+
+// AddTaskStatus adds v to the "task_status" field.
+func (u *CompapiAsynctaskUpsert) AddTaskStatus(v int8) *CompapiAsynctaskUpsert {
+	u.Add(compapiasynctask.FieldTaskStatus, v)
+	return u
+}
+
+// ClearTaskStatus clears the value of the "task_status" field.
+func (u *CompapiAsynctaskUpsert) ClearTaskStatus() *CompapiAsynctaskUpsert {
+	u.SetNull(compapiasynctask.FieldTaskStatus)
+	return u
+}
+
+// SetRetryCount sets the "retry_count" field.
+func (u *CompapiAsynctaskUpsert) SetRetryCount(v int8) *CompapiAsynctaskUpsert {
+	u.Set(compapiasynctask.FieldRetryCount, v)
+	return u
+}
+
+// UpdateRetryCount sets the "retry_count" field to the value that was provided on create.
+func (u *CompapiAsynctaskUpsert) UpdateRetryCount() *CompapiAsynctaskUpsert {
+	u.SetExcluded(compapiasynctask.FieldRetryCount)
+	return u
+}
+
+// AddRetryCount adds v to the "retry_count" field.
+func (u *CompapiAsynctaskUpsert) AddRetryCount(v int8) *CompapiAsynctaskUpsert {
+	u.Add(compapiasynctask.FieldRetryCount, v)
+	return u
+}
+
+// ClearRetryCount clears the value of the "retry_count" field.
+func (u *CompapiAsynctaskUpsert) ClearRetryCount() *CompapiAsynctaskUpsert {
+	u.SetNull(compapiasynctask.FieldRetryCount)
+	return u
+}
+
+// SetLastError sets the "last_error" field.
+func (u *CompapiAsynctaskUpsert) SetLastError(v string) *CompapiAsynctaskUpsert {
+	u.Set(compapiasynctask.FieldLastError, v)
+	return u
+}
+
+// UpdateLastError sets the "last_error" field to the value that was provided on create.
+func (u *CompapiAsynctaskUpsert) UpdateLastError() *CompapiAsynctaskUpsert {
+	u.SetExcluded(compapiasynctask.FieldLastError)
+	return u
+}
+
+// ClearLastError clears the value of the "last_error" field.
+func (u *CompapiAsynctaskUpsert) ClearLastError() *CompapiAsynctaskUpsert {
+	u.SetNull(compapiasynctask.FieldLastError)
+	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:
+//
+//	client.CompapiAsynctask.Create().
+//		OnConflict(
+//			sql.ResolveWithNewValues(),
+//			sql.ResolveWith(func(u *sql.UpdateSet) {
+//				u.SetIgnore(compapiasynctask.FieldID)
+//			}),
+//		).
+//		Exec(ctx)
+func (u *CompapiAsynctaskUpsertOne) UpdateNewValues() *CompapiAsynctaskUpsertOne {
+	u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
+	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
+		if _, exists := u.create.mutation.ID(); exists {
+			s.SetIgnore(compapiasynctask.FieldID)
+		}
+		if _, exists := u.create.mutation.CreatedAt(); exists {
+			s.SetIgnore(compapiasynctask.FieldCreatedAt)
+		}
+	}))
+	return u
+}
+
+// Ignore sets each column to itself in case of conflict.
+// Using this option is equivalent to using:
+//
+//	client.CompapiAsynctask.Create().
+//	    OnConflict(sql.ResolveWithIgnore()).
+//	    Exec(ctx)
+func (u *CompapiAsynctaskUpsertOne) Ignore() *CompapiAsynctaskUpsertOne {
+	u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
+	return u
+}
+
+// DoNothing configures the conflict_action to `DO NOTHING`.
+// Supported only by SQLite and PostgreSQL.
+func (u *CompapiAsynctaskUpsertOne) DoNothing() *CompapiAsynctaskUpsertOne {
+	u.create.conflict = append(u.create.conflict, sql.DoNothing())
+	return u
+}
+
+// Update allows overriding fields `UPDATE` values. See the CompapiAsynctaskCreate.OnConflict
+// documentation for more info.
+func (u *CompapiAsynctaskUpsertOne) Update(set func(*CompapiAsynctaskUpsert)) *CompapiAsynctaskUpsertOne {
+	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
+		set(&CompapiAsynctaskUpsert{UpdateSet: update})
+	}))
+	return u
+}
+
+// SetUpdatedAt sets the "updated_at" field.
+func (u *CompapiAsynctaskUpsertOne) SetUpdatedAt(v time.Time) *CompapiAsynctaskUpsertOne {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.SetUpdatedAt(v)
+	})
+}
+
+// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
+func (u *CompapiAsynctaskUpsertOne) UpdateUpdatedAt() *CompapiAsynctaskUpsertOne {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.UpdateUpdatedAt()
+	})
+}
+
+// SetAuthToken sets the "auth_token" field.
+func (u *CompapiAsynctaskUpsertOne) SetAuthToken(v string) *CompapiAsynctaskUpsertOne {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.SetAuthToken(v)
+	})
+}
+
+// UpdateAuthToken sets the "auth_token" field to the value that was provided on create.
+func (u *CompapiAsynctaskUpsertOne) UpdateAuthToken() *CompapiAsynctaskUpsertOne {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.UpdateAuthToken()
+	})
+}
+
+// SetEventType sets the "event_type" field.
+func (u *CompapiAsynctaskUpsertOne) SetEventType(v string) *CompapiAsynctaskUpsertOne {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.SetEventType(v)
+	})
+}
+
+// UpdateEventType sets the "event_type" field to the value that was provided on create.
+func (u *CompapiAsynctaskUpsertOne) UpdateEventType() *CompapiAsynctaskUpsertOne {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.UpdateEventType()
+	})
+}
+
+// SetChatID sets the "chat_id" field.
+func (u *CompapiAsynctaskUpsertOne) SetChatID(v string) *CompapiAsynctaskUpsertOne {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.SetChatID(v)
+	})
+}
+
+// UpdateChatID sets the "chat_id" field to the value that was provided on create.
+func (u *CompapiAsynctaskUpsertOne) UpdateChatID() *CompapiAsynctaskUpsertOne {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.UpdateChatID()
+	})
+}
+
+// ClearChatID clears the value of the "chat_id" field.
+func (u *CompapiAsynctaskUpsertOne) ClearChatID() *CompapiAsynctaskUpsertOne {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.ClearChatID()
+	})
+}
+
+// SetWorkidIdx sets the "workid_idx" field.
+func (u *CompapiAsynctaskUpsertOne) SetWorkidIdx(v int8) *CompapiAsynctaskUpsertOne {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.SetWorkidIdx(v)
+	})
+}
+
+// AddWorkidIdx adds v to the "workid_idx" field.
+func (u *CompapiAsynctaskUpsertOne) AddWorkidIdx(v int8) *CompapiAsynctaskUpsertOne {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.AddWorkidIdx(v)
+	})
+}
+
+// UpdateWorkidIdx sets the "workid_idx" field to the value that was provided on create.
+func (u *CompapiAsynctaskUpsertOne) UpdateWorkidIdx() *CompapiAsynctaskUpsertOne {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.UpdateWorkidIdx()
+	})
+}
+
+// ClearWorkidIdx clears the value of the "workid_idx" field.
+func (u *CompapiAsynctaskUpsertOne) ClearWorkidIdx() *CompapiAsynctaskUpsertOne {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.ClearWorkidIdx()
+	})
+}
+
+// SetOpenaiBase sets the "openai_base" field.
+func (u *CompapiAsynctaskUpsertOne) SetOpenaiBase(v string) *CompapiAsynctaskUpsertOne {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.SetOpenaiBase(v)
+	})
+}
+
+// UpdateOpenaiBase sets the "openai_base" field to the value that was provided on create.
+func (u *CompapiAsynctaskUpsertOne) UpdateOpenaiBase() *CompapiAsynctaskUpsertOne {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.UpdateOpenaiBase()
+	})
+}
+
+// SetOpenaiKey sets the "openai_key" field.
+func (u *CompapiAsynctaskUpsertOne) SetOpenaiKey(v string) *CompapiAsynctaskUpsertOne {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.SetOpenaiKey(v)
+	})
+}
+
+// UpdateOpenaiKey sets the "openai_key" field to the value that was provided on create.
+func (u *CompapiAsynctaskUpsertOne) UpdateOpenaiKey() *CompapiAsynctaskUpsertOne {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.UpdateOpenaiKey()
+	})
+}
+
+// SetRequestRaw sets the "request_raw" field.
+func (u *CompapiAsynctaskUpsertOne) SetRequestRaw(v string) *CompapiAsynctaskUpsertOne {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.SetRequestRaw(v)
+	})
+}
+
+// UpdateRequestRaw sets the "request_raw" field to the value that was provided on create.
+func (u *CompapiAsynctaskUpsertOne) UpdateRequestRaw() *CompapiAsynctaskUpsertOne {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.UpdateRequestRaw()
+	})
+}
+
+// SetResponseRaw sets the "response_raw" field.
+func (u *CompapiAsynctaskUpsertOne) SetResponseRaw(v string) *CompapiAsynctaskUpsertOne {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.SetResponseRaw(v)
+	})
+}
+
+// UpdateResponseRaw sets the "response_raw" field to the value that was provided on create.
+func (u *CompapiAsynctaskUpsertOne) UpdateResponseRaw() *CompapiAsynctaskUpsertOne {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.UpdateResponseRaw()
+	})
+}
+
+// ClearResponseRaw clears the value of the "response_raw" field.
+func (u *CompapiAsynctaskUpsertOne) ClearResponseRaw() *CompapiAsynctaskUpsertOne {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.ClearResponseRaw()
+	})
+}
+
+// SetCallbackURL sets the "callback_url" field.
+func (u *CompapiAsynctaskUpsertOne) SetCallbackURL(v string) *CompapiAsynctaskUpsertOne {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.SetCallbackURL(v)
+	})
+}
+
+// UpdateCallbackURL sets the "callback_url" field to the value that was provided on create.
+func (u *CompapiAsynctaskUpsertOne) UpdateCallbackURL() *CompapiAsynctaskUpsertOne {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.UpdateCallbackURL()
+	})
+}
+
+// SetTaskStatus sets the "task_status" field.
+func (u *CompapiAsynctaskUpsertOne) SetTaskStatus(v int8) *CompapiAsynctaskUpsertOne {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.SetTaskStatus(v)
+	})
+}
+
+// AddTaskStatus adds v to the "task_status" field.
+func (u *CompapiAsynctaskUpsertOne) AddTaskStatus(v int8) *CompapiAsynctaskUpsertOne {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.AddTaskStatus(v)
+	})
+}
+
+// UpdateTaskStatus sets the "task_status" field to the value that was provided on create.
+func (u *CompapiAsynctaskUpsertOne) UpdateTaskStatus() *CompapiAsynctaskUpsertOne {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.UpdateTaskStatus()
+	})
+}
+
+// ClearTaskStatus clears the value of the "task_status" field.
+func (u *CompapiAsynctaskUpsertOne) ClearTaskStatus() *CompapiAsynctaskUpsertOne {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.ClearTaskStatus()
+	})
+}
+
+// SetRetryCount sets the "retry_count" field.
+func (u *CompapiAsynctaskUpsertOne) SetRetryCount(v int8) *CompapiAsynctaskUpsertOne {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.SetRetryCount(v)
+	})
+}
+
+// AddRetryCount adds v to the "retry_count" field.
+func (u *CompapiAsynctaskUpsertOne) AddRetryCount(v int8) *CompapiAsynctaskUpsertOne {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.AddRetryCount(v)
+	})
+}
+
+// UpdateRetryCount sets the "retry_count" field to the value that was provided on create.
+func (u *CompapiAsynctaskUpsertOne) UpdateRetryCount() *CompapiAsynctaskUpsertOne {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.UpdateRetryCount()
+	})
+}
+
+// ClearRetryCount clears the value of the "retry_count" field.
+func (u *CompapiAsynctaskUpsertOne) ClearRetryCount() *CompapiAsynctaskUpsertOne {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.ClearRetryCount()
+	})
+}
+
+// SetLastError sets the "last_error" field.
+func (u *CompapiAsynctaskUpsertOne) SetLastError(v string) *CompapiAsynctaskUpsertOne {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.SetLastError(v)
+	})
+}
+
+// UpdateLastError sets the "last_error" field to the value that was provided on create.
+func (u *CompapiAsynctaskUpsertOne) UpdateLastError() *CompapiAsynctaskUpsertOne {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.UpdateLastError()
+	})
+}
+
+// ClearLastError clears the value of the "last_error" field.
+func (u *CompapiAsynctaskUpsertOne) ClearLastError() *CompapiAsynctaskUpsertOne {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.ClearLastError()
+	})
+}
+
+// Exec executes the query.
+func (u *CompapiAsynctaskUpsertOne) Exec(ctx context.Context) error {
+	if len(u.create.conflict) == 0 {
+		return errors.New("ent: missing options for CompapiAsynctaskCreate.OnConflict")
+	}
+	return u.create.Exec(ctx)
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (u *CompapiAsynctaskUpsertOne) ExecX(ctx context.Context) {
+	if err := u.create.Exec(ctx); err != nil {
+		panic(err)
+	}
+}
+
+// Exec executes the UPSERT query and returns the inserted/updated ID.
+func (u *CompapiAsynctaskUpsertOne) ID(ctx context.Context) (id uint64, err error) {
+	node, err := u.create.Save(ctx)
+	if err != nil {
+		return id, err
+	}
+	return node.ID, nil
+}
+
+// IDX is like ID, but panics if an error occurs.
+func (u *CompapiAsynctaskUpsertOne) IDX(ctx context.Context) uint64 {
+	id, err := u.ID(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return id
+}
+
+// CompapiAsynctaskCreateBulk is the builder for creating many CompapiAsynctask entities in bulk.
+type CompapiAsynctaskCreateBulk struct {
+	config
+	err      error
+	builders []*CompapiAsynctaskCreate
+	conflict []sql.ConflictOption
+}
+
+// Save creates the CompapiAsynctask entities in the database.
+func (cacb *CompapiAsynctaskCreateBulk) Save(ctx context.Context) ([]*CompapiAsynctask, error) {
+	if cacb.err != nil {
+		return nil, cacb.err
+	}
+	specs := make([]*sqlgraph.CreateSpec, len(cacb.builders))
+	nodes := make([]*CompapiAsynctask, len(cacb.builders))
+	mutators := make([]Mutator, len(cacb.builders))
+	for i := range cacb.builders {
+		func(i int, root context.Context) {
+			builder := cacb.builders[i]
+			builder.defaults()
+			var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
+				mutation, ok := m.(*CompapiAsynctaskMutation)
+				if !ok {
+					return nil, fmt.Errorf("unexpected mutation type %T", m)
+				}
+				if err := builder.check(); err != nil {
+					return nil, err
+				}
+				builder.mutation = mutation
+				var err error
+				nodes[i], specs[i] = builder.createSpec()
+				if i < len(mutators)-1 {
+					_, err = mutators[i+1].Mutate(root, cacb.builders[i+1].mutation)
+				} else {
+					spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
+					spec.OnConflict = cacb.conflict
+					// Invoke the actual operation on the latest mutation in the chain.
+					if err = sqlgraph.BatchCreate(ctx, cacb.driver, spec); err != nil {
+						if sqlgraph.IsConstraintError(err) {
+							err = &ConstraintError{msg: err.Error(), wrap: err}
+						}
+					}
+				}
+				if err != nil {
+					return nil, err
+				}
+				mutation.id = &nodes[i].ID
+				if specs[i].ID.Value != nil && nodes[i].ID == 0 {
+					id := specs[i].ID.Value.(int64)
+					nodes[i].ID = uint64(id)
+				}
+				mutation.done = true
+				return nodes[i], nil
+			})
+			for i := len(builder.hooks) - 1; i >= 0; i-- {
+				mut = builder.hooks[i](mut)
+			}
+			mutators[i] = mut
+		}(i, ctx)
+	}
+	if len(mutators) > 0 {
+		if _, err := mutators[0].Mutate(ctx, cacb.builders[0].mutation); err != nil {
+			return nil, err
+		}
+	}
+	return nodes, nil
+}
+
+// SaveX is like Save, but panics if an error occurs.
+func (cacb *CompapiAsynctaskCreateBulk) SaveX(ctx context.Context) []*CompapiAsynctask {
+	v, err := cacb.Save(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return v
+}
+
+// Exec executes the query.
+func (cacb *CompapiAsynctaskCreateBulk) Exec(ctx context.Context) error {
+	_, err := cacb.Save(ctx)
+	return err
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (cacb *CompapiAsynctaskCreateBulk) ExecX(ctx context.Context) {
+	if err := cacb.Exec(ctx); err != nil {
+		panic(err)
+	}
+}
+
+// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
+// of the `INSERT` statement. For example:
+//
+//	client.CompapiAsynctask.CreateBulk(builders...).
+//		OnConflict(
+//			// Update the row with the new values
+//			// the was proposed for insertion.
+//			sql.ResolveWithNewValues(),
+//		).
+//		// Override some of the fields with custom
+//		// update values.
+//		Update(func(u *ent.CompapiAsynctaskUpsert) {
+//			SetCreatedAt(v+v).
+//		}).
+//		Exec(ctx)
+func (cacb *CompapiAsynctaskCreateBulk) OnConflict(opts ...sql.ConflictOption) *CompapiAsynctaskUpsertBulk {
+	cacb.conflict = opts
+	return &CompapiAsynctaskUpsertBulk{
+		create: cacb,
+	}
+}
+
+// OnConflictColumns calls `OnConflict` and configures the columns
+// as conflict target. Using this option is equivalent to using:
+//
+//	client.CompapiAsynctask.Create().
+//		OnConflict(sql.ConflictColumns(columns...)).
+//		Exec(ctx)
+func (cacb *CompapiAsynctaskCreateBulk) OnConflictColumns(columns ...string) *CompapiAsynctaskUpsertBulk {
+	cacb.conflict = append(cacb.conflict, sql.ConflictColumns(columns...))
+	return &CompapiAsynctaskUpsertBulk{
+		create: cacb,
+	}
+}
+
+// CompapiAsynctaskUpsertBulk is the builder for "upsert"-ing
+// a bulk of CompapiAsynctask nodes.
+type CompapiAsynctaskUpsertBulk struct {
+	create *CompapiAsynctaskCreateBulk
+}
+
+// UpdateNewValues updates the mutable fields using the new values that
+// were set on create. Using this option is equivalent to using:
+//
+//	client.CompapiAsynctask.Create().
+//		OnConflict(
+//			sql.ResolveWithNewValues(),
+//			sql.ResolveWith(func(u *sql.UpdateSet) {
+//				u.SetIgnore(compapiasynctask.FieldID)
+//			}),
+//		).
+//		Exec(ctx)
+func (u *CompapiAsynctaskUpsertBulk) UpdateNewValues() *CompapiAsynctaskUpsertBulk {
+	u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
+	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
+		for _, b := range u.create.builders {
+			if _, exists := b.mutation.ID(); exists {
+				s.SetIgnore(compapiasynctask.FieldID)
+			}
+			if _, exists := b.mutation.CreatedAt(); exists {
+				s.SetIgnore(compapiasynctask.FieldCreatedAt)
+			}
+		}
+	}))
+	return u
+}
+
+// Ignore sets each column to itself in case of conflict.
+// Using this option is equivalent to using:
+//
+//	client.CompapiAsynctask.Create().
+//		OnConflict(sql.ResolveWithIgnore()).
+//		Exec(ctx)
+func (u *CompapiAsynctaskUpsertBulk) Ignore() *CompapiAsynctaskUpsertBulk {
+	u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
+	return u
+}
+
+// DoNothing configures the conflict_action to `DO NOTHING`.
+// Supported only by SQLite and PostgreSQL.
+func (u *CompapiAsynctaskUpsertBulk) DoNothing() *CompapiAsynctaskUpsertBulk {
+	u.create.conflict = append(u.create.conflict, sql.DoNothing())
+	return u
+}
+
+// Update allows overriding fields `UPDATE` values. See the CompapiAsynctaskCreateBulk.OnConflict
+// documentation for more info.
+func (u *CompapiAsynctaskUpsertBulk) Update(set func(*CompapiAsynctaskUpsert)) *CompapiAsynctaskUpsertBulk {
+	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
+		set(&CompapiAsynctaskUpsert{UpdateSet: update})
+	}))
+	return u
+}
+
+// SetUpdatedAt sets the "updated_at" field.
+func (u *CompapiAsynctaskUpsertBulk) SetUpdatedAt(v time.Time) *CompapiAsynctaskUpsertBulk {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.SetUpdatedAt(v)
+	})
+}
+
+// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
+func (u *CompapiAsynctaskUpsertBulk) UpdateUpdatedAt() *CompapiAsynctaskUpsertBulk {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.UpdateUpdatedAt()
+	})
+}
+
+// SetAuthToken sets the "auth_token" field.
+func (u *CompapiAsynctaskUpsertBulk) SetAuthToken(v string) *CompapiAsynctaskUpsertBulk {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.SetAuthToken(v)
+	})
+}
+
+// UpdateAuthToken sets the "auth_token" field to the value that was provided on create.
+func (u *CompapiAsynctaskUpsertBulk) UpdateAuthToken() *CompapiAsynctaskUpsertBulk {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.UpdateAuthToken()
+	})
+}
+
+// SetEventType sets the "event_type" field.
+func (u *CompapiAsynctaskUpsertBulk) SetEventType(v string) *CompapiAsynctaskUpsertBulk {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.SetEventType(v)
+	})
+}
+
+// UpdateEventType sets the "event_type" field to the value that was provided on create.
+func (u *CompapiAsynctaskUpsertBulk) UpdateEventType() *CompapiAsynctaskUpsertBulk {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.UpdateEventType()
+	})
+}
+
+// SetChatID sets the "chat_id" field.
+func (u *CompapiAsynctaskUpsertBulk) SetChatID(v string) *CompapiAsynctaskUpsertBulk {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.SetChatID(v)
+	})
+}
+
+// UpdateChatID sets the "chat_id" field to the value that was provided on create.
+func (u *CompapiAsynctaskUpsertBulk) UpdateChatID() *CompapiAsynctaskUpsertBulk {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.UpdateChatID()
+	})
+}
+
+// ClearChatID clears the value of the "chat_id" field.
+func (u *CompapiAsynctaskUpsertBulk) ClearChatID() *CompapiAsynctaskUpsertBulk {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.ClearChatID()
+	})
+}
+
+// SetWorkidIdx sets the "workid_idx" field.
+func (u *CompapiAsynctaskUpsertBulk) SetWorkidIdx(v int8) *CompapiAsynctaskUpsertBulk {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.SetWorkidIdx(v)
+	})
+}
+
+// AddWorkidIdx adds v to the "workid_idx" field.
+func (u *CompapiAsynctaskUpsertBulk) AddWorkidIdx(v int8) *CompapiAsynctaskUpsertBulk {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.AddWorkidIdx(v)
+	})
+}
+
+// UpdateWorkidIdx sets the "workid_idx" field to the value that was provided on create.
+func (u *CompapiAsynctaskUpsertBulk) UpdateWorkidIdx() *CompapiAsynctaskUpsertBulk {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.UpdateWorkidIdx()
+	})
+}
+
+// ClearWorkidIdx clears the value of the "workid_idx" field.
+func (u *CompapiAsynctaskUpsertBulk) ClearWorkidIdx() *CompapiAsynctaskUpsertBulk {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.ClearWorkidIdx()
+	})
+}
+
+// SetOpenaiBase sets the "openai_base" field.
+func (u *CompapiAsynctaskUpsertBulk) SetOpenaiBase(v string) *CompapiAsynctaskUpsertBulk {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.SetOpenaiBase(v)
+	})
+}
+
+// UpdateOpenaiBase sets the "openai_base" field to the value that was provided on create.
+func (u *CompapiAsynctaskUpsertBulk) UpdateOpenaiBase() *CompapiAsynctaskUpsertBulk {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.UpdateOpenaiBase()
+	})
+}
+
+// SetOpenaiKey sets the "openai_key" field.
+func (u *CompapiAsynctaskUpsertBulk) SetOpenaiKey(v string) *CompapiAsynctaskUpsertBulk {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.SetOpenaiKey(v)
+	})
+}
+
+// UpdateOpenaiKey sets the "openai_key" field to the value that was provided on create.
+func (u *CompapiAsynctaskUpsertBulk) UpdateOpenaiKey() *CompapiAsynctaskUpsertBulk {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.UpdateOpenaiKey()
+	})
+}
+
+// SetRequestRaw sets the "request_raw" field.
+func (u *CompapiAsynctaskUpsertBulk) SetRequestRaw(v string) *CompapiAsynctaskUpsertBulk {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.SetRequestRaw(v)
+	})
+}
+
+// UpdateRequestRaw sets the "request_raw" field to the value that was provided on create.
+func (u *CompapiAsynctaskUpsertBulk) UpdateRequestRaw() *CompapiAsynctaskUpsertBulk {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.UpdateRequestRaw()
+	})
+}
+
+// SetResponseRaw sets the "response_raw" field.
+func (u *CompapiAsynctaskUpsertBulk) SetResponseRaw(v string) *CompapiAsynctaskUpsertBulk {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.SetResponseRaw(v)
+	})
+}
+
+// UpdateResponseRaw sets the "response_raw" field to the value that was provided on create.
+func (u *CompapiAsynctaskUpsertBulk) UpdateResponseRaw() *CompapiAsynctaskUpsertBulk {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.UpdateResponseRaw()
+	})
+}
+
+// ClearResponseRaw clears the value of the "response_raw" field.
+func (u *CompapiAsynctaskUpsertBulk) ClearResponseRaw() *CompapiAsynctaskUpsertBulk {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.ClearResponseRaw()
+	})
+}
+
+// SetCallbackURL sets the "callback_url" field.
+func (u *CompapiAsynctaskUpsertBulk) SetCallbackURL(v string) *CompapiAsynctaskUpsertBulk {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.SetCallbackURL(v)
+	})
+}
+
+// UpdateCallbackURL sets the "callback_url" field to the value that was provided on create.
+func (u *CompapiAsynctaskUpsertBulk) UpdateCallbackURL() *CompapiAsynctaskUpsertBulk {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.UpdateCallbackURL()
+	})
+}
+
+// SetTaskStatus sets the "task_status" field.
+func (u *CompapiAsynctaskUpsertBulk) SetTaskStatus(v int8) *CompapiAsynctaskUpsertBulk {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.SetTaskStatus(v)
+	})
+}
+
+// AddTaskStatus adds v to the "task_status" field.
+func (u *CompapiAsynctaskUpsertBulk) AddTaskStatus(v int8) *CompapiAsynctaskUpsertBulk {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.AddTaskStatus(v)
+	})
+}
+
+// UpdateTaskStatus sets the "task_status" field to the value that was provided on create.
+func (u *CompapiAsynctaskUpsertBulk) UpdateTaskStatus() *CompapiAsynctaskUpsertBulk {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.UpdateTaskStatus()
+	})
+}
+
+// ClearTaskStatus clears the value of the "task_status" field.
+func (u *CompapiAsynctaskUpsertBulk) ClearTaskStatus() *CompapiAsynctaskUpsertBulk {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.ClearTaskStatus()
+	})
+}
+
+// SetRetryCount sets the "retry_count" field.
+func (u *CompapiAsynctaskUpsertBulk) SetRetryCount(v int8) *CompapiAsynctaskUpsertBulk {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.SetRetryCount(v)
+	})
+}
+
+// AddRetryCount adds v to the "retry_count" field.
+func (u *CompapiAsynctaskUpsertBulk) AddRetryCount(v int8) *CompapiAsynctaskUpsertBulk {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.AddRetryCount(v)
+	})
+}
+
+// UpdateRetryCount sets the "retry_count" field to the value that was provided on create.
+func (u *CompapiAsynctaskUpsertBulk) UpdateRetryCount() *CompapiAsynctaskUpsertBulk {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.UpdateRetryCount()
+	})
+}
+
+// ClearRetryCount clears the value of the "retry_count" field.
+func (u *CompapiAsynctaskUpsertBulk) ClearRetryCount() *CompapiAsynctaskUpsertBulk {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.ClearRetryCount()
+	})
+}
+
+// SetLastError sets the "last_error" field.
+func (u *CompapiAsynctaskUpsertBulk) SetLastError(v string) *CompapiAsynctaskUpsertBulk {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.SetLastError(v)
+	})
+}
+
+// UpdateLastError sets the "last_error" field to the value that was provided on create.
+func (u *CompapiAsynctaskUpsertBulk) UpdateLastError() *CompapiAsynctaskUpsertBulk {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.UpdateLastError()
+	})
+}
+
+// ClearLastError clears the value of the "last_error" field.
+func (u *CompapiAsynctaskUpsertBulk) ClearLastError() *CompapiAsynctaskUpsertBulk {
+	return u.Update(func(s *CompapiAsynctaskUpsert) {
+		s.ClearLastError()
+	})
+}
+
+// Exec executes the query.
+func (u *CompapiAsynctaskUpsertBulk) Exec(ctx context.Context) error {
+	if u.create.err != nil {
+		return u.create.err
+	}
+	for i, b := range u.create.builders {
+		if len(b.conflict) != 0 {
+			return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the CompapiAsynctaskCreateBulk instead", i)
+		}
+	}
+	if len(u.create.conflict) == 0 {
+		return errors.New("ent: missing options for CompapiAsynctaskCreateBulk.OnConflict")
+	}
+	return u.create.Exec(ctx)
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (u *CompapiAsynctaskUpsertBulk) ExecX(ctx context.Context) {
+	if err := u.create.Exec(ctx); err != nil {
+		panic(err)
+	}
+}

+ 88 - 0
ent/compapiasynctask_delete.go

@@ -0,0 +1,88 @@
+// Code generated by ent, DO NOT EDIT.
+
+package ent
+
+import (
+	"context"
+	"wechat-api/ent/compapiasynctask"
+	"wechat-api/ent/predicate"
+
+	"entgo.io/ent/dialect/sql"
+	"entgo.io/ent/dialect/sql/sqlgraph"
+	"entgo.io/ent/schema/field"
+)
+
+// CompapiAsynctaskDelete is the builder for deleting a CompapiAsynctask entity.
+type CompapiAsynctaskDelete struct {
+	config
+	hooks    []Hook
+	mutation *CompapiAsynctaskMutation
+}
+
+// Where appends a list predicates to the CompapiAsynctaskDelete builder.
+func (cad *CompapiAsynctaskDelete) Where(ps ...predicate.CompapiAsynctask) *CompapiAsynctaskDelete {
+	cad.mutation.Where(ps...)
+	return cad
+}
+
+// Exec executes the deletion query and returns how many vertices were deleted.
+func (cad *CompapiAsynctaskDelete) Exec(ctx context.Context) (int, error) {
+	return withHooks(ctx, cad.sqlExec, cad.mutation, cad.hooks)
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (cad *CompapiAsynctaskDelete) ExecX(ctx context.Context) int {
+	n, err := cad.Exec(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return n
+}
+
+func (cad *CompapiAsynctaskDelete) sqlExec(ctx context.Context) (int, error) {
+	_spec := sqlgraph.NewDeleteSpec(compapiasynctask.Table, sqlgraph.NewFieldSpec(compapiasynctask.FieldID, field.TypeUint64))
+	if ps := cad.mutation.predicates; len(ps) > 0 {
+		_spec.Predicate = func(selector *sql.Selector) {
+			for i := range ps {
+				ps[i](selector)
+			}
+		}
+	}
+	affected, err := sqlgraph.DeleteNodes(ctx, cad.driver, _spec)
+	if err != nil && sqlgraph.IsConstraintError(err) {
+		err = &ConstraintError{msg: err.Error(), wrap: err}
+	}
+	cad.mutation.done = true
+	return affected, err
+}
+
+// CompapiAsynctaskDeleteOne is the builder for deleting a single CompapiAsynctask entity.
+type CompapiAsynctaskDeleteOne struct {
+	cad *CompapiAsynctaskDelete
+}
+
+// Where appends a list predicates to the CompapiAsynctaskDelete builder.
+func (cado *CompapiAsynctaskDeleteOne) Where(ps ...predicate.CompapiAsynctask) *CompapiAsynctaskDeleteOne {
+	cado.cad.mutation.Where(ps...)
+	return cado
+}
+
+// Exec executes the deletion query.
+func (cado *CompapiAsynctaskDeleteOne) Exec(ctx context.Context) error {
+	n, err := cado.cad.Exec(ctx)
+	switch {
+	case err != nil:
+		return err
+	case n == 0:
+		return &NotFoundError{compapiasynctask.Label}
+	default:
+		return nil
+	}
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (cado *CompapiAsynctaskDeleteOne) ExecX(ctx context.Context) {
+	if err := cado.Exec(ctx); err != nil {
+		panic(err)
+	}
+}

+ 526 - 0
ent/compapiasynctask_query.go

@@ -0,0 +1,526 @@
+// Code generated by ent, DO NOT EDIT.
+
+package ent
+
+import (
+	"context"
+	"fmt"
+	"math"
+	"wechat-api/ent/compapiasynctask"
+	"wechat-api/ent/predicate"
+
+	"entgo.io/ent/dialect/sql"
+	"entgo.io/ent/dialect/sql/sqlgraph"
+	"entgo.io/ent/schema/field"
+)
+
+// CompapiAsynctaskQuery is the builder for querying CompapiAsynctask entities.
+type CompapiAsynctaskQuery struct {
+	config
+	ctx        *QueryContext
+	order      []compapiasynctask.OrderOption
+	inters     []Interceptor
+	predicates []predicate.CompapiAsynctask
+	// intermediate query (i.e. traversal path).
+	sql  *sql.Selector
+	path func(context.Context) (*sql.Selector, error)
+}
+
+// Where adds a new predicate for the CompapiAsynctaskQuery builder.
+func (caq *CompapiAsynctaskQuery) Where(ps ...predicate.CompapiAsynctask) *CompapiAsynctaskQuery {
+	caq.predicates = append(caq.predicates, ps...)
+	return caq
+}
+
+// Limit the number of records to be returned by this query.
+func (caq *CompapiAsynctaskQuery) Limit(limit int) *CompapiAsynctaskQuery {
+	caq.ctx.Limit = &limit
+	return caq
+}
+
+// Offset to start from.
+func (caq *CompapiAsynctaskQuery) Offset(offset int) *CompapiAsynctaskQuery {
+	caq.ctx.Offset = &offset
+	return caq
+}
+
+// Unique configures the query builder to filter duplicate records on query.
+// By default, unique is set to true, and can be disabled using this method.
+func (caq *CompapiAsynctaskQuery) Unique(unique bool) *CompapiAsynctaskQuery {
+	caq.ctx.Unique = &unique
+	return caq
+}
+
+// Order specifies how the records should be ordered.
+func (caq *CompapiAsynctaskQuery) Order(o ...compapiasynctask.OrderOption) *CompapiAsynctaskQuery {
+	caq.order = append(caq.order, o...)
+	return caq
+}
+
+// First returns the first CompapiAsynctask entity from the query.
+// Returns a *NotFoundError when no CompapiAsynctask was found.
+func (caq *CompapiAsynctaskQuery) First(ctx context.Context) (*CompapiAsynctask, error) {
+	nodes, err := caq.Limit(1).All(setContextOp(ctx, caq.ctx, "First"))
+	if err != nil {
+		return nil, err
+	}
+	if len(nodes) == 0 {
+		return nil, &NotFoundError{compapiasynctask.Label}
+	}
+	return nodes[0], nil
+}
+
+// FirstX is like First, but panics if an error occurs.
+func (caq *CompapiAsynctaskQuery) FirstX(ctx context.Context) *CompapiAsynctask {
+	node, err := caq.First(ctx)
+	if err != nil && !IsNotFound(err) {
+		panic(err)
+	}
+	return node
+}
+
+// FirstID returns the first CompapiAsynctask ID from the query.
+// Returns a *NotFoundError when no CompapiAsynctask ID was found.
+func (caq *CompapiAsynctaskQuery) FirstID(ctx context.Context) (id uint64, err error) {
+	var ids []uint64
+	if ids, err = caq.Limit(1).IDs(setContextOp(ctx, caq.ctx, "FirstID")); err != nil {
+		return
+	}
+	if len(ids) == 0 {
+		err = &NotFoundError{compapiasynctask.Label}
+		return
+	}
+	return ids[0], nil
+}
+
+// FirstIDX is like FirstID, but panics if an error occurs.
+func (caq *CompapiAsynctaskQuery) FirstIDX(ctx context.Context) uint64 {
+	id, err := caq.FirstID(ctx)
+	if err != nil && !IsNotFound(err) {
+		panic(err)
+	}
+	return id
+}
+
+// Only returns a single CompapiAsynctask entity found by the query, ensuring it only returns one.
+// Returns a *NotSingularError when more than one CompapiAsynctask entity is found.
+// Returns a *NotFoundError when no CompapiAsynctask entities are found.
+func (caq *CompapiAsynctaskQuery) Only(ctx context.Context) (*CompapiAsynctask, error) {
+	nodes, err := caq.Limit(2).All(setContextOp(ctx, caq.ctx, "Only"))
+	if err != nil {
+		return nil, err
+	}
+	switch len(nodes) {
+	case 1:
+		return nodes[0], nil
+	case 0:
+		return nil, &NotFoundError{compapiasynctask.Label}
+	default:
+		return nil, &NotSingularError{compapiasynctask.Label}
+	}
+}
+
+// OnlyX is like Only, but panics if an error occurs.
+func (caq *CompapiAsynctaskQuery) OnlyX(ctx context.Context) *CompapiAsynctask {
+	node, err := caq.Only(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return node
+}
+
+// OnlyID is like Only, but returns the only CompapiAsynctask ID in the query.
+// Returns a *NotSingularError when more than one CompapiAsynctask ID is found.
+// Returns a *NotFoundError when no entities are found.
+func (caq *CompapiAsynctaskQuery) OnlyID(ctx context.Context) (id uint64, err error) {
+	var ids []uint64
+	if ids, err = caq.Limit(2).IDs(setContextOp(ctx, caq.ctx, "OnlyID")); err != nil {
+		return
+	}
+	switch len(ids) {
+	case 1:
+		id = ids[0]
+	case 0:
+		err = &NotFoundError{compapiasynctask.Label}
+	default:
+		err = &NotSingularError{compapiasynctask.Label}
+	}
+	return
+}
+
+// OnlyIDX is like OnlyID, but panics if an error occurs.
+func (caq *CompapiAsynctaskQuery) OnlyIDX(ctx context.Context) uint64 {
+	id, err := caq.OnlyID(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return id
+}
+
+// All executes the query and returns a list of CompapiAsynctasks.
+func (caq *CompapiAsynctaskQuery) All(ctx context.Context) ([]*CompapiAsynctask, error) {
+	ctx = setContextOp(ctx, caq.ctx, "All")
+	if err := caq.prepareQuery(ctx); err != nil {
+		return nil, err
+	}
+	qr := querierAll[[]*CompapiAsynctask, *CompapiAsynctaskQuery]()
+	return withInterceptors[[]*CompapiAsynctask](ctx, caq, qr, caq.inters)
+}
+
+// AllX is like All, but panics if an error occurs.
+func (caq *CompapiAsynctaskQuery) AllX(ctx context.Context) []*CompapiAsynctask {
+	nodes, err := caq.All(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return nodes
+}
+
+// IDs executes the query and returns a list of CompapiAsynctask IDs.
+func (caq *CompapiAsynctaskQuery) IDs(ctx context.Context) (ids []uint64, err error) {
+	if caq.ctx.Unique == nil && caq.path != nil {
+		caq.Unique(true)
+	}
+	ctx = setContextOp(ctx, caq.ctx, "IDs")
+	if err = caq.Select(compapiasynctask.FieldID).Scan(ctx, &ids); err != nil {
+		return nil, err
+	}
+	return ids, nil
+}
+
+// IDsX is like IDs, but panics if an error occurs.
+func (caq *CompapiAsynctaskQuery) IDsX(ctx context.Context) []uint64 {
+	ids, err := caq.IDs(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return ids
+}
+
+// Count returns the count of the given query.
+func (caq *CompapiAsynctaskQuery) Count(ctx context.Context) (int, error) {
+	ctx = setContextOp(ctx, caq.ctx, "Count")
+	if err := caq.prepareQuery(ctx); err != nil {
+		return 0, err
+	}
+	return withInterceptors[int](ctx, caq, querierCount[*CompapiAsynctaskQuery](), caq.inters)
+}
+
+// CountX is like Count, but panics if an error occurs.
+func (caq *CompapiAsynctaskQuery) CountX(ctx context.Context) int {
+	count, err := caq.Count(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return count
+}
+
+// Exist returns true if the query has elements in the graph.
+func (caq *CompapiAsynctaskQuery) Exist(ctx context.Context) (bool, error) {
+	ctx = setContextOp(ctx, caq.ctx, "Exist")
+	switch _, err := caq.FirstID(ctx); {
+	case IsNotFound(err):
+		return false, nil
+	case err != nil:
+		return false, fmt.Errorf("ent: check existence: %w", err)
+	default:
+		return true, nil
+	}
+}
+
+// ExistX is like Exist, but panics if an error occurs.
+func (caq *CompapiAsynctaskQuery) ExistX(ctx context.Context) bool {
+	exist, err := caq.Exist(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return exist
+}
+
+// Clone returns a duplicate of the CompapiAsynctaskQuery builder, including all associated steps. It can be
+// used to prepare common query builders and use them differently after the clone is made.
+func (caq *CompapiAsynctaskQuery) Clone() *CompapiAsynctaskQuery {
+	if caq == nil {
+		return nil
+	}
+	return &CompapiAsynctaskQuery{
+		config:     caq.config,
+		ctx:        caq.ctx.Clone(),
+		order:      append([]compapiasynctask.OrderOption{}, caq.order...),
+		inters:     append([]Interceptor{}, caq.inters...),
+		predicates: append([]predicate.CompapiAsynctask{}, caq.predicates...),
+		// clone intermediate query.
+		sql:  caq.sql.Clone(),
+		path: caq.path,
+	}
+}
+
+// GroupBy is used to group vertices by one or more fields/columns.
+// It is often used with aggregate functions, like: count, max, mean, min, sum.
+//
+// Example:
+//
+//	var v []struct {
+//		CreatedAt time.Time `json:"created_at,omitempty"`
+//		Count int `json:"count,omitempty"`
+//	}
+//
+//	client.CompapiAsynctask.Query().
+//		GroupBy(compapiasynctask.FieldCreatedAt).
+//		Aggregate(ent.Count()).
+//		Scan(ctx, &v)
+func (caq *CompapiAsynctaskQuery) GroupBy(field string, fields ...string) *CompapiAsynctaskGroupBy {
+	caq.ctx.Fields = append([]string{field}, fields...)
+	grbuild := &CompapiAsynctaskGroupBy{build: caq}
+	grbuild.flds = &caq.ctx.Fields
+	grbuild.label = compapiasynctask.Label
+	grbuild.scan = grbuild.Scan
+	return grbuild
+}
+
+// Select allows the selection one or more fields/columns for the given query,
+// instead of selecting all fields in the entity.
+//
+// Example:
+//
+//	var v []struct {
+//		CreatedAt time.Time `json:"created_at,omitempty"`
+//	}
+//
+//	client.CompapiAsynctask.Query().
+//		Select(compapiasynctask.FieldCreatedAt).
+//		Scan(ctx, &v)
+func (caq *CompapiAsynctaskQuery) Select(fields ...string) *CompapiAsynctaskSelect {
+	caq.ctx.Fields = append(caq.ctx.Fields, fields...)
+	sbuild := &CompapiAsynctaskSelect{CompapiAsynctaskQuery: caq}
+	sbuild.label = compapiasynctask.Label
+	sbuild.flds, sbuild.scan = &caq.ctx.Fields, sbuild.Scan
+	return sbuild
+}
+
+// Aggregate returns a CompapiAsynctaskSelect configured with the given aggregations.
+func (caq *CompapiAsynctaskQuery) Aggregate(fns ...AggregateFunc) *CompapiAsynctaskSelect {
+	return caq.Select().Aggregate(fns...)
+}
+
+func (caq *CompapiAsynctaskQuery) prepareQuery(ctx context.Context) error {
+	for _, inter := range caq.inters {
+		if inter == nil {
+			return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
+		}
+		if trv, ok := inter.(Traverser); ok {
+			if err := trv.Traverse(ctx, caq); err != nil {
+				return err
+			}
+		}
+	}
+	for _, f := range caq.ctx.Fields {
+		if !compapiasynctask.ValidColumn(f) {
+			return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
+		}
+	}
+	if caq.path != nil {
+		prev, err := caq.path(ctx)
+		if err != nil {
+			return err
+		}
+		caq.sql = prev
+	}
+	return nil
+}
+
+func (caq *CompapiAsynctaskQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*CompapiAsynctask, error) {
+	var (
+		nodes = []*CompapiAsynctask{}
+		_spec = caq.querySpec()
+	)
+	_spec.ScanValues = func(columns []string) ([]any, error) {
+		return (*CompapiAsynctask).scanValues(nil, columns)
+	}
+	_spec.Assign = func(columns []string, values []any) error {
+		node := &CompapiAsynctask{config: caq.config}
+		nodes = append(nodes, node)
+		return node.assignValues(columns, values)
+	}
+	for i := range hooks {
+		hooks[i](ctx, _spec)
+	}
+	if err := sqlgraph.QueryNodes(ctx, caq.driver, _spec); err != nil {
+		return nil, err
+	}
+	if len(nodes) == 0 {
+		return nodes, nil
+	}
+	return nodes, nil
+}
+
+func (caq *CompapiAsynctaskQuery) sqlCount(ctx context.Context) (int, error) {
+	_spec := caq.querySpec()
+	_spec.Node.Columns = caq.ctx.Fields
+	if len(caq.ctx.Fields) > 0 {
+		_spec.Unique = caq.ctx.Unique != nil && *caq.ctx.Unique
+	}
+	return sqlgraph.CountNodes(ctx, caq.driver, _spec)
+}
+
+func (caq *CompapiAsynctaskQuery) querySpec() *sqlgraph.QuerySpec {
+	_spec := sqlgraph.NewQuerySpec(compapiasynctask.Table, compapiasynctask.Columns, sqlgraph.NewFieldSpec(compapiasynctask.FieldID, field.TypeUint64))
+	_spec.From = caq.sql
+	if unique := caq.ctx.Unique; unique != nil {
+		_spec.Unique = *unique
+	} else if caq.path != nil {
+		_spec.Unique = true
+	}
+	if fields := caq.ctx.Fields; len(fields) > 0 {
+		_spec.Node.Columns = make([]string, 0, len(fields))
+		_spec.Node.Columns = append(_spec.Node.Columns, compapiasynctask.FieldID)
+		for i := range fields {
+			if fields[i] != compapiasynctask.FieldID {
+				_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
+			}
+		}
+	}
+	if ps := caq.predicates; len(ps) > 0 {
+		_spec.Predicate = func(selector *sql.Selector) {
+			for i := range ps {
+				ps[i](selector)
+			}
+		}
+	}
+	if limit := caq.ctx.Limit; limit != nil {
+		_spec.Limit = *limit
+	}
+	if offset := caq.ctx.Offset; offset != nil {
+		_spec.Offset = *offset
+	}
+	if ps := caq.order; len(ps) > 0 {
+		_spec.Order = func(selector *sql.Selector) {
+			for i := range ps {
+				ps[i](selector)
+			}
+		}
+	}
+	return _spec
+}
+
+func (caq *CompapiAsynctaskQuery) sqlQuery(ctx context.Context) *sql.Selector {
+	builder := sql.Dialect(caq.driver.Dialect())
+	t1 := builder.Table(compapiasynctask.Table)
+	columns := caq.ctx.Fields
+	if len(columns) == 0 {
+		columns = compapiasynctask.Columns
+	}
+	selector := builder.Select(t1.Columns(columns...)...).From(t1)
+	if caq.sql != nil {
+		selector = caq.sql
+		selector.Select(selector.Columns(columns...)...)
+	}
+	if caq.ctx.Unique != nil && *caq.ctx.Unique {
+		selector.Distinct()
+	}
+	for _, p := range caq.predicates {
+		p(selector)
+	}
+	for _, p := range caq.order {
+		p(selector)
+	}
+	if offset := caq.ctx.Offset; offset != nil {
+		// limit is mandatory for offset clause. We start
+		// with default value, and override it below if needed.
+		selector.Offset(*offset).Limit(math.MaxInt32)
+	}
+	if limit := caq.ctx.Limit; limit != nil {
+		selector.Limit(*limit)
+	}
+	return selector
+}
+
+// CompapiAsynctaskGroupBy is the group-by builder for CompapiAsynctask entities.
+type CompapiAsynctaskGroupBy struct {
+	selector
+	build *CompapiAsynctaskQuery
+}
+
+// Aggregate adds the given aggregation functions to the group-by query.
+func (cagb *CompapiAsynctaskGroupBy) Aggregate(fns ...AggregateFunc) *CompapiAsynctaskGroupBy {
+	cagb.fns = append(cagb.fns, fns...)
+	return cagb
+}
+
+// Scan applies the selector query and scans the result into the given value.
+func (cagb *CompapiAsynctaskGroupBy) Scan(ctx context.Context, v any) error {
+	ctx = setContextOp(ctx, cagb.build.ctx, "GroupBy")
+	if err := cagb.build.prepareQuery(ctx); err != nil {
+		return err
+	}
+	return scanWithInterceptors[*CompapiAsynctaskQuery, *CompapiAsynctaskGroupBy](ctx, cagb.build, cagb, cagb.build.inters, v)
+}
+
+func (cagb *CompapiAsynctaskGroupBy) sqlScan(ctx context.Context, root *CompapiAsynctaskQuery, v any) error {
+	selector := root.sqlQuery(ctx).Select()
+	aggregation := make([]string, 0, len(cagb.fns))
+	for _, fn := range cagb.fns {
+		aggregation = append(aggregation, fn(selector))
+	}
+	if len(selector.SelectedColumns()) == 0 {
+		columns := make([]string, 0, len(*cagb.flds)+len(cagb.fns))
+		for _, f := range *cagb.flds {
+			columns = append(columns, selector.C(f))
+		}
+		columns = append(columns, aggregation...)
+		selector.Select(columns...)
+	}
+	selector.GroupBy(selector.Columns(*cagb.flds...)...)
+	if err := selector.Err(); err != nil {
+		return err
+	}
+	rows := &sql.Rows{}
+	query, args := selector.Query()
+	if err := cagb.build.driver.Query(ctx, query, args, rows); err != nil {
+		return err
+	}
+	defer rows.Close()
+	return sql.ScanSlice(rows, v)
+}
+
+// CompapiAsynctaskSelect is the builder for selecting fields of CompapiAsynctask entities.
+type CompapiAsynctaskSelect struct {
+	*CompapiAsynctaskQuery
+	selector
+}
+
+// Aggregate adds the given aggregation functions to the selector query.
+func (cas *CompapiAsynctaskSelect) Aggregate(fns ...AggregateFunc) *CompapiAsynctaskSelect {
+	cas.fns = append(cas.fns, fns...)
+	return cas
+}
+
+// Scan applies the selector query and scans the result into the given value.
+func (cas *CompapiAsynctaskSelect) Scan(ctx context.Context, v any) error {
+	ctx = setContextOp(ctx, cas.ctx, "Select")
+	if err := cas.prepareQuery(ctx); err != nil {
+		return err
+	}
+	return scanWithInterceptors[*CompapiAsynctaskQuery, *CompapiAsynctaskSelect](ctx, cas.CompapiAsynctaskQuery, cas, cas.inters, v)
+}
+
+func (cas *CompapiAsynctaskSelect) sqlScan(ctx context.Context, root *CompapiAsynctaskQuery, v any) error {
+	selector := root.sqlQuery(ctx)
+	aggregation := make([]string, 0, len(cas.fns))
+	for _, fn := range cas.fns {
+		aggregation = append(aggregation, fn(selector))
+	}
+	switch n := len(*cas.selector.flds); {
+	case n == 0 && len(aggregation) > 0:
+		selector.Select(aggregation...)
+	case n != 0 && len(aggregation) > 0:
+		selector.AppendSelect(aggregation...)
+	}
+	rows := &sql.Rows{}
+	query, args := selector.Query()
+	if err := cas.driver.Query(ctx, query, args, rows); err != nil {
+		return err
+	}
+	defer rows.Close()
+	return sql.ScanSlice(rows, v)
+}

+ 814 - 0
ent/compapiasynctask_update.go

@@ -0,0 +1,814 @@
+// Code generated by ent, DO NOT EDIT.
+
+package ent
+
+import (
+	"context"
+	"errors"
+	"fmt"
+	"time"
+	"wechat-api/ent/compapiasynctask"
+	"wechat-api/ent/predicate"
+
+	"entgo.io/ent/dialect/sql"
+	"entgo.io/ent/dialect/sql/sqlgraph"
+	"entgo.io/ent/schema/field"
+)
+
+// CompapiAsynctaskUpdate is the builder for updating CompapiAsynctask entities.
+type CompapiAsynctaskUpdate struct {
+	config
+	hooks    []Hook
+	mutation *CompapiAsynctaskMutation
+}
+
+// Where appends a list predicates to the CompapiAsynctaskUpdate builder.
+func (cau *CompapiAsynctaskUpdate) Where(ps ...predicate.CompapiAsynctask) *CompapiAsynctaskUpdate {
+	cau.mutation.Where(ps...)
+	return cau
+}
+
+// SetUpdatedAt sets the "updated_at" field.
+func (cau *CompapiAsynctaskUpdate) SetUpdatedAt(t time.Time) *CompapiAsynctaskUpdate {
+	cau.mutation.SetUpdatedAt(t)
+	return cau
+}
+
+// SetAuthToken sets the "auth_token" field.
+func (cau *CompapiAsynctaskUpdate) SetAuthToken(s string) *CompapiAsynctaskUpdate {
+	cau.mutation.SetAuthToken(s)
+	return cau
+}
+
+// SetNillableAuthToken sets the "auth_token" field if the given value is not nil.
+func (cau *CompapiAsynctaskUpdate) SetNillableAuthToken(s *string) *CompapiAsynctaskUpdate {
+	if s != nil {
+		cau.SetAuthToken(*s)
+	}
+	return cau
+}
+
+// SetEventType sets the "event_type" field.
+func (cau *CompapiAsynctaskUpdate) SetEventType(s string) *CompapiAsynctaskUpdate {
+	cau.mutation.SetEventType(s)
+	return cau
+}
+
+// SetNillableEventType sets the "event_type" field if the given value is not nil.
+func (cau *CompapiAsynctaskUpdate) SetNillableEventType(s *string) *CompapiAsynctaskUpdate {
+	if s != nil {
+		cau.SetEventType(*s)
+	}
+	return cau
+}
+
+// SetChatID sets the "chat_id" field.
+func (cau *CompapiAsynctaskUpdate) SetChatID(s string) *CompapiAsynctaskUpdate {
+	cau.mutation.SetChatID(s)
+	return cau
+}
+
+// SetNillableChatID sets the "chat_id" field if the given value is not nil.
+func (cau *CompapiAsynctaskUpdate) SetNillableChatID(s *string) *CompapiAsynctaskUpdate {
+	if s != nil {
+		cau.SetChatID(*s)
+	}
+	return cau
+}
+
+// ClearChatID clears the value of the "chat_id" field.
+func (cau *CompapiAsynctaskUpdate) ClearChatID() *CompapiAsynctaskUpdate {
+	cau.mutation.ClearChatID()
+	return cau
+}
+
+// SetWorkidIdx sets the "workid_idx" field.
+func (cau *CompapiAsynctaskUpdate) SetWorkidIdx(i int8) *CompapiAsynctaskUpdate {
+	cau.mutation.ResetWorkidIdx()
+	cau.mutation.SetWorkidIdx(i)
+	return cau
+}
+
+// SetNillableWorkidIdx sets the "workid_idx" field if the given value is not nil.
+func (cau *CompapiAsynctaskUpdate) SetNillableWorkidIdx(i *int8) *CompapiAsynctaskUpdate {
+	if i != nil {
+		cau.SetWorkidIdx(*i)
+	}
+	return cau
+}
+
+// AddWorkidIdx adds i to the "workid_idx" field.
+func (cau *CompapiAsynctaskUpdate) AddWorkidIdx(i int8) *CompapiAsynctaskUpdate {
+	cau.mutation.AddWorkidIdx(i)
+	return cau
+}
+
+// ClearWorkidIdx clears the value of the "workid_idx" field.
+func (cau *CompapiAsynctaskUpdate) ClearWorkidIdx() *CompapiAsynctaskUpdate {
+	cau.mutation.ClearWorkidIdx()
+	return cau
+}
+
+// SetOpenaiBase sets the "openai_base" field.
+func (cau *CompapiAsynctaskUpdate) SetOpenaiBase(s string) *CompapiAsynctaskUpdate {
+	cau.mutation.SetOpenaiBase(s)
+	return cau
+}
+
+// SetNillableOpenaiBase sets the "openai_base" field if the given value is not nil.
+func (cau *CompapiAsynctaskUpdate) SetNillableOpenaiBase(s *string) *CompapiAsynctaskUpdate {
+	if s != nil {
+		cau.SetOpenaiBase(*s)
+	}
+	return cau
+}
+
+// SetOpenaiKey sets the "openai_key" field.
+func (cau *CompapiAsynctaskUpdate) SetOpenaiKey(s string) *CompapiAsynctaskUpdate {
+	cau.mutation.SetOpenaiKey(s)
+	return cau
+}
+
+// SetNillableOpenaiKey sets the "openai_key" field if the given value is not nil.
+func (cau *CompapiAsynctaskUpdate) SetNillableOpenaiKey(s *string) *CompapiAsynctaskUpdate {
+	if s != nil {
+		cau.SetOpenaiKey(*s)
+	}
+	return cau
+}
+
+// SetRequestRaw sets the "request_raw" field.
+func (cau *CompapiAsynctaskUpdate) SetRequestRaw(s string) *CompapiAsynctaskUpdate {
+	cau.mutation.SetRequestRaw(s)
+	return cau
+}
+
+// SetNillableRequestRaw sets the "request_raw" field if the given value is not nil.
+func (cau *CompapiAsynctaskUpdate) SetNillableRequestRaw(s *string) *CompapiAsynctaskUpdate {
+	if s != nil {
+		cau.SetRequestRaw(*s)
+	}
+	return cau
+}
+
+// SetResponseRaw sets the "response_raw" field.
+func (cau *CompapiAsynctaskUpdate) SetResponseRaw(s string) *CompapiAsynctaskUpdate {
+	cau.mutation.SetResponseRaw(s)
+	return cau
+}
+
+// SetNillableResponseRaw sets the "response_raw" field if the given value is not nil.
+func (cau *CompapiAsynctaskUpdate) SetNillableResponseRaw(s *string) *CompapiAsynctaskUpdate {
+	if s != nil {
+		cau.SetResponseRaw(*s)
+	}
+	return cau
+}
+
+// ClearResponseRaw clears the value of the "response_raw" field.
+func (cau *CompapiAsynctaskUpdate) ClearResponseRaw() *CompapiAsynctaskUpdate {
+	cau.mutation.ClearResponseRaw()
+	return cau
+}
+
+// SetCallbackURL sets the "callback_url" field.
+func (cau *CompapiAsynctaskUpdate) SetCallbackURL(s string) *CompapiAsynctaskUpdate {
+	cau.mutation.SetCallbackURL(s)
+	return cau
+}
+
+// SetNillableCallbackURL sets the "callback_url" field if the given value is not nil.
+func (cau *CompapiAsynctaskUpdate) SetNillableCallbackURL(s *string) *CompapiAsynctaskUpdate {
+	if s != nil {
+		cau.SetCallbackURL(*s)
+	}
+	return cau
+}
+
+// SetTaskStatus sets the "task_status" field.
+func (cau *CompapiAsynctaskUpdate) SetTaskStatus(i int8) *CompapiAsynctaskUpdate {
+	cau.mutation.ResetTaskStatus()
+	cau.mutation.SetTaskStatus(i)
+	return cau
+}
+
+// SetNillableTaskStatus sets the "task_status" field if the given value is not nil.
+func (cau *CompapiAsynctaskUpdate) SetNillableTaskStatus(i *int8) *CompapiAsynctaskUpdate {
+	if i != nil {
+		cau.SetTaskStatus(*i)
+	}
+	return cau
+}
+
+// AddTaskStatus adds i to the "task_status" field.
+func (cau *CompapiAsynctaskUpdate) AddTaskStatus(i int8) *CompapiAsynctaskUpdate {
+	cau.mutation.AddTaskStatus(i)
+	return cau
+}
+
+// ClearTaskStatus clears the value of the "task_status" field.
+func (cau *CompapiAsynctaskUpdate) ClearTaskStatus() *CompapiAsynctaskUpdate {
+	cau.mutation.ClearTaskStatus()
+	return cau
+}
+
+// SetRetryCount sets the "retry_count" field.
+func (cau *CompapiAsynctaskUpdate) SetRetryCount(i int8) *CompapiAsynctaskUpdate {
+	cau.mutation.ResetRetryCount()
+	cau.mutation.SetRetryCount(i)
+	return cau
+}
+
+// SetNillableRetryCount sets the "retry_count" field if the given value is not nil.
+func (cau *CompapiAsynctaskUpdate) SetNillableRetryCount(i *int8) *CompapiAsynctaskUpdate {
+	if i != nil {
+		cau.SetRetryCount(*i)
+	}
+	return cau
+}
+
+// AddRetryCount adds i to the "retry_count" field.
+func (cau *CompapiAsynctaskUpdate) AddRetryCount(i int8) *CompapiAsynctaskUpdate {
+	cau.mutation.AddRetryCount(i)
+	return cau
+}
+
+// ClearRetryCount clears the value of the "retry_count" field.
+func (cau *CompapiAsynctaskUpdate) ClearRetryCount() *CompapiAsynctaskUpdate {
+	cau.mutation.ClearRetryCount()
+	return cau
+}
+
+// SetLastError sets the "last_error" field.
+func (cau *CompapiAsynctaskUpdate) SetLastError(s string) *CompapiAsynctaskUpdate {
+	cau.mutation.SetLastError(s)
+	return cau
+}
+
+// SetNillableLastError sets the "last_error" field if the given value is not nil.
+func (cau *CompapiAsynctaskUpdate) SetNillableLastError(s *string) *CompapiAsynctaskUpdate {
+	if s != nil {
+		cau.SetLastError(*s)
+	}
+	return cau
+}
+
+// ClearLastError clears the value of the "last_error" field.
+func (cau *CompapiAsynctaskUpdate) ClearLastError() *CompapiAsynctaskUpdate {
+	cau.mutation.ClearLastError()
+	return cau
+}
+
+// Mutation returns the CompapiAsynctaskMutation object of the builder.
+func (cau *CompapiAsynctaskUpdate) Mutation() *CompapiAsynctaskMutation {
+	return cau.mutation
+}
+
+// Save executes the query and returns the number of nodes affected by the update operation.
+func (cau *CompapiAsynctaskUpdate) Save(ctx context.Context) (int, error) {
+	cau.defaults()
+	return withHooks(ctx, cau.sqlSave, cau.mutation, cau.hooks)
+}
+
+// SaveX is like Save, but panics if an error occurs.
+func (cau *CompapiAsynctaskUpdate) SaveX(ctx context.Context) int {
+	affected, err := cau.Save(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return affected
+}
+
+// Exec executes the query.
+func (cau *CompapiAsynctaskUpdate) Exec(ctx context.Context) error {
+	_, err := cau.Save(ctx)
+	return err
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (cau *CompapiAsynctaskUpdate) ExecX(ctx context.Context) {
+	if err := cau.Exec(ctx); err != nil {
+		panic(err)
+	}
+}
+
+// defaults sets the default values of the builder before save.
+func (cau *CompapiAsynctaskUpdate) defaults() {
+	if _, ok := cau.mutation.UpdatedAt(); !ok {
+		v := compapiasynctask.UpdateDefaultUpdatedAt()
+		cau.mutation.SetUpdatedAt(v)
+	}
+}
+
+// check runs all checks and user-defined validators on the builder.
+func (cau *CompapiAsynctaskUpdate) check() error {
+	if v, ok := cau.mutation.CallbackURL(); ok {
+		if err := compapiasynctask.CallbackURLValidator(v); err != nil {
+			return &ValidationError{Name: "callback_url", err: fmt.Errorf(`ent: validator failed for field "CompapiAsynctask.callback_url": %w`, err)}
+		}
+	}
+	return nil
+}
+
+func (cau *CompapiAsynctaskUpdate) sqlSave(ctx context.Context) (n int, err error) {
+	if err := cau.check(); err != nil {
+		return n, err
+	}
+	_spec := sqlgraph.NewUpdateSpec(compapiasynctask.Table, compapiasynctask.Columns, sqlgraph.NewFieldSpec(compapiasynctask.FieldID, field.TypeUint64))
+	if ps := cau.mutation.predicates; len(ps) > 0 {
+		_spec.Predicate = func(selector *sql.Selector) {
+			for i := range ps {
+				ps[i](selector)
+			}
+		}
+	}
+	if value, ok := cau.mutation.UpdatedAt(); ok {
+		_spec.SetField(compapiasynctask.FieldUpdatedAt, field.TypeTime, value)
+	}
+	if value, ok := cau.mutation.AuthToken(); ok {
+		_spec.SetField(compapiasynctask.FieldAuthToken, field.TypeString, value)
+	}
+	if value, ok := cau.mutation.EventType(); ok {
+		_spec.SetField(compapiasynctask.FieldEventType, field.TypeString, value)
+	}
+	if value, ok := cau.mutation.ChatID(); ok {
+		_spec.SetField(compapiasynctask.FieldChatID, field.TypeString, value)
+	}
+	if cau.mutation.ChatIDCleared() {
+		_spec.ClearField(compapiasynctask.FieldChatID, field.TypeString)
+	}
+	if value, ok := cau.mutation.WorkidIdx(); ok {
+		_spec.SetField(compapiasynctask.FieldWorkidIdx, field.TypeInt8, value)
+	}
+	if value, ok := cau.mutation.AddedWorkidIdx(); ok {
+		_spec.AddField(compapiasynctask.FieldWorkidIdx, field.TypeInt8, value)
+	}
+	if cau.mutation.WorkidIdxCleared() {
+		_spec.ClearField(compapiasynctask.FieldWorkidIdx, field.TypeInt8)
+	}
+	if value, ok := cau.mutation.OpenaiBase(); ok {
+		_spec.SetField(compapiasynctask.FieldOpenaiBase, field.TypeString, value)
+	}
+	if value, ok := cau.mutation.OpenaiKey(); ok {
+		_spec.SetField(compapiasynctask.FieldOpenaiKey, field.TypeString, value)
+	}
+	if value, ok := cau.mutation.RequestRaw(); ok {
+		_spec.SetField(compapiasynctask.FieldRequestRaw, field.TypeString, value)
+	}
+	if value, ok := cau.mutation.ResponseRaw(); ok {
+		_spec.SetField(compapiasynctask.FieldResponseRaw, field.TypeString, value)
+	}
+	if cau.mutation.ResponseRawCleared() {
+		_spec.ClearField(compapiasynctask.FieldResponseRaw, field.TypeString)
+	}
+	if value, ok := cau.mutation.CallbackURL(); ok {
+		_spec.SetField(compapiasynctask.FieldCallbackURL, field.TypeString, value)
+	}
+	if value, ok := cau.mutation.TaskStatus(); ok {
+		_spec.SetField(compapiasynctask.FieldTaskStatus, field.TypeInt8, value)
+	}
+	if value, ok := cau.mutation.AddedTaskStatus(); ok {
+		_spec.AddField(compapiasynctask.FieldTaskStatus, field.TypeInt8, value)
+	}
+	if cau.mutation.TaskStatusCleared() {
+		_spec.ClearField(compapiasynctask.FieldTaskStatus, field.TypeInt8)
+	}
+	if value, ok := cau.mutation.RetryCount(); ok {
+		_spec.SetField(compapiasynctask.FieldRetryCount, field.TypeInt8, value)
+	}
+	if value, ok := cau.mutation.AddedRetryCount(); ok {
+		_spec.AddField(compapiasynctask.FieldRetryCount, field.TypeInt8, value)
+	}
+	if cau.mutation.RetryCountCleared() {
+		_spec.ClearField(compapiasynctask.FieldRetryCount, field.TypeInt8)
+	}
+	if value, ok := cau.mutation.LastError(); ok {
+		_spec.SetField(compapiasynctask.FieldLastError, field.TypeString, value)
+	}
+	if cau.mutation.LastErrorCleared() {
+		_spec.ClearField(compapiasynctask.FieldLastError, field.TypeString)
+	}
+	if n, err = sqlgraph.UpdateNodes(ctx, cau.driver, _spec); err != nil {
+		if _, ok := err.(*sqlgraph.NotFoundError); ok {
+			err = &NotFoundError{compapiasynctask.Label}
+		} else if sqlgraph.IsConstraintError(err) {
+			err = &ConstraintError{msg: err.Error(), wrap: err}
+		}
+		return 0, err
+	}
+	cau.mutation.done = true
+	return n, nil
+}
+
+// CompapiAsynctaskUpdateOne is the builder for updating a single CompapiAsynctask entity.
+type CompapiAsynctaskUpdateOne struct {
+	config
+	fields   []string
+	hooks    []Hook
+	mutation *CompapiAsynctaskMutation
+}
+
+// SetUpdatedAt sets the "updated_at" field.
+func (cauo *CompapiAsynctaskUpdateOne) SetUpdatedAt(t time.Time) *CompapiAsynctaskUpdateOne {
+	cauo.mutation.SetUpdatedAt(t)
+	return cauo
+}
+
+// SetAuthToken sets the "auth_token" field.
+func (cauo *CompapiAsynctaskUpdateOne) SetAuthToken(s string) *CompapiAsynctaskUpdateOne {
+	cauo.mutation.SetAuthToken(s)
+	return cauo
+}
+
+// SetNillableAuthToken sets the "auth_token" field if the given value is not nil.
+func (cauo *CompapiAsynctaskUpdateOne) SetNillableAuthToken(s *string) *CompapiAsynctaskUpdateOne {
+	if s != nil {
+		cauo.SetAuthToken(*s)
+	}
+	return cauo
+}
+
+// SetEventType sets the "event_type" field.
+func (cauo *CompapiAsynctaskUpdateOne) SetEventType(s string) *CompapiAsynctaskUpdateOne {
+	cauo.mutation.SetEventType(s)
+	return cauo
+}
+
+// SetNillableEventType sets the "event_type" field if the given value is not nil.
+func (cauo *CompapiAsynctaskUpdateOne) SetNillableEventType(s *string) *CompapiAsynctaskUpdateOne {
+	if s != nil {
+		cauo.SetEventType(*s)
+	}
+	return cauo
+}
+
+// SetChatID sets the "chat_id" field.
+func (cauo *CompapiAsynctaskUpdateOne) SetChatID(s string) *CompapiAsynctaskUpdateOne {
+	cauo.mutation.SetChatID(s)
+	return cauo
+}
+
+// SetNillableChatID sets the "chat_id" field if the given value is not nil.
+func (cauo *CompapiAsynctaskUpdateOne) SetNillableChatID(s *string) *CompapiAsynctaskUpdateOne {
+	if s != nil {
+		cauo.SetChatID(*s)
+	}
+	return cauo
+}
+
+// ClearChatID clears the value of the "chat_id" field.
+func (cauo *CompapiAsynctaskUpdateOne) ClearChatID() *CompapiAsynctaskUpdateOne {
+	cauo.mutation.ClearChatID()
+	return cauo
+}
+
+// SetWorkidIdx sets the "workid_idx" field.
+func (cauo *CompapiAsynctaskUpdateOne) SetWorkidIdx(i int8) *CompapiAsynctaskUpdateOne {
+	cauo.mutation.ResetWorkidIdx()
+	cauo.mutation.SetWorkidIdx(i)
+	return cauo
+}
+
+// SetNillableWorkidIdx sets the "workid_idx" field if the given value is not nil.
+func (cauo *CompapiAsynctaskUpdateOne) SetNillableWorkidIdx(i *int8) *CompapiAsynctaskUpdateOne {
+	if i != nil {
+		cauo.SetWorkidIdx(*i)
+	}
+	return cauo
+}
+
+// AddWorkidIdx adds i to the "workid_idx" field.
+func (cauo *CompapiAsynctaskUpdateOne) AddWorkidIdx(i int8) *CompapiAsynctaskUpdateOne {
+	cauo.mutation.AddWorkidIdx(i)
+	return cauo
+}
+
+// ClearWorkidIdx clears the value of the "workid_idx" field.
+func (cauo *CompapiAsynctaskUpdateOne) ClearWorkidIdx() *CompapiAsynctaskUpdateOne {
+	cauo.mutation.ClearWorkidIdx()
+	return cauo
+}
+
+// SetOpenaiBase sets the "openai_base" field.
+func (cauo *CompapiAsynctaskUpdateOne) SetOpenaiBase(s string) *CompapiAsynctaskUpdateOne {
+	cauo.mutation.SetOpenaiBase(s)
+	return cauo
+}
+
+// SetNillableOpenaiBase sets the "openai_base" field if the given value is not nil.
+func (cauo *CompapiAsynctaskUpdateOne) SetNillableOpenaiBase(s *string) *CompapiAsynctaskUpdateOne {
+	if s != nil {
+		cauo.SetOpenaiBase(*s)
+	}
+	return cauo
+}
+
+// SetOpenaiKey sets the "openai_key" field.
+func (cauo *CompapiAsynctaskUpdateOne) SetOpenaiKey(s string) *CompapiAsynctaskUpdateOne {
+	cauo.mutation.SetOpenaiKey(s)
+	return cauo
+}
+
+// SetNillableOpenaiKey sets the "openai_key" field if the given value is not nil.
+func (cauo *CompapiAsynctaskUpdateOne) SetNillableOpenaiKey(s *string) *CompapiAsynctaskUpdateOne {
+	if s != nil {
+		cauo.SetOpenaiKey(*s)
+	}
+	return cauo
+}
+
+// SetRequestRaw sets the "request_raw" field.
+func (cauo *CompapiAsynctaskUpdateOne) SetRequestRaw(s string) *CompapiAsynctaskUpdateOne {
+	cauo.mutation.SetRequestRaw(s)
+	return cauo
+}
+
+// SetNillableRequestRaw sets the "request_raw" field if the given value is not nil.
+func (cauo *CompapiAsynctaskUpdateOne) SetNillableRequestRaw(s *string) *CompapiAsynctaskUpdateOne {
+	if s != nil {
+		cauo.SetRequestRaw(*s)
+	}
+	return cauo
+}
+
+// SetResponseRaw sets the "response_raw" field.
+func (cauo *CompapiAsynctaskUpdateOne) SetResponseRaw(s string) *CompapiAsynctaskUpdateOne {
+	cauo.mutation.SetResponseRaw(s)
+	return cauo
+}
+
+// SetNillableResponseRaw sets the "response_raw" field if the given value is not nil.
+func (cauo *CompapiAsynctaskUpdateOne) SetNillableResponseRaw(s *string) *CompapiAsynctaskUpdateOne {
+	if s != nil {
+		cauo.SetResponseRaw(*s)
+	}
+	return cauo
+}
+
+// ClearResponseRaw clears the value of the "response_raw" field.
+func (cauo *CompapiAsynctaskUpdateOne) ClearResponseRaw() *CompapiAsynctaskUpdateOne {
+	cauo.mutation.ClearResponseRaw()
+	return cauo
+}
+
+// SetCallbackURL sets the "callback_url" field.
+func (cauo *CompapiAsynctaskUpdateOne) SetCallbackURL(s string) *CompapiAsynctaskUpdateOne {
+	cauo.mutation.SetCallbackURL(s)
+	return cauo
+}
+
+// SetNillableCallbackURL sets the "callback_url" field if the given value is not nil.
+func (cauo *CompapiAsynctaskUpdateOne) SetNillableCallbackURL(s *string) *CompapiAsynctaskUpdateOne {
+	if s != nil {
+		cauo.SetCallbackURL(*s)
+	}
+	return cauo
+}
+
+// SetTaskStatus sets the "task_status" field.
+func (cauo *CompapiAsynctaskUpdateOne) SetTaskStatus(i int8) *CompapiAsynctaskUpdateOne {
+	cauo.mutation.ResetTaskStatus()
+	cauo.mutation.SetTaskStatus(i)
+	return cauo
+}
+
+// SetNillableTaskStatus sets the "task_status" field if the given value is not nil.
+func (cauo *CompapiAsynctaskUpdateOne) SetNillableTaskStatus(i *int8) *CompapiAsynctaskUpdateOne {
+	if i != nil {
+		cauo.SetTaskStatus(*i)
+	}
+	return cauo
+}
+
+// AddTaskStatus adds i to the "task_status" field.
+func (cauo *CompapiAsynctaskUpdateOne) AddTaskStatus(i int8) *CompapiAsynctaskUpdateOne {
+	cauo.mutation.AddTaskStatus(i)
+	return cauo
+}
+
+// ClearTaskStatus clears the value of the "task_status" field.
+func (cauo *CompapiAsynctaskUpdateOne) ClearTaskStatus() *CompapiAsynctaskUpdateOne {
+	cauo.mutation.ClearTaskStatus()
+	return cauo
+}
+
+// SetRetryCount sets the "retry_count" field.
+func (cauo *CompapiAsynctaskUpdateOne) SetRetryCount(i int8) *CompapiAsynctaskUpdateOne {
+	cauo.mutation.ResetRetryCount()
+	cauo.mutation.SetRetryCount(i)
+	return cauo
+}
+
+// SetNillableRetryCount sets the "retry_count" field if the given value is not nil.
+func (cauo *CompapiAsynctaskUpdateOne) SetNillableRetryCount(i *int8) *CompapiAsynctaskUpdateOne {
+	if i != nil {
+		cauo.SetRetryCount(*i)
+	}
+	return cauo
+}
+
+// AddRetryCount adds i to the "retry_count" field.
+func (cauo *CompapiAsynctaskUpdateOne) AddRetryCount(i int8) *CompapiAsynctaskUpdateOne {
+	cauo.mutation.AddRetryCount(i)
+	return cauo
+}
+
+// ClearRetryCount clears the value of the "retry_count" field.
+func (cauo *CompapiAsynctaskUpdateOne) ClearRetryCount() *CompapiAsynctaskUpdateOne {
+	cauo.mutation.ClearRetryCount()
+	return cauo
+}
+
+// SetLastError sets the "last_error" field.
+func (cauo *CompapiAsynctaskUpdateOne) SetLastError(s string) *CompapiAsynctaskUpdateOne {
+	cauo.mutation.SetLastError(s)
+	return cauo
+}
+
+// SetNillableLastError sets the "last_error" field if the given value is not nil.
+func (cauo *CompapiAsynctaskUpdateOne) SetNillableLastError(s *string) *CompapiAsynctaskUpdateOne {
+	if s != nil {
+		cauo.SetLastError(*s)
+	}
+	return cauo
+}
+
+// ClearLastError clears the value of the "last_error" field.
+func (cauo *CompapiAsynctaskUpdateOne) ClearLastError() *CompapiAsynctaskUpdateOne {
+	cauo.mutation.ClearLastError()
+	return cauo
+}
+
+// Mutation returns the CompapiAsynctaskMutation object of the builder.
+func (cauo *CompapiAsynctaskUpdateOne) Mutation() *CompapiAsynctaskMutation {
+	return cauo.mutation
+}
+
+// Where appends a list predicates to the CompapiAsynctaskUpdate builder.
+func (cauo *CompapiAsynctaskUpdateOne) Where(ps ...predicate.CompapiAsynctask) *CompapiAsynctaskUpdateOne {
+	cauo.mutation.Where(ps...)
+	return cauo
+}
+
+// Select allows selecting one or more fields (columns) of the returned entity.
+// The default is selecting all fields defined in the entity schema.
+func (cauo *CompapiAsynctaskUpdateOne) Select(field string, fields ...string) *CompapiAsynctaskUpdateOne {
+	cauo.fields = append([]string{field}, fields...)
+	return cauo
+}
+
+// Save executes the query and returns the updated CompapiAsynctask entity.
+func (cauo *CompapiAsynctaskUpdateOne) Save(ctx context.Context) (*CompapiAsynctask, error) {
+	cauo.defaults()
+	return withHooks(ctx, cauo.sqlSave, cauo.mutation, cauo.hooks)
+}
+
+// SaveX is like Save, but panics if an error occurs.
+func (cauo *CompapiAsynctaskUpdateOne) SaveX(ctx context.Context) *CompapiAsynctask {
+	node, err := cauo.Save(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return node
+}
+
+// Exec executes the query on the entity.
+func (cauo *CompapiAsynctaskUpdateOne) Exec(ctx context.Context) error {
+	_, err := cauo.Save(ctx)
+	return err
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (cauo *CompapiAsynctaskUpdateOne) ExecX(ctx context.Context) {
+	if err := cauo.Exec(ctx); err != nil {
+		panic(err)
+	}
+}
+
+// defaults sets the default values of the builder before save.
+func (cauo *CompapiAsynctaskUpdateOne) defaults() {
+	if _, ok := cauo.mutation.UpdatedAt(); !ok {
+		v := compapiasynctask.UpdateDefaultUpdatedAt()
+		cauo.mutation.SetUpdatedAt(v)
+	}
+}
+
+// check runs all checks and user-defined validators on the builder.
+func (cauo *CompapiAsynctaskUpdateOne) check() error {
+	if v, ok := cauo.mutation.CallbackURL(); ok {
+		if err := compapiasynctask.CallbackURLValidator(v); err != nil {
+			return &ValidationError{Name: "callback_url", err: fmt.Errorf(`ent: validator failed for field "CompapiAsynctask.callback_url": %w`, err)}
+		}
+	}
+	return nil
+}
+
+func (cauo *CompapiAsynctaskUpdateOne) sqlSave(ctx context.Context) (_node *CompapiAsynctask, err error) {
+	if err := cauo.check(); err != nil {
+		return _node, err
+	}
+	_spec := sqlgraph.NewUpdateSpec(compapiasynctask.Table, compapiasynctask.Columns, sqlgraph.NewFieldSpec(compapiasynctask.FieldID, field.TypeUint64))
+	id, ok := cauo.mutation.ID()
+	if !ok {
+		return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "CompapiAsynctask.id" for update`)}
+	}
+	_spec.Node.ID.Value = id
+	if fields := cauo.fields; len(fields) > 0 {
+		_spec.Node.Columns = make([]string, 0, len(fields))
+		_spec.Node.Columns = append(_spec.Node.Columns, compapiasynctask.FieldID)
+		for _, f := range fields {
+			if !compapiasynctask.ValidColumn(f) {
+				return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
+			}
+			if f != compapiasynctask.FieldID {
+				_spec.Node.Columns = append(_spec.Node.Columns, f)
+			}
+		}
+	}
+	if ps := cauo.mutation.predicates; len(ps) > 0 {
+		_spec.Predicate = func(selector *sql.Selector) {
+			for i := range ps {
+				ps[i](selector)
+			}
+		}
+	}
+	if value, ok := cauo.mutation.UpdatedAt(); ok {
+		_spec.SetField(compapiasynctask.FieldUpdatedAt, field.TypeTime, value)
+	}
+	if value, ok := cauo.mutation.AuthToken(); ok {
+		_spec.SetField(compapiasynctask.FieldAuthToken, field.TypeString, value)
+	}
+	if value, ok := cauo.mutation.EventType(); ok {
+		_spec.SetField(compapiasynctask.FieldEventType, field.TypeString, value)
+	}
+	if value, ok := cauo.mutation.ChatID(); ok {
+		_spec.SetField(compapiasynctask.FieldChatID, field.TypeString, value)
+	}
+	if cauo.mutation.ChatIDCleared() {
+		_spec.ClearField(compapiasynctask.FieldChatID, field.TypeString)
+	}
+	if value, ok := cauo.mutation.WorkidIdx(); ok {
+		_spec.SetField(compapiasynctask.FieldWorkidIdx, field.TypeInt8, value)
+	}
+	if value, ok := cauo.mutation.AddedWorkidIdx(); ok {
+		_spec.AddField(compapiasynctask.FieldWorkidIdx, field.TypeInt8, value)
+	}
+	if cauo.mutation.WorkidIdxCleared() {
+		_spec.ClearField(compapiasynctask.FieldWorkidIdx, field.TypeInt8)
+	}
+	if value, ok := cauo.mutation.OpenaiBase(); ok {
+		_spec.SetField(compapiasynctask.FieldOpenaiBase, field.TypeString, value)
+	}
+	if value, ok := cauo.mutation.OpenaiKey(); ok {
+		_spec.SetField(compapiasynctask.FieldOpenaiKey, field.TypeString, value)
+	}
+	if value, ok := cauo.mutation.RequestRaw(); ok {
+		_spec.SetField(compapiasynctask.FieldRequestRaw, field.TypeString, value)
+	}
+	if value, ok := cauo.mutation.ResponseRaw(); ok {
+		_spec.SetField(compapiasynctask.FieldResponseRaw, field.TypeString, value)
+	}
+	if cauo.mutation.ResponseRawCleared() {
+		_spec.ClearField(compapiasynctask.FieldResponseRaw, field.TypeString)
+	}
+	if value, ok := cauo.mutation.CallbackURL(); ok {
+		_spec.SetField(compapiasynctask.FieldCallbackURL, field.TypeString, value)
+	}
+	if value, ok := cauo.mutation.TaskStatus(); ok {
+		_spec.SetField(compapiasynctask.FieldTaskStatus, field.TypeInt8, value)
+	}
+	if value, ok := cauo.mutation.AddedTaskStatus(); ok {
+		_spec.AddField(compapiasynctask.FieldTaskStatus, field.TypeInt8, value)
+	}
+	if cauo.mutation.TaskStatusCleared() {
+		_spec.ClearField(compapiasynctask.FieldTaskStatus, field.TypeInt8)
+	}
+	if value, ok := cauo.mutation.RetryCount(); ok {
+		_spec.SetField(compapiasynctask.FieldRetryCount, field.TypeInt8, value)
+	}
+	if value, ok := cauo.mutation.AddedRetryCount(); ok {
+		_spec.AddField(compapiasynctask.FieldRetryCount, field.TypeInt8, value)
+	}
+	if cauo.mutation.RetryCountCleared() {
+		_spec.ClearField(compapiasynctask.FieldRetryCount, field.TypeInt8)
+	}
+	if value, ok := cauo.mutation.LastError(); ok {
+		_spec.SetField(compapiasynctask.FieldLastError, field.TypeString, value)
+	}
+	if cauo.mutation.LastErrorCleared() {
+		_spec.ClearField(compapiasynctask.FieldLastError, field.TypeString)
+	}
+	_node = &CompapiAsynctask{config: cauo.config}
+	_spec.Assign = _node.assignValues
+	_spec.ScanValues = _node.scanValues
+	if err = sqlgraph.UpdateNode(ctx, cauo.driver, _spec); err != nil {
+		if _, ok := err.(*sqlgraph.NotFoundError); ok {
+			err = &NotFoundError{compapiasynctask.Label}
+		} else if sqlgraph.IsConstraintError(err) {
+			err = &ConstraintError{msg: err.Error(), wrap: err}
+		}
+		return nil, err
+	}
+	cauo.mutation.done = true
+	return _node, nil
+}

+ 2 - 2
ent/ent.go

@@ -17,7 +17,7 @@ import (
 	"wechat-api/ent/category"
 	"wechat-api/ent/chatrecords"
 	"wechat-api/ent/chatsession"
-	"wechat-api/ent/compapijob"
+	"wechat-api/ent/compapiasynctask"
 	"wechat-api/ent/contact"
 	"wechat-api/ent/creditbalance"
 	"wechat-api/ent/creditusage"
@@ -123,7 +123,7 @@ func checkColumn(table, column string) error {
 			category.Table:            category.ValidColumn,
 			chatrecords.Table:         chatrecords.ValidColumn,
 			chatsession.Table:         chatsession.ValidColumn,
-			compapijob.Table:          compapijob.ValidColumn,
+			compapiasynctask.Table:    compapiasynctask.ValidColumn,
 			contact.Table:             contact.ValidColumn,
 			creditbalance.Table:       creditbalance.ValidColumn,
 			creditusage.Table:         creditusage.ValidColumn,

+ 6 - 6
ent/hook/hook.go

@@ -116,16 +116,16 @@ func (f ChatSessionFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value,
 	return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ChatSessionMutation", m)
 }
 
-// The CompapiJobFunc type is an adapter to allow the use of ordinary
-// function as CompapiJob mutator.
-type CompapiJobFunc func(context.Context, *ent.CompapiJobMutation) (ent.Value, error)
+// The CompapiAsynctaskFunc type is an adapter to allow the use of ordinary
+// function as CompapiAsynctask mutator.
+type CompapiAsynctaskFunc func(context.Context, *ent.CompapiAsynctaskMutation) (ent.Value, error)
 
 // Mutate calls f(ctx, m).
-func (f CompapiJobFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
-	if mv, ok := m.(*ent.CompapiJobMutation); ok {
+func (f CompapiAsynctaskFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
+	if mv, ok := m.(*ent.CompapiAsynctaskMutation); ok {
 		return f(ctx, mv)
 	}
-	return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.CompapiJobMutation", m)
+	return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.CompapiAsynctaskMutation", m)
 }
 
 // The ContactFunc type is an adapter to allow the use of ordinary

+ 14 - 14
ent/intercept/intercept.go

@@ -15,7 +15,7 @@ import (
 	"wechat-api/ent/category"
 	"wechat-api/ent/chatrecords"
 	"wechat-api/ent/chatsession"
-	"wechat-api/ent/compapijob"
+	"wechat-api/ent/compapiasynctask"
 	"wechat-api/ent/contact"
 	"wechat-api/ent/creditbalance"
 	"wechat-api/ent/creditusage"
@@ -352,31 +352,31 @@ func (f TraverseChatSession) Traverse(ctx context.Context, q ent.Query) error {
 	return fmt.Errorf("unexpected query type %T. expect *ent.ChatSessionQuery", q)
 }
 
-// The CompapiJobFunc type is an adapter to allow the use of ordinary function as a Querier.
-type CompapiJobFunc func(context.Context, *ent.CompapiJobQuery) (ent.Value, error)
+// The CompapiAsynctaskFunc type is an adapter to allow the use of ordinary function as a Querier.
+type CompapiAsynctaskFunc func(context.Context, *ent.CompapiAsynctaskQuery) (ent.Value, error)
 
 // Query calls f(ctx, q).
-func (f CompapiJobFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
-	if q, ok := q.(*ent.CompapiJobQuery); ok {
+func (f CompapiAsynctaskFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
+	if q, ok := q.(*ent.CompapiAsynctaskQuery); ok {
 		return f(ctx, q)
 	}
-	return nil, fmt.Errorf("unexpected query type %T. expect *ent.CompapiJobQuery", q)
+	return nil, fmt.Errorf("unexpected query type %T. expect *ent.CompapiAsynctaskQuery", q)
 }
 
-// The TraverseCompapiJob type is an adapter to allow the use of ordinary function as Traverser.
-type TraverseCompapiJob func(context.Context, *ent.CompapiJobQuery) error
+// The TraverseCompapiAsynctask type is an adapter to allow the use of ordinary function as Traverser.
+type TraverseCompapiAsynctask func(context.Context, *ent.CompapiAsynctaskQuery) error
 
 // Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
-func (f TraverseCompapiJob) Intercept(next ent.Querier) ent.Querier {
+func (f TraverseCompapiAsynctask) Intercept(next ent.Querier) ent.Querier {
 	return next
 }
 
 // Traverse calls f(ctx, q).
-func (f TraverseCompapiJob) Traverse(ctx context.Context, q ent.Query) error {
-	if q, ok := q.(*ent.CompapiJobQuery); ok {
+func (f TraverseCompapiAsynctask) Traverse(ctx context.Context, q ent.Query) error {
+	if q, ok := q.(*ent.CompapiAsynctaskQuery); ok {
 		return f(ctx, q)
 	}
-	return fmt.Errorf("unexpected query type %T. expect *ent.CompapiJobQuery", q)
+	return fmt.Errorf("unexpected query type %T. expect *ent.CompapiAsynctaskQuery", q)
 }
 
 // The ContactFunc type is an adapter to allow the use of ordinary function as a Querier.
@@ -1264,8 +1264,8 @@ func NewQuery(q ent.Query) (Query, error) {
 		return &query[*ent.ChatRecordsQuery, predicate.ChatRecords, chatrecords.OrderOption]{typ: ent.TypeChatRecords, tq: q}, nil
 	case *ent.ChatSessionQuery:
 		return &query[*ent.ChatSessionQuery, predicate.ChatSession, chatsession.OrderOption]{typ: ent.TypeChatSession, tq: q}, nil
-	case *ent.CompapiJobQuery:
-		return &query[*ent.CompapiJobQuery, predicate.CompapiJob, compapijob.OrderOption]{typ: ent.TypeCompapiJob, tq: q}, nil
+	case *ent.CompapiAsynctaskQuery:
+		return &query[*ent.CompapiAsynctaskQuery, predicate.CompapiAsynctask, compapiasynctask.OrderOption]{typ: ent.TypeCompapiAsynctask, tq: q}, nil
 	case *ent.ContactQuery:
 		return &query[*ent.ContactQuery, predicate.Contact, contact.OrderOption]{typ: ent.TypeContact, tq: q}, nil
 	case *ent.CreditBalanceQuery:

+ 22 - 25
ent/migrate/schema.go

@@ -273,37 +273,34 @@ var (
 			},
 		},
 	}
-	// CompapiJobColumns holds the columns for the "compapi_job" table.
-	CompapiJobColumns = []*schema.Column{
+	// CompapiAsynctaskColumns holds the columns for the "compapi_asynctask" table.
+	CompapiAsynctaskColumns = []*schema.Column{
 		{Name: "id", Type: field.TypeUint64, Increment: true},
 		{Name: "created_at", Type: field.TypeTime, Comment: "Create Time | 创建日期"},
 		{Name: "updated_at", Type: field.TypeTime, Comment: "Update Time | 修改日期"},
-		{Name: "dist_at", Type: field.TypeTime, Nullable: true, Comment: "Dist Time | 分发时间"},
-		{Name: "dist_status", Type: field.TypeInt8, Nullable: true, Comment: "dist status | 分发状态 0 未 1 已", Default: 0},
-		{Name: "callback_status", Type: field.TypeInt8, Nullable: true, Comment: "callback_status | 回调状态 10 准备回调 20 ", Default: 10},
-		{Name: "callback_url", Type: field.TypeString, Comment: "异步执行回调地址"},
-		{Name: "request_json", Type: field.TypeJSON, Comment: "请求参数结构JSON"},
-		{Name: "auth_token", Type: field.TypeString, Comment: "发起请求者的授权token", Default: ""},
-		{Name: "event_type", Type: field.TypeString, Comment: "发起请求者的类型", Default: ""},
-		{Name: "workid_idx", Type: field.TypeInt8, Nullable: true, Comment: "workId在字典中的索引", Default: 0},
+		{Name: "auth_token", Type: field.TypeString, Comment: "发起请求者的授权token"},
+		{Name: "event_type", Type: field.TypeString, Comment: "请求目标类型", Default: "fastgpt"},
 		{Name: "chat_id", Type: field.TypeString, Nullable: true, Comment: "会话ID", Default: ""},
+		{Name: "workid_idx", Type: field.TypeInt8, Nullable: true, Comment: "workId在字典中的索引值", Default: 0},
+		{Name: "openai_base", Type: field.TypeString, Comment: "待请求的大模型服务地址"},
+		{Name: "openai_key", Type: field.TypeString, Comment: "待请求的大模型服务密钥授权token"},
+		{Name: "request_raw", Type: field.TypeString, Comment: "请求参数结构字符串"},
+		{Name: "response_raw", Type: field.TypeString, Nullable: true, Comment: "请求响应结构字符串", Default: ""},
+		{Name: "callback_url", Type: field.TypeString, Size: 255, Comment: "异步执行回调地址"},
+		{Name: "task_status", Type: field.TypeInt8, Nullable: true, Comment: "callback_status | 任务完成状态 10 任务就绪 20 请求API完成 30 请求回调完成 60 任务暂停 70 任务失败", Default: 10},
 		{Name: "retry_count", Type: field.TypeInt8, Nullable: true, Comment: "retry count | 重试次数", Default: 0},
+		{Name: "last_error", Type: field.TypeString, Nullable: true, Comment: "最后一次出错信息", Default: ""},
 	}
-	// CompapiJobTable holds the schema information for the "compapi_job" table.
-	CompapiJobTable = &schema.Table{
-		Name:       "compapi_job",
-		Columns:    CompapiJobColumns,
-		PrimaryKey: []*schema.Column{CompapiJobColumns[0]},
+	// CompapiAsynctaskTable holds the schema information for the "compapi_asynctask" table.
+	CompapiAsynctaskTable = &schema.Table{
+		Name:       "compapi_asynctask",
+		Columns:    CompapiAsynctaskColumns,
+		PrimaryKey: []*schema.Column{CompapiAsynctaskColumns[0]},
 		Indexes: []*schema.Index{
 			{
-				Name:    "compapijob_dist_status",
+				Name:    "compapiasynctask_task_status",
 				Unique:  false,
-				Columns: []*schema.Column{CompapiJobColumns[4]},
-			},
-			{
-				Name:    "compapijob_callback_status",
-				Unique:  false,
-				Columns: []*schema.Column{CompapiJobColumns[5]},
+				Columns: []*schema.Column{CompapiAsynctaskColumns[12]},
 			},
 		},
 	}
@@ -1457,7 +1454,7 @@ var (
 		CategoryTable,
 		ChatRecordsTable,
 		ChatSessionTable,
-		CompapiJobTable,
+		CompapiAsynctaskTable,
 		ContactTable,
 		CreditBalanceTable,
 		CreditUsageTable,
@@ -1522,8 +1519,8 @@ func init() {
 	ChatSessionTable.Annotation = &entsql.Annotation{
 		Table: "chat_session",
 	}
-	CompapiJobTable.Annotation = &entsql.Annotation{
-		Table: "compapi_job",
+	CompapiAsynctaskTable.Annotation = &entsql.Annotation{
+		Table: "compapi_asynctask",
 	}
 	ContactTable.Annotation = &entsql.Annotation{
 		Table: "contact",

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 316 - 313
ent/mutation.go


+ 27 - 27
ent/pagination.go

@@ -14,7 +14,7 @@ import (
 	"wechat-api/ent/category"
 	"wechat-api/ent/chatrecords"
 	"wechat-api/ent/chatsession"
-	"wechat-api/ent/compapijob"
+	"wechat-api/ent/compapiasynctask"
 	"wechat-api/ent/contact"
 	"wechat-api/ent/creditbalance"
 	"wechat-api/ent/creditusage"
@@ -824,62 +824,62 @@ func (cs *ChatSessionQuery) Page(
 	return ret, nil
 }
 
-type CompapiJobPager struct {
-	Order  compapijob.OrderOption
-	Filter func(*CompapiJobQuery) (*CompapiJobQuery, error)
+type CompapiAsynctaskPager struct {
+	Order  compapiasynctask.OrderOption
+	Filter func(*CompapiAsynctaskQuery) (*CompapiAsynctaskQuery, error)
 }
 
-// CompapiJobPaginateOption enables pagination customization.
-type CompapiJobPaginateOption func(*CompapiJobPager)
+// CompapiAsynctaskPaginateOption enables pagination customization.
+type CompapiAsynctaskPaginateOption func(*CompapiAsynctaskPager)
 
-// DefaultCompapiJobOrder is the default ordering of CompapiJob.
-var DefaultCompapiJobOrder = Desc(compapijob.FieldID)
+// DefaultCompapiAsynctaskOrder is the default ordering of CompapiAsynctask.
+var DefaultCompapiAsynctaskOrder = Desc(compapiasynctask.FieldID)
 
-func newCompapiJobPager(opts []CompapiJobPaginateOption) (*CompapiJobPager, error) {
-	pager := &CompapiJobPager{}
+func newCompapiAsynctaskPager(opts []CompapiAsynctaskPaginateOption) (*CompapiAsynctaskPager, error) {
+	pager := &CompapiAsynctaskPager{}
 	for _, opt := range opts {
 		opt(pager)
 	}
 	if pager.Order == nil {
-		pager.Order = DefaultCompapiJobOrder
+		pager.Order = DefaultCompapiAsynctaskOrder
 	}
 	return pager, nil
 }
 
-func (p *CompapiJobPager) ApplyFilter(query *CompapiJobQuery) (*CompapiJobQuery, error) {
+func (p *CompapiAsynctaskPager) ApplyFilter(query *CompapiAsynctaskQuery) (*CompapiAsynctaskQuery, error) {
 	if p.Filter != nil {
 		return p.Filter(query)
 	}
 	return query, nil
 }
 
-// CompapiJobPageList is CompapiJob PageList result.
-type CompapiJobPageList struct {
-	List        []*CompapiJob `json:"list"`
-	PageDetails *PageDetails  `json:"pageDetails"`
+// CompapiAsynctaskPageList is CompapiAsynctask PageList result.
+type CompapiAsynctaskPageList struct {
+	List        []*CompapiAsynctask `json:"list"`
+	PageDetails *PageDetails        `json:"pageDetails"`
 }
 
-func (cj *CompapiJobQuery) Page(
-	ctx context.Context, pageNum uint64, pageSize uint64, opts ...CompapiJobPaginateOption,
-) (*CompapiJobPageList, error) {
+func (ca *CompapiAsynctaskQuery) Page(
+	ctx context.Context, pageNum uint64, pageSize uint64, opts ...CompapiAsynctaskPaginateOption,
+) (*CompapiAsynctaskPageList, error) {
 
-	pager, err := newCompapiJobPager(opts)
+	pager, err := newCompapiAsynctaskPager(opts)
 	if err != nil {
 		return nil, err
 	}
 
-	if cj, err = pager.ApplyFilter(cj); err != nil {
+	if ca, err = pager.ApplyFilter(ca); err != nil {
 		return nil, err
 	}
 
-	ret := &CompapiJobPageList{}
+	ret := &CompapiAsynctaskPageList{}
 
 	ret.PageDetails = &PageDetails{
 		Page: pageNum,
 		Size: pageSize,
 	}
 
-	query := cj.Clone()
+	query := ca.Clone()
 	query.ctx.Fields = nil
 	count, err := query.Count(ctx)
 
@@ -890,13 +890,13 @@ func (cj *CompapiJobQuery) Page(
 	ret.PageDetails.Total = uint64(count)
 
 	if pager.Order != nil {
-		cj = cj.Order(pager.Order)
+		ca = ca.Order(pager.Order)
 	} else {
-		cj = cj.Order(DefaultCompapiJobOrder)
+		ca = ca.Order(DefaultCompapiAsynctaskOrder)
 	}
 
-	cj = cj.Offset(int((pageNum - 1) * pageSize)).Limit(int(pageSize))
-	list, err := cj.All(ctx)
+	ca = ca.Offset(int((pageNum - 1) * pageSize)).Limit(int(pageSize))
+	list, err := ca.All(ctx)
 	if err != nil {
 		return nil, err
 	}

+ 2 - 2
ent/predicate/predicate.go

@@ -33,8 +33,8 @@ type ChatRecords func(*sql.Selector)
 // ChatSession is the predicate function for chatsession builders.
 type ChatSession func(*sql.Selector)
 
-// CompapiJob is the predicate function for compapijob builders.
-type CompapiJob func(*sql.Selector)
+// CompapiAsynctask is the predicate function for compapiasynctask builders.
+type CompapiAsynctask func(*sql.Selector)
 
 // Contact is the predicate function for contact builders.
 type Contact func(*sql.Selector)

+ 48 - 44
ent/runtime/runtime.go

@@ -13,7 +13,7 @@ import (
 	"wechat-api/ent/category"
 	"wechat-api/ent/chatrecords"
 	"wechat-api/ent/chatsession"
-	"wechat-api/ent/compapijob"
+	"wechat-api/ent/compapiasynctask"
 	"wechat-api/ent/contact"
 	"wechat-api/ent/creditbalance"
 	"wechat-api/ent/creditusage"
@@ -379,49 +379,53 @@ func init() {
 	chatsessionDescBotType := chatsessionFields[3].Descriptor()
 	// chatsession.DefaultBotType holds the default value on creation for the bot_type field.
 	chatsession.DefaultBotType = chatsessionDescBotType.Default.(uint8)
-	compapijobMixin := schema.CompapiJob{}.Mixin()
-	compapijobMixinFields0 := compapijobMixin[0].Fields()
-	_ = compapijobMixinFields0
-	compapijobFields := schema.CompapiJob{}.Fields()
-	_ = compapijobFields
-	// compapijobDescCreatedAt is the schema descriptor for created_at field.
-	compapijobDescCreatedAt := compapijobMixinFields0[1].Descriptor()
-	// compapijob.DefaultCreatedAt holds the default value on creation for the created_at field.
-	compapijob.DefaultCreatedAt = compapijobDescCreatedAt.Default.(func() time.Time)
-	// compapijobDescUpdatedAt is the schema descriptor for updated_at field.
-	compapijobDescUpdatedAt := compapijobMixinFields0[2].Descriptor()
-	// compapijob.DefaultUpdatedAt holds the default value on creation for the updated_at field.
-	compapijob.DefaultUpdatedAt = compapijobDescUpdatedAt.Default.(func() time.Time)
-	// compapijob.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
-	compapijob.UpdateDefaultUpdatedAt = compapijobDescUpdatedAt.UpdateDefault.(func() time.Time)
-	// compapijobDescDistStatus is the schema descriptor for dist_status field.
-	compapijobDescDistStatus := compapijobFields[1].Descriptor()
-	// compapijob.DefaultDistStatus holds the default value on creation for the dist_status field.
-	compapijob.DefaultDistStatus = compapijobDescDistStatus.Default.(int8)
-	// compapijobDescCallbackStatus is the schema descriptor for callback_status field.
-	compapijobDescCallbackStatus := compapijobFields[2].Descriptor()
-	// compapijob.DefaultCallbackStatus holds the default value on creation for the callback_status field.
-	compapijob.DefaultCallbackStatus = compapijobDescCallbackStatus.Default.(int8)
-	// compapijobDescAuthToken is the schema descriptor for auth_token field.
-	compapijobDescAuthToken := compapijobFields[5].Descriptor()
-	// compapijob.DefaultAuthToken holds the default value on creation for the auth_token field.
-	compapijob.DefaultAuthToken = compapijobDescAuthToken.Default.(string)
-	// compapijobDescEventType is the schema descriptor for event_type field.
-	compapijobDescEventType := compapijobFields[6].Descriptor()
-	// compapijob.DefaultEventType holds the default value on creation for the event_type field.
-	compapijob.DefaultEventType = compapijobDescEventType.Default.(string)
-	// compapijobDescWorkidIdx is the schema descriptor for workid_idx field.
-	compapijobDescWorkidIdx := compapijobFields[7].Descriptor()
-	// compapijob.DefaultWorkidIdx holds the default value on creation for the workid_idx field.
-	compapijob.DefaultWorkidIdx = compapijobDescWorkidIdx.Default.(int8)
-	// compapijobDescChatID is the schema descriptor for chat_id field.
-	compapijobDescChatID := compapijobFields[8].Descriptor()
-	// compapijob.DefaultChatID holds the default value on creation for the chat_id field.
-	compapijob.DefaultChatID = compapijobDescChatID.Default.(string)
-	// compapijobDescRetryCount is the schema descriptor for retry_count field.
-	compapijobDescRetryCount := compapijobFields[9].Descriptor()
-	// compapijob.DefaultRetryCount holds the default value on creation for the retry_count field.
-	compapijob.DefaultRetryCount = compapijobDescRetryCount.Default.(int8)
+	compapiasynctaskMixin := schema.CompapiAsynctask{}.Mixin()
+	compapiasynctaskMixinFields0 := compapiasynctaskMixin[0].Fields()
+	_ = compapiasynctaskMixinFields0
+	compapiasynctaskFields := schema.CompapiAsynctask{}.Fields()
+	_ = compapiasynctaskFields
+	// compapiasynctaskDescCreatedAt is the schema descriptor for created_at field.
+	compapiasynctaskDescCreatedAt := compapiasynctaskMixinFields0[1].Descriptor()
+	// compapiasynctask.DefaultCreatedAt holds the default value on creation for the created_at field.
+	compapiasynctask.DefaultCreatedAt = compapiasynctaskDescCreatedAt.Default.(func() time.Time)
+	// compapiasynctaskDescUpdatedAt is the schema descriptor for updated_at field.
+	compapiasynctaskDescUpdatedAt := compapiasynctaskMixinFields0[2].Descriptor()
+	// compapiasynctask.DefaultUpdatedAt holds the default value on creation for the updated_at field.
+	compapiasynctask.DefaultUpdatedAt = compapiasynctaskDescUpdatedAt.Default.(func() time.Time)
+	// compapiasynctask.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
+	compapiasynctask.UpdateDefaultUpdatedAt = compapiasynctaskDescUpdatedAt.UpdateDefault.(func() time.Time)
+	// compapiasynctaskDescEventType is the schema descriptor for event_type field.
+	compapiasynctaskDescEventType := compapiasynctaskFields[1].Descriptor()
+	// compapiasynctask.DefaultEventType holds the default value on creation for the event_type field.
+	compapiasynctask.DefaultEventType = compapiasynctaskDescEventType.Default.(string)
+	// compapiasynctaskDescChatID is the schema descriptor for chat_id field.
+	compapiasynctaskDescChatID := compapiasynctaskFields[2].Descriptor()
+	// compapiasynctask.DefaultChatID holds the default value on creation for the chat_id field.
+	compapiasynctask.DefaultChatID = compapiasynctaskDescChatID.Default.(string)
+	// compapiasynctaskDescWorkidIdx is the schema descriptor for workid_idx field.
+	compapiasynctaskDescWorkidIdx := compapiasynctaskFields[3].Descriptor()
+	// compapiasynctask.DefaultWorkidIdx holds the default value on creation for the workid_idx field.
+	compapiasynctask.DefaultWorkidIdx = compapiasynctaskDescWorkidIdx.Default.(int8)
+	// compapiasynctaskDescResponseRaw is the schema descriptor for response_raw field.
+	compapiasynctaskDescResponseRaw := compapiasynctaskFields[7].Descriptor()
+	// compapiasynctask.DefaultResponseRaw holds the default value on creation for the response_raw field.
+	compapiasynctask.DefaultResponseRaw = compapiasynctaskDescResponseRaw.Default.(string)
+	// compapiasynctaskDescCallbackURL is the schema descriptor for callback_url field.
+	compapiasynctaskDescCallbackURL := compapiasynctaskFields[8].Descriptor()
+	// compapiasynctask.CallbackURLValidator is a validator for the "callback_url" field. It is called by the builders before save.
+	compapiasynctask.CallbackURLValidator = compapiasynctaskDescCallbackURL.Validators[0].(func(string) error)
+	// compapiasynctaskDescTaskStatus is the schema descriptor for task_status field.
+	compapiasynctaskDescTaskStatus := compapiasynctaskFields[9].Descriptor()
+	// compapiasynctask.DefaultTaskStatus holds the default value on creation for the task_status field.
+	compapiasynctask.DefaultTaskStatus = compapiasynctaskDescTaskStatus.Default.(int8)
+	// compapiasynctaskDescRetryCount is the schema descriptor for retry_count field.
+	compapiasynctaskDescRetryCount := compapiasynctaskFields[10].Descriptor()
+	// compapiasynctask.DefaultRetryCount holds the default value on creation for the retry_count field.
+	compapiasynctask.DefaultRetryCount = compapiasynctaskDescRetryCount.Default.(int8)
+	// compapiasynctaskDescLastError is the schema descriptor for last_error field.
+	compapiasynctaskDescLastError := compapiasynctaskFields[11].Descriptor()
+	// compapiasynctask.DefaultLastError holds the default value on creation for the last_error field.
+	compapiasynctask.DefaultLastError = compapiasynctaskDescLastError.Default.(string)
 	contactMixin := schema.Contact{}.Mixin()
 	contactMixinHooks2 := contactMixin[2].Hooks()
 	contact.Hooks[0] = contactMixinHooks2[0]

+ 18 - 18
ent/schema/compapi_asynctask.go

@@ -1,8 +1,6 @@
 package schema
 
 import (
-	"wechat-api/ent/custom_types"
-
 	"entgo.io/ent"
 	"entgo.io/ent/dialect/entsql"
 	"entgo.io/ent/schema"
@@ -12,45 +10,47 @@ import (
 )
 
 // CompapiJob holds the schema definition for the CompapiJob entity.
-type CompapiaAsynctask struct {
+type CompapiAsynctask struct {
 	ent.Schema
 }
 
 // Fields of the CompapiJob.
-func (CompapiaAsynctask) Fields() []ent.Field {
+func (CompapiAsynctask) Fields() []ent.Field {
 
 	return []ent.Field{
-		field.String("auth_token").Default("").Annotations(entsql.WithComments(true)).Comment("发起请求者的授权token"),
-		field.String("event_type").Default("fastgpt").Annotations(entsql.WithComments(true)).Comment("发起请求者的类型"),
+		field.String("auth_token").Annotations(entsql.WithComments(true)).Comment("发起请求者的授权token"),
+		field.String("event_type").Default("fastgpt").Annotations(entsql.WithComments(true)).Comment("请求目标类型"),
 		field.String("chat_id").Optional().Default("").Annotations(entsql.WithComments(true)).Comment("会话ID"),
 		field.Int8("workid_idx").Optional().Default(0).Annotations(entsql.WithComments(true)).Comment("workId在字典中的索引值"),
-		field.String("openai_base").Default("").Annotations(entsql.WithComments(true)).Comment("待请求的大模型服务地址"),
-		field.String("openai_key").Default("").Annotations(entsql.WithComments(true)).Comment("待请求的大模型服务密钥授权token"),
-		field.JSON("request_json", custom_types.OriginalData{}).Annotations(entsql.WithComments(true)).Comment("请求参数结构JSON"),
-		field.String("callback_url").Annotations(entsql.WithComments(true)).Comment("异步执行回调地址"),
-		field.Int8("dist_status").Optional().Default(0).Annotations(entsql.WithComments(true)).Comment("dist status | 分发状态 0 未 1 已"),
-		field.Time("dist_at").Optional().Annotations(entsql.WithComments(true)).Comment("Dist Time | 分发时间"),
-		field.Int8("task_status").Optional().Default(10).Annotations(entsql.WithComments(true)).Comment("callback_status | 任务完成状态 10 任务就绪 20 请求API完成 30 请求回调完成 50 任务全部完成 60 任务暂停 70 任务失败"),
+		field.String("openai_base").Annotations(entsql.WithComments(true)).Comment("待请求的大模型服务地址"),
+		field.String("openai_key").Annotations(entsql.WithComments(true)).Comment("待请求的大模型服务密钥授权token"),
+		field.String("request_raw").Annotations(entsql.WithComments(true)).Comment("请求参数结构字符串"),
+		field.String("response_raw").Optional().Default("").Annotations(entsql.WithComments(true)).Comment("请求响应结构字符串"),
+		field.String("callback_url").MaxLen(255).Annotations(entsql.WithComments(true)).Comment("异步执行回调地址"),
+		//field.Int8("dist_status").Optional().Default(0).Annotations(entsql.WithComments(true)).Comment("dist status | 分发状态 0 未 1 已"),
+		//field.Time("dist_at").Optional().Annotations(entsql.WithComments(true)).Comment("Dist Time | 分发时间"),
+		field.Int8("task_status").Optional().Default(10).Annotations(entsql.WithComments(true)).Comment("callback_status | 任务完成状态 10 任务就绪 20 请求API完成 30 请求回调完成 60 任务暂停 70 任务失败"),
 		field.Int8("retry_count").Optional().Default(0).Annotations(entsql.WithComments(true)).Comment("retry count | 重试次数"),
+		field.String("last_error").Optional().Default("").Annotations(entsql.WithComments(true)).Comment("最后一次出错信息"),
 	}
 }
 
-func (CompapiaAsynctask) Mixin() []ent.Mixin {
+func (CompapiAsynctask) Mixin() []ent.Mixin {
 	return []ent.Mixin{
 		mixins.IDMixin{},
 	}
 }
 
-func (CompapiaAsynctask) Indexes() []ent.Index {
+func (CompapiAsynctask) Indexes() []ent.Index {
 	return []ent.Index{
-		index.Fields("dist_status"),
+		//index.Fields("dist_status"),
 		index.Fields("task_status"),
 	}
 }
 
-func (CompapiaAsynctask) Edges() []ent.Edge { return []ent.Edge{} }
+func (CompapiAsynctask) Edges() []ent.Edge { return []ent.Edge{} }
 
-func (CompapiaAsynctask) Annotations() []schema.Annotation {
+func (CompapiAsynctask) Annotations() []schema.Annotation {
 	return []schema.Annotation{
 		entsql.WithComments(true),
 		entsql.Annotation{Table: "compapi_asynctask"},

+ 0 - 56
ent/schema/compapi_job.go

@@ -1,56 +0,0 @@
-package schema
-
-import (
-	"wechat-api/ent/custom_types"
-
-	"entgo.io/ent"
-	"entgo.io/ent/dialect/entsql"
-	"entgo.io/ent/schema"
-	"entgo.io/ent/schema/field"
-	"entgo.io/ent/schema/index"
-	"github.com/suyuan32/simple-admin-common/orm/ent/mixins"
-)
-
-// CompapiJob holds the schema definition for the CompapiJob entity.
-type CompapiJob struct {
-	ent.Schema
-}
-
-// Fields of the CompapiJob.
-func (CompapiJob) Fields() []ent.Field {
-
-	return []ent.Field{
-		field.Time("dist_at").Optional().Annotations(entsql.WithComments(true)).Comment("Dist Time | 分发时间"),
-		field.Int8("dist_status").Optional().Default(0).Annotations(entsql.WithComments(true)).Comment("dist status | 分发状态 0 未 1 已"),
-		field.Int8("callback_status").Optional().Default(10).Annotations(entsql.WithComments(true)).Comment("callback_status | 回调状态 10 准备回调 20 "),
-		field.String("callback_url").Annotations(entsql.WithComments(true)).Comment("异步执行回调地址"),
-		field.JSON("request_json", custom_types.OriginalData{}).Annotations(entsql.WithComments(true)).Comment("请求参数结构JSON"),
-		field.String("auth_token").Default("").Annotations(entsql.WithComments(true)).Comment("发起请求者的授权token"),
-		field.String("event_type").Default("").Annotations(entsql.WithComments(true)).Comment("发起请求者的类型"),
-		field.Int8("workid_idx").Optional().Default(0).Annotations(entsql.WithComments(true)).Comment("workId在字典中的索引"),
-		field.String("chat_id").Optional().Default("").Annotations(entsql.WithComments(true)).Comment("会话ID"),
-		field.Int8("retry_count").Optional().Default(0).Annotations(entsql.WithComments(true)).Comment("retry count | 重试次数"),
-	}
-}
-
-func (CompapiJob) Mixin() []ent.Mixin {
-	return []ent.Mixin{
-		mixins.IDMixin{},
-	}
-}
-
-func (CompapiJob) Indexes() []ent.Index {
-	return []ent.Index{
-		index.Fields("dist_status"),
-		index.Fields("callback_status"),
-	}
-}
-
-func (CompapiJob) Edges() []ent.Edge { return []ent.Edge{} }
-
-func (CompapiJob) Annotations() []schema.Annotation {
-	return []schema.Annotation{
-		entsql.WithComments(true),
-		entsql.Annotation{Table: "compapi_job"},
-	}
-}

+ 147 - 99
ent/set_not_nil.go

@@ -2096,267 +2096,315 @@ func (cs *ChatSessionCreate) SetNotNilBotType(value *uint8) *ChatSessionCreate {
 }
 
 // set field if value's pointer is not nil.
-func (cj *CompapiJobUpdate) SetNotNilUpdatedAt(value *time.Time) *CompapiJobUpdate {
+func (ca *CompapiAsynctaskUpdate) SetNotNilUpdatedAt(value *time.Time) *CompapiAsynctaskUpdate {
 	if value != nil {
-		return cj.SetUpdatedAt(*value)
+		return ca.SetUpdatedAt(*value)
 	}
-	return cj
+	return ca
 }
 
 // set field if value's pointer is not nil.
-func (cj *CompapiJobUpdateOne) SetNotNilUpdatedAt(value *time.Time) *CompapiJobUpdateOne {
+func (ca *CompapiAsynctaskUpdateOne) SetNotNilUpdatedAt(value *time.Time) *CompapiAsynctaskUpdateOne {
 	if value != nil {
-		return cj.SetUpdatedAt(*value)
+		return ca.SetUpdatedAt(*value)
 	}
-	return cj
+	return ca
 }
 
 // set field if value's pointer is not nil.
-func (cj *CompapiJobCreate) SetNotNilUpdatedAt(value *time.Time) *CompapiJobCreate {
+func (ca *CompapiAsynctaskCreate) SetNotNilUpdatedAt(value *time.Time) *CompapiAsynctaskCreate {
 	if value != nil {
-		return cj.SetUpdatedAt(*value)
+		return ca.SetUpdatedAt(*value)
 	}
-	return cj
+	return ca
 }
 
 // set field if value's pointer is not nil.
-func (cj *CompapiJobUpdate) SetNotNilDistAt(value *time.Time) *CompapiJobUpdate {
+func (ca *CompapiAsynctaskUpdate) SetNotNilAuthToken(value *string) *CompapiAsynctaskUpdate {
 	if value != nil {
-		return cj.SetDistAt(*value)
+		return ca.SetAuthToken(*value)
 	}
-	return cj
+	return ca
 }
 
 // set field if value's pointer is not nil.
-func (cj *CompapiJobUpdateOne) SetNotNilDistAt(value *time.Time) *CompapiJobUpdateOne {
+func (ca *CompapiAsynctaskUpdateOne) SetNotNilAuthToken(value *string) *CompapiAsynctaskUpdateOne {
 	if value != nil {
-		return cj.SetDistAt(*value)
+		return ca.SetAuthToken(*value)
 	}
-	return cj
+	return ca
 }
 
 // set field if value's pointer is not nil.
-func (cj *CompapiJobCreate) SetNotNilDistAt(value *time.Time) *CompapiJobCreate {
+func (ca *CompapiAsynctaskCreate) SetNotNilAuthToken(value *string) *CompapiAsynctaskCreate {
 	if value != nil {
-		return cj.SetDistAt(*value)
+		return ca.SetAuthToken(*value)
 	}
-	return cj
+	return ca
 }
 
 // set field if value's pointer is not nil.
-func (cj *CompapiJobUpdate) SetNotNilDistStatus(value *int8) *CompapiJobUpdate {
+func (ca *CompapiAsynctaskUpdate) SetNotNilEventType(value *string) *CompapiAsynctaskUpdate {
 	if value != nil {
-		return cj.SetDistStatus(*value)
+		return ca.SetEventType(*value)
 	}
-	return cj
+	return ca
 }
 
 // set field if value's pointer is not nil.
-func (cj *CompapiJobUpdateOne) SetNotNilDistStatus(value *int8) *CompapiJobUpdateOne {
+func (ca *CompapiAsynctaskUpdateOne) SetNotNilEventType(value *string) *CompapiAsynctaskUpdateOne {
 	if value != nil {
-		return cj.SetDistStatus(*value)
+		return ca.SetEventType(*value)
 	}
-	return cj
+	return ca
 }
 
 // set field if value's pointer is not nil.
-func (cj *CompapiJobCreate) SetNotNilDistStatus(value *int8) *CompapiJobCreate {
+func (ca *CompapiAsynctaskCreate) SetNotNilEventType(value *string) *CompapiAsynctaskCreate {
 	if value != nil {
-		return cj.SetDistStatus(*value)
+		return ca.SetEventType(*value)
 	}
-	return cj
+	return ca
 }
 
 // set field if value's pointer is not nil.
-func (cj *CompapiJobUpdate) SetNotNilCallbackStatus(value *int8) *CompapiJobUpdate {
+func (ca *CompapiAsynctaskUpdate) SetNotNilChatID(value *string) *CompapiAsynctaskUpdate {
 	if value != nil {
-		return cj.SetCallbackStatus(*value)
+		return ca.SetChatID(*value)
 	}
-	return cj
+	return ca
 }
 
 // set field if value's pointer is not nil.
-func (cj *CompapiJobUpdateOne) SetNotNilCallbackStatus(value *int8) *CompapiJobUpdateOne {
+func (ca *CompapiAsynctaskUpdateOne) SetNotNilChatID(value *string) *CompapiAsynctaskUpdateOne {
 	if value != nil {
-		return cj.SetCallbackStatus(*value)
+		return ca.SetChatID(*value)
 	}
-	return cj
+	return ca
 }
 
 // set field if value's pointer is not nil.
-func (cj *CompapiJobCreate) SetNotNilCallbackStatus(value *int8) *CompapiJobCreate {
+func (ca *CompapiAsynctaskCreate) SetNotNilChatID(value *string) *CompapiAsynctaskCreate {
 	if value != nil {
-		return cj.SetCallbackStatus(*value)
+		return ca.SetChatID(*value)
 	}
-	return cj
+	return ca
 }
 
 // set field if value's pointer is not nil.
-func (cj *CompapiJobUpdate) SetNotNilCallbackURL(value *string) *CompapiJobUpdate {
+func (ca *CompapiAsynctaskUpdate) SetNotNilWorkidIdx(value *int8) *CompapiAsynctaskUpdate {
 	if value != nil {
-		return cj.SetCallbackURL(*value)
+		return ca.SetWorkidIdx(*value)
 	}
-	return cj
+	return ca
 }
 
 // set field if value's pointer is not nil.
-func (cj *CompapiJobUpdateOne) SetNotNilCallbackURL(value *string) *CompapiJobUpdateOne {
+func (ca *CompapiAsynctaskUpdateOne) SetNotNilWorkidIdx(value *int8) *CompapiAsynctaskUpdateOne {
 	if value != nil {
-		return cj.SetCallbackURL(*value)
+		return ca.SetWorkidIdx(*value)
 	}
-	return cj
+	return ca
 }
 
 // set field if value's pointer is not nil.
-func (cj *CompapiJobCreate) SetNotNilCallbackURL(value *string) *CompapiJobCreate {
+func (ca *CompapiAsynctaskCreate) SetNotNilWorkidIdx(value *int8) *CompapiAsynctaskCreate {
 	if value != nil {
-		return cj.SetCallbackURL(*value)
+		return ca.SetWorkidIdx(*value)
 	}
-	return cj
+	return ca
 }
 
 // set field if value's pointer is not nil.
-func (cj *CompapiJobUpdate) SetNotNilRequestJSON(value *custom_types.OriginalData) *CompapiJobUpdate {
+func (ca *CompapiAsynctaskUpdate) SetNotNilOpenaiBase(value *string) *CompapiAsynctaskUpdate {
 	if value != nil {
-		return cj.SetRequestJSON(*value)
+		return ca.SetOpenaiBase(*value)
 	}
-	return cj
+	return ca
 }
 
 // set field if value's pointer is not nil.
-func (cj *CompapiJobUpdateOne) SetNotNilRequestJSON(value *custom_types.OriginalData) *CompapiJobUpdateOne {
+func (ca *CompapiAsynctaskUpdateOne) SetNotNilOpenaiBase(value *string) *CompapiAsynctaskUpdateOne {
 	if value != nil {
-		return cj.SetRequestJSON(*value)
+		return ca.SetOpenaiBase(*value)
 	}
-	return cj
+	return ca
 }
 
 // set field if value's pointer is not nil.
-func (cj *CompapiJobCreate) SetNotNilRequestJSON(value *custom_types.OriginalData) *CompapiJobCreate {
+func (ca *CompapiAsynctaskCreate) SetNotNilOpenaiBase(value *string) *CompapiAsynctaskCreate {
 	if value != nil {
-		return cj.SetRequestJSON(*value)
+		return ca.SetOpenaiBase(*value)
 	}
-	return cj
+	return ca
 }
 
 // set field if value's pointer is not nil.
-func (cj *CompapiJobUpdate) SetNotNilAuthToken(value *string) *CompapiJobUpdate {
+func (ca *CompapiAsynctaskUpdate) SetNotNilOpenaiKey(value *string) *CompapiAsynctaskUpdate {
 	if value != nil {
-		return cj.SetAuthToken(*value)
+		return ca.SetOpenaiKey(*value)
 	}
-	return cj
+	return ca
 }
 
 // set field if value's pointer is not nil.
-func (cj *CompapiJobUpdateOne) SetNotNilAuthToken(value *string) *CompapiJobUpdateOne {
+func (ca *CompapiAsynctaskUpdateOne) SetNotNilOpenaiKey(value *string) *CompapiAsynctaskUpdateOne {
 	if value != nil {
-		return cj.SetAuthToken(*value)
+		return ca.SetOpenaiKey(*value)
 	}
-	return cj
+	return ca
 }
 
 // set field if value's pointer is not nil.
-func (cj *CompapiJobCreate) SetNotNilAuthToken(value *string) *CompapiJobCreate {
+func (ca *CompapiAsynctaskCreate) SetNotNilOpenaiKey(value *string) *CompapiAsynctaskCreate {
 	if value != nil {
-		return cj.SetAuthToken(*value)
+		return ca.SetOpenaiKey(*value)
 	}
-	return cj
+	return ca
 }
 
 // set field if value's pointer is not nil.
-func (cj *CompapiJobUpdate) SetNotNilEventType(value *string) *CompapiJobUpdate {
+func (ca *CompapiAsynctaskUpdate) SetNotNilRequestRaw(value *string) *CompapiAsynctaskUpdate {
 	if value != nil {
-		return cj.SetEventType(*value)
+		return ca.SetRequestRaw(*value)
 	}
-	return cj
+	return ca
 }
 
 // set field if value's pointer is not nil.
-func (cj *CompapiJobUpdateOne) SetNotNilEventType(value *string) *CompapiJobUpdateOne {
+func (ca *CompapiAsynctaskUpdateOne) SetNotNilRequestRaw(value *string) *CompapiAsynctaskUpdateOne {
 	if value != nil {
-		return cj.SetEventType(*value)
+		return ca.SetRequestRaw(*value)
 	}
-	return cj
+	return ca
 }
 
 // set field if value's pointer is not nil.
-func (cj *CompapiJobCreate) SetNotNilEventType(value *string) *CompapiJobCreate {
+func (ca *CompapiAsynctaskCreate) SetNotNilRequestRaw(value *string) *CompapiAsynctaskCreate {
 	if value != nil {
-		return cj.SetEventType(*value)
+		return ca.SetRequestRaw(*value)
 	}
-	return cj
+	return ca
 }
 
 // set field if value's pointer is not nil.
-func (cj *CompapiJobUpdate) SetNotNilWorkidIdx(value *int8) *CompapiJobUpdate {
+func (ca *CompapiAsynctaskUpdate) SetNotNilResponseRaw(value *string) *CompapiAsynctaskUpdate {
 	if value != nil {
-		return cj.SetWorkidIdx(*value)
+		return ca.SetResponseRaw(*value)
 	}
-	return cj
+	return ca
 }
 
 // set field if value's pointer is not nil.
-func (cj *CompapiJobUpdateOne) SetNotNilWorkidIdx(value *int8) *CompapiJobUpdateOne {
+func (ca *CompapiAsynctaskUpdateOne) SetNotNilResponseRaw(value *string) *CompapiAsynctaskUpdateOne {
 	if value != nil {
-		return cj.SetWorkidIdx(*value)
+		return ca.SetResponseRaw(*value)
 	}
-	return cj
+	return ca
 }
 
 // set field if value's pointer is not nil.
-func (cj *CompapiJobCreate) SetNotNilWorkidIdx(value *int8) *CompapiJobCreate {
+func (ca *CompapiAsynctaskCreate) SetNotNilResponseRaw(value *string) *CompapiAsynctaskCreate {
 	if value != nil {
-		return cj.SetWorkidIdx(*value)
+		return ca.SetResponseRaw(*value)
 	}
-	return cj
+	return ca
 }
 
 // set field if value's pointer is not nil.
-func (cj *CompapiJobUpdate) SetNotNilChatID(value *string) *CompapiJobUpdate {
+func (ca *CompapiAsynctaskUpdate) SetNotNilCallbackURL(value *string) *CompapiAsynctaskUpdate {
 	if value != nil {
-		return cj.SetChatID(*value)
+		return ca.SetCallbackURL(*value)
 	}
-	return cj
+	return ca
 }
 
 // set field if value's pointer is not nil.
-func (cj *CompapiJobUpdateOne) SetNotNilChatID(value *string) *CompapiJobUpdateOne {
+func (ca *CompapiAsynctaskUpdateOne) SetNotNilCallbackURL(value *string) *CompapiAsynctaskUpdateOne {
 	if value != nil {
-		return cj.SetChatID(*value)
+		return ca.SetCallbackURL(*value)
 	}
-	return cj
+	return ca
 }
 
 // set field if value's pointer is not nil.
-func (cj *CompapiJobCreate) SetNotNilChatID(value *string) *CompapiJobCreate {
+func (ca *CompapiAsynctaskCreate) SetNotNilCallbackURL(value *string) *CompapiAsynctaskCreate {
 	if value != nil {
-		return cj.SetChatID(*value)
+		return ca.SetCallbackURL(*value)
 	}
-	return cj
+	return ca
 }
 
 // set field if value's pointer is not nil.
-func (cj *CompapiJobUpdate) SetNotNilRetryCount(value *int8) *CompapiJobUpdate {
+func (ca *CompapiAsynctaskUpdate) SetNotNilTaskStatus(value *int8) *CompapiAsynctaskUpdate {
 	if value != nil {
-		return cj.SetRetryCount(*value)
+		return ca.SetTaskStatus(*value)
 	}
-	return cj
+	return ca
 }
 
 // set field if value's pointer is not nil.
-func (cj *CompapiJobUpdateOne) SetNotNilRetryCount(value *int8) *CompapiJobUpdateOne {
+func (ca *CompapiAsynctaskUpdateOne) SetNotNilTaskStatus(value *int8) *CompapiAsynctaskUpdateOne {
 	if value != nil {
-		return cj.SetRetryCount(*value)
+		return ca.SetTaskStatus(*value)
 	}
-	return cj
+	return ca
 }
 
 // set field if value's pointer is not nil.
-func (cj *CompapiJobCreate) SetNotNilRetryCount(value *int8) *CompapiJobCreate {
+func (ca *CompapiAsynctaskCreate) SetNotNilTaskStatus(value *int8) *CompapiAsynctaskCreate {
 	if value != nil {
-		return cj.SetRetryCount(*value)
+		return ca.SetTaskStatus(*value)
 	}
-	return cj
+	return ca
+}
+
+// set field if value's pointer is not nil.
+func (ca *CompapiAsynctaskUpdate) SetNotNilRetryCount(value *int8) *CompapiAsynctaskUpdate {
+	if value != nil {
+		return ca.SetRetryCount(*value)
+	}
+	return ca
+}
+
+// set field if value's pointer is not nil.
+func (ca *CompapiAsynctaskUpdateOne) SetNotNilRetryCount(value *int8) *CompapiAsynctaskUpdateOne {
+	if value != nil {
+		return ca.SetRetryCount(*value)
+	}
+	return ca
+}
+
+// set field if value's pointer is not nil.
+func (ca *CompapiAsynctaskCreate) SetNotNilRetryCount(value *int8) *CompapiAsynctaskCreate {
+	if value != nil {
+		return ca.SetRetryCount(*value)
+	}
+	return ca
+}
+
+// set field if value's pointer is not nil.
+func (ca *CompapiAsynctaskUpdate) SetNotNilLastError(value *string) *CompapiAsynctaskUpdate {
+	if value != nil {
+		return ca.SetLastError(*value)
+	}
+	return ca
+}
+
+// set field if value's pointer is not nil.
+func (ca *CompapiAsynctaskUpdateOne) SetNotNilLastError(value *string) *CompapiAsynctaskUpdateOne {
+	if value != nil {
+		return ca.SetLastError(*value)
+	}
+	return ca
+}
+
+// set field if value's pointer is not nil.
+func (ca *CompapiAsynctaskCreate) SetNotNilLastError(value *string) *CompapiAsynctaskCreate {
+	if value != nil {
+		return ca.SetLastError(*value)
+	}
+	return ca
 }
 
 // set field if value's pointer is not nil.

+ 3 - 3
ent/tx.go

@@ -32,8 +32,8 @@ type Tx struct {
 	ChatRecords *ChatRecordsClient
 	// ChatSession is the client for interacting with the ChatSession builders.
 	ChatSession *ChatSessionClient
-	// CompapiJob is the client for interacting with the CompapiJob builders.
-	CompapiJob *CompapiJobClient
+	// CompapiAsynctask is the client for interacting with the CompapiAsynctask builders.
+	CompapiAsynctask *CompapiAsynctaskClient
 	// Contact is the client for interacting with the Contact builders.
 	Contact *ContactClient
 	// CreditBalance is the client for interacting with the CreditBalance builders.
@@ -238,7 +238,7 @@ func (tx *Tx) init() {
 	tx.Category = NewCategoryClient(tx.config)
 	tx.ChatRecords = NewChatRecordsClient(tx.config)
 	tx.ChatSession = NewChatSessionClient(tx.config)
-	tx.CompapiJob = NewCompapiJobClient(tx.config)
+	tx.CompapiAsynctask = NewCompapiAsynctaskClient(tx.config)
 	tx.Contact = NewContactClient(tx.config)
 	tx.CreditBalance = NewCreditBalanceClient(tx.config)
 	tx.CreditUsage = NewCreditUsageClient(tx.config)

+ 109 - 99
internal/logic/chat/chat_completions_logic.go

@@ -2,21 +2,19 @@ package chat
 
 import (
 	"context"
+	"encoding/json"
 	"errors"
-	"fmt"
 	"net"
 	"net/url"
+	"regexp"
 	"strconv"
 	"strings"
-	"time"
-	"unicode"
 
 	"wechat-api/ent"
 	"wechat-api/internal/svc"
 	"wechat-api/internal/types"
 	"wechat-api/internal/utils/compapi"
 	"wechat-api/internal/utils/contextkey"
-	"wechat-api/internal/utils/typekit"
 
 	"wechat-api/ent/custom_types"
 	"wechat-api/ent/predicate"
@@ -63,30 +61,31 @@ func (l *ChatCompletionsLogic) ChatCompletions(req *types.CompApiReq) (asyncMode
 	}
 
 	//微调apiKeyObj的openaikey
-	apiKeyObjAdjust(req.EventType, req.WorkId, apiKeyObj)
+	//apiKeyObjAdjust(req.EventType, req.WorkId, apiKeyObj)
 
-	apiKeyObj.CreatedAt = time.Now()
-	fmt.Println(typekit.PrettyPrint(apiKeyObj))
-
-	fmt.Println("=========================================")
-	fmt.Printf("In ChatCompletion Get Token Info:\nKey:'%s'\n", apiKeyObj.Key)
-	fmt.Printf("Title:'%s'\n", apiKeyObj.Title)
-	fmt.Printf("OpenaiBase:'%s'\n", apiKeyObj.OpenaiBase)
-	fmt.Printf("OpenaiKey:'%s'\n", apiKeyObj.OpenaiKey)
-	fmt.Printf("workToken:'%s' because %s/%s\n", apiKeyObj.OpenaiKey, req.EventType, req.WorkId)
-	fmt.Printf("req.ChatId:'%s VS req.FastgptChatId:'%s'\n", req.ChatId, req.FastgptChatId)
-	fmt.Printf("apiKeyObj.CreatedAt:'%v' || apiKeyObj.UpdatedAt:'%v'\n", apiKeyObj.CreatedAt, apiKeyObj.UpdatedAt)
-	fmt.Println("=========================================")
+	/*
+		fmt.Println("=========================================")
+		fmt.Printf("In ChatCompletion Get Token Info:\nKey:'%s'\n", apiKeyObj.Key)
+		fmt.Printf("Title:'%s'\n", apiKeyObj.Title)
+		fmt.Printf("OpenaiBase:'%s'\n", apiKeyObj.OpenaiBase)
+		fmt.Printf("OpenaiKey:'%s'\n", apiKeyObj.OpenaiKey)
+		fmt.Printf("workToken:'%s' because %s/%s\n", apiKeyObj.OpenaiKey, req.EventType, req.WorkId)
+		fmt.Printf("req.ChatId:'%s VS req.FastgptChatId:'%s'\n", req.ChatId, req.FastgptChatId)
+		fmt.Printf("apiKeyObj.CreatedAt:'%v' || apiKeyObj.UpdatedAt:'%v'\n", apiKeyObj.CreatedAt, apiKeyObj.UpdatedAt)
+		fmt.Println("=========================================")
+	*/
 
 	if isAsyncReqest(req) { //异步请求处理模式
-		fmt.Println("~~~~~~~~~~~~~~~~~~~isAsyncReqest:", req.Callback)
+		//fmt.Println("~~~~~~~~~~~~~~~~~~~isAsyncReqest:", req.Callback)
 		asyncMode = true
 		err = l.appendAsyncRequest(apiKeyObj, req)
 	} else { //同步请求处理模式
-		fmt.Println("~~~~~~~~~~~~~~~~~~~isSyncReqest")
+		//fmt.Println("~~~~~~~~~~~~~~~~~~~isSyncReqest")
 		resp, err = l.workForFastgpt(apiKeyObj, req)
-		if err == nil && resp != nil {
+		if err == nil && resp != nil && len(resp.Choices) > 0 {
 			l.doSyncRequestLog(apiKeyObj, req, resp) //请求记录
+		} else if resp != nil && len(resp.Choices) == 0 {
+			err = errors.New("返回结果缺失,请检查访问地址及权限")
 		}
 	}
 	return asyncMode, resp, err
@@ -94,15 +93,21 @@ func (l *ChatCompletionsLogic) ChatCompletions(req *types.CompApiReq) (asyncMode
 
 func (l *ChatCompletionsLogic) appendAsyncRequest(apiKeyObj *ent.ApiKey, req *types.CompApiReq) error {
 
-	workIDIdx := int8(compapi.GetWorkIdxByID(req.EventType, req.WorkId))
-	rawReqResp := custom_types.OriginalData{Request: req}
-	res, err := l.svcCtx.DB.CompapiJob.Create().
-		SetNotNilCallbackURL(&req.Callback).
+	//workIDIdx := int8(compapi.GetWorkIdxByID(req.EventType, req.WorkId))
+	rawReqBs, err := json.Marshal(*req)
+	if err != nil {
+		return err
+	}
+	rawReqStr := string(rawReqBs)
+	res, err := l.svcCtx.DB.CompapiAsynctask.Create().
 		SetNotNilAuthToken(&apiKeyObj.Key).
 		SetNotNilEventType(&req.EventType).
-		SetNillableWorkidIdx(&workIDIdx).
-		SetNotNilRequestJSON(&rawReqResp).
 		SetNillableChatID(&req.ChatId).
+		//SetNillableWorkidIdx(&workIDIdx).
+		SetNotNilOpenaiBase(&apiKeyObj.OpenaiBase).
+		SetNotNilOpenaiKey(&apiKeyObj.OpenaiKey).
+		SetNotNilRequestRaw(&rawReqStr).
+		SetNotNilCallbackURL(&req.Callback).
 		Save(l.ctx)
 
 	if err == nil {
@@ -180,10 +185,27 @@ func (l *ChatCompletionsLogic) sumTotalTokensByAuthToken(authToken string) (uint
 	return totalTokens, err
 }
 
+func getMessageContentStr(input any) string {
+	str := ""
+	switch val := input.(type) {
+	case string:
+		str = val
+	case []interface{}:
+		if len(val) > 0 {
+			if valc, ok := val[0].(map[string]interface{}); ok {
+				if valcc, ok := valc["text"]; ok {
+					str, _ = valcc.(string)
+				}
+			}
+		}
+	}
+	return str
+}
+
 func (l *ChatCompletionsLogic) appendUsageDetailLog(authToken string, req *types.CompApiReq, resp *types.CompOpenApiResp) error {
 
 	logType := 5
-	workIdx := int(compapi.GetWorkIdxByID(req.EventType, req.WorkId))
+	//workIdx := int(compapi.GetWorkIdxByID(req.EventType, req.WorkId))
 	rawReqResp := custom_types.OriginalData{Request: req, Response: resp}
 	tmpId := 0
 	tmpId, _ = strconv.Atoi(resp.ID)
@@ -197,26 +219,15 @@ func (l *ChatCompletionsLogic) appendUsageDetailLog(authToken string, req *types
 	completionToken := uint64(resp.Usage.CompletionTokens)
 	totalTokens := promptTokens + completionToken
 
-	msgContent := ""
-	switch val := req.Messages[0].Content.(type) {
-	case string:
-		msgContent = val
-	case []interface{}:
-		if len(val) > 0 {
-			if valc, ok := val[0].(map[string]interface{}); ok {
-				if valcc, ok := valc["text"]; ok {
-					msgContent, _ = valcc.(string)
-				}
-			}
-		}
-	}
+	msgContent := getMessageContentStr(req.Messages[0].Content)
 
+	_, _, _ = logType, sessionId, totalTokens
 	res, err := l.svcCtx.DB.UsageDetail.Create().
 		SetNotNilType(&logType).
 		SetNotNilBotID(&authToken).
 		SetNotNilReceiverID(&req.EventType).
 		SetNotNilSessionID(&sessionId).
-		SetNillableApp(&workIdx).
+		//SetNillableApp(&workIdx).
 		SetNillableRequest(&msgContent).
 		SetNillableResponse(&resp.Choices[0].Message.Content).
 		SetNillableOrganizationID(&orgId).
@@ -236,10 +247,12 @@ func (l *ChatCompletionsLogic) workForFastgpt(apiKeyObj *ent.ApiKey, req *types.
 
 	//apiKey := "fastgpt-d2uehCb2T40h9chNGjf4bpFrVKmMkCFPbrjfVLZ6DAL2zzqzOFJWP"
 	return compapi.NewFastgptChatCompletions(l.ctx, apiKeyObj.OpenaiKey, apiKeyObj.OpenaiBase, req)
-
 }
 
 func reqAdjust(req *types.CompApiReq) {
+	if len(req.EventType) == 0 {
+		req.EventType = "fastgpt"
+	}
 	if req.EventType != "fastgpt" {
 		return
 	}
@@ -265,89 +278,86 @@ func apiKeyObjAdjust(eventType string, workId string, obj *ent.ApiKey) {
 	obj.OpenaiKey, _ = compapi.GetWorkInfoByID(eventType, workId)
 }
 
-func IsValidURL(s string) bool {
-	// 阶段1:快速预检
-	if len(s) < 10 || len(s) > 2048 { // 常见URL长度范围
+// 合法域名正则(支持通配符、中文域名等场景按需调整)
+var domainRegex = regexp.MustCompile(
+	// 多级域名(如 example.com)
+	`^([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,63}$` +
+		`|` +
+		// 单级域名(如 localhost 或 mytest-svc)
+		`^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$`,
+)
+
+func IsValidURL(input *string, adjust bool) bool {
+	// 空值直接返回
+	if *input == "" {
 		return false
 	}
+	inputStr := *input
+
+	// --- 预处理输入:自动补全协议 ---
+	// 若输入不包含协议头,默认添加 http://
+	if !strings.Contains(*input, "://") {
+		inputStr = "http://" + *input
+	}
 
-	// 阶段2:标准库解析
-	u, err := url.Parse(s)
-	if err != nil || u.Scheme == "" || u.Host == "" {
+	// --- 解析 URL ---
+	u, err := url.Parse(inputStr)
+	if err != nil {
 		return false
 	}
 
-	// 阶段3:协议校验(支持常见网络协议)
+	// --- 校验协议 ---
+	// 只允许常见协议(按需扩展)
 	switch u.Scheme {
-	case "http", "https", "ftp", "ftps", "sftp":
-		// 允许的协议类型
+	case "http", "https", "ftp", "ftps":
 	default:
 		return false
 	}
 
-	// 阶段4:主机名深度校验
-	host := u.Hostname()
-	if strings.Contains(host, "..") || strings.ContainsAny(host, "!#$%&'()*,:;<=>?[]^`{|}~") {
-		return false
+	// --- 拆分 Host 和 Port ---
+	host, port, err := net.SplitHostPort(u.Host)
+	if err != nil {
+		// 无端口时,整个 Host 作为主机名
+		host = u.Host
+		port = ""
 	}
 
-	// IPv4/IPv6 校验
+	// --- 校验主机名 ---
+	// 场景1:IPv4 或 IPv6
 	if ip := net.ParseIP(host); ip != nil {
-		return true // 有效IP地址
-	}
-
-	// 域名格式校验
-	if !isValidDomain(host) {
-		return false
+		// 允许私有或保留 IP(按需调整)
+		// 示例中允许所有合法 IP
+	} else {
+		// 场景2:域名(包括 localhost)
+		if !domainRegex.MatchString(host) {
+			return false
+		}
 	}
 
-	// 阶段5:端口校验(可选)
-	if port := u.Port(); port != "" {
-		for _, r := range port {
-			if !unicode.IsDigit(r) {
+	// --- 校验端口 ---
+	if port != "" {
+		p, err := net.LookupPort("tcp", port) // 动态获取端口(如 "http" 对应 80)
+		if err != nil {
+			// 直接尝试解析为数字端口
+			numPort, err := strconv.Atoi(port)
+			if err != nil || numPort < 1 || numPort > 65535 {
 				return false
 			}
-		}
-		if len(port) > 5 || port == "0" {
+		} else if p == 0 { // 动态端口为 0 时无效
 			return false
 		}
 	}
-
+	if adjust {
+		*input = inputStr
+	}
 	return true
 }
 
-// 高性能域名校验 (支持国际化域名IDNA)
-func isValidDomain(host string) bool {
-	// 快速排除非法字符
-	if strings.ContainsAny(host, " _+/\\") {
-		return false
-	}
-
-	// 分段检查
-	labels := strings.Split(host, ".")
-	if len(labels) < 2 { // 至少包含顶级域和二级域
+func isAsyncReqest(req *types.CompApiReq) bool {
+	if !req.IsBatch || !IsValidURL(&req.Callback, true) {
 		return false
 	}
-
-	for _, label := range labels {
-		if len(label) < 1 || len(label) > 63 {
-			return false
-		}
-		if label[0] == '-' || label[len(label)-1] == '-' {
-			return false
-		}
-	}
-
-	// 最终DNS格式校验
-	if _, err := net.LookupHost(host); err == nil {
-		return true // 实际DNS解析验证(根据需求开启)
-	}
-
-	return true // 若不需要实际解析可始终返回true
-}
-
-func isAsyncReqest(req *types.CompApiReq) bool {
-	if !req.IsBatch || !IsValidURL(req.Callback) {
+	if req.Stream { //异步模式暂时不支持流模式
 		return false
 	}
 	return true

+ 27 - 6
internal/types/types.go

@@ -1927,25 +1927,25 @@ type CompCtlReq struct {
 	//EventType事件类型
 	EventType string `json:"event_type,default=fastgpt"`
 	//WorkId工作流ID
-	WorkId string `json:"work_id"`
+	WorkId string `json:"work_id,optional,omitempty"`
 	//IsBatch 是同步还是异步,默认及取值false表明同步
 	IsBatch bool `json:"is_batch,default=false"`
 	//异步回调地址
-	Callback string `json:"callback,optional"`
+	Callback string `json:"callback,optional,omitempty"`
 }
 
 // swagger:model FastGptSpecReq
 type FastGptSpecReq struct {
 	//ChatId
-	ChatId string `json:"chat_id,optional"`
+	ChatId string `json:"chat_id,optional,omitempty"`
 	//FastgptChatId
-	FastgptChatId string `json:"chatId,optional"`
+	FastgptChatId string `json:"chatId,optional,omitempty"`
 	//ResponseChatItemId
-	ResponseChatItemId string `json:"response_chat_item_id,optional"`
+	ResponseChatItemId string `json:"response_chat_item_id,optional,omitempty"`
 	//Detail 详情开关
 	Detail bool `json:"detail,default=false"`
 	//Variables
-	Variables map[string]string `json:"variables,optional"`
+	Variables map[string]string `json:"variables,optional,omitempty"`
 }
 
 type StdCompMessage struct {
@@ -1958,6 +1958,7 @@ type StdCompMessage struct {
 type CompOpenApiResp struct {
 	StdCompApiResp
 	FastgptSpecResp
+	FastgptErrResp
 }
 
 // swagger:model StdCompApiResp
@@ -1990,6 +1991,26 @@ type FastgptSpecResp struct {
 	NewVariables map[string]interface{}   `json:"newVariables,omitempty"`
 }
 
+// swagger:model FastgptErrResp
+type FastgptErrResp struct {
+	FgtErrCode      *int    `json:"code,omitempty"`
+	FgtErrStatusTxt *string `json:"statusText,omitempty"`
+	FgtErrMessage   *string `json:"message,omitempty"`
+}
+
+// swagger:model DeepseekErrResp
+type DeepseekErrResp struct {
+	DSErr DeepseekErrInfo `json:"error,omitempty"`
+}
+
+// swagger:model DeepseekErrInfo
+type DeepseekErrInfo struct {
+	Message string      `json:"message,omitempty"`
+	Type    string      `json:"type,omitempty"`
+	Code    string      `json:"code,omitempty"`
+	Param   interface{} `json:"param,omitempty"`
+}
+
 type ChatCompletionAudio struct {
 	// Unique identifier for this audio response.
 	ID string `json:"id"`

+ 9 - 3
internal/utils/compapi/func.go

@@ -17,8 +17,12 @@ import (
 )
 
 func NewAiClient(apiKey string, apiBase string) *openai.Client {
-	return openai.NewClient(option.WithAPIKey(apiKey),
-		option.WithBaseURL(apiBase))
+	opts := []option.RequestOption{}
+	if len(apiKey) > 0 {
+		opts = append(opts, option.WithAPIKey(apiKey))
+	}
+	opts = append(opts, option.WithBaseURL(apiBase))
+	return openai.NewClient(opts...)
 }
 
 func NewFastgptClient(apiKey string) *openai.Client {
@@ -50,8 +54,10 @@ func DoChatCompletions(ctx context.Context, client *openai.Client, chatInfo *typ
 	if _, err = client.Chat.Completions.New(ctx, emptyParams, reqBodyOps, respBodyOps); err != nil {
 		return nil, err
 	}
+	if customResp.FgtErrCode != nil && customResp.FgtErrStatusTxt != nil { //针对fastgpt出错但New()不返回错误的情况
+		return nil, fmt.Errorf("%s(%d)", *customResp.FgtErrStatusTxt, *customResp.FgtErrCode)
+	}
 	return &customResp, nil
-
 }
 
 func DoChatCompletionsStream(ctx context.Context, client *openai.Client, chatInfo *types.CompApiReq) (res *types.CompOpenApiResp, err error) {

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio