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
864f97cc
authored
2023-02-15 21:08:50 +0800
by
jeff
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
jeff_fix_maxtoken
1 parent
2bf0467a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
9 deletions
index.js
index.js
View file @
864f97c
...
...
@@ -33,16 +33,45 @@ app.use(rateLimiter)
// Primary Open AI Route
app
.
post
(
'/api'
,
async
(
req
,
res
)
=>
{
const
{
message
,
currentModel
,
temperature
}
=
req
.
body
;
const
response
=
await
openai
.
createCompletion
({
model
:
`
${
currentModel
}
`
,
// "text-davinci-003",
prompt
:
`
${
message
}
`
,
max_tokens
:
2500
,
temperature
,
});
res
.
json
({
message
:
response
.
data
.
choices
[
0
].
text
,
})
let
query_prompt
=
`
${
message
}
`
;
str_length
=
req
.
body
.
message
.
split
(
' '
).
length
;
if
(
str_length
>=
1000
){
arr_body
=
req
.
body
.
message
.
split
(
"\n"
);
if
(
arr_body
.
length
>=
4
){
var
i
=
arr_body
.
length
-
2
while
(
i
--
)
{
arr_body
.
splice
(
i
,
1
);
}
query_prompt
=
arr_body
.
join
(
"\n"
)
}
}
try
{
const
response
=
await
openai
.
createCompletion
({
model
:
`
${
currentModel
}
`
,
// "text-davinci-003",
prompt
:
query_prompt
,
max_tokens
:
3000
,
temperature
,
});
res
.
json
({
message
:
response
.
data
.
choices
[
0
].
text
,
})
}
catch
(
e
)
{
// let error_msg = e.response.data.error.message ? e.response.data.error.message : '';
// if (error_msg.indexOf('maximum context length')>=0){
// console.log(error_msg);
// }else{
// console.log(e.response);
// }
console
.
log
(
e
.
response
);
}
finally
{
// console.log('We do cleanup here');
}
});
// Get Models Route
...
...
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