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
e5cad7a5
Commit
e5cad7a5
authored
Dec 17, 2022
by
Alex Shand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feature: Add browserPath option
parent
abd6dd1c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
5 deletions
+22
-5
src/chatgpt-api-browser.ts
src/chatgpt-api-browser.ts
+16
-3
src/openai-auth.ts
src/openai-auth.ts
+6
-2
No files found.
src/chatgpt-api-browser.ts
View file @
e5cad7a5
...
...
@@ -3,7 +3,11 @@ import type { Browser, HTTPRequest, HTTPResponse, Page } from 'puppeteer'
import
{
v4
as
uuidv4
}
from
'
uuid
'
import
*
as
types
from
'
./types
'
import
{
getBrowser
,
getOpenAIAuth
}
from
'
./openai-auth
'
import
{
defaultChromeExecutablePath
,
getBrowser
,
getOpenAIAuth
}
from
'
./openai-auth
'
import
{
browserPostEventStream
,
isRelevantRequest
,
...
...
@@ -22,6 +26,7 @@ export class ChatGPTAPIBrowser {
protected
_email
:
string
protected
_password
:
string
protected
_browserPath
:
string
protected
_browser
:
Browser
protected
_page
:
Page
...
...
@@ -46,6 +51,9 @@ export class ChatGPTAPIBrowser {
/** @defaultValue `undefined` **/
captchaToken
?:
string
/** @defaultValue `undefined` **/
browserPath
?:
string
})
{
const
{
email
,
...
...
@@ -54,7 +62,8 @@ export class ChatGPTAPIBrowser {
debug
=
false
,
isGoogleLogin
=
false
,
minimize
=
true
,
captchaToken
captchaToken
,
browserPath
=
defaultChromeExecutablePath
()
}
=
opts
this
.
_email
=
email
...
...
@@ -65,6 +74,7 @@ export class ChatGPTAPIBrowser {
this
.
_isGoogleLogin
=
!!
isGoogleLogin
this
.
_minimize
=
!!
minimize
this
.
_captchaToken
=
captchaToken
this
.
_browserPath
=
browserPath
}
async
init
()
{
...
...
@@ -75,7 +85,10 @@ export class ChatGPTAPIBrowser {
}
try
{
this
.
_browser
=
await
getBrowser
({
captchaToken
:
this
.
_captchaToken
})
this
.
_browser
=
await
getBrowser
({
captchaToken
:
this
.
_captchaToken
,
executablePath
:
this
.
_browserPath
})
this
.
_page
=
(
await
this
.
_browser
.
pages
())[
0
]
||
(
await
this
.
_browser
.
newPage
())
...
...
src/openai-auth.ts
View file @
e5cad7a5
...
...
@@ -186,7 +186,11 @@ export async function getBrowser(
captchaToken
?:
string
}
=
{}
)
{
const
{
captchaToken
=
process
.
env
.
CAPTCHA_TOKEN
,
...
launchOptions
}
=
opts
const
{
captchaToken
=
process
.
env
.
CAPTCHA_TOKEN
,
executablePath
=
defaultChromeExecutablePath
(),
...
launchOptions
}
=
opts
if
(
captchaToken
&&
!
hasRecaptchaPlugin
)
{
hasRecaptchaPlugin
=
true
...
...
@@ -207,7 +211,7 @@ export async function getBrowser(
headless
:
false
,
args
:
[
'
--no-sandbox
'
,
'
--exclude-switches
'
,
'
enable-automation
'
],
ignoreHTTPSErrors
:
true
,
executablePath
:
defaultChromeExecutablePath
()
,
executablePath
,
...
launchOptions
})
}
...
...
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