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
1d354b8b
authored
2023-11-13 10:00:48 +0800
by
Jonille Arreglo
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
update
1 parent
0c874f9b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
7 deletions
index.js
package.json
index.js
View file @
1d354b8
...
...
@@ -46,6 +46,7 @@ const tiktokenModels = [
'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)
...
...
@@ -126,16 +127,16 @@ app.post('/api', async (req, res) => {
usage
.
prompt_tokens
=
(
enc
.
encode
(
query_prompt
)).
length
;
usage
.
completion_tokens
=
(
enc
.
encode
(
input
)).
length
;
usage
.
total_tokens
=
usage
.
prompt_tokens
+
usage
.
completion_tokens
;
// TOKEN USAGE
axios
.
post
(
`
${
process
.
env
.
API_URL
}
e/set-chat-usage`
,
{
aiwp_logged_in
:
req
.
cookies
[
user_secret_id
],
app
:
'chatbot'
,
prompt_token
:
usage
.
prompt_tokens
,
total_token
:
usage
.
total_tokens
},
{
headers
:
{
'content-type'
:
'application/x-www-form-urlencoded'
}
});
}
catch
(
e
)
{
console
.
log
(
'Error encoding prompt text'
,
e
);
}
// TOKEN USAGE
axios
.
post
(
`
${
process
.
env
.
API_URL
}
e/set-chat-usage`
,
{
app
:
'chatbot'
,
prompt_token
:
usage
.
prompt_tokens
,
total_token
:
usage
.
total_tokens
},
{
headers
:
{
'content-type'
:
'application/x-www-form-urlencoded'
}
});
res
.
json
({
message
:
anchorme
({
input
,
...
...
@@ -205,7 +206,7 @@ async function runGPTTurbo(req, res) {
// TOKEN USAGE
axios
.
post
(
`
${
process
.
env
.
API_URL
}
e/set-chat-usage`
,
{
app
:
'chatbot'
,
prompt_token
:
usage
.
prompt_tokens
,
total_token
:
usage
.
total_tokens
},
{
a
iwp_logged_in
:
req
.
cookies
[
user_secret_id
],
a
pp
:
'chatbot'
,
prompt_token
:
usage
.
prompt_tokens
,
total_token
:
usage
.
total_tokens
},
{
headers
:
{
'content-type'
:
'application/x-www-form-urlencoded'
}
});
}
catch
(
e
)
{
...
...
package.json
View file @
1d354b8
...
...
@@ -13,6 +13,8 @@
"anchorme"
:
"^2.1.2"
,
"axios"
:
"^1.5.1"
,
"body-parser"
:
"^1.20.1"
,
"cookie"
:
"0.5.0"
,
"cookie-parser"
:
"1.4.6"
,
"cors"
:
"^2.8.5"
,
"dotenv"
:
"^16.0.3"
,
"express"
:
"^4.18.2"
,
...
...
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