Update app.py
Browse files
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 |
-
#
|
| 16 |
-
chatbot = pipeline("text-generation", model="
|
| 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
|
| 23 |
-
-
|
| 24 |
-
-
|
| 25 |
-
-
|
| 26 |
-
-
|
| 27 |
-
-
|
| 28 |
"""
|
| 29 |
|
| 30 |
-
response = chatbot(prompt, max_length=
|
| 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
|