This project is for experimenting with LangChain. It provides a practical implementation of the LangChain Quickstart guide and serves as a playground for testing and understanding the capabilities of LangChain.
Follow the instructions in the LangChain Quickstart Guide to get up and running with this project.
You will need the following environment variables set:
OPENAI_API_KEY
: Your OpenAI API key.TAVILY_API_KEY
: Your Tavily API key.
- Clone the repository.
- Install the dependencies with
npm install
. - Run the project with
make start-dev
. This command runsnodemon
, which is a utility that monitors for any changes in your source code and automatically restarts your server. This is particularly useful during development, as it saves you from having to manually restart your server every time you make changes to your code.
The application will listen on port 3003 by default, but this can be reconfigured with the PORT
environment variable. The application serves the following URLs:
- http://localhost:3003/api/langchain/simple: This endpoint calls the OpenAI API with a simple prompt.
- http://localhost:3003/api/langchain/retrieval: This endpoint implements a Retrieval Augmented Generation (RAG) example. The chain behind this endpoint downloads the webpage of LangSmith and generates an answer based on that. It uses in-memory vector embeddings.
- http://localhost:3003/api/langchain/conversation: This endpoint preserves the conversation history and uses the same Retrieval Augmented Generation (RAG) approach as the above endpoint.
- http://localhost:3003/api/langchain/search: This endpoint uses Tavily search to answer the question.
- http://localhost:3003/api/langchain/tokenize?text=HelloWorld: This endpoint uses the tiktoken tokenizer to generate tokens from the input text. You can read more abot this here: https://platform.openai.com/tokenizer
Contributions are welcome. Please submit a pull request or create an issue to discuss the changes you want to make.
This project is licensed under the MIT License. See the LICENSE file for details.