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

Upgrade to @pinecone-database/pinecone version 1.1.0 #14

Merged
merged 17 commits into from
Oct 3, 2023

Conversation

zackproser
Copy link
Contributor

@zackproser zackproser commented Sep 14, 2023

Problem

Describe the purpose of this change. What problem is being solved and why?

Blocked by pinecone-io/pinecone-ts-client#108

These changes upgrade the pinecone-vercel-starter template to use @pinecone-database/pinecone version 1.1.0

Blocked on

Solution

Describe the approach you took. Link to any relevant bugs, issues, docs, or other resources.

These changes make the required signature changes and some minor logic changes to accommodate the new behavior of the v1 SDK.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Infrastructure change (CI configs, etc)
  • Non-code change (docs, etc)
  • None of the above: (explain here)

Test Plan

Describe specific steps for validating this change.

Ran locally, but pinecone-io/pinecone-ts-client#108 is currently blocking this.

@glody007
Copy link

Hi
I hope you're doing well. I want to express my enthusiasm for this initiative – it's a great idea to stay up-to-date with the latest version of Pinecone.

As I've been actively working on an application that uses Pinecone 1.0, I encountered a particular issue related to the chunkedUpsert and createIndexIfNotExists functions. These functions have been deprecated in Pinecone 1.0, which prompted me to take the initiative to reimplement them as utilities that are compatible with Pinecone 1.0.

Now, my question is: Do you have plans to integrate these updated utilities? it will ensure compatibility with Pinecone 1.0

Moreover, I'm more than willing to contribute to the integration process and help with any necessary modifications

@zackproser
Copy link
Contributor Author

Hi I hope you're doing well. I want to express my enthusiasm for this initiative – it's a great idea to stay up-to-date with the latest version of Pinecone.

As I've been actively working on an application that uses Pinecone 1.0, I encountered a particular issue related to the chunkedUpsert and createIndexIfNotExists functions. These functions have been deprecated in Pinecone 1.0, which prompted me to take the initiative to reimplement them as utilities that are compatible with Pinecone 1.0.

Now, my question is: Do you have plans to integrate these updated utilities? it will ensure compatibility with Pinecone 1.0

Moreover, I'm more than willing to contribute to the integration process and help with any necessary modifications

Hi @glody007,

Thanks for the feedback and helpful pointers - do you have a fork or branch where you made those changes you could point me at? If those helper methods are indeed broken with the upgrade to 1.0, then I could take care of them as part of this pull request.

Thank you!

src/app/utils/pinecone.ts Outdated Show resolved Hide resolved
src/app/utils/pinecone.ts Outdated Show resolved Hide resolved
src/app/utils/pinecone.ts Outdated Show resolved Hide resolved
src/app/utils/pinecone.ts Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
Copy link
Contributor

@jhamon jhamon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to update all the code that is copy/pasted to the README when you're done changing the code.

@glody007
Copy link

Hi I hope you're doing well. I want to express my enthusiasm for this initiative – it's a great idea to stay up-to-date with the latest version of Pinecone.
As I've been actively working on an application that uses Pinecone 1.0, I encountered a particular issue related to the chunkedUpsert and createIndexIfNotExists functions. These functions have been deprecated in Pinecone 1.0, which prompted me to take the initiative to reimplement them as utilities that are compatible with Pinecone 1.0.
Now, my question is: Do you have plans to integrate these updated utilities? it will ensure compatibility with Pinecone 1.0
Moreover, I'm more than willing to contribute to the integration process and help with any necessary modifications

Hi @glody007,

Thanks for the feedback and helpful pointers - do you have a fork or branch where you made those changes you could point me at? If those helper methods are indeed broken with the upgrade to 1.0, then I could take care of them as part of this pull request.

Thank you!

I will PR your fork

@zackproser
Copy link
Contributor Author

zackproser commented Sep 15, 2023

I made the code changes requested. Locally, I'm getting an error connecting to Pinecone, but I've supplied my own API key and an azure environment...still debugging...

I've tried east azure and GCP and triple-cheked API keys...but I keep getting the same error. When I dump the pinecone config to the console I see the correct environment and API key values, and I'm setting them via:

  • PINECONE_API_KEY
  • PINECONE_ENVIRONMENT
- error node_modules/.pnpm/@pinecone-database+pinecone@1.0.1/node_modules/@pinecone-database/pinecone/dist/errors/handling.js (52:38) @ eval
- error Request failed to reach Pinecone. Verify you have the correct environment, project id, and index name configured.

I've also tried:

  • Setting the values in .env.local, which according to the output of npm run dev I can see is being loaded at startup
  • Creating the full PineconeConfiguration object and passing that into new Pinecone - with the same results.
  • Using a completely separate set of credentials - a Pinecone API key and environment from a different account, which I can see are being set properly when I console.dir the Pinecone client
  • Creating and using credentials both for GCP and AWS
  • Passing or not passing the project ID from the full https endpoint generated on the Pinecone console

🤔

@jhamon or @rschwabco LMK if you see something obvious that I've missed.

@zackproser zackproser changed the title Upgrade to @pinecone-database/pinecone version 1.0 Upgrade to @pinecone-database/pinecone version 1.0.1 Sep 15, 2023
@glody007
Copy link

Hi I hope you're doing well. I want to express my enthusiasm for this initiative – it's a great idea to stay up-to-date with the latest version of Pinecone.
As I've been actively working on an application that uses Pinecone 1.0, I encountered a particular issue related to the chunkedUpsert and createIndexIfNotExists functions. These functions have been deprecated in Pinecone 1.0, which prompted me to take the initiative to reimplement them as utilities that are compatible with Pinecone 1.0.
Now, my question is: Do you have plans to integrate these updated utilities? it will ensure compatibility with Pinecone 1.0
Moreover, I'm more than willing to contribute to the integration process and help with any necessary modifications

Hi @glody007,

Thanks for the feedback and helpful pointers - do you have a fork or branch where you made those changes you could point me at? If those helper methods are indeed broken with the upgrade to 1.0, then I could take care of them as part of this pull request.

Thank you!

I just submitted a pull request for the change here #zackproser#2 (comment)

@jhamon
Copy link
Contributor

