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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -9
app.py CHANGED
@@ -12,22 +12,22 @@ 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
- # Load a smaller AI model that fits within 16GB memory
16
- chatbot = pipeline("text-generation", model="mistralai/Mistral-7B-8Bit", 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 a travel assistant. Generate a detailed day-by-day itinerary for a trip to {destination}.
23
- - Trip Duration: {start_date} to {end_date}
24
- - Type of traveler: {traveler_type}
25
- - Traveling with: {companion}
26
- - Each day should have 3 activities for morning, afternoon, and night.
27
- - Provide unique local recommendations based on the traveler's interests.
28
  """
29
 
30
- response = chatbot(prompt, max_length=150, 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
+ # 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