Skip to content

Use Vercel AI SDK and Next.js App Directory#19

Merged
zeke merged 9 commits intoreplicate:mainfrom
MaxLeiter:max/vercel-ai-sdk
Aug 8, 2023
Merged

Use Vercel AI SDK and Next.js App Directory#19
zeke merged 9 commits intoreplicate:mainfrom
MaxLeiter:max/vercel-ai-sdk

Conversation

@MaxLeiter
Copy link
Copy Markdown

@MaxLeiter MaxLeiter commented Aug 1, 2023

I haven't completely tested this but it should be a good PoC if anyone wants to pick it up.

  1. I noticed there's both a yarn.lock and package-lock, so I went with a 3rd choice and used pnpm. Happy to change it to whatever you prefer
  2. Migrated to the Next.js App Directory
  3. Use the Vercel AI SDK and it's ReplicateStream and useCompletion utilities.
    3a. It'd be nice to use the useChat hook instead but that would be a more invasive change.

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Aug 1, 2023

@MaxLeiter is attempting to deploy a commit to the Replicate Team on Vercel.

A member of the Team first needs to authorize it.

@MaxLeiter MaxLeiter marked this pull request as draft August 1, 2023 08:11
@MaxLeiter MaxLeiter marked this pull request as ready for review August 1, 2023 18:45
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Aug 2, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
llama-chat ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 8, 2023 4:50pm

Copy link
Copy Markdown
Member

@zeke zeke left a comment

Choose a reason for hiding this comment

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

I took this for a spin locally and it worked like a charm. I didn't inspect all the changes closely, but overall this looks good to me. 👍🏼

What do you think, @cbh123 and @fofr?

Couple little blockers:

  • npm ci is failing. Looks like there's an issue with the package lock. We generally use npm for Replicate demo projects, but I have no opposition to yarn or pnpm as long as we're consistent in the project.
  • Looks like there's a merge conflict.

@MaxLeiter
Copy link
Copy Markdown
Author

Switched to npm and resolved the conflict 👍

@zeke
Copy link
Copy Markdown
Member

zeke commented Aug 2, 2023

Now the build is failing with Missing required parameter: auth from the Replicate JavaScript client constructor.

That's because process.env.REPLICATE_API_TOKEN is not present in the build environment.

I can reproduce this locally with:

REPLICATE_API_TOKEN="" npm t

And I was able to get around it like this:

 REPLICATE_API_TOKEN="r8_fake_token" npm t

We could update scripts.test to have that env assignment as a prefix, but it feels a bit unsavory. 🤔

@mattt any thoughts on what would be the best way to handle this?

@mattt
Copy link
Copy Markdown
Contributor

mattt commented Aug 8, 2023

@zeke This is now fixed in v0.15.1. See replicate/replicate-javascript#120

@zeke
Copy link
Copy Markdown
Member

zeke commented Aug 8, 2023

@MaxLeiter you wanna npm install replicate@latest and give this another go?

@zeke zeke merged commit 37b9d35 into replicate:main Aug 8, 2023
@MaxLeiter MaxLeiter deleted the max/vercel-ai-sdk branch August 8, 2023 17:22
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.

3 participants