ameursg commited on
Commit
cb2beda
Β·
verified Β·
1 Parent(s): 1126f99

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -0
app.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load Mistral-7B-Instruct AI model
5
+ chatbot = pipeline("text-generation", model="mistralai/Mistral-7B-Instruct-v0.1")
6
+
7
+ def generate_itinerary(destination, start_date, end_date, traveler_type, companion):
8
+ """Generates an AI-powered travel itinerary based on user preferences"""
9
+
10
+ prompt = f"""
11
+ You are a travel assistant. Generate a detailed day-by-day itinerary for a trip to {destination}.
12
+ - Trip Duration: {start_date} to {end_date}
13
+ - Type of traveler: {traveler_type}
14
+ - Traveling with: {companion}
15
+ - Each day should have 3 activities for morning, afternoon, and night.
16
+ - Provide unique local recommendations based on the traveler's interests.
17
+ """
18
+
19
+ response = chatbot(prompt, max_length=1000, do_sample=True)
20
+ return response[0]['generated_text']
21
+
22
+ # Creating a simple user interface
23
+ interface = gr.Interface(
24
+ fn=generate_itinerary,
25
+ inputs=[
26
+ gr.Textbox(label="Destination"),
27
+ gr.Textbox(label="Start Date (YYYY-MM-DD)"),
28
+ gr.Textbox(label="End Date (YYYY-MM-DD)"),
29
+ gr.Dropdown(["Art", "Food", "Nature", "Culture", "Nightlife"], label="Traveler Type"),
30
+ gr.Dropdown(["Alone", "With Family", "With Friends", "With Partner"], label="Companion Type"),
31
+ ],
32
+ outputs="text",
33
+ title="✈️ AI Travel Assistant",
34
+ description="Enter your details, and let AI plan your perfect trip!"
35
+ )
36
+
37
+ interface.launch()