@@ -47,10 +45,10 @@ import { ChatGPTAPI } from 'chatgpt'
asyncfunctionexample(){
constapi=newChatGPTAPI()
// open chromium and wait until the user has logged in
// open chromium and wait until you've logged in
awaitapi.init({auth:'blocking'})
// send a message and wait for a complete response, then parse it as markdown
// send a message and wait for the response
constresponse=awaitapi.sendMessage(
'Write a python version of bubble sort. Do not include example usage.'
)
...
...
@@ -82,14 +80,12 @@ def bubble_sort(lst):
returnlst
```
The default functionality is to parse ChatGPT responses as markdown using [html-to-md](https://github.com/stonehank/html-to-md). I've found the markdown parsing to work really well during my testing, but if you'd rather output plaintext, you can use:
The default functionality parses ChatGPT responses as markdown using [html-to-md](https://github.com/stonehank/html-to-md). I've found that this works really well during my testing, but if you'd rather output plaintext, you can use:
```ts
constapi=newChatGPTAPI({markdown:false})
```
## Example
A full [example](./src/example.ts) is included for testing purposes:
```
...
...
@@ -100,12 +96,6 @@ npx tsx src/example.ts
See the [auto-generated docs](./docs/classes/ChatGPTAPI.md) for more info on methods parameters.
## Todo
- [ ] Add message and conversation IDs
- [ ] Add support for streaming responses
- [ ] Add basic unit tests
## Related
- Inspired by this [Go module](https://github.com/danielgross/whatsapp-gpt) by [Daniel Gross](https://github.com/danielgross)