This repository contains two Flask applications that utilize Langchain for natural language processing. The first application handles text inputs (llama31.py), while the second application processes both text and image inputs (llava.py).
- Python 3.7+
-
Clone this repository:
git clone https://github.com/AditHash/ollama-api.git cd ollama-api -
Create and activate a virtual environment:
# create venv python -m venv venv # for linux only source venv/bin/activate # for windows only venv\Scripts\activate
-
Install the required packages:
pip install -r requirements.txt
This application processes text inputs and generates responses using the Langchain model with conversation memory.
-
Navigate to the directory containing
llama31.py:cd path/to/llama3.1 -
Run the Flask application:
python llama31.py
-
The application will be available at
http://127.0.0.1:5000/chat.
-
POST /chat- Request Body: JSON object containing
user_input. - Response: JSON object containing the generated response.
{ "user_input": "What is the capital of France?" } - Request Body: JSON object containing
This application processes both text and image inputs, converts the image to a Base64 encoded string, and generates responses using the Langchain model with conversation memory.
-
Navigate to the directory containing
llava.py:cd path/to/llava -
Run the Flask application:
python llava.py
-
The application will be available at
http://127.0.0.1:5000/image-chat.
-
POST /image-chat- Request Parameters:
image_input: File (JPEG, JPG, PNG).user_input: Text input.
- Response: JSON object containing the generated response.
Example using
curl:curl -X POST http://127.0.0.1:5000/image-chat \ -F "image_input=@/path/to/image.jpg" \ -F "user_input=What is the animal shown in image?" - Request Parameters: