Skip to content

Commit

Permalink
feat: support for chatGPT Plus
Browse files Browse the repository at this point in the history
Signed-off-by: josc146 <josStorer@outlook.com>
  • Loading branch information
josStorer committed Feb 11, 2023
1 parent 0e502e8 commit d73791b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/background/chatgpt.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ export async function sendModerations(token, question, conversationId, messageId
})
}

export async function getModels(token) {
const response = JSON.parse((await request(token, 'GET', '/models')).responseText)
return response.models
}

/**
* @param {Runtime.Port} port
* @param {string} question
Expand All @@ -51,6 +56,8 @@ export async function generateAnswersWithChatGptApi(port, question, session, acc
deleteConversation()
})

const models = await getModels(accessToken).catch(() => ({}))

await fetchSSE('https://chat.openai.com/backend-api/conversation', {
method: 'POST',
signal: controller.signal,
Expand All @@ -71,7 +78,7 @@ export async function generateAnswersWithChatGptApi(port, question, session, acc
},
},
],
model: Models.normal.value,
model: models ? models[0].slug : Models.normal.value,
parent_message_id: session.parentMessageId,
}),
onMessage(message) {
Expand Down

0 comments on commit d73791b

Please sign in to comment.