mirror of
https://github.com/yangjian102621/geekai.git
synced 2025-09-17 16:56:38 +08:00
fixed bug for dalle prompt translate
This commit is contained in:
parent
13c917ad7e
commit
24e4be019a
@ -126,7 +126,7 @@ func (s *Service) Image(task types.DallTask, sync bool) (string, error) {
|
|||||||
|
|
||||||
// get image generation API KEY
|
// get image generation API KEY
|
||||||
var apiKey model.ApiKey
|
var apiKey model.ApiKey
|
||||||
tx := s.db.Where("platform", types.OpenAI).
|
tx := s.db.Where("platform", types.OpenAI.Value).
|
||||||
Where("type", "img").
|
Where("type", "img").
|
||||||
Where("enabled", true).
|
Where("enabled", true).
|
||||||
Order("last_used_at ASC").First(&apiKey)
|
Order("last_used_at ASC").First(&apiKey)
|
||||||
@ -162,11 +162,14 @@ func (s *Service) Image(task types.DallTask, sync bool) (string, error) {
|
|||||||
// update the api key last use time
|
// update the api key last use time
|
||||||
s.db.Model(&apiKey).UpdateColumn("last_used_at", time.Now().Unix())
|
s.db.Model(&apiKey).UpdateColumn("last_used_at", time.Now().Unix())
|
||||||
// update task progress
|
// update task progress
|
||||||
s.db.Model(&model.DallJob{Id: task.JobId}).UpdateColumns(map[string]interface{}{
|
tx = s.db.Model(&model.DallJob{Id: task.JobId}).UpdateColumns(map[string]interface{}{
|
||||||
"progress": 100,
|
"progress": 100,
|
||||||
"org_url": res.Data[0].Url,
|
"org_url": res.Data[0].Url,
|
||||||
"prompt": prompt,
|
"prompt": prompt,
|
||||||
})
|
})
|
||||||
|
if tx.Error != nil {
|
||||||
|
return "", fmt.Errorf("err with update database: %v", tx.Error)
|
||||||
|
}
|
||||||
|
|
||||||
s.notifyQueue.RPush(sd.NotifyMessage{UserId: int(task.UserId), JobId: int(task.JobId), Message: sd.Finished})
|
s.notifyQueue.RPush(sd.NotifyMessage{UserId: int(task.UserId), JobId: int(task.JobId), Message: sd.Finished})
|
||||||
var content string
|
var content string
|
||||||
|
@ -54,7 +54,7 @@ type apiErrRes struct {
|
|||||||
|
|
||||||
func OpenAIRequest(db *gorm.DB, prompt string) (string, error) {
|
func OpenAIRequest(db *gorm.DB, prompt string) (string, error) {
|
||||||
var apiKey model.ApiKey
|
var apiKey model.ApiKey
|
||||||
res := db.Where("platform = ?", types.OpenAI).Where("type = ?", "chat").Where("enabled = ?", true).First(&apiKey)
|
res := db.Where("platform = ?", types.OpenAI.Value).Where("type", "chat").Where("enabled = ?", true).First(&apiKey)
|
||||||
if res.Error != nil {
|
if res.Error != nil {
|
||||||
return "", fmt.Errorf("error with fetch OpenAI API KEY:%v", res.Error)
|
return "", fmt.Errorf("error with fetch OpenAI API KEY:%v", res.Error)
|
||||||
}
|
}
|
||||||
@ -90,4 +90,4 @@ func OpenAIRequest(db *gorm.DB, prompt string) (string, error) {
|
|||||||
db.Model(&apiKey).UpdateColumn("last_used_at", time.Now().Unix())
|
db.Model(&apiKey).UpdateColumn("last_used_at", time.Now().Unix())
|
||||||
|
|
||||||
return response.Choices[0].Message.Content, nil
|
return response.Choices[0].Message.Content, nil
|
||||||
}
|
}
|
||||||
|
1
database/update-v4.0.8.sql
Normal file
1
database/update-v4.0.8.sql
Normal file
@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE `chatgpt_dall_jobs` CHANGE `org_url` `org_url` VARCHAR(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '原图地址';
|
Loading…
Reference in New Issue
Block a user