Spaces:
Sleeping
Sleeping
Upload 5 files
Browse files- .gitignore +2 -0
- READM.md +53 -0
- app.py +80 -0
- documentation.docx +0 -0
- requirements.txt +4 -0
.gitignore
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Ignore virtual environments
|
| 2 |
+
myenv/
|
READM.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Travel-Itinerary-Project
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
# AI-Powered Travel Planner ποΈβοΈ
|
| 5 |
+
|
| 6 |
+
An AI-driven travel itinerary generator that creates customized travel plans based on user preferences, budget, and duration. This app uses **Streamlit**, **Hugging face**, and **Wikipedia API** to provide detailed travel recommendations.
|
| 7 |
+
|
| 8 |
+
## π Features
|
| 9 |
+
- Generates multi-day travel itineraries based on user input.
|
| 10 |
+
- Suggests **famous attractions, hidden gems, food spots, and accommodations**.
|
| 11 |
+
- Includes **transportation options, cultural experiences, and local events**.
|
| 12 |
+
- Fetches relevant travel information from **Wikipedia**.
|
| 13 |
+
- Simple **Streamlit UI** for easy interaction.
|
| 14 |
+
|
| 15 |
+
## π οΈ Technologies & Libraries Used
|
| 16 |
+
- **Python**: Core programming language
|
| 17 |
+
- **Streamlit**: Web-based UI framework
|
| 18 |
+
- **Hugging face**: LLaMA 3.2:1B model for itinerary generation
|
| 19 |
+
- **Requests**: API calls to fetch travel information
|
| 20 |
+
- **Wikipedia API**: Fetches destination details
|
| 21 |
+
|
| 22 |
+
## π― How It Works
|
| 23 |
+
1. User enters **starting location, destination, budget, trip duration, purpose, and preferences**.
|
| 24 |
+
2. The app **fetches information** from Wikipedia about the destination.
|
| 25 |
+
3. A **detailed itinerary** is generated using **Ollama (LLaMA 3.2:1B)**.
|
| 26 |
+
4. The AI-generated travel plan is displayed in the **Streamlit UI**.
|
| 27 |
+
|
| 28 |
+
## π Installation Guide
|
| 29 |
+
|
| 30 |
+
### 1οΈβ£ Clone the Repository
|
| 31 |
+
```sh
|
| 32 |
+
git clone https://github.com/karthi311/Traven-Itinerary-Project.git
|
| 33 |
+
cd Traven-Itinerary-Project
|
| 34 |
+
```
|
| 35 |
+
|
| 36 |
+
### 2οΈβ£ Install Dependencies
|
| 37 |
+
|
| 38 |
+
Make sure you have Python 3.8+ installed. Then, run:
|
| 39 |
+
```sh
|
| 40 |
+
pip install -r requirements.txt
|
| 41 |
+
```
|
| 42 |
+
|
| 43 |
+
### 4οΈβ£ Run the Streamlit App
|
| 44 |
+
|
| 45 |
+
Start the app using:
|
| 46 |
+
|
| 47 |
+
```sh
|
| 48 |
+
streamlit run main.py
|
| 49 |
+
```
|
| 50 |
+
|
| 51 |
+
## π License
|
| 52 |
+
|
| 53 |
+
This project is open-source. Feel free to modify and improve it!
|
app.py
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import requests
|
| 3 |
+
import torch
|
| 4 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 5 |
+
|
| 6 |
+
# Load Hugging Face Model
|
| 7 |
+
tokenizer = AutoTokenizer.from_pretrained("unsloth/Llama-3.2-1B", trust_remote_code=True)
|
| 8 |
+
model = AutoModelForCausalLM.from_pretrained("unsloth/Llama-3.2-1B", trust_remote_code=True)
|
| 9 |
+
|
| 10 |
+
def generate_text(prompt):
|
| 11 |
+
inputs = tokenizer(prompt, return_tensors="pt", padding=True, truncation=True, max_length=1024)
|
| 12 |
+
with torch.no_grad():
|
| 13 |
+
outputs = model.generate(**inputs, max_length=1024, pad_token_id=tokenizer.eos_token_id)
|
| 14 |
+
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 15 |
+
|
| 16 |
+
# Function to fetch Wikipedia summary
|
| 17 |
+
def search_travel_info(destination):
|
| 18 |
+
url = f"https://en.wikipedia.org/api/rest_v1/page/summary/{destination}"
|
| 19 |
+
response = requests.get(url)
|
| 20 |
+
if response.status_code == 200:
|
| 21 |
+
data = response.json()
|
| 22 |
+
return data.get("extract", "No information found.")
|
| 23 |
+
return "No results found."
|
| 24 |
+
|
| 25 |
+
# Function to generate travel itinerary
|
| 26 |
+
def generate_itinerary(start_location, budget, duration, destination, purpose, preferences):
|
| 27 |
+
search_results = search_travel_info(destination)
|
| 28 |
+
|
| 29 |
+
# System Prompt
|
| 30 |
+
system_prompt = "You are an expert travel guide. Your goal is to create a well-structured, detailed itinerary based on the user's preferences."
|
| 31 |
+
|
| 32 |
+
# User Prompt
|
| 33 |
+
user_prompt = f"""
|
| 34 |
+
{system_prompt}
|
| 35 |
+
|
| 36 |
+
### π·οΈ **Traveler Information**:
|
| 37 |
+
- **Budget**: {budget}
|
| 38 |
+
- **Purpose of Travel**: {purpose}
|
| 39 |
+
- **Preferences**: {preferences}
|
| 40 |
+
|
| 41 |
+
### π **Day-wise Itinerary**:
|
| 42 |
+
- π Day-by-day activities, including morning, afternoon, and evening plans
|
| 43 |
+
- π Must-visit attractions (famous landmarks + hidden gems)
|
| 44 |
+
- π½οΈ Local cuisines and top dining recommendations
|
| 45 |
+
- π¨ Best places to stay (based on budget)
|
| 46 |
+
- π Transportation options (from {start_location} to {destination} and local travel)
|
| 47 |
+
|
| 48 |
+
### π **Additional Considerations**:
|
| 49 |
+
- π Cultural experiences, festivals, or seasonal events
|
| 50 |
+
- ποΈ Shopping and souvenir recommendations
|
| 51 |
+
- πΉ Safety tips, best times to visit, and local customs
|
| 52 |
+
- πΊοΈ Alternative plans for bad weather days
|
| 53 |
+
|
| 54 |
+
### βΉοΈ **Additional Information from External Sources**:
|
| 55 |
+
{search_results}
|
| 56 |
+
|
| 57 |
+
Make sure the itinerary is engaging, practical, and customized based on the userβs budget and preferences.
|
| 58 |
+
"""
|
| 59 |
+
|
| 60 |
+
# Generate Response
|
| 61 |
+
return generate_text(user_prompt)
|
| 62 |
+
|
| 63 |
+
# Streamlit UI
|
| 64 |
+
st.title("AI-Powered Travel Planner")
|
| 65 |
+
st.write("Plan your next trip with AI!")
|
| 66 |
+
|
| 67 |
+
start_location = st.text_input("Starting Location")
|
| 68 |
+
destination = st.text_input("Destination")
|
| 69 |
+
budget = st.selectbox("Select Budget", ["Low", "Moderate", "Luxury"])
|
| 70 |
+
duration = st.number_input("Trip Duration (days)", min_value=1, max_value=30, value=3)
|
| 71 |
+
purpose = st.text_area("Purpose of Trip")
|
| 72 |
+
preferences = st.text_area("Your Preferences (e.g., adventure, food, history)")
|
| 73 |
+
|
| 74 |
+
if st.button("Generate Itinerary"):
|
| 75 |
+
if start_location and destination and purpose and preferences:
|
| 76 |
+
itinerary = generate_itinerary(start_location, budget, duration, destination, purpose, preferences)
|
| 77 |
+
st.subheader("Your AI-Generated Itinerary:")
|
| 78 |
+
st.write(itinerary)
|
| 79 |
+
else:
|
| 80 |
+
st.warning("Please fill in all fields.")
|
documentation.docx
ADDED
|
Binary file (17.9 kB). View file
|
|
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
streamlit
|
| 2 |
+
transformers>=4.35.0
|
| 3 |
+
torch
|
| 4 |
+
requests
|