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
duanjinfei
llm-server-test
Commits
f5a686c8
Commit
f5a686c8
authored
Mar 19, 2024
by
duanjinfei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update return file content
parent
58e85a8b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
11 deletions
+8
-11
LLMController.go
controllers/LLMController.go
+8
-11
No files found.
controllers/LLMController.go
View file @
f5a686c8
...
@@ -3,6 +3,7 @@ package controllers
...
@@ -3,6 +3,7 @@ package controllers
import
(
import
(
"bytes"
"bytes"
"crypto/ecdsa"
"crypto/ecdsa"
"encoding/base64"
"encoding/json"
"encoding/json"
"fmt"
"fmt"
"github.com/astaxie/beego"
"github.com/astaxie/beego"
...
@@ -13,8 +14,9 @@ import (
...
@@ -13,8 +14,9 @@ import (
_
"image/gif"
// 导入 GIF 支持
_
"image/gif"
// 导入 GIF 支持
_
"image/jpeg"
// 导入 JPEG 支持
_
"image/jpeg"
// 导入 JPEG 支持
_
"image/png"
// 导入 PNG 支持
_
"image/png"
// 导入 PNG 支持
"io/ioutil"
"net/http"
"net/http"
"
o
s"
"
string
s"
"time"
"time"
"token-uri/models"
"token-uri/models"
)
)
...
@@ -55,23 +57,18 @@ func (c *LLMController) GetContainerSign() {
...
@@ -55,23 +57,18 @@ func (c *LLMController) GetContainerSign() {
func
(
c
*
LLMController
)
GetImage
()
{
func
(
c
*
LLMController
)
GetImage
()
{
filePath
:=
"response.png"
// 替换为实际图片文件路径
filePath
:=
"response.png"
// 替换为实际图片文件路径
// 打开图片文件
// 打开图片文件
file
,
err
:=
os
.
Open
(
filePath
)
readFile
,
err
:=
ioutil
.
ReadFile
(
filePath
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Error
(
"Error opening file:"
,
err
)
log
.
Error
(
"Error opening file:"
,
err
)
c
.
ResponseInfo
(
500
,
"Error opening file:"
,
err
)
c
.
ResponseInfo
(
500
,
"Error opening file:"
,
err
)
return
return
}
}
defer
func
(
file
*
os
.
File
)
{
err
:=
file
.
Close
()
if
err
!=
nil
{
log
.
Error
(
"Error closing file:"
,
err
)
}
}(
file
)
// 设置 Content-Type 为图片类型
// 设置 Content-Type 为图片类型
c
.
Ctx
.
Output
.
Header
(
"Content-Type"
,
"image/jpeg"
)
c
.
Ctx
.
Output
.
Header
(
"Content-Type"
,
"application/json"
)
toString
:=
base64
.
StdEncoding
.
EncodeToString
(
readFile
)
http
.
ServeContent
(
c
.
Ctx
.
ResponseWriter
,
c
.
Ctx
.
Request
,
""
,
time
.
Now
(),
file
)
res
:=
fmt
.
Sprintf
(
"data:image/png;base64,%s"
,
toString
)
http
.
ServeContent
(
c
.
Ctx
.
ResponseWriter
,
c
.
Ctx
.
Request
,
""
,
time
.
Now
(),
strings
.
NewReader
(
res
))
}
}
...
...
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