Coder Social home page Coder Social logo

replicate / getting-started-nextjs-language Goto Github PK

View Code? Open in Web Editor NEW
26.0 14.0 3.0 364 KB

A template Next.js app for running language models like FLAN-T5 with Replicate's API

JavaScript 88.15% CSS 11.85%
flan-t5 large-language-models nextjs replicate

getting-started-nextjs-language's Introduction

Next.js template for running language models with Replicate

This is a Next.js template project that's preconfigured for interacting with a language model like FLAN-T5 with Replicate's API.

You can use this as a quick jumping-off point to build a web app using Replicate's API, or you can recreate this codebase from scratch by following the guide at replicate.com/docs/get-started/nextjs

Screenshot 2023-03-13 at 7 00 18 PM

Noteworthy files

Usage

Install dependencies:

npm install

Add your Replicate API token to .env.local:

REPLICATE_API_TOKEN=<your-token-here>

Run the development server:

npm run dev

Open http://localhost:3000 with your browser.

Changing the model

This example app is configured to use the FLAN-T5 model by default, but you can change it to use any other Replicate model that has a similar input and output format.

To change the model, update the modelVersion constant in pages/api/predictions/index.js to the version ID of the Replicate model you want to run.

Editing the homepage

The homepage is a React component in pages/index.js. You can edit it to change the look and feel of the app.

Deploy to Vercel

For detailed instructions on how to create and use this template, see replicate.com/docs/get-started/nextjs

There are many ways to deploy apps to Vercel, but for the sake of brevity, we'll use the vercel CLI here. Start by installing the CLI and running it:

npx vercel

The command above installs the CLI, then walks you through the process of logging in to Vercel, creating the app, and deploying it. Once you've deployed your app, you need to add your Replicate API token to the remote app's environment variables. This allows your app to make requests to the Replicate API.

vercel env add REPLICATE_API_TOKEN

The command above prompts you to enter a value for your token. Paste your token fron replicate.com/account. You then need to deploy again:

npx vercel deploy --prod

getting-started-nextjs-language's People

Contributors

bfirsh avatar zeke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.