mirror of
https://github.com/coaidev/coai.git
synced 2025-05-19 21:10:18 +09:00
23 lines
728 B
Go
23 lines
728 B
Go
package generation
|
|
|
|
import (
|
|
"chat/utils"
|
|
"fmt"
|
|
)
|
|
|
|
func CreateGenerationWithCache(model string, prompt string, enableReverse bool, hook func(buffer *utils.Buffer, data string)) (string, error) {
|
|
hash, path := GetFolderByHash(model, prompt)
|
|
if !utils.Exists(path) {
|
|
if err := CreateGeneration(model, prompt, path, enableReverse, hook); err != nil {
|
|
fmt.Println(fmt.Sprintf("[Project] error during generation %s (model %s): %s", prompt, model, err.Error()))
|
|
return "", fmt.Errorf("error during generate project: %s", err.Error())
|
|
}
|
|
}
|
|
|
|
if _, _, err := utils.GenerateCompressTask(hash, path, path); err != nil {
|
|
return "", fmt.Errorf("error during generate compress task: %s", err.Error())
|
|
}
|
|
|
|
return hash, nil
|
|
}
|