mirror of
				https://github.com/yangjian102621/geekai.git
				synced 2025-11-04 16:23:42 +08:00 
			
		
		
		
	fixed bug for dalle prompt translate
This commit is contained in:
		@@ -126,7 +126,7 @@ func (s *Service) Image(task types.DallTask, sync bool) (string, error) {
 | 
			
		||||
 | 
			
		||||
	// get image generation API KEY
 | 
			
		||||
	var apiKey model.ApiKey
 | 
			
		||||
	tx := s.db.Where("platform", types.OpenAI).
 | 
			
		||||
	tx := s.db.Where("platform", types.OpenAI.Value).
 | 
			
		||||
		Where("type", "img").
 | 
			
		||||
		Where("enabled", true).
 | 
			
		||||
		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
 | 
			
		||||
	s.db.Model(&apiKey).UpdateColumn("last_used_at", time.Now().Unix())
 | 
			
		||||
	// 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,
 | 
			
		||||
		"org_url":  res.Data[0].Url,
 | 
			
		||||
		"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})
 | 
			
		||||
	var content string
 | 
			
		||||
 
 | 
			
		||||
@@ -54,7 +54,7 @@ type apiErrRes struct {
 | 
			
		||||
 | 
			
		||||
func OpenAIRequest(db *gorm.DB, prompt string) (string, error) {
 | 
			
		||||
	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 {
 | 
			
		||||
		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())
 | 
			
		||||
 | 
			
		||||
	return response.Choices[0].Message.Content, nil
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user