Introducing our cutting-edge code that revolutionizes the way you interact with your custom data – the Ready-to-Use API that answers your questions. With this meticulously crafted API, effortlessly obtain precise answers directly from your documents, text files, and websites.
Our innovative code empowers you to seamlessly integrate ChatGPT’s capabilities into your workflow, opening the door to a world of efficient information retrieval.
Experience the future of data interaction as you extract insights and solutions using our advanced API, simplifying the process and enhancing your access to knowledge like never before.
Get Answers from your documents, textfiles, and websites. Ready to use API for your Custom Data Using LlamaIndex and OpenAI.
💡 Basic knowledge of Python and Docker is required. We’ve used LlamaIndex and OpenAI. No need to expert on any of them.
⭐ LlamaIndex is a simple, flexible data framework for connecting custom data sources to large language models (LLMs).
⭐ OpenAI offers a spectrum of models with different levels of power suitable for different tasks
Steps
- Setup Docker Or Install Python
- Get the OpenAI API key and replace it in the source code.
- Build Model
- Run Server
- Call API and Ask any questions
Code Setup using Docker
- Setup Docker – Refer to FAQ #1 👇
- Prepare Context Data in simple TXT, CSV, or PDF format. Ability to parse multiple files, just paste files into the context_data folder.
- Get your OpenAI API key and replace it in server.py and build_model.py
- Build Docker
# Build a Docker image with the tag "my-bot" using the current directory (.) as the build context. docker build --no-cache -t my-bot .
5. Run Docker
# Run a Docker container using the "my-bot" image and map port 5001 on the host to port 5001 in the container. docker run -p 5001:5001 my-bot
Code Setup Manually
- Install Python
# Linux: # Ubuntu/Debian: sudo apt update sudo apt install python3 # Fedora: sudo dnf install python3 # Windows: # Download the Python installer executable from the official website (https://www.python.org/downloads/windows/). # Run the installer executable and follow the installation wizard. # macOS: # Homebrew: brew install python sudo port install python
2. Install Dependencies
pip install Flask==2.0.1 pip install requests==2.26.0 pip install llama-index==0.5.6 pip install langchain==0.0.148 pip install flask-basicauth pip install PyPDF2
3. Prepare Context Data in simple TXT, CSV, or PDF format. Ability to parse multiple files, just paste files into the context_data folder.
4. Get your OpenAI API key and replace it in server.py and build_model.py
5. Build Model
python build_model.py
6. Run Server
python server.py
Run API – Node JS
I’ve included Postman collection in this bundle so you can export code in your programming language.
const axios = require('axios'); let data = JSON.stringify({ "query": "Can you summarize this judgement?" }); let config = { method: 'post', maxBodyLength: Infinity, url: 'http://127.0.0.1:5001/ask_ai', headers: { 'Content-Type': 'application/json', 'Authorization': 'Basic ZWxpdGVjaDplbGl0ZWNoMTIzKg==' }, data : data }; axios.request(config) .then((response) => { console.log(JSON.stringify(response.data)); }) .catch((error) => { console.log(error); });
FAQ
- How to set up Docker?
To install Docker on various operating systems, follow the instructions below:
Install Docker on Linux: For Linux distributions, Docker provides installation scripts that you can use to install Docker Engine. Here’s a general method to install Docker on most Linux distributions: Open a terminal and run the following commands:
sudo apt update sudo apt install -y curl curl -fsSL https://get.docker.com -o get-docker.sh sudo sh get-docker.sh
After installation, start and enable the Docker service:
sudo systemctl start docker sudo systemctl enable docker
Install Docker on macOS: Docker Desktop is the recommended way to install Docker on macOS. You can download it from the official Docker website and follow the installation instructions provided: Download Docker Desktop for macOS
Install Docker on Windows: Similarly, Docker Desktop is the preferred method for installing Docker on Windows. Download it from the official Docker website and follow the installation instructions: Download Docker Desktop for Windows Note that Docker Desktop requires Windows 10 Pro or Enterprise (64-bit) for installation.
- After installing Docker, you can verify the installation by running the following command in your terminal:
docker --version
- This should display the version of the Docker that was installed.
Hey! We specialize in assisting you with the seamless integration of GPT into your product.
Let’s discuss.
Comments are closed.