Added my contributions to community-contributions-RAG

This commit is contained in:
Maryam Mouzarani
2025-05-11 10:31:32 +02:00
parent 06fb950d9f
commit 4736625e43
4 changed files with 170 additions and 0 deletions

View File

@@ -0,0 +1,67 @@
# Tourist Assistant
An interactive voice-enabled tourist guide that provides information about cities, landmarks, and destinations worldwide. This application uses OpenAI's GPT models for text generation and speech features for a natural conversation experience, along with RAG capabilities and Google Places API integration for real-time attraction information.
![Tourist Assistant Screenshot](travel.jpg)
## Features
- Text-based chat interface for asking questions about tourist destinations
- Voice input capability through microphone recording
- Audio responses using OpenAI's text-to-speech technology
- Clean, responsive user interface with Gradio
- RAG (Retrieval-Augmented Generation) system using PDF knowledge base
- Google Places API integration for real-time information about attractions
- Set current location for contextual queries
- Quick access to nearby attractions information
## Requirements
- Python 3.9+
- OpenAI API key
- Google Places API key (optional, for location search features)
## Installation
1. Clone this repository
2. Install the required dependencies:
```
pip install -r requirements.txt
```
3. Create a `.env` file in the project directory with your API keys:
```
OPENAI_API_KEY=your_openai_api_key_here
GOOGLE_PLACES_API_KEY=your_google_places_api_key_here
```
4. (Optional) Add PDF files to the `knowledge-base/` directory to enhance the assistant's knowledge about specific locations
## Running the Application
Start the application by running:
```bash
python tourist-assistant.py
```
The interface will automatically open in your default web browser. If it doesn't, navigate to the URL shown in the terminal (typically http://127.0.0.1:7860/).
## Usage
1. Type your question about any tourist destination in the text box
2. Or click the microphone button and speak your question
3. The assistant will respond with text and spoken audio
4. Set your current location using the "Set Location" feature
5. Click "Nearby Attractions" to get information about attractions near your current location
6. Use the "Refresh Knowledge Base" button to reload PDFs in the knowledge-base directory
7. Use the "Clear" button to start a new conversation
## Technologies Used
- OpenAI GPT-4o Mini for chat completions
- OpenAI Whisper for speech-to-text
- OpenAI TTS for text-to-speech
- Langchain for RAG implementation
- FAISS for vector storage
- Google Places API for location-based attraction information
- Gradio for the web interface
- pydub for audio processing

View File

@@ -0,0 +1,11 @@
openai>=1.0.0
gradio>=4.0.0
python-dotenv>=1.0.0
pydub>=0.25.1
pypdf>=4.0.0
langchain>=0.1.0
langchain-openai>=0.0.5
langchain-community>=0.0.13
faiss-cpu>=1.7.4
tiktoken>=0.5.2
requests>=2.31.0

View File

@@ -0,0 +1,92 @@
/* Styling for Tourist Assistant */
.container {
max-width: 850px;
margin: auto;
background-color: rgba(255, 255, 255, 0.95);
padding: 20px;
border-radius: 15px;
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}
.title {
text-align: center;
font-size: 2.5rem !important;
margin-bottom: 0.5rem;
color: #2563EB;
font-weight: 600;
}
.subtitle {
text-align: center;
font-size: 1.1rem !important;
margin-bottom: 1.5rem;
color: #4B5563;
}
.footer {
text-align: center;
margin-top: 1rem;
color: #6B7280;
font-size: 0.9rem !important;
}
.mic-container {
text-align: center;
margin: 1rem auto;
}
.clear-button {
max-width: 120px;
margin-left: auto;
}
.chatbot-container {
border-radius: 10px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
background-color: white;
}
/* Styling for the microphone button */
#mic-btn {
width: 150px !important;
margin: 0 auto !important;
}
#mic-btn .wrap {
display: flex;
justify-content: center;
}
/* Make the mic button more prominent and attractive */
#mic-btn button.record-button {
width: 60px !important;
height: 60px !important;
border-radius: 50% !important;
background-color: #3B82F6 !important;
color: white !important;
font-size: 24px !important;
display: flex !important;
align-items: center !important;
justify-content: center !important;
margin: 0 auto !important;
border: none !important;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1) !important;
transition: all 0.2s ease !important;
margin-bottom: 10px !important;
}
#mic-btn button.record-button:hover {
transform: scale(1.05) !important;
box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15) !important;
}
/* Hide the audio controls */
#mic-btn .audio-controls {
display: none !important;
}
/* Hide the audio playback */
#mic-btn audio {
display: none !important;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB