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.
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.
Follow the steps to setup the project before running it:
- Update the value for
OPENAI_API_KEYbyexport OPENAI_API_KEY=you_openai_key- If using Jetify Cloud (Sandboxes or Deployments) you can set this via Jetify Secrets.
devbox run installto install dependencies.devbox run startto run the rag application.
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:
-
Modify prompt template: Adjust the
templatevariable inmain.pyfor different NLP tasks. -
Tune model parameters: Change the
temperaturein theOpenAIinitialization to control output randomness. -
Switch language models: Replace OpenAI with other LangChain-supported models.
-
Implement complex chains: Combine multiple prompts, models, or tools for advanced applications.
-
Use alternative parsers: Replace
StrOutputParser()with other LangChain parsers for structured outputs. -
Add input preprocessing: Implement text cleaning or tokenization before model input.
-
Integrate external data: Modify code to process data from APIs, databases, or files instead of hardcoded examples.


