kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
feat: add support for completionParams to sendMessage
rodzic
5fef0f6ead
commit
e21126e4e4
|
@ -19,7 +19,7 @@ jobs:
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Install Node.js
|
- name: Install Node.js
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
|
|
||||||
|
|
|
@ -125,6 +125,7 @@ export class ChatGPTAPI {
|
||||||
* @param opts.timeoutMs - Optional timeout in milliseconds (defaults to no timeout)
|
* @param opts.timeoutMs - Optional timeout in milliseconds (defaults to no timeout)
|
||||||
* @param opts.onProgress - Optional callback which will be invoked every time the partial response is updated
|
* @param opts.onProgress - Optional callback which will be invoked every time the partial response is updated
|
||||||
* @param opts.abortSignal - Optional callback used to abort the underlying `fetch` call using an [AbortController](https://developer.mozilla.org/en-US/docs/Web/API/AbortController)
|
* @param opts.abortSignal - Optional callback used to abort the underlying `fetch` call using an [AbortController](https://developer.mozilla.org/en-US/docs/Web/API/AbortController)
|
||||||
|
* @param completionParams - Optional overrides to send to the [OpenAI chat completion API](https://platform.openai.com/docs/api-reference/chat/create). Options like `temperature` and `presence_penalty` can be tweaked to change the personality of the assistant.
|
||||||
*
|
*
|
||||||
* @returns The response from ChatGPT
|
* @returns The response from ChatGPT
|
||||||
*/
|
*/
|
||||||
|
@ -137,7 +138,8 @@ export class ChatGPTAPI {
|
||||||
messageId = uuidv4(),
|
messageId = uuidv4(),
|
||||||
timeoutMs,
|
timeoutMs,
|
||||||
onProgress,
|
onProgress,
|
||||||
stream = onProgress ? true : false
|
stream = onProgress ? true : false,
|
||||||
|
completionParams
|
||||||
} = opts
|
} = opts
|
||||||
|
|
||||||
let { abortSignal } = opts
|
let { abortSignal } = opts
|
||||||
|
@ -178,6 +180,7 @@ export class ChatGPTAPI {
|
||||||
const body = {
|
const body = {
|
||||||
max_tokens: maxTokens,
|
max_tokens: maxTokens,
|
||||||
...this._completionParams,
|
...this._completionParams,
|
||||||
|
...completionParams,
|
||||||
messages,
|
messages,
|
||||||
stream
|
stream
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ export type ChatGPTAPIOptions = {
|
||||||
debug?: boolean
|
debug?: boolean
|
||||||
|
|
||||||
completionParams?: Partial<
|
completionParams?: Partial<
|
||||||
Omit<openai.CreateChatCompletionRequest, 'messages' | 'n'>
|
Omit<openai.CreateChatCompletionRequest, 'messages' | 'n' | 'stream'>
|
||||||
>
|
>
|
||||||
|
|
||||||
systemMessage?: string
|
systemMessage?: string
|
||||||
|
@ -42,6 +42,9 @@ export type SendMessageOptions = {
|
||||||
timeoutMs?: number
|
timeoutMs?: number
|
||||||
onProgress?: (partialResponse: ChatMessage) => void
|
onProgress?: (partialResponse: ChatMessage) => void
|
||||||
abortSignal?: AbortSignal
|
abortSignal?: AbortSignal
|
||||||
|
completionParams?: Partial<
|
||||||
|
Omit<openai.CreateChatCompletionRequest, 'messages' | 'n' | 'stream'>
|
||||||
|
>
|
||||||
}
|
}
|
||||||
|
|
||||||
export type MessageActionType = 'next' | 'variant'
|
export type MessageActionType = 'next' | 'variant'
|
||||||
|
|
Ładowanie…
Reference in New Issue