Langchain

Framework
Langchain
Publisher
Jetify
{
  "$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.12.0/.schema/devbox.schema.json",
  "packages": [
    "python@3.12"
  ],
  "shell": {
    "init_hook": [
      ". $VENV_DIR/bin/activate"
    ],
    "scripts": {
      "install": "pip install -r requirements.txt",
      "start": "python3 main.py"
    }
  }
}

Python Langchain

This project demonstrates a simple text summarization application using LangChain and OpenAI. The main.py file sets up a prompt template, and creates a chain that combines the prompt, a language model, and an output parser. It then processes a sample input text, generating and printing a summary. This example showcases the basic usage of LangChain for natural language processing tasks.

Usage

Prerequisites

This project's environment is setup via devbox so it requires devbox to be installed.

It also requires an OpenAI API Key since it uses ChatGPT as the Language Model part of this application. The API Key needs to be set under the env variable OPENAI_API_KEY.

Setup

Follow the steps to setup the project before running it:

  1. Update the value for OPENAI_API_KEY by export OPENAI_API_KEY=you_openai_key
    1. If using Jetify Cloud (Sandboxes or Deployments) you can set this via Jetify Secrets.
  2. devbox run install to install dependencies.
  3. devbox run start to run the rag application.

Customization

This project uses LangChain to build text summarization application. You can replace it with any other usecase you'd like to build with Langchain. You can customize this application by doing one or more of the following:

  1. Modify prompt template: Adjust the template variable in main.py for different NLP tasks.

  2. Tune model parameters: Change the temperature in the OpenAI initialization to control output randomness.

  3. Switch language models: Replace OpenAI with other LangChain-supported models.

  4. Implement complex chains: Combine multiple prompts, models, or tools for advanced applications.

  5. Use alternative parsers: Replace StrOutputParser() with other LangChain parsers for structured outputs.

  6. Add input preprocessing: Implement text cleaning or tokenization before model input.

  7. Integrate external data: Modify code to process data from APIs, databases, or files instead of hardcoded examples.

README.md

Level up your dev environment

No need to switch your style. Devbox works with any coding language, so you can get results as you write.
PREPARE FOR LAUNCH

Plans for teams of any size

Jetify Cloud offers pricing plans for Solo Developers to Large Enterprises, and everything in between. All plans include free credits, and you are only billed for what you use. Need something custom? Contact our team and we can help.
YOUR INPUT COUNTS

Join the community

Discuss ideas, uses and builds with the Jetify team and others.