sparticleinc / chatgpt-google-summary-extension

Chrome extension to view ChatGPT summaries alongside Google search results and YouTube videos, also supports Yahoo! ニュース、PubMed、PMC、NewsPicks、Github、Nikkei、 Bing、Google Patents, and any page summary.
https://glarity.app
GNU General Public License v3.0
1.7k stars 213 forks source link

Errors when loading the self-built package to chrome #206

Open h4n0 opened 2 months ago

h4n0 commented 2 months ago

Describe the bug I cloned the latest main branch and built it locally following the instructions. Chrome shows errors when I load the package. The error messages are:

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'config')
Context
options.html
Stack Trace
options.js:203 (anonymous function)
Uncaught (in promise) TypeError: Cannot set properties of undefined (setting 'apiKey')
Context
https://github.com/sparticleinc/chatgpt-google-summary-extension/issues/new/choose
Stack Trace
content-script.js:6 (anonymous function)

Desktop (please complete the following information):

folkevil commented 2 months ago

I got the same problem

dillontkh commented 1 month ago

Was able to resolve this by modifying src/options/ProviderSelect.tsx

function ProviderSelect() {
  ...

  if (query.isLoading) {
    return <Spinner />
  }

  // Added this
  if (query.error) {
    return <div>Error loading provider configurations.</div>
  }

  // Don't think you need this but added it to be safe
  if (!query.data || !query.data.config) {
    return <div>No provider configurations found.</div>
  }

  return <ConfigPanel config={query.data!.config} models={models} />
}

as well as src/config/index.ts

export async function getProviderConfigs(): Promise<ProviderConfigs> {
  ...

  // Ensure result[configKey] is not undefined
  if (!result[configKey]) {
    result[configKey] = {}
  }
  result[configKey].apiKey = apiKey

  return {
    provider,
    configs: {
      [ProviderType.GPT3]: result[configKey],
    },
  }
}