Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
C
Chatgpt Puppeteer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
Chatgpt Puppeteer
Commits
25ca608d
Commit
25ca608d
authored
Jan 20, 2023
by
Travis Fischer
Committed by
GitHub
Jan 20, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #271 from kodjunkie/patch-2
parents
b5698e3a
55b56693
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
4 deletions
+48
-4
package.json
package.json
+1
-0
pnpm-lock.yaml
pnpm-lock.yaml
+36
-2
src/chatgpt-api-browser.ts
src/chatgpt-api-browser.ts
+11
-2
No files found.
package.json
View file @
25ca608d
...
...
@@ -47,6 +47,7 @@
"
random
"
:
"
^4.1.0
"
,
"
remark
"
:
"
^14.0.2
"
,
"
strip-markdown
"
:
"
^5.0.0
"
,
"
tempy
"
:
"
^3.0.0
"
,
"
uuid
"
:
"
^9.0.0
"
},
"devDependencies"
:
{
...
...
pnpm-lock.yaml
View file @
25ca608d
...
...
@@ -24,6 +24,7 @@ specifiers:
random
:
^4.1.0
remark
:
^14.0.2
strip-markdown
:
^5.0.0
tempy
:
^3.0.0
tsup
:
^6.5.0
tsx
:
^3.12.1
typedoc
:
^0.23.21
...
...
@@ -43,6 +44,7 @@ dependencies:
random
:
4.1.0
remark
:
14.0.2
strip-markdown
:
5.0.0
tempy
:
3.0.0
uuid
:
9.0.0
devDependencies
:
...
...
@@ -1042,6 +1044,13 @@ packages:
which
:
2.0.2
dev
:
true
/crypto-random-string/4.0.0
:
resolution
:
{
integrity
:
sha512-x8dy3RnvYdlUcPOjkEHqozhiwzKNSq7GcPuXFbnyMOCHxX8V3OgIg/pYuabl2sbUPfIJaeAQB7PMOK8DFIdoRA==
}
engines
:
{
node
:
'
>=12'
}
dependencies
:
type-fest
:
1.4.0
dev
:
false
/currently-unhandled/0.4.1
:
resolution
:
{
integrity
:
sha512-/fITjgjGU50vjQ4FH6eUoYu+iUoUKIXws2hL15JJpIR+BbTxaXQsMuuyjtNh2WqsSBS5nsaZHFsFecyw5CCAng==
}
engines
:
{
node
:
'
>=0.10.0'
}
...
...
@@ -2064,7 +2073,6 @@ packages:
/is-stream/3.0.0
:
resolution
:
{
integrity
:
sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==
}
engines
:
{
node
:
^12.20.0 || ^14.13.1 || >=16.0.0
}
dev
:
true
/is-string/1.0.7
:
resolution
:
{
integrity
:
sha512-tE2UXzivje6ofPW7l23cjDOMa09gb7xlAqG6jG5ej6uPV32TlWP3NKPigtaGeHNu9fohccRYvIiZMfOOnOYUtg==
}
...
...
@@ -3750,11 +3758,26 @@ packages:
inherits
:
2.0.4
readable-stream
:
3.6.0
/temp-dir/2.0.0
:
resolution
:
{
integrity
:
sha512-aoBAniQmmwtcKp/7BzsH8Cxzv8OL736p7v1ihGb5e9DJ9kTwGWHrQrVB5+lfVDzfGrdRzXch+ig7LHaY1JTOrg==
}
engines
:
{
node
:
'
>=8'
}
dev
:
false
/temp-dir/3.0.0
:
resolution
:
{
integrity
:
sha512-nHc6S/bwIilKHNRgK/3jlhDoIHcp45YgyiwcAk46Tr0LfEqGBVpmiAyuiuxeVE44m3mXnEeVhaipLOEWmH+Njw==
}
engines
:
{
node
:
'
>=14.16'
}
dev
:
true
/tempy/3.0.0
:
resolution
:
{
integrity
:
sha512-B2I9X7+o2wOaW4r/CWMkpOO9mdiTRCxXNgob6iGvPmfPWgH/KyUD6Uy5crtWBxIBe3YrNZKR2lSzv1JJKWD4vA==
}
engines
:
{
node
:
'
>=14.16'
}
dependencies
:
is-stream
:
3.0.0
temp-dir
:
2.0.0
type-fest
:
2.19.0
unique-string
:
3.0.0
dev
:
false
/thenify-all/1.6.0
:
resolution
:
{
integrity
:
sha512-RNxQH/qI8/t3thXJDwcstUO4zeqo64+Uy/+sNVRBx4Xn2OX+OZ9oP+iJnNFqplFra2ZUVeKCSa2oVWi3T4uVmA==
}
engines
:
{
node
:
'
>=0.8'
}
...
...
@@ -3879,7 +3902,11 @@ packages:
/type-fest/1.4.0
:
resolution
:
{
integrity
:
sha512-yGSza74xk0UG8k+pLh5oeoYirvIiWo5t0/o3zHHAO2tRDiZcxWP7fywNlXhqb6/r6sWvwi+RsyQMWhVLe4BVuA==
}
engines
:
{
node
:
'
>=10'
}
dev
:
true
/type-fest/2.19.0
:
resolution
:
{
integrity
:
sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA==
}
engines
:
{
node
:
'
>=12.20'
}
dev
:
false
/typedoc-plugin-markdown/3.13.6_typedoc@0.23.21
:
resolution
:
{
integrity
:
sha512-ISSc9v3BK7HkokxSBuJPttXox4tJ6hP0N9wfSIk0fmLN67+eqtAxbk97gs2nDiuha+RTO5eW9gdeAb+RPP0mgg==
}
...
...
@@ -3945,6 +3972,13 @@ packages:
vfile
:
5.3.6
dev
:
false
/unique-string/3.0.0
:
resolution
:
{
integrity
:
sha512-VGXBUVwxKMBUznyffQweQABPRRW1vHZAbadFZud4pLFAqRGvv/96vafgjWFqzourzr8YonlQiPgH0YCJfawoGQ==
}
engines
:
{
node
:
'
>=12'
}
dependencies
:
crypto-random-string
:
4.0.0
dev
:
false
/unist-util-is/5.1.1
:
resolution
:
{
integrity
:
sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==
}
dev
:
false
...
...
src/chatgpt-api-browser.ts
View file @
25ca608d
import
delay
from
'
delay
'
import
type
{
Browser
,
HTTPRequest
,
HTTPResponse
,
Page
}
from
'
puppeteer
'
import
{
temporaryDirectory
}
from
'
tempy
'
import
{
v4
as
uuidv4
}
from
'
uuid
'
import
*
as
types
from
'
./types
'
...
...
@@ -37,6 +38,7 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
string
,
(
partialResponse
:
types
.
ChatResponse
)
=>
void
>
protected
_userDataDir
:
string
/**
* Creates a new client for automating the ChatGPT webapp.
...
...
@@ -71,6 +73,9 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
/** @defaultValue `undefined` **/
proxyServer
?:
string
/** @defaultValue `random directory with email as prefix` **/
userDataDir
?:
string
})
{
super
()
...
...
@@ -85,7 +90,8 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
captchaToken
,
nopechaKey
,
executablePath
,
proxyServer
proxyServer
,
userDataDir
}
=
opts
this
.
_email
=
email
...
...
@@ -102,6 +108,8 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
this
.
_proxyServer
=
proxyServer
this
.
_isRefreshing
=
false
this
.
_messageOnProgressHandlers
=
{}
this
.
_userDataDir
=
userDataDir
??
temporaryDirectory
({
prefix
:
this
.
_email
})
if
(
!
this
.
_email
)
{
const
error
=
new
types
.
ChatGPTError
(
'
ChatGPT invalid email
'
)
...
...
@@ -127,7 +135,8 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
nopechaKey
:
this
.
_nopechaKey
,
executablePath
:
this
.
_executablePath
,
proxyServer
:
this
.
_proxyServer
,
minimize
:
this
.
_minimize
minimize
:
this
.
_minimize
,
userDataDir
:
this
.
_userDataDir
})
this
.
_page
=
await
getPage
(
this
.
_browser
,
{
...
...
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