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
541e07e6
authored
Dec 26, 2024
by
xqx333
Committed by
GitHub
Dec 26, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update relay-text.go
在上下文中存入promptTokens,避免重试过程重复计算
parent
620f9f19
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
4 deletions
+11
-4
relay/relay-text.go
+11
-4
No files found.
relay/relay-text.go
View file @
541e07e6
...
@@ -108,10 +108,17 @@ func TextHelper(c *gin.Context) (openaiErr *dto.OpenAIErrorWithStatusCode) {
...
@@ -108,10 +108,17 @@ func TextHelper(c *gin.Context) (openaiErr *dto.OpenAIErrorWithStatusCode) {
}
}
}
}
promptTokens
,
err
:=
getPromptTokens
(
textRequest
,
relayInfo
)
// 获取 promptTokens,如果上下文中已经存在,则直接使用
// count messages token error 计算promptTokens错误
var
promptTokens
int
if
err
!=
nil
{
if
value
,
exists
:=
c
.
Get
(
"prompt_tokens"
);
exists
{
return
service
.
OpenAIErrorWrapper
(
err
,
"count_token_messages_failed"
,
http
.
StatusInternalServerError
)
promptTokens
=
value
.
(
int
)
}
else
{
promptTokens
,
err
=
getPromptTokens
(
textRequest
,
relayInfo
)
// count messages token error 计算promptTokens错误
if
err
!=
nil
{
return
service
.
OpenAIErrorWrapper
(
err
,
"count_token_messages_failed"
,
http
.
StatusInternalServerError
)
}
c
.
Set
(
"prompt_tokens"
,
promptTokens
)
}
}
if
!
getModelPriceSuccess
{
if
!
getModelPriceSuccess
{
...
...
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