Skip to content
This repository was archived by the owner on Mar 6, 2024. It is now read-only.

Commit ba574b3

Browse files
authored
Timeout (#58)
<!-- This is an auto-generated comment: release notes by openai --> ### Summary by OpenAI **Release Notes** - New Feature: Added `timeoutMs` option to the `opts` object passed to the `sendMessage` method in the `Bot` class. - Refactor: Renamed the `turbo` property to `api`. - Refactor: Assigned the result of calling `this.api.sendMessage` to the `response` variable instead of `this.turbo.sendMessage`. - Chore: Added logging statements for debugging purposes. These changes improve the functionality and maintainability of the codebase. <!-- end of auto-generated comment: release notes by openai -->
1 parent a024c41 commit ba574b3

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

dist/index.js

Lines changed: 7 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/bot.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ export type Ids = {
1111
}
1212

1313
export class Bot {
14-
private turbo: openai.ChatGPTAPI | null = null // not free
14+
private api: openai.ChatGPTAPI | null = null // not free
1515

1616
private options: optionsJs.Options
1717

1818
constructor(options: optionsJs.Options) {
1919
this.options = options
2020
if (process.env.OPENAI_API_KEY) {
21-
this.turbo = new openai.ChatGPTAPI({
21+
this.api = new openai.ChatGPTAPI({
2222
systemMessage: options.system_message,
2323
apiKey: process.env.OPENAI_API_KEY,
2424
debug: options.debug,
@@ -58,13 +58,15 @@ export class Bot {
5858
}
5959

6060
let response: openai.ChatMessage | null = null
61-
if (this.turbo) {
62-
const opts: openai.SendMessageOptions = {}
61+
if (this.api) {
62+
const opts: openai.SendMessageOptions = {
63+
timeoutMs: 90000
64+
}
6365
if (ids.parentMessageId) {
6466
opts.parentMessageId = ids.parentMessageId
6567
}
66-
response = await this.turbo.sendMessage(message, opts)
6768
try {
69+
response = await this.api.sendMessage(message, opts)
6870
const end = Date.now()
6971
core.info(`response: ${JSON.stringify(response)}`)
7072
core.info(`openai response time: ${end - start} ms`)

0 commit comments

Comments
 (0)