jhamon commented Sep 22, 2023

I suspect nextjs is doing something with fetch that causes a problem with the cross-fetch polyfill the client library is using to make network calls. Looking into it.

@athrael-soju
Copy link

athrael-soju commented Sep 23, 2023

api/clearIndex/route.ts will also need to be updated.

Something like this should do the trick:

import { Pinecone } from '@pinecone-database/pinecone';

export async function POST() {
  const pinecone = new Pinecone();
  pinecone.Index(process.env.PINECONE_INDEX!).deleteAll();
  return NextResponse.json({
    success: true,
  });
}

@athrael-soju
Copy link

I made the code changes requested. Locally, I'm getting an error connecting to Pinecone, but I've supplied my own API key and an azure environment...still debugging...

I've tried east azure and GCP and triple-cheked API keys...but I keep getting the same error. When I dump the pinecone config to the console I see the correct environment and API key values, and I'm setting them via:

  • PINECONE_API_KEY
  • PINECONE_ENVIRONMENT
- error node_modules/.pnpm/@pinecone-database+pinecone@1.0.1/node_modules/@pinecone-database/pinecone/dist/errors/handling.js (52:38) @ eval
- error Request failed to reach Pinecone. Verify you have the correct environment, project id, and index name configured.

I've also tried:

  • Setting the values in .env.local, which according to the output of npm run dev I can see is being loaded at startup
  • Creating the full PineconeConfiguration object and passing that into new Pinecone - with the same results.
  • Using a completely separate set of credentials - a Pinecone API key and environment from a different account, which I can see are being set properly when I console.dir the Pinecone client
  • Creating and using credentials both for GCP and AWS
  • Passing or not passing the project ID from the full https endpoint generated on the Pinecone console

🤔

@jhamon or @rschwabco LMK if you see something obvious that I've missed.

I think @jhamon is right. If you comment out export const runtime = 'edge'; in src\app\api\crawl\route.ts the chunked upsert works fine. I looked into crawl/seed.ts and although the request reaches the endpont, when the route runs as 'Edge' the pages returned aren't in in the right format.

With export const runtime = 'edge';

