Comparing version 0.4.0 to 0.5.0
@@ -7,3 +7,4 @@ "use strict"; | ||
if (!process.env.OPENAI_API_KEY) { | ||
throw new Error("No API key provided"); | ||
// throw new Error("No API key provided"); | ||
return ""; | ||
} | ||
@@ -10,0 +11,0 @@ return process.env.OPENAI_API_KEY; |
@@ -129,3 +129,4 @@ import { z } from "zod"; | ||
export interface PromptOptions { | ||
apiKey?: string; | ||
temperature?: number; | ||
} |
@@ -19,3 +19,5 @@ "use strict"; | ||
async prompt(model, messages, options) { | ||
const headers = this.prepareAuthHeaders(this.apiKey); | ||
// Extract only apiKey from options | ||
const { apiKey, ...restOptions } = options; | ||
const headers = this.prepareAuthHeaders(apiKey ?? this.apiKey); | ||
const response = await this.fetchService.sendRequest(this.url, { | ||
@@ -27,3 +29,3 @@ method: "POST", | ||
messages, | ||
...options, | ||
...restOptions, | ||
}), | ||
@@ -30,0 +32,0 @@ }, this.parser); |
{ | ||
"name": "ts-chatgpt", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"main": "./build/index.js", | ||
@@ -5,0 +5,0 @@ "types": "./build/index.d.ts", |
# ts-chatgpt | ||
[](https://badge.fury.io/js/ts-chatgpt) | ||
 | ||
[](https://opensource.org/licenses/MIT) | ||
@@ -74,2 +75,3 @@ | ||
| ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | | ||
| `apiKey` | API key that can be obtained from the [OpenAI configuration page](https://platform.openai.com/account/api-keys). You can omit this value by setting the `OPENAI_API_KEY` environment variable. | `string` | | ||
| `temperature` | **The lower the temperature, the more accurate the results.** API temperatures set to 0 or close to 0 (e.g. 0.1 or 0.2) tend to give better results in most cases; with GPT-3, the higher the temperature, the more creative and random the results, while with Codex, the higher the temperature, the more truly random and erratic the response can be. | `number` | | ||
@@ -76,0 +78,0 @@ |
21912
393
139