Skip to content

Commit bec4d0c

Browse files
author
mohsenari
committed
updated readme
1 parent 93f2fa2 commit bec4d0c

2 files changed

Lines changed: 40 additions & 5 deletions

File tree

README.md

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,38 @@
1-
# python-langchain
1+
# Python Langchain
22

3-
python with langchaing framework
3+
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.
4+
5+
## Usage
6+
7+
### Prerequisites
8+
9+
This project's environment is setup via devbox so it requires [devbox](https://www.jetify.com/devbox/docs/installing_devbox/) to be installed.
10+
11+
It also requires an OpenAI [API Key](https://help.openai.com/en/articles/4936850-where-do-i-find-my-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`.
12+
13+
### Setup
14+
15+
Follow the steps to setup the project before running it:
16+
17+
1. Update the value for `OPENAI_API_KEY` by `export OPENAI_API_KEY=you_openai_key`
18+
1. If using Jetify Cloud (Sandboxes or Deployments) you can set this via Jetify Secrets.
19+
1. `devbox run install` to install dependencies.
20+
1. `devbox run start` to run the rag application.
21+
22+
## Customization
23+
24+
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:
25+
26+
1. Modify prompt template: Adjust the `template` variable in `main.py` for different NLP tasks.
27+
28+
2. Tune model parameters: Change the `temperature` in the `OpenAI` initialization to control output randomness.
29+
30+
3. Switch language models: Replace OpenAI with other LangChain-supported models.
31+
32+
4. Implement complex chains: Combine multiple prompts, models, or tools for advanced applications.
33+
34+
5. Use alternative parsers: Replace `StrOutputParser()` with other LangChain parsers for structured outputs.
35+
36+
6. Add input preprocessing: Implement text cleaning or tokenization before model input.
37+
38+
7. Integrate external data: Modify code to process data from APIs, databases, or files instead of hardcoded examples.

requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
langchain_community
2-
langchain_core
3-
langchain_openai
1+
langchain_community==0.2.16
2+
langchain_core==0.2.16
3+
langchain_openai==0.1.23

0 commit comments

Comments
 (0)