Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
ai-tech
dify
Commits
dd4b3e2c
Commit
dd4b3e2c
authored
Jul 28, 2023
by
John Wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add tokens-per-second stat
parent
a330aa68
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
6 deletions
+7
-6
statistic.py
api/controllers/console/app/statistic.py
+7
-6
No files found.
api/controllers/console/app/statistic.py
View file @
dd4b3e2c
...
...
@@ -412,12 +412,13 @@ class TokensPerSecondStatistic(Resource):
parser
.
add_argument
(
'end'
,
type
=
datetime_string
(
'
%
Y-
%
m-
%
d
%
H:
%
M'
),
location
=
'args'
)
args
=
parser
.
parse_args
()
sql_query
=
'''
SELECT date(DATE_TRUNC('day', created_at AT TIME ZONE 'UTC' AT TIME ZONE :tz )) AS date,
(sum(answer_tokens) / provider_response_latency) as tokens_per_second
FROM messages
WHERE app_id = :app_id
'''
sql_query
=
'''SELECT date(DATE_TRUNC('day', created_at AT TIME ZONE 'UTC' AT TIME ZONE :tz )) AS date,
CASE
WHEN SUM(provider_response_latency) = 0 THEN 0
ELSE (SUM(answer_tokens) / SUM(provider_response_latency))
END as tokens_per_second
FROM messages
WHERE app_id = :app_id'''
arg_dict
=
{
'tz'
:
account
.
timezone
,
'app_id'
:
app_model
.
id
}
timezone
=
pytz
.
timezone
(
account
.
timezone
)
...
...
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