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
62469a52
authored
Dec 26, 2024
by
CalciumIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: support azure stream_options
parent
bb48f5dc
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4 additions
and
4 deletions
+4
-4
relay/channel/openai/adaptor.go
+1
-1
relay/common/relay_info.go
+1
-1
service/token_counter.go
+2
-2
No files found.
relay/channel/openai/adaptor.go
View file @
62469a52
...
@@ -106,7 +106,7 @@ func (a *Adaptor) ConvertRequest(c *gin.Context, info *relaycommon.RelayInfo, re
...
@@ -106,7 +106,7 @@ func (a *Adaptor) ConvertRequest(c *gin.Context, info *relaycommon.RelayInfo, re
if
request
==
nil
{
if
request
==
nil
{
return
nil
,
errors
.
New
(
"request is nil"
)
return
nil
,
errors
.
New
(
"request is nil"
)
}
}
if
info
.
ChannelType
!=
common
.
ChannelTypeOpenAI
{
if
info
.
ChannelType
!=
common
.
ChannelTypeOpenAI
&&
info
.
ChannelType
!=
common
.
ChannelTypeAzure
{
request
.
StreamOptions
=
nil
request
.
StreamOptions
=
nil
}
}
if
strings
.
HasPrefix
(
request
.
Model
,
"o1"
)
{
if
strings
.
HasPrefix
(
request
.
Model
,
"o1"
)
{
...
...
relay/common/relay_info.go
View file @
62469a52
...
@@ -109,7 +109,7 @@ func GenRelayInfo(c *gin.Context) *RelayInfo {
...
@@ -109,7 +109,7 @@ func GenRelayInfo(c *gin.Context) *RelayInfo {
}
}
if
info
.
ChannelType
==
common
.
ChannelTypeOpenAI
||
info
.
ChannelType
==
common
.
ChannelTypeAnthropic
||
if
info
.
ChannelType
==
common
.
ChannelTypeOpenAI
||
info
.
ChannelType
==
common
.
ChannelTypeAnthropic
||
info
.
ChannelType
==
common
.
ChannelTypeAws
||
info
.
ChannelType
==
common
.
ChannelTypeGemini
||
info
.
ChannelType
==
common
.
ChannelTypeAws
||
info
.
ChannelType
==
common
.
ChannelTypeGemini
||
info
.
ChannelType
==
common
.
ChannelCloudflare
{
info
.
ChannelType
==
common
.
ChannelCloudflare
||
info
.
ChannelType
==
common
.
ChannelTypeAzure
{
info
.
SupportStreamOptions
=
true
info
.
SupportStreamOptions
=
true
}
}
return
info
return
info
...
...
service/token_counter.go
View file @
62469a52
...
@@ -92,11 +92,11 @@ func getImageToken(imageUrl *dto.MessageImageUrl, model string, stream bool) (in
...
@@ -92,11 +92,11 @@ func getImageToken(imageUrl *dto.MessageImageUrl, model string, stream bool) (in
}
}
// TODO: 非流模式下不计算图片token数量
// TODO: 非流模式下不计算图片token数量
if
!
constant
.
GetMediaTokenNotStream
&&
!
stream
{
if
!
constant
.
GetMediaTokenNotStream
&&
!
stream
{
return
1000
,
nil
return
256
,
nil
}
}
// 是否统计图片token
// 是否统计图片token
if
!
constant
.
GetMediaToken
{
if
!
constant
.
GetMediaToken
{
return
1000
,
nil
return
256
,
nil
}
}
// 同步One API的图片计费逻辑
// 同步One API的图片计费逻辑
if
imageUrl
.
Detail
==
"auto"
||
imageUrl
.
Detail
==
""
{
if
imageUrl
.
Detail
==
"auto"
||
imageUrl
.
Detail
==
""
{
...
...
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