From 44bceb87754995928e041cb6fb9592b78106e7e7 Mon Sep 17 00:00:00 2001 From: hgaogaogao Date: Mon, 11 Dec 2023 00:37:26 +0800 Subject: [PATCH 1/2] fix:The initial installation cannot create groups. --- src/popup.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/popup.tsx b/src/popup.tsx index e4b5c4f..1892e9d 100644 --- a/src/popup.tsx +++ b/src/popup.tsx @@ -20,6 +20,7 @@ const Popup = () => { getStorage("types").then((types) => { if (!types) { setTypes(DEFAULT_GROUP); + setStorage("types", DEFAULT_GROUP); return; } setTypes(types); From 63a9e244be1464bb951c05588d382b50dca271cc Mon Sep 17 00:00:00 2001 From: hgaogaogao Date: Mon, 11 Dec 2023 00:51:25 +0800 Subject: [PATCH 2/2] Add request headers to support Azure's API. --- src/services.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/services.ts b/src/services.ts index 36b3187..1e48011 100644 --- a/src/services.ts +++ b/src/services.ts @@ -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: [ @@ -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: [