Skip to content

feat: update nuxt example for proper streaming support #295

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

Merged
merged 5 commits into from
Aug 15, 2023

Conversation

Hebilicious
Copy link
Contributor

@Hebilicious Hebilicious commented Jul 7, 2023

@changeset-bot
Copy link

changeset-bot bot commented Jul 7, 2023

⚠️ No Changeset found

Latest commit: a2b2f9a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pi0
Copy link
Contributor

pi0 commented Jul 7, 2023

Hi @Hebilicious thanks for following this up 🚀 I think we can avoid this workaround and instead hotfix upstream (unenv, h3, nitro) to promote a proper working example.

I am currently working on some fixes.

@Hebilicious Hebilicious marked this pull request as draft July 7, 2023 20:22
@Hebilicious
Copy link
Contributor Author

Hebilicious commented Jul 7, 2023

@pi0 i'll tag this as draft in the meantime. Do we have 3 separate tracking issues (unenv/h3/nitro) opened ?

Edit: The alias issue has been fixed with the latest unenv version.

@jaredpalmer
Copy link
Collaborator

Checking on this, what is status of streaming w/nuxt?

@pi0
Copy link
Contributor

pi0 commented Aug 1, 2023

@jaredpalmer It is ready on edge release channels ready to release ~tomorrow on nuxt 3.7 👍🏼

@Hebilicious Would you please update PR with edge to verify?

@Hebilicious Hebilicious force-pushed the feat/nuxt-streaming-fix branch from 891f020 to 90c6def Compare August 2, 2023 15:53
@Hebilicious
Copy link
Contributor Author

Hebilicious commented Aug 7, 2023

@pi0
Updating to nitro and h3 nightly :

  • works on dev

  • deploying on vercel edge :

{
    "url": "/api/chat",
    "statusCode": 405,
    "statusMessage": "HTTP method is not allowed.",
    "message": "HTTP method is not allowed.",
    "stack": ""
}

@Hebilicious Hebilicious closed this Aug 7, 2023
@Hebilicious Hebilicious reopened this Aug 7, 2023
@Hebilicious
Copy link
Contributor Author

Hebilicious commented Aug 7, 2023

Here's a separated repo with the deployed example : https://github.com/Hebilicious/nuxt-openai-vercel-edge-demo

Deployed here :

-vercel-edge preset : https://nuxt-vercel-edge-hebilicious.vercel.app/
-cloudflare-pages preset : https://d182f224.openai-nuxt-test.pages.dev/

The code works the same on all platforms and on dev.

Note: The code doesn't work without resolutions/overrides.

  "resolutions": {
    "h3": "1.8.0-rc.2",
    "nitropack": "2.5.2"
  }

@Hebilicious Hebilicious force-pushed the feat/nuxt-streaming-fix branch from 80acfbd to 7e5790f Compare August 7, 2023 13:11
@Hebilicious Hebilicious marked this pull request as ready for review August 7, 2023 13:11
@Hebilicious Hebilicious requested a review from pi0 August 7, 2023 13:11
Copy link
Contributor

@pi0 pi0 left a comment

Choose a reason for hiding this comment

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

Thanks for working on this dear @Hebilicious ❤️

I think it looks good to me. I have tested with your external repo and it works all fine (made few quick changes would be nice consider some from https://github.com/pi0/nuxt-openai-demo/tree/main)

Also if Vercel team is okay, it would probably be a good idea to merge PR as is with edge dependencies since is better than current example anyway and we will make sure to come with another PR as soon as stable nuxt/nitro with streaming support released 👍🏼

@Hebilicious Hebilicious force-pushed the feat/nuxt-streaming-fix branch from 088da3b to f6c4e3f Compare August 10, 2023 19:30
kodiakhq bot pushed a commit that referenced this pull request Aug 11, 2023
discovered in #295, using `useSWRV` to track a loading state means we actually get a fetch to the loading API key. We can just use a vue `ref` to handle this state, however.
@danielroe
Copy link
Contributor

We hope to have a new version of Nuxt + Nitro released in next couple of days. It might be worth deferring merge of this PR until that point.

@pi0
Copy link
Contributor

pi0 commented Aug 12, 2023

Agreed let's wait to merge and announce by time of release! We can also remove nitro/h3 explicitly pins by next edge release of Nuxt (pending CI)

@MaxLeiter
Copy link
Member

Marking this as a draft so it doesn't get accidentally merged. Please ping me here / on Slack when it's ready to go 🚀

@pi0 @danielroe @Hebilicious

@MaxLeiter MaxLeiter marked this pull request as draft August 13, 2023 21:45
@pi0
Copy link
Contributor

pi0 commented Aug 15, 2023

Good news! h3 1.8 is released and immediately available for all Nuxt users. Just make sure to renew lock file and node_modules and remove any resolutions are you are good to go for vercel edge support! (validated on my repo ~> https://nuxt-openai-demo.vercel.app/).

Hebilicious and others added 5 commits August 15, 2023 21:55
feat: update nuxt example for proper streaming support

chore: remove settings.json

chore: typos

fix: unenv hotfix

refactor: properly type messages

feat: update to latest versions

chore: regenerate lockfile for nuxt

chore: remove api key

chore: remove .vercel

feat: try edge workarounds

chore: update to nightly

feat: working implementation

feat: improve implementation

chore: remove nuxt resolution

chore: use h3 and nitropack edge

chore: lockfile
Co-authored-by: Daniel Roe <daniel@roe.dev>
@Hebilicious Hebilicious force-pushed the feat/nuxt-streaming-fix branch from a2b2f9a to d3194b8 Compare August 15, 2023 14:59
@Hebilicious Hebilicious marked this pull request as ready for review August 15, 2023 14:59
@Hebilicious
Copy link
Contributor Author

Updated the deps and the lockfile, this should be good to go 🚀

@MaxLeiter
Copy link
Member

Thanks so much @Hebilicious, @pi0, and @danielroe! 🚀

@MaxLeiter MaxLeiter merged commit 9316842 into vercel:main Aug 15, 2023
venus-heaven added a commit to venus-heaven/vercel-react-ai that referenced this pull request Apr 18, 2024
discovered in vercel/ai#295, using `useSWRV` to track a loading state means we actually get a fetch to the loading API key. We can just use a vue `ref` to handle this state, however.
masterdev0218 added a commit to masterdev0218/ai that referenced this pull request May 6, 2024
discovered in vercel/ai#295, using `useSWRV` to track a loading state means we actually get a fetch to the loading API key. We can just use a vue `ref` to handle this state, however.
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.

Nuxt - Streaming Issue with the example "Nuxt OpenAI Starter" on Vercel
5 participants