https://github.com/pakagronglb/python-rag-agent-pydantic-ai
A powerful property information assistant built with Python, OpenAI, and LanceDB that uses Retrieval Augmented Generation (RAG) to answer questions about property listings.
https://github.com/pakagronglb/python-rag-agent-pydantic-ai
lancedb openai pydantic pydantic-ai python rag streamlit
Last synced: 4 months ago
JSON representation
A powerful property information assistant built with Python, OpenAI, and LanceDB that uses Retrieval Augmented Generation (RAG) to answer questions about property listings.
- Host: GitHub
- URL: https://github.com/pakagronglb/python-rag-agent-pydantic-ai
- Owner: pakagronglb
- Created: 2025-03-03T00:34:25.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-03-03T01:25:37.000Z (7 months ago)
- Last Synced: 2025-03-03T01:27:49.643Z (7 months ago)
- Topics: lancedb, openai, pydantic, pydantic-ai, python, rag, streamlit
- Language: Python
- Homepage:
- Size: 0 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 🏠 Property Information RAG Assistant
A powerful property information assistant built with Python, OpenAI, and LanceDB that uses Retrieval Augmented Generation (RAG) to answer questions about property listings.
[](https://www.python.org/)
[](https://openai.com/)
[](https://lancedb.com/)
[](https://streamlit.io/)
[](https://pydantic.dev/)## 🚀 Features
- **Vector Search**: Fast and accurate semantic search using LanceDB and OpenAI embeddings
- **Conversational UI**: Clean user interface built with Streamlit
- **Rich Property Information**: Query details about properties, including:
- Pet policies (allowed pets, fees, weight limits)
- Location information
- Amenities and features
- Pricing details
- **Intelligent Query Understanding**: Converts natural language questions into optimized search queries
- **Well-formatted Responses**: Clear, structured answers with relevant property details## 📋 Table of Contents
- [Installation](#installation)
- [Usage](#usage)
- [Project Structure](#project-structure)
- [How It Works](#how-it-works)
- [Credits](#credits)
- [License](#license)## 🔧 Installation
1. Clone the repository:
```bash
git clone http://www.github.com/pakagronglb/python-rag-agent-pydantic-ai
cd python-rag-agent-pantic-ai
```2. Create and activate a virtual environment:
```bash
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
```3. Install the required packages:
```bash
pip install -r requirements.txt
```4. Set up your OpenAI API key in a `.env` file:
```
OPENAI_API_KEY=your_api_key_here
```## 💻 Usage
1. Run the setup script to initialize the knowledge base:
```bash
python lancedb_setup.py
```2. Launch the Streamlit web interface:
```bash
python -m streamlit run app.py
```3. Open your browser and navigate to:
```
http://localhost:8501
```4. Enter your property-related questions in the input field and click "Search"
## 🏗️ Project Structure
- `app.py`: Streamlit web interface
- `agent_run.py`: Command-line version of the query agent
- `lancedb_setup.py`: Knowledge base setup and vector database operations
- `knowledge-file/`: Directory containing markdown property information files## ⚙️ How It Works
1. **Data Ingestion**: Property information is stored as markdown files in the `knowledge-file` directory
2. **Vector Embedding**: The text is chunked and embedded using OpenAI's text-embedding-3-small model
3. **Query Processing**: User queries are converted to optimized search queries using an LLM
4. **Vector Search**: LanceDB retrieves the most semantically similar documents
5. **Response Generation**: An LLM generates a well-formatted response based on the retrieved context## 🙏 Credits
This project was inspired by [Jie Jenn's YouTube tutorial](https://www.youtube.com/watch?v=P212vYt6Xo8) on building RAG applications with Python. His clear explanations and practical approach were instrumental in creating this application.
## 📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🏠 Property Information Assistant
[Header]Ask a Question
[Input Form with background]
[Full-width Search button]📝 Response
[Response area with background]