This project implements an AI agent that extracts answers from a PDF document using OpenAI's language models and posts the results to a Slack channel.
- PDF text extraction
- Question answering using OpenAI's GPT models
- Slack integration for result posting
- Comprehensive error handling and logging
- Python 3.7+
- OpenAI API key
- Slack Bot Token
- PDF document for analysis
-
Clone the repository:
git clone https://github.com/your-repo/ai-agent.git cd ai-agent
-
Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install dependencies:
pip install -r requirements.txt
-
Configure environment variables: Create a
.env
file in the project root and add the following:OPENAI_API_KEY=your_openai_api_key SLACK_BOT_TOKEN=your_slack_bot_token SLACK_CHANNEL=your_slack_channel_id
-
Configure the application: Update
config/config.yaml
with your desired settings:openai_model: "gpt-4o-mini"
-
Run the main script:
python src/main.py
-
Follow the prompts to enter the PDF file path and questions.
Run unit tests:
pytest tests/
src/
: Contains the main application codepdf_processor.py
: Handles PDF text extractionquestion_answering.py
: Interacts with OpenAI APIslack_notifier.py
: Posts results to Slackmain.py
: Orchestrates the workflow
tests/
: Contains unit testsconfig/
: Configuration filesrequirements.txt
: List of Python dependencies
The application includes comprehensive error handling and logging. Check the application logs for detailed information about any issues encountered during execution.
This project is licensed under the MIT License.