โก Build context-aware reasoning applications โก
This repository is a part of LangChain tutorial. It demonstrates the integration of OpenAI model using the LangChain framework. It includes several examples to illustrate the capabilities of LangChain in creating context-aware applications.
Before starting, ensure you have the following:
- Python (3.x recommended) installed on your system.
- OpenAI API key (Follow these instructions to get your OpenAI API key)
-
Clone the Repository: First, clone this repository to your local machine using your preferred method.
-
Create a Virtual Environment:
- Navigate to the project directory in your terminal.
- Create a virtual environment:
python3 -m venv venv
- Activate the virtual environment:
- On Windows:
venv\Scripts\activate
- On MacOS/Linux:
source venv/bin/activate
- On Windows:
- Install Requirements:
- Ensure your virtual environment is active.
- Install the required packages using:
pip install -r requirements.txt
- Set Up OpenAI API Key:
- Obtain an OpenAI API key (Follow theseย instructionsย to get your OpenAI API key.).
- Create a
.env
file in the root of the project directory. - Add your API key to the file:
OPENAI_API_KEY=your_api_key_here
This repository includes several example scripts showcasing different features of LangChain with OpenAI:
- Simple Interaction (
simple_interaction.py
):
-
Demonstrates a basic interaction with OpenAI's API.
-
Run the script with:
python simple_interaction.py
- Multiple Prompts (
multiple_prompts.py
):
-
Shows how to send multiple prompts to the AI model.
-
Run with:
python multiple_prompts.py
- Prompt Templating (
prompt_templating.py
):
-
Illustrates dynamic data injection in prompts.
-
Execute the script using:
python prompt_templating.py
- Output Parser (
output_parser.py
):
-
Shows how to parse and refine LLM responses.
-
Execute with:
python output_parser.py
- Chain Integration (
chain_integration.py
):
-
Demonstrates how to streamline processes using LangChain's syntax.
-
Run using:
python chain_integration.py