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
74368462
Commit
74368462
authored
Feb 08, 2023
by
Travis Fischer
Committed by
GitHub
Feb 08, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #294 from lvlinkeji/v3
parents
a1875fe6
1ec65e40
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
2 deletions
+19
-2
src/chatgpt-api-browser.ts
src/chatgpt-api-browser.ts
+3
-1
src/chatgpt-api.ts
src/chatgpt-api.ts
+1
-1
src/utils.ts
src/utils.ts
+15
-0
No files found.
src/chatgpt-api-browser.ts
View file @
74368462
...
...
@@ -8,6 +8,7 @@ import { AChatGPTAPI } from './abstract-chatgpt-api'
import
{
getBrowser
,
getOpenAIAuth
,
getPage
}
from
'
./openai-auth
'
import
{
browserPostEventStream
,
deleteFolderRecursive
,
isRelevantRequest
,
markdownToText
,
maximizePage
,
...
...
@@ -351,6 +352,7 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
console
.
log
(
'
>>> closing session
'
,
this
.
_email
)
await
this
.
closeSession
()
console
.
log
(
'
<<< closing session
'
,
this
.
_email
)
await
deleteFolderRecursive
(
this
.
_userDataDir
)
await
this
.
initSession
()
console
.
log
(
`ChatGPT "
${
this
.
_email
}
" refreshSession success`
)
}
catch
(
err
)
{
...
...
@@ -464,7 +466,7 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI {
],
model
:
this
.
_isProAccount
?
'
text-davinci-002-render-paid
'
:
'
text-davinci-002-render
-next
'
,
:
'
text-davinci-002-render
'
,
parent_message_id
:
parentMessageId
}
...
...
src/chatgpt-api.ts
View file @
74368462
...
...
@@ -212,7 +212,7 @@ export class ChatGPTAPI extends AChatGPTAPI {
}
}
],
model
:
'
text-davinci-002-render
-next
'
,
model
:
'
text-davinci-002-render
'
,
parent_message_id
:
parentMessageId
}
...
...
src/utils.ts
View file @
74368462
...
...
@@ -3,6 +3,7 @@ import type {
EventSourceParseCallback
,
EventSourceParser
}
from
'
eventsource-parser
'
import
fs
from
'
fs
'
import
type
{
Page
}
from
'
puppeteer
'
import
{
remark
}
from
'
remark
'
import
stripMarkdown
from
'
strip-markdown
'
...
...
@@ -32,6 +33,20 @@ export async function minimizePage(page: Page) {
})
}
export
async
function
deleteFolderRecursive
(
path
:
string
)
{
if
(
fs
.
existsSync
(
path
))
{
fs
.
readdirSync
(
path
).
forEach
(
function
(
file
,
index
)
{
var
curPath
=
path
+
'
/
'
+
file
if
(
fs
.
lstatSync
(
curPath
).
isDirectory
())
{
deleteFolderRecursive
(
curPath
)
}
else
{
fs
.
unlinkSync
(
curPath
)
}
})
fs
.
rmdirSync
(
path
)
}
}
export
async
function
maximizePage
(
page
:
Page
)
{
const
session
=
await
page
.
target
().
createCDPSession
()
const
goods
=
await
session
.
send
(
'
Browser.getWindowForTarget
'
)
...
...
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