Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
h4n0 opened this issue Apr 16, 2024 · 2 comments
Open

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

h4n0 opened this issue Apr 16, 2024 · 2 comments

Comments

@h4n0
Copy link

h4n0 commented Apr 16, 2024

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
Copy link

folkevil commented May 2, 2024

I got the same problem

@dillontkh
Copy link

dillontkh commented May 17, 2024

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],
    },
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants