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
4693de97
Commit
4693de97
authored
Dec 06, 2022
by
Travis Fischer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
docs: update readme for new release
parent
52ae3679
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
8 deletions
+42
-8
readme.md
readme.md
+42
-8
No files found.
readme.md
View file @
4693de97
...
...
@@ -11,8 +11,9 @@
-
[
Intro
](
#intro
)
-
[
Install
](
#install
)
-
[
Usage
](
#usage
)
-
[
Docs
](
#docs
)
-
[
How it works
](
#how-it-works
)
-
[
Docs
](
#docs
)
-
[
Demos
](
#demos
)
-
[
Session Tokens
](
#session-tokens
)
-
[
Compatibility
](
#compatibility
)
-
[
Examples
](
#examples
)
-
[
Credit
](
#credit
)
...
...
@@ -37,7 +38,9 @@ import { ChatGPTAPI } from 'chatgpt'
async
function
example
()
{
// sessionToken is required; see below for details
const
api
=
new
ChatGPTAPI
({
sessionToken
:
process
.
env
.
SESSION_TOKEN
})
const
api
=
new
ChatGPTAPI
({
sessionToken
:
process
.
env
.
SESSION_TOKEN
})
// ensure the API is properly authenticated
await
api
.
ensureAuth
()
...
...
@@ -52,7 +55,7 @@ async function example() {
}
```
By default, the response will b
e formatted as markdown. If you want to work with plaintext only, you can use:
The default ChatGPT responses ar
e formatted as markdown. If you want to work with plaintext only, you can use:
```
ts
const
api
=
new
ChatGPTAPI
({
...
...
@@ -61,6 +64,25 @@ const api = new ChatGPTAPI({
})
```
If you want to automatically track the conversation, you can use
`ChatGPTAPI.getConversation()`
:
```
ts
const
api
=
new
ChatGPTAPI
({
sessionToken
:
process
.
env
.
SESSION_TOKEN
})
const
conversation
=
api
.
getConversation
()
// send a message and wait for the response
const
response0
=
await
conversation
.
sendMessage
(
'
What is OpenAI?
'
)
// send a follow-up prompt to the previous message and wait for the response
const
response1
=
await
conversation
.
sendMessage
(
'
Can you expand on that?
'
)
// send another follow-up to the same conversation
const
response2
=
await
conversation
.
sendMessage
(
'
Oh cool; thank you
'
)
```
<details>
<summary>
Usage in CommonJS (Dynamic import)
</summary>
...
...
@@ -81,7 +103,13 @@ async function example() {
</details>
A full
[
demo
](
./src/demo.ts
)
is included for testing purposes:
### Docs
See the
[
auto-generated docs
](
./docs/classes/ChatGPTAPI.md
)
for more info on methods and parameters.
### Demos
A
[
basic demo
](
./src/demo.ts
)
is included for testing purposes:
```
bash
# 1. clone repo
...
...
@@ -91,11 +119,17 @@ A full [demo](./src/demo.ts) is included for testing purposes:
npx tsx src/demo.ts
```
## Docs
A
[
conversation demo
](
./src/demo-conversation.ts
)
is also included:
See the
[
auto-generated docs
](
./docs/classes/ChatGPTAPI.md
)
for more info on methods and parameters.
```
bash
# 1. clone repo
# 2. install node deps
# 3. set `SESSION_TOKEN` in .env
# 4. run:
npx tsx src/demo-conversation.ts
```
##
How it work
s
##
# Session Token
s
**This package requires a valid session token from ChatGPT to access it's unofficial REST API.**
...
...
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