MichaelYuhe / ai-group-tabs

Organize and group your Chrome tabs with AI
MIT License
982 stars 88 forks source link

Click 'Group Existing Tabs' yields no response; #41

Closed hfguo02 closed 10 months ago

hfguo02 commented 10 months ago

Description

checking the Chrome extensions reveals an error prompt.

Error log

Error in event handler: TypeError: Cannot read properties of undefined (reading '0') at chrome-extension://gnclkpnopkmphjkajnolljlogjmoglec/service_worker.js:1:313 at Array.forEach (<anonymous>) at chrome-extension://gnclkpnopkmphjkajnolljlogjmoglec/service_worker.js:1:295
TypeError: Cannot read properties of undefined (reading '0')
import{g as s}from"./utils.fb-KO4Ve.js";async function f(n,e,r){const o=n.map(t=>({id:t.id,title:t.title,url:t.url})),a=e.map(t=>({type:t,tabIds:[]})),i=await s("model")||"gpt-4",c=await s("apiURL")||"https://api.openai.com";try{return await Promise.all(o.map(async t=>{if(!t.url)return;const p=(await(await fetch(`${c}/v1/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`},body:JSON.stringify({messages:[{role:"system",content:"You are a classificator"},{role:"user",content:`Based on the URL ${t.url}, classify the browser tab type as one of the following: ${e.join(", ")}. Respond with only the classification keyword from the list.`}],model:i})})).json()).choices[0].message.content,l=e.indexOf(p);l!==-1&&a[l].tabIds.push(t.id)})),a}catch(t){return console.error(t),a}}async function u(n,e,r){try{const o=await s("model")||"gpt-4",a=await s("apiURL")||"https://api.openai.com";return(await(await fetch(`${a}/v1/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`},body:JSON.stringify({messages:[{role:"system",content:"You are a classificator"},{role:"user",content:`Based on the URL ${n.url}, classify the browser tab type as one of the following: ${e.join(", ")}. Respond with only the classification keyword from the list.`}],model:o})})).json()).choices[0].message.content}catch(o){console.error(o)}}export{f as b,u as h};
hfguo02 commented 10 months ago

image

hfguo02 commented 10 months ago

The selected model, GPT-3.5, cannot be used properly.

MichaelYuhe commented 10 months ago

Did u try other models? can they work normally?

GentlemanHu commented 10 months ago

Same here, all models not working

image

Stack Trace

import{g as r}from"./utils.Xiu07ssm.js";async function m(n,e,o){const a=n.map(t=>({id:t.id,title:t.title,url:t.url})),s=e.map(t=>({type:t,tabIds:[]})),i=await r("model")||"gpt-3.5-turbo",c=await r("apiURL")||"https://api.openai.com/v1/chat/completions";try{return await Promise.all(a.map(async t=>{if(!t.url)return;const p=(await(await fetch(c,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`,"Api-Key":o},body:JSON.stringify({messages:[{role:"system",content:"You are a classificator"},{role:"user",content:`Based on the URL: "${t.url}" and title: "${t.title}", classify the browser tab type as one of the following: ${e.join(", ")}. Respond with only the classification keyword from the list.`}],model:i})})).json()).choices[0].message.content,l=e.indexOf(p);l!==-1&&s[l].tabIds.push(t.id)})),s}catch(t){return console.error(t),s}}async function f(n,e,o){try{const a=await r("model")||"gpt-3.5-turbo",s=await r("apiURL")||"https://api.openai.com/v1/chat/completions";return(await(await fetch(s,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`,"Api-Key":o},body:JSON.stringify({messages:[{role:"system",content:"You are a classificator"},{role:"user",content:`Based on the URL: "${n.url}" and title: "${n.title}", classify the browser tab type as one of the following: ${e.join(", ")}. Respond with only the classification keyword from the list.`}],model:a})})).json()).choices[0].message.content}catch(a){console.error(a)}}export{m as b,f as h};
GentlemanHu commented 10 months ago

Using openai alternative api, seems apiURL not read from options config.

image image
MichaelYuhe commented 10 months ago
image

It should be working, can u check the network in the Network panel?

GentlemanHu commented 10 months ago

no log in Network panel

image
MichaelYuhe commented 10 months ago

You need to check in service_worker console

hfguo02 commented 10 months ago

I think found the reason,I created my own Assistants ChatGPT 3.5-turbo model on OpenAI and am verifying if my key works.

I'm not sure if there is a necessary connection, but it is currently working fine.

cc: @GentlemanHu

GentlemanHu commented 10 months ago

Yes, maybe the config not saved if not close Options tab; after closing Options tab, my config works.