Ask And Pay is a robust Python application that enables document processing and intelligent query handling using embedding models. It supports file uploads, tracks query usage, and integrates Stripe for secure payment processing. Built with Flask, it is ideal for applications requiring intelligent document interaction.
- File Uploads: Supports PDF, text, and markdown files up to 10 MB.
- Query Processing: Leverages advanced embedding models for intelligent query resolution.
- Payment Integration: Tracks queries and processes payments using Stripe.
- Customizable Models: Easily switch between different NLP and embedding models.
- Secure & Scalable: Built with Flask, with clear configuration and extensibility.
Follow these steps to set up the application locally:
- Install Python (version 3.8 or higher).
- Install
pip
andvirtualenv
for managing dependencies.
-
Clone the repository:
git clone https://github.com/your-username/AskAndPay.git cd AskAndPay
-
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install the dependencies:
pip install -r requirements.txt
-
Set up environment variables:
Create a
.env
file in the project root and add the following:STRIPE_KEY=your-stripe-secret-key MODEL_NAME=llama3-8b-8192 EMBEDDING_MODEL=BAAI/bge-small-en-v1.5 UPLOAD_FOLDER=uploads MAX_FILE_SIZE=10485760
-
Run the application:
python app.py
-
Access the application: Open your browser and navigate to
http://127.0.0.1:5000
.
- File:
simple_usage.ipynb
- Purpose: Simplifies testing the application's core features in a Jupyter Notebook environment.
- How to Use:
- Open the notebook:
jupyter notebook simple_usage.ipynb
- Follow the instructions in the notebook to test:
- File uploads.
- Query processing.
- API interactions.
- Open the notebook:
This is especially useful for developers or testers who want to validate the application quickly without using external tools like Postman.
-
/upload
- Method: POST
- Description: Uploads a file for processing.
- Request:
{ "file": <file> }
- Response:
- Success:
{ "message": "File uploaded and processed successfully" }
- Error:
{ "error": "Error message" }
- Success:
-
/set_sender
- Method: POST
- Description: Sets sender information.
- Request:
{ "sender_email": "user@example.com", "sender_name": "John Doe" }
- Response:
- Success:
{ "customer_id": "cus_12345", "email": "user@example.com" }
- Error:
{ "error": "Error message" }
- Success:
-
/query
- Method: POST
- Description: Handles queries and tracks usage.
- Request:
{ "question": "What is the main topic of the document?" }
- Response:
- Success:
{ "answer": "Response text", "timestamp": "2023-01-01T00:00:00Z" }
- Error:
{ "error": "Error message" }
- Success:
The application includes automated test scripts and a Jupyter Notebook for easy testing.
-
Using Test Script:
- Run the test suite:
python test.py
- View logs to verify test results.
- Run the test suite:
-
Using Jupyter Notebook:
- Open
simple_usage.ipynb
for a guided testing experience.
- Open
AskAndPay/
├── app.py # Main Flask application
├── config.py # Configuration settings
├── test.py # Test suite for API
├── simple_usage.ipynb # Jupyter Notebook for easy testing
├── uploads/ # Directory for uploaded files
├── requirements.txt # Dependency list
├── .env # Environment variables (not included in repo)
├── README.md # Project documentation
Contributions are welcome! To contribute:
- Fork the repository.
- Create a new branch:
git checkout -b feature/your-feature
- Commit your changes:
git commit -m 'Add some feature'
- Push to the branch:
git push origin feature/your-feature
- Open a Pull Request.
This project is licensed under the MIT License. See the LICENSE
file for details.
- Flask for the web framework.
- Stripe for payment integration.
- HuggingFace for embedding models.