47 lines
880 B
Go
47 lines
880 B
Go
package activities
|
|
|
|
import (
|
|
"beacon/pkg/openai"
|
|
"fmt"
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
type OpenAI struct {
|
|
}
|
|
|
|
func (s OpenAI) Create(ctx *gin.Context) {
|
|
file, err := ctx.FormFile("file")
|
|
if err != nil {
|
|
zap.L().Info(fmt.Sprintf("获取文件失败:%s", err.Error()))
|
|
ctx.JSON(http.StatusBadRequest, gin.H{"message": err.Error()})
|
|
return
|
|
}
|
|
|
|
//err, data := openai.GetGeminiAICaptcha(file)
|
|
//if err != nil {
|
|
// ctx.JSON(http.StatusOK, gin.H{
|
|
// "message": "success",
|
|
// "data": err.Error(),
|
|
// })
|
|
// return
|
|
//}
|
|
|
|
err, data := openai.GetOllamaAICaptcha(file)
|
|
if err != nil {
|
|
zap.L().Info(fmt.Sprintf("GetOllamaAICaptcha %s", err.Error()))
|
|
ctx.JSON(http.StatusOK, gin.H{
|
|
"message": "success",
|
|
"data": err.Error(),
|
|
})
|
|
return
|
|
}
|
|
|
|
ctx.JSON(http.StatusOK, gin.H{
|
|
"message": "success",
|
|
"data": data,
|
|
})
|
|
}
|