Skip to content

Commit

Permalink
more documentation improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
atinylittleshell committed Aug 21, 2023
1 parent 24758c8 commit 51cdc39
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 25 deletions.
37 changes: 24 additions & 13 deletions doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,28 @@ function-gpt

### ChatGPTSessionOptions

Ƭ **ChatGPTSessionOptions**: { `apiKey?`: `string` ; `baseURL?`: `string` ; `systemMessage?`: `string` ; `timeout?`: `number` ; `maxRetries?`: `number` ; `dangerouslyAllowBrowser?`: `boolean` } & `ClientOptions`
Ƭ **ChatGPTSessionOptions**: `Object`

Options for the ChatGPTSession constructor. Compatible with the OpenAI node client options.

**`See`**

[OpenAI Node Client](https://github.com/openai/openai-node)

#### Type declaration

| Name | Type | Description |
| :------ | :------ | :------ |
| `apiKey?` | `string` | Your API key for the OpenAI API. **`Default`** ```ts process.env["OPENAI_API_KEY"] ``` |
| `baseURL?` | `string` | Override the default base URL for the API, e.g., "https://api.example.com/v2/" |
| `systemMessage?` | `string` | A system message to send to the assistant before the user's first message. Useful for setting up the assistant's behavior. **`Default`** ```ts No system message set. ``` |
| `timeout?` | `number` | The maximum amount of time (in milliseconds) that the client should wait for a response from the server before timing out a single request. Note that request timeouts are retried by default, so in a worst-case scenario you may wait much longer than this timeout before the promise succeeds or fails. |
| `maxRetries?` | `number` | The maximum number of times that the client will retry a request in case of a temporary failure, like a network error or a 5XX error from the server. **`Default`** ```ts 2 ``` |
| `dangerouslyAllowBrowser?` | `boolean` | By default, client-side use of this library is not allowed, as it risks exposing your secret API credentials to attackers. Only set this option to `true` if you understand the risks and have appropriate mitigations in place. |

#### Defined in

[src/session.ts:71](https://github.com/atinylittleshell/function-gpt/blob/8014308/src/session.ts#L71)
[src/session.ts:71](https://github.com/atinylittleshell/function-gpt/blob/24758c8/src/session.ts#L71)

___

Expand All @@ -59,7 +70,7 @@ Represents a function call requested by ChatGPT.

#### Defined in

[src/session.ts:119](https://github.com/atinylittleshell/function-gpt/blob/8014308/src/session.ts#L119)
[src/session.ts:119](https://github.com/atinylittleshell/function-gpt/blob/24758c8/src/session.ts#L119)

___

Expand All @@ -80,7 +91,7 @@ Represents a message in a ChatGPT session.

#### Defined in

[src/session.ts:127](https://github.com/atinylittleshell/function-gpt/blob/8014308/src/session.ts#L127)
[src/session.ts:127](https://github.com/atinylittleshell/function-gpt/blob/24758c8/src/session.ts#L127)

___

Expand Down Expand Up @@ -112,7 +123,7 @@ Options for the ChatGPTSession.send method.

#### Defined in

[src/session.ts:139](https://github.com/atinylittleshell/function-gpt/blob/8014308/src/session.ts#L139)
[src/session.ts:139](https://github.com/atinylittleshell/function-gpt/blob/24758c8/src/session.ts#L139)

## Functions

Expand Down Expand Up @@ -153,7 +164,7 @@ Use this decorator on a method within a ChatGPTSession subclass to enable it for

#### Defined in

[src/decorators.ts:19](https://github.com/atinylittleshell/function-gpt/blob/8014308/src/decorators.ts#L19)
[src/decorators.ts:19](https://github.com/atinylittleshell/function-gpt/blob/24758c8/src/decorators.ts#L19)

___

Expand Down Expand Up @@ -190,7 +201,7 @@ Use this decorator on a property within a custom class to include it as a parame

#### Defined in

[src/decorators.ts:53](https://github.com/atinylittleshell/function-gpt/blob/8014308/src/decorators.ts#L53)
[src/decorators.ts:53](https://github.com/atinylittleshell/function-gpt/blob/24758c8/src/decorators.ts#L53)

___

Expand Down Expand Up @@ -226,7 +237,7 @@ Use this decorator on a string property within a custom class to include it as a

#### Defined in

[src/decorators.ts:142](https://github.com/atinylittleshell/function-gpt/blob/8014308/src/decorators.ts#L142)
[src/decorators.ts:142](https://github.com/atinylittleshell/function-gpt/blob/24758c8/src/decorators.ts#L142)

___

Expand Down Expand Up @@ -262,7 +273,7 @@ Use this decorator on a number property within a custom class to include it as a

#### Defined in

[src/decorators.ts:152](https://github.com/atinylittleshell/function-gpt/blob/8014308/src/decorators.ts#L152)
[src/decorators.ts:152](https://github.com/atinylittleshell/function-gpt/blob/24758c8/src/decorators.ts#L152)

___

Expand Down Expand Up @@ -298,7 +309,7 @@ Use this decorator on a boolean property within a custom class to include it as

#### Defined in

[src/decorators.ts:162](https://github.com/atinylittleshell/function-gpt/blob/8014308/src/decorators.ts#L162)
[src/decorators.ts:162](https://github.com/atinylittleshell/function-gpt/blob/24758c8/src/decorators.ts#L162)

___

Expand Down Expand Up @@ -335,7 +346,7 @@ Use this decorator on a custom class property within a custom class to include i

#### Defined in

[src/decorators.ts:173](https://github.com/atinylittleshell/function-gpt/blob/8014308/src/decorators.ts#L173)
[src/decorators.ts:173](https://github.com/atinylittleshell/function-gpt/blob/24758c8/src/decorators.ts#L173)

___

Expand Down Expand Up @@ -372,7 +383,7 @@ Use this decorator on a custom class property within a custom class to include i

#### Defined in

[src/decorators.ts:184](https://github.com/atinylittleshell/function-gpt/blob/8014308/src/decorators.ts#L184)
[src/decorators.ts:184](https://github.com/atinylittleshell/function-gpt/blob/24758c8/src/decorators.ts#L184)

___

Expand Down Expand Up @@ -409,4 +420,4 @@ Use this decorator on an array of strings property within a custom class to incl

#### Defined in

[src/decorators.ts:194](https://github.com/atinylittleshell/function-gpt/blob/8014308/src/decorators.ts#L194)
[src/decorators.ts:194](https://github.com/atinylittleshell/function-gpt/blob/24758c8/src/decorators.ts#L194)
20 changes: 10 additions & 10 deletions doc/classes/ChatGPTSession.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ Provide functions to the assistant by decorating them with the `@gptFunction` de

| Name | Type | Description |
| :------ | :------ | :------ |
| `options` | [`ChatGPTSessionOptions`](../README.md#chatgptsessionoptions) | Options for the ChatGPTSession constructor. |
| `options` | [`ChatGPTSessionOptions`](../README.md#chatgptsessionoptions) & `ClientOptions` | Options for the ChatGPTSession constructor. |

**`See`**

[ChatGPTSessionOptions](../README.md#chatgptsessionoptions)

#### Defined in

[src/session.ts:252](https://github.com/atinylittleshell/function-gpt/blob/8014308/src/session.ts#L252)
[src/session.ts:252](https://github.com/atinylittleshell/function-gpt/blob/24758c8/src/session.ts#L252)

## Properties

Expand All @@ -59,7 +59,7 @@ Provide functions to the assistant by decorating them with the `@gptFunction` de

#### Defined in

[src/session.ts:243](https://github.com/atinylittleshell/function-gpt/blob/8014308/src/session.ts#L243)
[src/session.ts:243](https://github.com/atinylittleshell/function-gpt/blob/24758c8/src/session.ts#L243)

___

Expand All @@ -69,7 +69,7 @@ ___

#### Defined in

[src/session.ts:244](https://github.com/atinylittleshell/function-gpt/blob/8014308/src/session.ts#L244)
[src/session.ts:244](https://github.com/atinylittleshell/function-gpt/blob/24758c8/src/session.ts#L244)

___

Expand All @@ -79,19 +79,19 @@ ___

#### Defined in

[src/session.ts:245](https://github.com/atinylittleshell/function-gpt/blob/8014308/src/session.ts#L245)
[src/session.ts:245](https://github.com/atinylittleshell/function-gpt/blob/24758c8/src/session.ts#L245)

___

### options

`Private` `Readonly` **options**: [`ChatGPTSessionOptions`](../README.md#chatgptsessionoptions) = `{}`
`Private` `Readonly` **options**: [`ChatGPTSessionOptions`](../README.md#chatgptsessionoptions) & `ClientOptions` = `{}`

Options for the ChatGPTSession constructor.

#### Defined in

[src/session.ts:252](https://github.com/atinylittleshell/function-gpt/blob/8014308/src/session.ts#L252)
[src/session.ts:252](https://github.com/atinylittleshell/function-gpt/blob/24758c8/src/session.ts#L252)

## Accessors

Expand All @@ -107,7 +107,7 @@ The messages sent to and from the assistant so far.

#### Defined in

[src/session.ts:302](https://github.com/atinylittleshell/function-gpt/blob/8014308/src/session.ts#L302)
[src/session.ts:302](https://github.com/atinylittleshell/function-gpt/blob/24758c8/src/session.ts#L302)

## Methods

Expand All @@ -134,7 +134,7 @@ The assistant's response.

#### Defined in

[src/session.ts:269](https://github.com/atinylittleshell/function-gpt/blob/8014308/src/session.ts#L269)
[src/session.ts:269](https://github.com/atinylittleshell/function-gpt/blob/24758c8/src/session.ts#L269)

___

Expand All @@ -155,4 +155,4 @@ ___

#### Defined in

[src/session.ts:306](https://github.com/atinylittleshell/function-gpt/blob/8014308/src/session.ts#L306)
[src/session.ts:306](https://github.com/atinylittleshell/function-gpt/blob/24758c8/src/session.ts#L306)
4 changes: 2 additions & 2 deletions src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export type ChatGPTSessionOptions = {
* Only set this option to `true` if you understand the risks and have appropriate mitigations in place.
*/
dangerouslyAllowBrowser?: boolean;
} & ClientOptions;
};

/**
* Represents a function call requested by ChatGPT.
Expand Down Expand Up @@ -249,7 +249,7 @@ export class ChatGPTSession {
*
* @see {@link ChatGPTSessionOptions}
*/
constructor(private readonly options: ChatGPTSessionOptions = {}) {
constructor(private readonly options: ChatGPTSessionOptions & ClientOptions = {}) {
this.openai = new OpenAI(options);

const metadata = GPT_CLIENT_METADATA.get(this.constructor as new () => ChatGPTSession);
Expand Down

0 comments on commit 51cdc39

Please sign in to comment.