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

Timeout #58

Merged
merged 2 commits into from
Mar 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ export type Ids = {
}

export class Bot {
private turbo: openai.ChatGPTAPI | null = null // not free
private api: openai.ChatGPTAPI | null = null // not free

private options: optionsJs.Options

constructor(options: optionsJs.Options) {
this.options = options
if (process.env.OPENAI_API_KEY) {
this.turbo = new openai.ChatGPTAPI({
this.api = new openai.ChatGPTAPI({
systemMessage: options.system_message,
apiKey: process.env.OPENAI_API_KEY,
debug: options.debug,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 OpenAI

This patch has already been reviewed and accepted. No further action is needed.

Expand Down Expand Up @@ -58,13 +58,15 @@ export class Bot {
}

let response: openai.ChatMessage | null = null
if (this.turbo) {
const opts: openai.SendMessageOptions = {}
if (this.api) {
const opts: openai.SendMessageOptions = {
timeoutMs: 90000
}
if (ids.parentMessageId) {
opts.parentMessageId = ids.parentMessageId
}
response = await this.turbo.sendMessage(message, opts)
try {
response = await this.api.sendMessage(message, opts)
const end = Date.now()
core.info(`response: ${JSON.stringify(response)}`)
core.info(`openai response time: ${end - start} ms`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 OpenAI

This patch has already been reviewed and accepted. No further action is needed.

Expand Down