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
ff4b5b3f
authored
Aug 30, 2025
by
creamlike1024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: improve ratio update
parent
2875dbba
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
14 deletions
+19
-14
setting/ratio_setting/model_ratio.go
+19
-14
No files found.
setting/ratio_setting/model_ratio.go
View file @
ff4b5b3f
...
@@ -619,6 +619,7 @@ func getHardcodedCompletionModelRatio(name string) (float64, bool) {
...
@@ -619,6 +619,7 @@ func getHardcodedCompletionModelRatio(name string) (float64, bool) {
func
GetAudioRatio
(
name
string
)
float64
{
func
GetAudioRatio
(
name
string
)
float64
{
audioRatioMapMutex
.
RLock
()
audioRatioMapMutex
.
RLock
()
defer
audioRatioMapMutex
.
RUnlock
()
defer
audioRatioMapMutex
.
RUnlock
()
name
=
FormatMatchingModelName
(
name
)
if
ratio
,
ok
:=
audioRatioMap
[
name
];
ok
{
if
ratio
,
ok
:=
audioRatioMap
[
name
];
ok
{
return
ratio
return
ratio
}
}
...
@@ -628,6 +629,7 @@ func GetAudioRatio(name string) float64 {
...
@@ -628,6 +629,7 @@ func GetAudioRatio(name string) float64 {
func
GetAudioCompletionRatio
(
name
string
)
float64
{
func
GetAudioCompletionRatio
(
name
string
)
float64
{
audioCompletionRatioMapMutex
.
RLock
()
audioCompletionRatioMapMutex
.
RLock
()
defer
audioCompletionRatioMapMutex
.
RUnlock
()
defer
audioCompletionRatioMapMutex
.
RUnlock
()
name
=
FormatMatchingModelName
(
name
)
if
ratio
,
ok
:=
audioCompletionRatioMap
[
name
];
ok
{
if
ratio
,
ok
:=
audioCompletionRatioMap
[
name
];
ok
{
return
ratio
return
ratio
...
@@ -698,14 +700,16 @@ func AudioRatio2JSONString() string {
...
@@ -698,14 +700,16 @@ func AudioRatio2JSONString() string {
}
}
func
UpdateAudioRatioByJSONString
(
jsonStr
string
)
error
{
func
UpdateAudioRatioByJSONString
(
jsonStr
string
)
error
{
audioRatioMapMutex
.
Lock
()
defer
audioRatioMapMutex
.
Unlock
()
tmp
:=
make
(
map
[
string
]
float64
)
audioRatioMap
=
make
(
map
[
string
]
float64
)
if
err
:=
common
.
Unmarshal
([]
byte
(
jsonStr
),
&
tmp
);
err
!=
nil
{
err
:=
common
.
Unmarshal
([]
byte
(
jsonStr
),
&
audioRatioMap
)
return
err
if
err
==
nil
{
InvalidateExposedDataCache
()
}
}
return
err
audioRatioMapMutex
.
Lock
()
audioRatioMap
=
tmp
audioRatioMapMutex
.
Unlock
()
InvalidateExposedDataCache
()
return
nil
}
}
func
GetAudioRatioCopy
()
map
[
string
]
float64
{
func
GetAudioRatioCopy
()
map
[
string
]
float64
{
...
@@ -729,14 +733,15 @@ func AudioCompletionRatio2JSONString() string {
...
@@ -729,14 +733,15 @@ func AudioCompletionRatio2JSONString() string {
}
}
func
UpdateAudioCompletionRatioByJSONString
(
jsonStr
string
)
error
{
func
UpdateAudioCompletionRatioByJSONString
(
jsonStr
string
)
error
{
audioCompletionRatioMapMutex
.
Lock
()
tmp
:=
make
(
map
[
string
]
float64
)
defer
audioCompletionRatioMapMutex
.
Unlock
()
if
err
:=
common
.
Unmarshal
([]
byte
(
jsonStr
),
&
tmp
);
err
!=
nil
{
audioCompletionRatioMap
=
make
(
map
[
string
]
float64
)
return
err
err
:=
common
.
Unmarshal
([]
byte
(
jsonStr
),
&
audioCompletionRatioMap
)
if
err
==
nil
{
InvalidateExposedDataCache
()
}
}
return
err
audioCompletionRatioMapMutex
.
Lock
()
audioCompletionRatioMap
=
tmp
audioCompletionRatioMapMutex
.
Unlock
()
InvalidateExposedDataCache
()
return
nil
}
}
func
GetAudioCompletionRatioCopy
()
map
[
string
]
float64
{
func
GetAudioCompletionRatioCopy
()
map
[
string
]
float64
{
...
...
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