This repository contains code that demonstrates how to build a custom chat agent using Langchain, integrating GPT-3.5 from OpenAI. The agent can handle conversational context, provide various tools, and assist in answering questions, including math-related queries.
The project showcases the implementation of a custom chat agent that leverages Langchain, an open-source framework, to interact with users in a conversational manner. The agent uses a conversational business document search tool. This agent is powered by GPT-3.5 for natural language understanding and generation.
-
Clone this repository to your local machine.
-
Install the required dependencies by running:
pip install -r requirements.txt
-
Obtain the API keys from OpenAI and Pinecone.
-
You must create a
config.py
file that defines the following:OPENAI_API_KEY = 'YOUR_OPENAI_API_KEY' PINECONE_API_KEY = 'YOUR_PINECONE_API_KEY' PINECONE_API_ENVIRONMENT = 'YOUR_PINECONE_ENVIRONMENT'
-
Get a previously created Pinecone index name, for document retrieval and set it in the
constants.py
file.
To use the custom chat agent:
- Run the provided Python script:
python main.py
- Enter your message as a user prompt.
- The agent will process the input and respond with relevant information or tools.
The configuration of the chat agent can be customized by modifying the parameters in the main.py
script. Key components include:
- Memory: Adjust the conversation memory buffer settings.
- Tools: Define and configure different tools the agent can use.
- Prompt Template: Modify the structure of the prompt used to interact with GPT-3.5.
- Output Parsing: Configure how the agent interprets and processes the model's responses.
This project is licensed under the MIT License.