Fleek Langchain template
🦜️🔗 Fleek-LangChain Starter Tenplate
This template scaffolds a LangChain.js + Next.js starter app. It showcases how to use and combine LangChain modules for several use cases. Specifically:
- Simple chat
- Returning structured output from an LLM call
- Answering complex, multi-step questions with agents
- Retrieval augmented generation (RAG) with a chain and a vector store
- Retrieval augmented generation (RAG) with an agent and a vector store
It is perfect for developers looking to build AI applications in Next.js and on Fleek seamlessly with any features they want.
Prerequisites
- Node 18.18.0+
- Fleek Account
- Fleek CLI
- Fleek Next Adapter
Getting Started
- Fork the repository
- Clone the repository by running the following command:
git clone https://github.com/<your-id>/langchain-nextjs-fleek.git
- Enter the correct directory, install dependencies and run locally:
cd langchain-nextjs-fleek
npm i
npm run dev
- Ensure that you install the Fleek CLI and the Fleek Next Adapter:
// local installation
npm i @fleek-platform/cli
npm i @fleek-platform/next
// global installation
npm i -g @fleek-platform/cli
npm i -g @fleek-platform/next
- Set up your an
.env.local
file with the following environment variables:
# NEXT_PUBLIC_OPENAI_API_KEY=""
# NEXT_PUBLIC_SERPAPI_API_KEY=""
# NEXT_PUBLIC_LANGCHAIN_CALLBACKS_BACKGROUND=true
# Required for retrieval examples
# SUPABASE_PRIVATE_KEY="YOUR_SUPABASE_PRIVATE_KEY"
# SUPABASE_URL="YOUR_SUPABASE_URL"
# Optional: For Tracing with LangSmith
# LANGCHAIN_TRACING_V2=true
# LANGCHAIN_API_KEY=YOUR_API_KEY
# LANGCHAIN_PROJECT=nextjs-starter
# Optional: Other model keys
# ANTHROPIC_API_KEY="YOUR_API_KEY"
# Turn on demo mode
# NEXT_PUBLIC_DEMO="true"
💡: you can check the Fleek CLI version by running fleek -v. Any version >= 2.10.1 should be good. As for the Fleek Next adapter, you can check the Fleek Next Adapter version by running fleek-next -v. Any version >= 2.1.0 should be good.
Building and Deploying
- Build the project using the Fleek Next Adapter:
npx fleek-next build
# or if installed globally
fleek-next build
- Now, Create the Fleek Function using the Fleek CLI:
//syntax
fleek functions create --name '<name of your function>'
//example
fleek functions create --name fumadocs
- Finally, deploy using the Fleek CLI:
//syntax
fleek functions deploy --bundle=false --path .fleek/dist/index.js --assets .fleek/static --name '<name of your function>' --envFile '<path to your environment>'
//example
fleek functions deploy --bundle=false --path .fleek/dist/index.js --assets .fleek/static --name langchain-fleek-project --envFile .env
As you complete all the steps successfully here, you will be able to access your fullstack Next.js app using a link that looks like this- https://millions-smartphone-ancient.functions.on-fleek.app/
Deploying from the Fleek web application
To deploy your application from the Fleek web app, you need to ensure that the project exists as a Github repository.
- Go to the app.fleek.xyz
- Connect your Github account to your project
- Click on the repository
- Add your environment variables
- Deploy your application
Contributing
Reporting Issues
- Use GitHub Issues to report bugs or suggest features.
- Provide clear details and steps to reproduce any issues.
Pull Requests
- Fork the repository.
- Create a feature branch:
git checkout -b feature/your-feature
- Commit changes with clear messages.
- Push to your fork and submit a pull request.
Learn More
- Fleek CLI Docs
- Fleek Function Docs
- Fleek Next Docs
- Next.js Documentation - learn about Next.js features and API.
- Learn Next.js - an interactive Next.js tutorial.
- Langchain - learn about Langchain