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
9e891f52
Commit
9e891f52
authored
Dec 06, 2022
by
simon3000
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added some comment
parent
d716a35b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
2 deletions
+18
-2
src/chatgpt-api.ts
src/chatgpt-api.ts
+18
-2
No files found.
src/chatgpt-api.ts
View file @
9e891f52
...
@@ -10,19 +10,35 @@ const KEY_ACCESS_TOKEN = 'accessToken'
...
@@ -10,19 +10,35 @@ const KEY_ACCESS_TOKEN = 'accessToken'
const
USER_AGENT
=
const
USER_AGENT
=
'
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36
'
'
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36
'
/**
* A conversation wrapper around the ChatGPT API. This allows you to send
* multiple messages to ChatGPT and receive responses, without having to
* manually pass the conversation ID and parent message ID for each message.
*/
class
Conversation
{
class
Conversation
{
protected
_api
:
ChatGPTAPI
protected
_api
:
ChatGPTAPI
protected
_conversationId
:
string
=
undefined
protected
_conversationId
:
string
=
undefined
protected
_parentMessageId
:
string
=
undefined
protected
_parentMessageId
:
string
=
undefined
/**
* Creates a new conversation wrapper around the ChatGPT API.
* @param api - The ChatGPT API instance to use.
*/
constructor
(
api
:
ChatGPTAPI
)
{
constructor
(
api
:
ChatGPTAPI
)
{
this
.
_api
=
api
this
.
_api
=
api
}
}
/**
/**
* Sends a message to ChatGPT, waits for the response to resolve, and returns
* Sends a message to ChatGPT, waits for the response to resolve, and returns
* the response. If the conversation has not yet been started, this will
* the response.
* automatically start the conversation.
* If this is the first message in the conversation, the conversation ID and
* parent message ID will be automatically set.
* This allows you to send multiple messages to ChatGPT and receive responses,
* without having to manually pass the conversation ID and parent message ID
* for each message.
* If you want to manually pass the conversation ID and parent message ID,
* use `api.sendMessage` instead.
*
* @param message - The plaintext message to send.
* @param message - The plaintext message to send.
* @param opts.onProgress - Optional listener which will be called every time the partial response is updated
* @param opts.onProgress - Optional listener which will be called every time the partial response is updated
* @param opts.onConversationResponse - Optional listener which will be called every time a conversation response is received
* @param opts.onConversationResponse - Optional listener which will be called every time a conversation response is received
...
...
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