Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Administrator
/
chatgpt.ai-pro.org
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
3
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
216d3b57
authored
2023-11-15 09:55:29 +0000
by
Jonille Arreglo
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch '28594_usage_tracking' into 'master'
28594_usage_tracking See merge request
!78
2 parents
006c6848
c1504d56
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
5 deletions
index.js
package.json
index.js
View file @
216d3b5
...
...
@@ -6,7 +6,7 @@ require('dotenv').config()
const
rateLimit
=
require
(
'express-rate-limit'
)
const
anchorme
=
require
(
"anchorme"
).
default
;
const
axios
=
require
(
'axios'
);
const
tiktoken
=
require
(
'@dqbd/
tiktoken'
);
const
{
encodingForModel
}
=
require
(
'js-
tiktoken'
);
const
tiktokenModels
=
[
'text-davinci-003'
,
'text-davinci-002'
,
...
...
@@ -45,8 +45,6 @@ const tiktokenModels = [
'gpt-3.5-turbo'
,
'gpt-3.5-turbo-0301'
];
const
encoding_for_model
=
tiktoken
.
encoding_for_model
;
const
user_secret_id
=
process
.
env
.
USER_SECRET_ID
?
process
.
env
.
USER_SECRET_ID
:
"aiwp_logged_in"
;
// Open AI Configuration
// console.log(process.env.OPENAI_API_ORG)
...
...
@@ -123,7 +121,7 @@ app.post('/api', async (req, res) => {
let
usage
=
{};
let
enc
=
null
;
try
{
enc
=
encoding
_for_m
odel
(
tiktokenModels
.
includes
(
currentModel
)
?
currentModel
:
'gpt-3.5-turbo'
);
enc
=
encoding
ForM
odel
(
tiktokenModels
.
includes
(
currentModel
)
?
currentModel
:
'gpt-3.5-turbo'
);
usage
.
prompt_tokens
=
(
enc
.
encode
(
query_prompt
)).
length
;
usage
.
completion_tokens
=
(
enc
.
encode
(
input
)).
length
;
usage
.
total_tokens
=
usage
.
prompt_tokens
+
usage
.
completion_tokens
;
...
...
package.json
View file @
216d3b5
...
...
@@ -9,7 +9,7 @@
"author"
:
""
,
"license"
:
"ISC"
,
"dependencies"
:
{
"
@dqbd/tiktoken"
:
"^
1.0.7"
,
"
js-tiktoken"
:
"
1.0.7"
,
"anchorme"
:
"^2.1.2"
,
"axios"
:
"^1.5.1"
,
"body-parser"
:
"^1.20.1"
,
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
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 post a comment