Comparing version 1.0.3 to 1.0.4
{ | ||
"name": "bettergpt", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"scripts": { | ||
@@ -9,3 +9,4 @@ "dev": "nodemon index.ts" | ||
"eventsource-parser": "^1.0.0" | ||
} | ||
}, | ||
"keywords": ["openai", "chatgpt", "chat", "gpt", "gpt-3", "gpt3", "gpt-4", "gpt4", "chatbot", "machine learning", "ai", "conversation", "bot"] | ||
} |
@@ -10,6 +10,41 @@ # About | ||
# Usage | ||
### Official API | ||
# Example | ||
```js | ||
const { GPT } = require("bettergpt") | ||
async function example() { | ||
let gpt = new GPT('your_api_key'); | ||
gpt.useProxy('https://ai.fakeopen.com/api/conversation'); | ||
let response = await gpt.sendMessage('hey!'); | ||
console.log(response) | ||
} | ||
example() | ||
``` | ||
### History | ||
```ts | ||
import GPT, { Message } from './bettergpt'; | ||
function example() { | ||
let gpt = new GPT('your_api_key'); | ||
gpt.useProxy('https://ai.fakeopen.com/api/conversation'); | ||
gpt.addMessage({ | ||
role: 'system', | ||
text: `You can only response with JSON format from now, { | ||
message: "your message", | ||
}`, | ||
}) | ||
gpt.onProgress = (message: Message) => { | ||
console.log(message.text); | ||
} | ||
let result = await gpt.sendMessage("hey!"); | ||
console.log(result); | ||
} | ||
example(); | ||
``` |
20473
49