Skip to content
This repository has been archived by the owner on Sep 25, 2024. It is now read-only.

Commit

Permalink
Merge pull request #40 from hgaogao/main
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelYuhe authored Dec 11, 2023
2 parents 671e79e + 63a9e24 commit 01f9b7e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const Popup = () => {
getStorage<string[]>("types").then((types) => {
if (!types) {
setTypes(DEFAULT_GROUP);
setStorage<string[]>("types", DEFAULT_GROUP);
return;
}
setTypes(types);
Expand Down
14 changes: 10 additions & 4 deletions src/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,20 @@ export async function batchGroupTabs(
});

const model = (await getStorage("model")) || "gpt-4";
const apiURL = (await getStorage("apiURL")) || "https://api.openai.com";
const apiURL =
(await getStorage("apiURL")) ||
"https://api.openai.com/v1/chat/completions";

try {
await Promise.all(
tabInfoList.map(async (tab) => {
if (!tab.url) return;
const response = await fetch(`${apiURL}/v1/chat/completions`, {
const response = await fetch(apiURL, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${openAIKey}`,
"Api-Key": openAIKey,
},
body: JSON.stringify({
messages: [
Expand Down Expand Up @@ -79,13 +82,16 @@ export async function handleOneTab(
) {
try {
const model = (await getStorage("model")) || "gpt-4";
const apiURL = (await getStorage("apiURL")) || "https://api.openai.com";
const apiURL =
(await getStorage("apiURL")) ||
"https://api.openai.com/v1/chat/completions";

const response = await fetch(`${apiURL}/v1/chat/completions`, {
const response = await fetch(apiURL, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${openAIKey}`,
"Api-Key": openAIKey,
},
body: JSON.stringify({
messages: [
Expand Down

0 comments on commit 01f9b7e

Please sign in to comment.