This repository contains a Laravel application that leverages Laravel Prism and Spatie's PDF-to-Text packages to create an AI chatbot capable of answering questions about PDF documents.
- PDF Parsing: Extract text from PDFs using Spatie's pdf-to-text library.
- AI Chat Integration: Use Laravel Prism to power AI-driven question-answering capabilities.
Before you begin, ensure you have the following installed:
- PHP 8.2 or higher
- Composer
- Laravel ^11.31
- A PDF parsing tool (default:
pdftotext
)
Note: For PDF parsing,
pdftotext
must be installed on your server. Installation Guide
-
Clone the repository:
git clone https://github.com/cvtmal/chatPDF cd chatPDF
-
Install dependencies:
composer install npm install && npm run dev
-
Set up environment variables: Copy
.env.example
to.env
and configure your database and other settings:cp .env.example .env
Update the following variables in the
.env
file:OPENAI_URL= OPENAI_API_KEY= OPENAI_ORGANIZATION= ANTHROPIC_API_KEY= ANTHROPIC_API_VERSION= OLLAMA_URL= MISTRAL_API_KEY= MISTRAL_URL= GROQ_API_KEY= GROQ_URL= XAI_API_KEY= XAI_URL= GEMINI_API_KEY= GEMINI_URL= SERPS_API_KEY=
-
Generate application key:
php artisan key:generate
-
Run migrations:
php artisan migrate
-
Start the application:
php artisan serve
Visit the application at
http://localhost:8000
.
- Upload a PDF document using the interface.
- Ask questions related to the uploaded PDF.
- The chatbot will provide AI-driven answers based on the content of the PDF.
Ensure that your Laravel Prism configuration is set up correctly. Refer to the Laravel Prism Documentation for setup instructions.
The package uses the pdftotext
binary to extract text from PDFs. Verify that pdftotext
is correctly installed on your system and accessible in the PATH.
Run the test suite to ensure everything is working as expected:
php artisan test
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a feature branch.
- Commit your changes.
- Push to the branch.
- Open a pull request.
This project is open-sourced software licensed under the MIT license.
The Laravel framework is open-sourced software licensed under the MIT license.