ameursg commited on
Commit
d603dc2
Β·
verified Β·
1 Parent(s): 0bce549

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -11
app.py CHANGED
@@ -12,22 +12,34 @@ if HF_TOKEN:
12
  else:
13
  raise ValueError("🚨 Hugging Face token not found! Please add it to Secrets in your Hugging Face Space.")
14
 
15
- # Use Phi-2 (optimized for free-tier)
16
- chatbot = pipeline("text-generation", model="microsoft/phi-2", token=HF_TOKEN)
 
 
 
 
 
17
 
18
  def generate_itinerary(destination, start_date, end_date, traveler_type, companion):
19
  """Generates an AI-powered travel itinerary based on user preferences"""
20
-
21
  prompt = f"""
22
- You are an AI travel assistant. Generate a detailed itinerary for {destination}.
23
- - Dates: {start_date} to {end_date}
24
- - Traveler type: {traveler_type}
25
- - Companion: {companion}
26
- - Provide 3 activities per day (Morning, Afternoon, Night)
27
- - Keep responses short and optimized for fast generation.
 
 
 
 
 
 
 
28
  """
29
-
30
- response = chatbot(prompt, max_length=200, do_sample=True, temperature=0.7, top_p=0.9)
31
  return response[0]['generated_text']
32
 
33
  # Creating a simple user interface
 
12
  else:
13
  raise ValueError("🚨 Hugging Face token not found! Please add it to Secrets in your Hugging Face Space.")
14
 
15
+ # Load AI model (optimized for T4 Small GPU)
16
+ chatbot = pipeline(
17
+ "text-generation",
18
+ model="mistralai/Mistral-7B-Instruct-v0.1",
19
+ token=HF_TOKEN,
20
+ device=0 # Runs on GPU
21
+ )
22
 
23
  def generate_itinerary(destination, start_date, end_date, traveler_type, companion):
24
  """Generates an AI-powered travel itinerary based on user preferences"""
25
+
26
  prompt = f"""
27
+ You are a professional travel assistant. Create a **day-by-day itinerary** for a trip to {destination}.
28
+ - πŸ“… **Dates**: {start_date} to {end_date}
29
+ - 🎭 **Traveler Type**: {traveler_type}
30
+ - 🧳 **Companion**: {companion}
31
+ - Provide **3 activities per day**: πŸŒ… Morning, β˜€οΈ Afternoon, πŸŒ™ Night.
32
+ - Include **real attractions, famous landmarks, hidden gems, and local experiences**.
33
+ - Keep responses **structured, short, and engaging**.
34
+
35
+ πŸ“Œ **Example Format**:
36
+ **Day 1**:
37
+ - πŸŒ… **Morning**: Visit [Famous Landmark] in {destination}
38
+ - β˜€οΈ **Afternoon**: Try [Local Food] at [Best Restaurant]
39
+ - πŸŒ™ **Night**: Experience [Cultural/Nightlife Activity]
40
  """
41
+
42
+ response = chatbot(prompt, max_length=300, do_sample=True, temperature=0.6, top_p=0.85)
43
  return response[0]['generated_text']
44
 
45
  # Creating a simple user interface