Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
llm-server-test
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Odysseus
llm-server-test
Commits
4f20c2a2
Commit
4f20c2a2
authored
Feb 23, 2024
by
duanjinfei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add aigic resp
parent
fcc546ba
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
0 deletions
+34
-0
LLMController.go
controllers/LLMController.go
+33
-0
response.png
response.png
+0
-0
router.go
routers/router.go
+1
-0
No files found.
controllers/LLMController.go
View file @
4f20c2a2
...
...
@@ -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"
)
...
...
response.png
0 → 100644
View file @
4f20c2a2
This diff is collapsed.
Click to expand it.
routers/router.go
View file @
4f20c2a2
...
...
@@ -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"
)
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment