Commit 4f20c2a2 authored by duanjinfei's avatar duanjinfei

add aigic resp

parent fcc546ba
......@@ -8,6 +8,12 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"
_ "image/gif" // 导入 GIF 支持
_ "image/jpeg" // 导入 JPEG 支持
_ "image/png" // 导入 PNG 支持
"net/http"
"os"
"time"
"token-uri/models"
)
......@@ -41,6 +47,33 @@ func (c *LLMController) GetContainerSign() {
c.ResponseInfo(200, "sign container successful", signHex)
}
func (c *LLMController) GetImage() {
filePath := "response.png" // 替换为实际图片文件路径
// 打开图片文件
file, err := os.Open(filePath)
if err != nil {
log.Error("Error opening file:", err)
c.ResponseInfo(500, "Error opening file:", err)
return
}
defer func(file *os.File) {
err := file.Close()
if err != nil {
log.Error("Error closing file:", err)
}
}(file)
// 设置 Content-Type 为图片类型
c.Ctx.Output.Header("Content-Type", "image/jpeg")
http.ServeContent(c.Ctx.ResponseWriter, c.Ctx.Request, "", time.Now(), file)
}
func (c *LLMController) GetText() {
c.ResponseInfo(200, "sss", nil)
}
func (c *LLMController) GetExecRes() {
time.Sleep(time.Second * 5)
c.ResponseInfo(200, "OK", "https://paint4art.oss-cn-beijing.aliyuncs.com/aiimages/SN90P6aKwh.jpg")
......
This diff is collapsed.
......@@ -8,4 +8,5 @@ import (
func init() {
beego.Router("/llm/test/get/sign", &controllers.LLMController{}, "post:GetContainerSign")
beego.Router("/llm/test/op/res", &controllers.LLMController{}, "post:GetExecRes")
beego.Router("/aigic", &controllers.LLMController{}, "post:GetImage")
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment