Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
f24a1da7
authored
Dec 18, 2023
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复vision格式问题
parent
b51c1333
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
4 deletions
+21
-4
controller/relay-utils.go
+18
-1
controller/relay.go
+3
-3
No files found.
controller/relay-utils.go
View file @
f24a1da7
...
...
@@ -160,10 +160,27 @@ func countTokenMessages(messages []Message, model string) (int, error) {
}
else
{
for
_
,
m
:=
range
arrayContent
{
if
m
.
Type
==
"image_url"
{
imageTokenNum
,
err
:=
getImageToken
(
&
m
.
ImageUrl
)
var
imageTokenNum
int
if
str
,
ok
:=
m
.
ImageUrl
.
(
string
);
ok
{
imageTokenNum
,
err
=
getImageToken
(
&
MessageImageUrl
{
Url
:
str
,
Detail
:
"auto"
})
}
else
{
imageUrlMap
:=
m
.
ImageUrl
.
(
map
[
string
]
interface
{})
detail
,
ok
:=
imageUrlMap
[
"detail"
]
if
ok
{
imageUrlMap
[
"detail"
]
=
detail
.
(
string
)
}
else
{
imageUrlMap
[
"detail"
]
=
"auto"
}
imageUrl
:=
MessageImageUrl
{
Url
:
imageUrlMap
[
"url"
]
.
(
string
),
Detail
:
imageUrlMap
[
"detail"
]
.
(
string
),
}
imageTokenNum
,
err
=
getImageToken
(
&
imageUrl
)
}
if
err
!=
nil
{
return
0
,
err
}
tokenNum
+=
imageTokenNum
log
.
Printf
(
"image token num: %d"
,
imageTokenNum
)
}
else
{
...
...
controller/relay.go
View file @
f24a1da7
...
...
@@ -19,9 +19,9 @@ type Message struct {
}
type
MediaMessage
struct
{
Type
string
`json:"type"`
Text
string
`json:"text"`
ImageUrl
MessageImageUrl
`json:"image_url,omitempty"`
Type
string
`json:"type"`
Text
string
`json:"text"`
ImageUrl
any
`json:"image_url,omitempty"`
}
type
MessageImageUrl
struct
{
...
...
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