pages [
  {
  url: 'https://cleantechnica.com/2023/06/29/solar-82-of-power-capacity-growth-in-india-in-2022/',
  content: '![CleanTechnica](https://cleantechnica.com/files/2021/03/CT_LOGO_45HIGH.png) \n\n* #270639 (no title)\n* #270646 (no title)\n* #270647 (no title)\n* #270651 (no title)\n* #275264 (no title)\n* #213858 (no title)\n* #215263 (no title)\n* #200420 (no title)\n* #215290 (no title)\n* 70%, 80%, 99.9%, 100% Renewables — Study Central\n* About Wind Energy / Why Wind Energy\n* Advertise with CleanTechnica\n* Advertising\n* Aftermarket Tesla Accessories\n* Authors\n* Best Tesla Accessories\n* Branded Thought Leadership Series\n* Calendar\n* Clean Energy\n* Clean tech and sustainability market research\n* Cleantech Billionaires\n* Cleantech Glossary\n* Cleantech Jobs  \n   * Submit a Resumé\n* CleanTech Talk\n* CleanTechnica Comment Policy\n* CleanTechnica Editorial Ethics\n* CleanTechnica Newsletters\n* CleanTechnica Reports & Guides\n* CleanTechnica’s E-Bike Guide: How To Choose An E-Bike You’ll Love\n* CleanTechnica’s EV Chargers & Charging Guide\n* CleanTechnica’s Shop!\n* CleanTechnica’s Top Tesla Aftermarket Accessories Guide\n* Climate Change Solutions: Why 1.5°C Is So Important\n* Community Solar Power Guide\n* Contact CleanTechnica\n* Contract\n* Electric Vehicle Charging\n* Electric Vehicle Charging Infrastructure: Guidelines For Cities\n* Electric Vehicle Sales Charts, Graphs, & Stats\n* Energy Storage\n* Engage Global Competition: Technology for a Sustainable Future\n* General Inquiries\n* Get Your Cleantech Event Featured!\n* Home Efficiency\n* Home Solar – Simplified\n* How Do You Charge An Electric Car At Home?\n* How To Charge An Electric Vehicle — 101\n* How To Improve Storage In A Tesla\n* Invest in CleanTechnica\n* Invest in CleanTechnica\n* Investment\n* Letters to tomorrow\n* Manage Job Listings\n* MASSIVE Electric Bike Buyer’s Guide — All the Biggest Brands & Models\n* Microgrids Explained\n* Mission and Vision\n* Native Content Guidelines\n* Navigating EV Fast Charging Challenges with Energy Storage\n* NIO ES8 — The Chinese Electric SUV Outselling The Tesla Model X\n* Nukes, Renewables, and the Union of Concerned Scientists\n* Our Team\n* Pitch deck\n* Privacy Policy\n* Reality Check — Correcting the Cleantech Record\n* REGISTRATION TESTER\n* Renewable Energy Sources\n* Resources For Solar Installers\n* Shop For E-Bikes AND Support CleanTechnica!\n* Solar Energy\n* Solar Energy Resources\n* Solar Panel Installers — Top Solar Panel Installers & How To Evaluate Them\n* Solar Power\n* Sponsor CleanTechnica\n* Stay Connected With CleanTechnica\n* Style Guide — Draft\n* Support CleanTechnica\n* Sustainable Business Virtual Trade Show\n* Switching to an Electric Fleet – Learn About Charging, Payments, & More\n* Syndicate Our Content\n* Terms of Use\n* Tesla Insurance\n* Tesla Myths & FAQ\n* Test\n* Testimonials: Why Readers Love CleanTechnica\n* Top Clean Energy Resources\n* Trusted Partners\n* Upcoming CleanTech Events\n* Use of CleanTechnica Content\n* Vanadium Flow Batteries Demystified\n* What has CleanTechnica meant to you?\n* Wind Energy\n* Wind Energy Facts\n* Wind Energy Resources\n* World’s Top Cleantech Site\n* Xpeng G3\n* Xpeng P7\n\nConnect with us \n\nHi, what are you looking for?\n  \n  \n![CleanTechnica](https://cleantechnica.com/files/2021/03/pixel.jpg) \n\n![CleanTechnica](https://cleantechnica.com/files/2021/03/CT_LOGO_45HIGH.png) \n\n## CleanTechnica\n\n* Clean Energy  \n   * Solar Energy  \n   * Wind Energy  \n   * Geothermal Energy  \n   * Energy Storage  \n   * Smart Grid  \n   * Energy Efficiency\n* EVs  \n   * All EV News & Analysis  \n   * EV Sales  \n   * EV Total Cost of Ownership  \n   * EV Reviews  \n         * All Reviews\n* Tesla News  \n   * Tesla Model 3 Long-Term Review  \n   * Tesla Model S Long-Term Review\n* Exclusives  \n   * CleanTechnica Analysis  \n   * CleanTechnica Reviews  \n   * CleanTechnica Reports & Guides  \n   * CleanTechnica Videos  \n   * CleanTechnica.TV (YouTube)  \n   * Cleantech Talk (Our Podcast)  \n   * Series Pages  \n         * EV Charging  \n         * EV Fleet Charging  \n         * How to Charge An EV At Home  \n         * Fast Home EV Charging  \n         * Battery Powered EV Charging  \n         * Aftermarket Tesla Accessories  \n         * Best Tesla Accessories  \n         * Home Efficiency  \n         * Microgrids  \n         * Vanadium Flow Batteries Demystified  \n         * Home Solar … Simplified\n* About  \n   * Connect With CleanTechnica  \n   * Testimonials: Why Readers Love CleanTechnica  \n   * Support CleanTechnica  \n   * Contact Us  \n   * Advertise  \n   * Our Team  \n   * Editorial Ethics  \n   * Mission & Vision  \n   * Invest  \n   * Privacy Policy  \n   * RSS  \n   * Syndicate Our Content\n\n![](https://cleantechnica.com/files/2023/06/India-Solar-Power-Additions-2022.png) \n\n### Clean Power \n\n# Solar = 82% Of Power Capacity Growth In India In 2022!\n\n![](https://secure.gravatar.com/avatar/3af65bafd82ab5c33087e1e70a5d2e62?s=40&d=blank&r=g) \n\nBy\n\nZachary Shahan \n\nPublished\n\nJune 29, 2023 \n\n_Sign up for daily news updates from CleanTechnica on email. Or follow us on Google News!_ \n\n---\n\nThere’s no doubt about it — China leads the world in solar power growth and Spain leads the world in solar power as a share of electricity — but India deserves some praise, too. Asian giant #2 had its biggest year for solar power growth — and it wasn’t even close.\n\n### Quick India Solar Power Growth\n\nIn 2022, India installed 13 GWac (18 GWdc) of new solar power capacity, 27% more than it installed in 2021, which was its previous best year ever.\n\n![](https://cleantechnica.com/files/2023/06/India-Solar-Power-Additions-2022.png)\n\nChart courtesy of National Renewable Energy Laboratory (NREL).\n\nUnlike China, where distributed solar PV has taken off, India’s solar power market was dominated by utility-scale solar power additions. “Large-scale projects increased 33% from 2021 and made up 87% of new 2022 PV capacity,” the National Renewable Energy Laboratory (NREL) writes. In fact, it wasn’t even a case of utility-scale solar PV growing faster than rooftop solar — rooftop solar power additions _declined_ year over year. “Rooftop projects decreased 4% from 2021 and made up 13% of new 2022 PV capacity.”\n\nBut here’s the stat where India crushes China, and probably everyone else: solar PV capacity growth accounted for **_82%_** of the country’s total power capacity growth. It absolutely dominated the new power plant market. In China, which did well itself on this front, 44% of new power capacity came from solar. That’s dominance — forget 2050.\n\nAnd don’t expect the Indian solar power market to slow down. At the end of 2022, 58 GWac of large solar power projects were still in the pipeline and yet another 51 GWac were pending auction. There’s plenty more solar PV project growth for years of growth like 2022 saw. In fact, just combining those numbers, you could have more than 8 years of growth at the 13 GWac level, or you could have more than 5 years of solar power growth above 20 GWac a year. And that’s not even counting rooftop solar power.\n\n### India Solar PV Exports\n\nWhile India’s internal solar power growth was truly impressive in 2022, its solar PV power export growth was at least as impressive.\n\n![](https://cleantechnica.com/files/2023/06/India-Solar-PV-Exports-US-e1688071134914.png)\n\nChart courtesy of National Renewable Energy Laboratory (NREL).\n\nThat’s an enormous jump in solar power exports, and as you can see, it’s the result of one certain market — the USA. I wonder why that is? Oh, and as you can see, that’s the change from the first half of the year compared to the second half of the year!\n\n“Indian module exports jumped more than tenfold between the first and second halves of 2022, with all the increase going to the United States,” NREL writes. Also noteworthy for those Indian module manufacturers, “The US module market yields higher profit margins than the Indian market.” (Who doesn’t like that … aside from US solar panel buyers?)\n\nA little more on the specifics of why Indian solar modules flooded the US market, NREL writes, “Mid-year U.S. policies (UFLPA, AD/CVD investigation) contributed to demand for Indian modules.”\n\nTo sweeten the pie and go even further, some Indian solar module manufacturers are reportedly looking at building solar module factories in the United States to take advantage of US Inflation Reduction Act subsidies Joe Biden brought to town.\n\n---\n\n_Have a tip for CleanTechnica? Want to advertise? Want to suggest a guest for our CleanTech Talk podcast? Contact us here._ \n\n---\n\n### EV Obsession Daily!\n\n---\n\n_I don\'t like paywalls. You don\'t like paywalls. Who likes paywalls? Here at CleanTechnica, we implemented a limited paywall for a while, but it always felt wrong — and it was always tough to decide what we should put behind there. In theory, your most exclusive and best content goes behind a paywall. But then fewer people read it!! So, we\'ve decided to completely nix paywalls here at CleanTechnica. But..._\n\n_Like other media companies, we need reader support! If you support us, please chip in a bit monthly to help our team write, edit, and publish 15 cleantech stories a day!_\n\n_Thank you!_\n\n---\n\n### Tesla Sales in 2023, 2024, and 2030\n\n---\n\nAdvertisement\n\n---\n\n_CleanTechnica uses affiliate links. See our policy here._ \n\nIn this article:India, India Solar, India Solar Modules, India Solar Power \n\n![](https://secure.gravatar.com/avatar/3af65bafd82ab5c33087e1e70a5d2e62?s=150&d=blank&r=g) \n\nWritten By Zachary Shahan \n\nZach is tryin\' to help society help itself one word at a time. He spends most of his time here on _CleanTechnica_ as its director, chief editor, and CEO. Zach is recognized globally as an electric vehicle, solar energy, and energy storage expert. He has presented about cleantech at conferences in India, the UAE, Ukraine, Poland, Germany, the Netherlands, the USA, Canada, and Curaçao. Zach has long-term investments in Tesla \\[TSLA\\], NIO \\[NIO\\], Xpeng \\[XPEV\\], Ford \\[F\\], ChargePoint \\[CHPT\\], Amazon \\[AMZN\\], Piedmont Lithium \\[PLL\\], Lithium Americas \\[LAC\\], Albemarle Corporation \\[ALB\\], Nouveau Monde Graphite \\[NMGRF\\], Talon Metals \\[TLOFF\\], Arclight Clean Transition Corp \\[ACTC\\], and Starbucks \\[SBUX\\]. But he does not offer (explicitly or implicitly) investment advice of any sort.\n\n![](https://cleantechnica.com/files/2021/03/CT_LOGO_45HIGH.png) \n\nComments \n\nComments \n\n**Advertise with _CleanTechnica_ to get your company in front of millions of monthly readers.**\n\n#### Listen to Cleantech Talk\n\n![](https://cleantechnica.com/files/2019/09/CleanTech-Talk_with_log-w350px.jpg)\n\n#### Trending\n\n![](https://cleantechnica.com/files/2023/09/202309-wind-122894-innovation-analysis-100x100.jpg) \n\n### Clean Power\n\n## 80% More U.S. Wind Energy Potential This Decade From Tech Innovation\n\n![](https://cleantechnica.com/files/2023/09/US-State-EV-Sales-100x100.jpeg) \n\n### Cars\n\n## Electric Vehicle Sales in US Hit the Accelerator Pedal — Even Beyond California\n\n![heat pump](https://cleantechnica.com/files/2022/10/How-a-Heat-Pump-Works-100x100.jpg) \n\n### Energy Efficiency\n\n## 25 States Agree To Quadruple Number Of Heat Pumps In America\n\n![DeSantis](https://cleantechnica.com/files/2023/09/Ron-DeSantis-for-president-100x100.jpg) \n\n### Clean Transport\n\n## DeSantis Wants To “Repeal Biden’s EV Mandates” And “Achieve $2 Gas In 2025”\n\n![](https://cleantechnica.com/files/2023/09/2023.07-candela-c-8-electric-boat-watercraft-polestar-motor-hyrdrofoil-OFFICIAL-candela_C8_SF_DSC_5425-100x100.jpg) \n\n### Cars\n\n## Candela Sets 24-Hour Distance Record For Electric Boats — 777 Kilometers!\n\n#### Tesla News\n\n![](https://cleantechnica.com/files/2019/09/Sarasota-Tesla-Model-3-Superchargers-White-Blue-National-Drive-Electric-Week-Sarasota-Florida-CleanTechnica.jpg)\n\n#### EV Reviews\n\n![](https://cleantechnica.com/files/2017/12/Tesla-Model-X-News.jpg)\n\n#### You May Also Like \n\n![Saudi Arabia solar energy IRENA map](https://cleantechnica.com/files/2015/02/Saudi-Arabia-solar-energy-IRENA-map-600x337.png) ![Saudi Arabia solar energy IRENA map](https://cleantechnica.com/files/2015/02/Saudi-Arabia-solar-energy-IRENA-map-100x100.png) \n\n### Clean Power\n\n## First HVDC Undersea Power Project In The Developing World & Saudi Entry Into Exporting Renewable Power\n\nSign up for daily news updates from CleanTechnica on email. Or follow us on Google News! A few days ago, private companies in India...\n\nPaul FosseSeptember 17, 2023 \n\n![](https://cleantechnica.com/files/2023/04/EV-electric-car-charging-CleanTechnica-Watermark-600x337.png) ![](https://cleantechnica.com/files/2023/04/EV-electric-car-charging-CleanTechnica-Watermark-100x100.png) \n\n### Cars\n\n## Bringing Clean Deliveries to India\n\nWith the help of RMI’s Acceleration Fund, the Shoonya campaign has catalyzed clean growth in a high-pollution industry.\n\nRMISeptember 10, 2023 \n\n![](https://cleantechnica.com/files/2023/09/TVS-X-electric-scooter-pic-3-600x337.jpeg) ![](https://cleantechnica.com/files/2023/09/TVS-X-electric-scooter-pic-3-100x100.jpeg) \n\n### Clean Transport\n\n## TVS Releases Battery-Powered X Crossover, A Mix Of A Motorcycle & Scooter\n\nSign up for daily news updates from CleanTechnica on email. Or follow us on Google News! Chennai-based Indian motorcycle maker TVS Motor Company recently...\n\nRaymond TribdinoSeptember 7, 2023 \n\n![](https://cleantechnica.com/files/2023/04/Wind-turbines-energy-CleanTechnica-watermark-600x337.png) ![](https://cleantechnica.com/files/2023/04/Wind-turbines-energy-CleanTechnica-watermark-100x100.png) \n\n### Clean Power\n\n## India Has The Potential To Dominate The Global Wind Energy Supply Chain\n\nSign up for daily news updates from CleanTechnica on email. Or follow us on Google News! India could emerge as a central figure in...\n\nRaymond TribdinoSeptember 7, 2023 \n\n![CleanTechnica](https://cleantechnica.com/files/2021/02/CleanTechnica-solar-EV-battery-cleantech-news-2.png) \n\nCopyright © 2023 CleanTechnica. The content produced by this site is for entertainment purposes only. Opinions and comments published on this site may not be sanctioned by and do not necessarily represent the views of CleanTechnica, its owners, sponsors, affiliates, or subsidiaries. \n\n## \n\n## \n\nLoading Comments... \n\nWrite a Comment... \n\nEmail (Required) \n\nName (Required) \n\nWebsite \n\n### \n\n/\\* <!\\[CDATA\\[ \\*/ var jetpackSwiperLibraryPath = {"url":"https:\\\\/\\\\/cleantechnica.com\\\\/wp-content\\\\/plugins\\\\/jetpack\\\\/\\_inc\\\\/build\\\\/carousel\\\\/swiper-bundle.min.js"}; var jetpackCarouselStrings = {"widths":\\[370,700,1000,1200,1400,2000\\],"is\\_logged\\_in":"","lang":"en","ajaxurl":"https:\\\\/\\\\/cleantechnica.com\\\\/wp-admin\\\\/admin-ajax.php","nonce":"73469a033a","display\\_exif":"1","display\\_comments":"1","single\\_image\\_gallery":"1","single\\_image\\_gallery\\_media\\_file":"","background\\_color":"black","comment":"Comment","post\\_comment":"Post Comment","write\\_comment":"Write a Comment...","loading\\_comments":"Loading Comments...","download\\_original":"View full size {0}\\\\u00d7<\\\\/span>{1}<\\\\/span>","no\\_comment\\_text":"Please be sure to submit some text with your comment.","no\\_comment\\_email":"Please provide an email address to comment.","no\\_comment\\_author":"Please provide your name to comment.","comment\\_post\\_error":"Sorry, but there was an error posting your comment. Please try again later.","comment\\_approved":"Your comment was approved.","comment\\_unapproved":"Your comment is in moderation.","camera":"Camera","aperture":"Aperture","shutter\\_speed":"Shutter Speed","focal\\_length":"Focal Length","copyright":"Copyright","comment\\_registration":"0","require\\_name\\_email":"1","login\\_url":"https:\\\\/\\\\/cleantechnica.com\\\\/wp-login.php?redirect\\_to=https%3A%2F%2Fcleantechnica.com%2F2023%2F06%2F29%2Fsolar-82-of-power-capacity-growth-in-india-in-2022%2F","blog\\_id":"1351","meta\\_data":\\["camera","aperture","shutter\\_speed","focal\\_length","copyright"\\]}; /\\* \\]\\]> \\*/ '  
}
]
- error unhandledRejection: Error [PineconeConnectionError]: Request failed to reach Pinecone. Verify you have the correct environment, project id, and index name configured.
    at eval (webpack-internal:///(sc_server)/./node_modules/@pinecone-database/pinecone/dist/errors/handling.js:146:25)
    at step (webpack-internal:///(sc_server)/./node_modules/@pinecone-database/pinecone/dist/errors/handling.js:107:23)
    at Object.eval [as next] (webpack-internal:///(sc_server)/./node_modules/@pinecone-database/pinecone/dist/errors/handling.js:48:20)
    at eval (webpack-internal:///(sc_server)/./node_modules/@pinecone-database/pinecone/dist/errors/handling.js:26:71)
    at new Promise (<anonymous>)
    at __awaiter (webpack-internal:///(sc_server)/./node_modules/@pinecone-database/pinecone/dist/errors/handling.js:8:12)
    at handleFetchError (webpack-internal:///(sc_server)/./node_modules/@pinecone-database/pinecone/dist/errors/handling.js:136:12)
    at eval (webpack-internal:///(sc_server)/./node_modules/@pinecone-database/pinecone/dist/errors/handling.js:170:54)
    at step (webpack-internal:///(sc_server)/./node_modules/@pinecone-database/pinecone/dist/errors/handling.js:107:23)
    at Object.eval [as next] (webpack-internal:///(sc_server)/./node_modules/@pinecone-database/pinecone/dist/errors/handling.js:48:20) {
  digest: undefined
}
Error upserting chunk  [PineconeConnectionError: Request failed to reach Pinecone. Verify you have the correct environment, project id, and index name configured.] {
  name: 'PineconeConnectionError'
}
Error upserting chunk  [PineconeConnectionError: Request failed to reach Pinecone. Verify you have the correct environment, project id, and index name configured.] {
  name: 'PineconeConnectionError'
}
Error upserting chunk  [PineconeConnectionError: Request failed to reach Pinecone. Verify you have the correct environment, project id, and index name configured.] {
  name: 'PineconeConnectionError'
}

without export const runtime = 'edge';

- event compiled successfully in 510 ms (940 modules)
pages [
  {
    url: 'https://cleantechnica.com/2023/06/29/solar-82-of-power-capacity-growth-in-india-in-2022/',
    content: '![CleanTechnica](https://cleantechnica.com/files/2021/03/CT_LOGO_45HIGH.png) \n' +
      '\n' +
      '* #270639 (no title)\n' +
      '* #270646 (no title)\n' +
      '* #270647 (no title)\n' +
      '* #270651 (no title)\n' +
      '* #275264 (no title)\n' +
      '* #213858 (no title)\n' +
      '* #215263 (no title)\n' +
      '* #200420 (no title)\n' +
      '* #215290 (no title)\n' +
      '* 70%, 80%, 99.9%, 100% Renewables — Study Central\n' +
      '* About Wind Energy / Why Wind Energy\n' +
      '* Advertise with CleanTechnica\n' +
      '* Advertising\n' +
      '* Aftermarket Tesla Accessories\n' +
      '* Authors\n' +
      '* Best Tesla Accessories\n' +
      '* Branded Thought Leadership Series\n' +
      '* Calendar\n' +
      '* Clean Energy\n' +
      '* Clean tech and sustainability market research\n' +
      '* Cleantech Billionaires\n' +
      '* Cleantech Glossary\n' +
      '* Cleantech Jobs  \n' +
      '   * Submit a Resumé\n' +
      '* CleanTech Talk\n' +
      '* CleanTechnica Comment Policy\n' +
      '* CleanTechnica Editorial Ethics\n' +
      '* CleanTechnica Newsletters\n' +
      '* CleanTechnica Reports & Guides\n' +
      '* CleanTechnica’s E-Bike Guide: How To Choose An E-Bike You’ll Love\n' +
      '* CleanTechnica’s EV Chargers & Charging Guide\n' +
      '* CleanTechnica’s Shop!\n' +
      '* CleanTechnica’s Top Tesla Aftermarket Accessories Guide\n' +
      '* Climate Change Solutions: Why 1.5°C Is So Important\n' +
      '* Community Solar Power Guide\n' +
      '* Contact CleanTechnica\n' +
      '* Contract\n' +
      '* Electric Vehicle Charging\n' +
      '* Electric Vehicle Charging Infrastructure: Guidelines For Cities\n' +
      '* Electric Vehicle Sales Charts, Graphs, & Stats\n' +
      '* Energy Storage\n' +
      '* Engage Global Competition: Technology for a Sustainable Future\n' +
      '* General Inquiries\n' +
      '* Get Your Cleantech Event Featured!\n' +
      '* Home Efficiency\n' +
      '* Home Solar – Simplified\n' +
      '* How Do You Charge An Electric Car At Home?\n' +
      '* How To Charge An Electric Vehicle — 101\n' +
      '* How To Improve Storage In A Tesla\n' +
      '* Invest in CleanTechnica\n' +
      '* Invest in CleanTechnica\n' +
      '* Investment\n' +
      '* Letters to tomorrow\n' +
      '* Manage Job Listings\n' +
      '* MASSIVE Electric Bike Buyer’s Guide — All the Biggest Brands & Models\n' +
      '* Microgrids Explained\n' +
      '* Mission and Vision\n' +
      '* Native Content Guidelines\n' +
      '* Navigating EV Fast Charging Challenges with Energy Storage\n' +
      '* NIO ES8 — The Chinese Electric SUV Outselling The Tesla Model X\n' +
      '* Nukes, Renewables, and the Union of Concerned Scientists\n' +
      '* Our Team\n' +
      '* Pitch deck\n' +
      '* Privacy Policy\n' +
      '* Reality Check — Correcting the Cleantech Record\n' +
      '* REGISTRATION TESTER\n' +
      '* Renewable Energy Sources\n' +
      '* Resources For Solar Installers\n' +
      '* Shop For E-Bikes AND Support CleanTechnica!\n' +
      '* Solar Energy\n' +
      '* Solar Energy Resources\n' +
      '* Solar Panel Installers — Top Solar Panel Installers & How To Evaluate Them\n' +
      '* Solar Power\n' +
      '* Sponsor CleanTechnica\n' +
      '* Stay Connected With CleanTechnica\n' +
      '* Style Guide — Draft\n' +
      '* Support CleanTechnica\n' +
      '* Sustainable Business Virtual Trade Show\n' +
      '* Switching to an Electric Fleet – Learn About Charging, Payments, & More\n' +
      '* Syndicate Our Content\n' +
      '* Terms of Use\n' +
      '* Tesla Insurance\n' +
      '* Tesla Myths & FAQ\n' +
      '* Test\n' +
      '* Testimonials: Why Readers Love CleanTechnica\n' +
      '* Top Clean Energy Resources\n' +
      '* Trusted Partners\n' +
      '* Upcoming CleanTech Events\n' +
      '* Use of CleanTechnica Content\n' +
      '* Vanadium Flow Batteries Demystified\n' +
      '* What has CleanTechnica meant to you?\n' +
      '* Wind Energy\n' +
      '* Wind Energy Facts\n' +
      '* Wind Energy Resources\n' +
      '* World’s Top Cleantech Site\n' +
      '* Xpeng G3\n' +
      '* Xpeng P7\n' +
      '\n' +
      'Connect with us \n' +
      '\n' +
      'Hi, what are you looking for?\n' +
      '  \n' +
      '  \n' +
      '![CleanTechnica](https://cleantechnica.com/files/2021/03/pixel.jpg) \n' +
      '\n' +
      '![CleanTechnica](https://cleantechnica.com/files/2021/03/CT_LOGO_45HIGH.png) \n' +
      '\n' +
      '## CleanTechnica\n' +
      '\n' +
      '* Clean Energy  \n' +
      '   * Solar Energy  \n' +
      '   * Wind Energy  \n' +
      '   * Geothermal Energy  \n' +
      '   * Energy Storage  \n' +
      '   * Smart Grid  \n' +
      '   * Energy Efficiency\n' +
      '* EVs  \n' +
      '   * All EV News & Analysis  \n' +
      '   * EV Sales  \n' +
      '   * EV Total Cost of Ownership  \n' +
      '   * EV Reviews  \n' +
      '         * All Reviews\n' +
      '* Tesla News  \n' +
      '   * Tesla Model 3 Long-Term Review  \n' +
      '   * Tesla Model S Long-Term Review\n' +
      '* Exclusives  \n' +
      '   * CleanTechnica Analysis  \n' +
      '   * CleanTechnica Reviews  \n' +
      '   * CleanTechnica Reports & Guides  \n' +
      '   * CleanTechnica Videos  \n' +
      '   * CleanTechnica.TV (YouTube)  \n' +
      '   * Cleantech Talk (Our Podcast)  \n' +
      '   * Series Pages  \n' +
      '         * EV Charging  \n' +
      '         * EV Fleet Charging  \n' +
      '         * How to Charge An EV At Home  \n' +
      '         * Fast Home EV Charging  \n' +
      '         * Battery Powered EV Charging  \n' +
      '         * Aftermarket Tesla Accessories  \n' +
      '         * Best Tesla Accessories  \n' +
      '         * Home Efficiency  \n' +
      '         * Microgrids  \n' +
      '         * Vanadium Flow Batteries Demystified  \n' +
      '         * Home Solar … Simplified\n' +
      '* About  \n' +
      '   * Connect With CleanTechnica  \n' +
      '   * Testimonials: Why Readers Love CleanTechnica  \n' +
      '   * Support CleanTechnica  \n' +
      '   * Contact Us  \n' +
      '   * Advertise  \n' +
      '   * Our Team  \n' +
      '   * Editorial Ethics  \n' +
      '   * Mission & Vision  \n' +
      '   * Invest  \n' +
      '   * Privacy Policy  \n' +
      '   * RSS  \n' +
      '   * Syndicate Our Content\n' +
      '\n' +
      '![](https://cleantechnica.com/files/2023/06/India-Solar-Power-Additions-2022.png) \n' +
      '\n' +
      '### Clean Power \n' +
      '\n' +
      '# Solar = 82% Of Power Capacity Growth In India In 2022!\n' +
      '\n' +
      '![](https://secure.gravatar.com/avatar/3af65bafd82ab5c33087e1e70a5d2e62?s=40&d=blank&r=g) \n' +
      '\n' +
      'By\n' +
      '\n' +
      'Zachary Shahan \n' +
      '\n' +
      'Published\n' +
      '\n' +
      'June 29, 2023 \n' +
      '\n' +
      '_Sign up for daily news updates from CleanTechnica on email. Or follow us on Google News!_ \n' +
      '\n' +
      '---\n' +
      '\n' +
      'There’s no doubt about it — China leads the world in solar power growth and Spain leads the world in solar power as a share of electricity — but India deserves some praise, too. Asian giant #2 had its biggest year for solar power growth — and it wasn’t even close.\n' +
      '\n' +
      '### Quick India Solar Power Growth\n' +
      '\n' +
      'In 2022, India installed 13 GWac (18 GWdc) of new solar power capacity, 27% more than it installed in 2021, which was its previous best year ever.\n' +
      '\n' +
      '![](https://cleantechnica.com/files/2023/06/India-Solar-Power-Additions-2022.png)\n' +
      '\n' +
      'Chart courtesy of National Renewable Energy Laboratory (NREL).\n' +
      '\n' +
      'Unlike China, where distributed solar PV has taken off, India’s solar power market was dominated by utility-scale solar power additions. “Large-scale projects increased 33% from 2021 and made up 87% of new 2022 PV capacity,” the National Renewable Energy Laboratory (NREL) writes. In fact, it wasn’t even a case of utility-scale solar PV growing faster than rooftop solar — rooftop solar power additions _declined_ year over year. “Rooftop projects decreased 4% from 2021 and made up 13% of new 2022 PV capacity.”\n' +
      '\n' +
      'But here’s the stat where India crushes China, and probably everyone else: solar PV capacity growth accounted for **_82%_** of the country’s total power capacity growth. It absolutely dominated the new power plant market. In China, which did well itself on this front, 44% of new power capacity came from solar. That’s dominance — forget 2050.\n' +
      '\n' +
      'And don’t expect the Indian solar power market to slow down. At the end of 2022, 58 GWac of large solar power projects were still in the pipeline and yet another 51 GWac were pending auction. There’s plenty more solar PV project growth for years of growth like 2022 saw. In fact, just combining those numbers, you could have more than 8 years of growth at the 13 GWac level, or you could have more than 5 years of solar power growth above 20 GWac a year. And that’s not even counting rooftop solar power.\n' +
      '\n' +
      '### India Solar PV Exports\n' +
      '\n' +
      'While India’s internal solar power growth was truly impressive in 2022, its solar PV power export growth was at least as impressive.\n' +
      '\n' +
      '![](https://cleantechnica.com/files/2023/06/India-Solar-PV-Exports-US-e1688071134914.png)\n' +
      '\n' +
      'Chart courtesy of National Renewable Energy Laboratory (NREL).\n' +
      '\n' +
      'That’s an enormous jump in solar power exports, and as you can see, it’s the result of one certain market — the USA. I wonder why that is? Oh, and as you can see, that’s the change from the first half of the year compared to the second half of the year!\n' +     
      '\n' +
      '“Indian module exports jumped more than tenfold between the first and second halves of 2022, with all the increase going to the United States,” NREL writes. Also noteworthy for those Indian module manufacturers, “The US module market yields higher profit margins than the Indian market.” (Who doesn’t like that … aside from US solar panel buyers?)\n' +
      '\n' +
      'A little more on the specifics of why Indian solar modules flooded the US market, NREL writes, “Mid-year U.S. policies (UFLPA, AD/CVD investigation) contributed to demand for Indian modules.”\n' +
      '\n' +
      'To sweeten the pie and go even further, some Indian solar module manufacturers are reportedly looking at building solar module factories in the United States to take advantage of US Inflation Reduction Act subsidies Joe Biden brought to town.\n' +
      '\n' +
      '---\n' +
      '\n' +
      '_Have a tip for CleanTechnica? Want to advertise? Want to suggest a guest for our CleanTech Talk podcast? Contact us here._ \n' +
      '\n' +
      '---\n' +
      '\n' +
      '### EV Obsession Daily!\n' +
      '\n' +
      '---\n' +
      '\n' +
      "_I don't like paywalls. You don't like paywalls. Who likes paywalls? Here at CleanTechnica, we implemented a limited paywall for a while, but it always felt wrong — and it was always tough to decide what we should put behind there. In theory, your most exclusive and best content goes behind a paywall. But then fewer people read it!! So, we've decided to completely nix paywalls here at CleanTechnica. But..._\n" +
      '\n' +
      '_Like other media companies, we need reader support! If you support us, please chip in a bit monthly to help our team write, edit, and publish 15 cleantech stories a day!_\n' +
      '\n' +
      '_Thank you!_\n' +
      '\n' +
      '---\n' +
      '\n' +
      '### Tesla Sales in 2023, 2024, and 2030\n' +
      '\n' +
      '---\n' +
      '\n' +
      'Advertisement\n' +
      '\n' +
      '---\n' +
      '\n' +
      '_CleanTechnica uses affiliate links. See our policy here._ \n' +
      '\n' +
      'In this article:India, India Solar, India Solar Modules, India Solar Power \n' +
      '\n' +
      '![](https://secure.gravatar.com/avatar/3af65bafd82ab5c33087e1e70a5d2e62?s=150&d=blank&r=g) \n' +
      '\n' +
      'Written By Zachary Shahan \n' +
      '\n' +
      "Zach is tryin' to help society help itself one word at a time. He spends most of his time here on _CleanTechnica_ as its director, chief editor, and CEO. Zach is recognized globally as an electric vehicle, solar energy, and energy storage expert. He has presented about cleantech at conferences in India, the UAE, Ukraine, Poland, Germany, the Netherlands, the USA, Canada, and Curaçao. Zach has long-term investments in Tesla \\[TSLA\\], NIO \\[NIO\\], Xpeng \\[XPEV\\], Ford \\[F\\], ChargePoint \\[CHPT\\], Amazon \\[AMZN\\], Piedmont Lithium \\[PLL\\], Lithium Americas \\[LAC\\], Albemarle Corporation \\[ALB\\], Nouveau Monde Graphite \\[NMGRF\\], Talon Metals \\[TLOFF\\], Arclight Clean Tran"... 5706 more characters
  }
]

-  ┌ POST /api/crawl 200 in 3875ms
   │
   └──── GET https://cleantechnica.co../2023/06/29/solar-82-of-.. 200 in 544ms (cache: MISS)

Sorry for the wall of text. Hope that helps.

jhamon added a commit to pinecone-io/pinecone-ts-client that referenced this pull request Sep 27, 2023
## Problem

Next.js seems to stub out the cross-fetch polyfill which has the effect
of silently breaking code which depends on cross-fetch to make API
requests.

Related bugs: 
- #124 
- v1 migration problems in
pinecone-io/pinecone-vercel-starter#14

## Solution

I have added a `getFetch` utility which looks for a `fetch`
implementation already loaded in the global scope and returns the
cross-fetch implementation only as a last resort.

- Now when using our client library in a next.js project, this should
result in the `@vercel/fetch` implementation being used in favor of the
disabled polyfill.
- When using this client library in other environments where next.js is
not being used, it still activates the cross-fetch polyfill.
- Also, I've exposed an experimental configuration option for anyone who
wants to pass in a different fetch implementation to use. This could
open up some flexibility for people with specific network configurations
who need the ability to configure the http client being used in some
way. If the user provides a fetch implementation through the `fetchApi`
config option, it will take priority over a fetch in the global scope or
the cross-fetch polyfill.

### Other changes

- Added additional integration tests for `query` method
- Added an explicit dependency on the `encoding` module to resolve a
warning message [similar to this
one](vercel/next.js#54109)

## Type of Change

- [x] Bug fix (non-breaking change which fixes an issue)

## Test Plan

I am currently testing this change in the context of work-in-progress to
migrate our vercel-starter example to using the v1 version of the
client. pinecone-io/pinecone-vercel-starter#14

- Checkout the PR branch from pinecone-vercel-starter in a sibling
directory
- Install my local changes to this client with `npm install
../pinecone-ts-client`
- Try to run the starter project with `npm run dev`
- Attempt to use the sample app and observe it progresses beyond the
error related broken cross-fetch
@athrael-soju
Copy link

Thanks for the fix @jhamon. Using version 1.1.0 seems to work and the upsert is working again. One thing, however, is that I don't seem to be getting the POST response log back, when export const runtime = 'edge';

When disabled, we can see this:

- wait compiling /api/crawl/route (client and server)...
- event compiled successfully in 762 ms (939 modules)

-  ┌ POST /api/crawl 200 in 3069ms
   │
   ├──── GET https://www.google.com/search?q=athos%20georgiou 200 in 283ms (cache: MISS)
   │
   ├── 1 level ── GET https://controller.us-we../databases 200 in 1334ms (cache: MISS)
   │
   └── 1 level ── POST https://iridium-index-a4../vectors/upsert 200 in 906ms (cache: MISS)

When enabled:

- wait compiling /api/crawl/route (client and server)...
- event compiled successfully in 539 ms (425 modules)

I can raise an issue, if this is related to this template.

@zackproser
Copy link
Contributor Author

Thank you for the attention and helpful feedback @athrael-soju and @glody007 - we're getting closer here. This latest commit worked for me locally end to end and I was able to perform the expected demo. Requesting some more internal reviews now.

@zackproser zackproser changed the title Upgrade to @pinecone-database/pinecone version 1.0.1 Upgrade to @pinecone-database/pinecone version 1.1.0 Sep 28, 2023
src/app/utils/pinecone.ts Outdated Show resolved Hide resolved
Comment on lines 11 to 21
let exists = false
for (const index of indexes) {
if (index.name === process.env.PINECONE_INDEX!) {
exists = true
}
}

// Check if the desired index is present, else throw an error
if (!indexes.includes(process.env.PINECONE_INDEX!)) {
if (!exists) {
throw (new Error(`Index ${process.env.PINECONE_INDEX} does not exist`))
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this whole section lines 9-21 can be simplified as something like

  const indexName: string = process.env.PINECONE_INDEX || '';
  if (indexName === '') {
    throw new Error('PINECONE_INDEX environment variable not set')
  } 

  // Retrieve the list of indexes to check if expected index exists
  const indexes = await pinecone.listIndexes()
  if (indexes.filter(i => i.name === indexName).length !== 1) {
    throw new Error(`Index ${indexName} does not exist`)
  }

I don't think having this exists variable around is doing anything helpful for readability.

src/app/utils/pinecone.ts Outdated Show resolved Hide resolved
// Check if the desired index is present, else throw an error
if (!indexes.includes(process.env.PINECONE_INDEX!)) {
if (!exists) {
throw (new Error(`Index ${process.env.PINECONE_INDEX} does not exist`))
}

// Get the Pinecone index
const index = pinecone!.Index(process.env.PINECONE_INDEX!);
Copy link
Contributor

@jhamon jhamon Sep 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you use the generic type parameter in the method signature above, you also need to pass it here. Then typescript will understand types for metadata without the need to cast the query results elsewhere using as.

const index = pinecone.index<Metadata>(indexName);

The capital version (pinecone.Index) should also work for backwards compatibility, but it's not the usage I typically show.

@jhamon
Copy link
Contributor

jhamon commented Sep 28, 2023

As I mentioned on slack, the pnpm-lock.yaml file needs to be either updated or deleted in order to successfully deploy this to Vercel.

Screenshot 2023-09-28 at 5 55 54 AM

@athrael-soju
Copy link

@zackproser just a heads up that the next.js version used is outdated and may make sense to update next/react in this PR.

If not, happy to raise a PR after this one is merged. I've done the update in my project and everything runs quite well, of not better.

@zackproser
Copy link
Contributor Author

With the latest commit the unit tests defined via GitHub actions are passing on my fork: https://github.com/zackproser/pinecone-vercel-starter/actions/runs/6357115562/job/17267819591

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants