Giter Club home page Giter Club logo

langchainjs-expressjs-boilerplate's Introduction

LangChain Express API Boilerplate πŸš€

A feature-packed boilerplate for building expressive and powerful APIs using LangChain and Express.js. This boilerplate provides a solid foundation for creating your own custom API with a wide range of functionalities. Get started quickly and build amazing APIs with ease! πŸŽ‰

Automatically Generated API Frontend

Automatically Generated API Documentation

🌈 Features

  • πŸ“¦ Example implementations of common large language model tasks (e.g., translation, poem generation)
  • πŸ“‹ Clear and simple structure for adding new methods
  • πŸ“š Auto-generated API documentation using OpenAPI and Swagger UI
  • 🚦 Rate limiting and input validation for API routes
  • πŸ“ˆ Logging and error handling
  • 🎨 Beautiful and autogenerated frontend for testing your API
  • πŸš€ Easy deployment to your favorite hosting platform
  • 🐳 Docker-ready for smooth deployment

πŸŽ“ Getting Started

  1. Clone this repository:
git clone https://github.com/Texterous/LangChainJS-ExpressJS-Boilerplate.git
  1. Install dependencies:
cd langchain-express-boilerplate
npm install
  1. Create a .env file in the root directory and add your OpenAI API key:
OPENAI_API_KEY=your_openai_api_key_here
  1. Start the development server:
npm run start
  1. Open your browser and navigate to http://localhost:3000 to see the frontend and test your API.

  2. Check out the auto-generated API documentation at http://localhost:3000/api-docs.

πŸ›  Adding New Methods

  1. Open the methods.js file in the root directory.

  2. Add a new method object to the methods array. The method object should have the following properties:

    • id: A unique identifier for the method (e.g., "translation").
    • route: The API route for the method (e.g., "/translate").
    • method: The HTTP method for the route (e.g., "post").
    • description: A brief description of the method.
    • inputVariables: An array of input variable names (e.g., ["Input Language", "Output Language", "Text"]).
    • execute: An async function that takes the input variables and returns the result.
  3. In the execute function, you can use the LangChain library to create your Large Language Model chain. Check out the existing methods for examples.

  4. Save the file and restart the development server. Your new method will be automatically added to the API and the documentation.

πŸ“– Documentation

🚒 Deployment

You can easily deploy your LangChain Express API to your favorite hosting platform (e.g., Heroku, AWS, Google Cloud, etc.). Just follow the platform-specific deployment instructions and make sure to set the OPENAI_API_KEY environment variable in your deployment environment. You can also use Docker.

🀝 Contributing

We welcome contributions to the LangChain Express Boilerplate! If you have any ideas, suggestions, or bug reports, please feel free to open an issue or submit a pull request.

πŸ“ƒ License

This project is licensed under the MIT License. See the LICENSE file for details.


Made with ❀️ by Thomas Übellacker and the Texterous Team

langchainjs-expressjs-boilerplate's People

Contributors

thomasuebi avatar thefranciscook 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.