rahul7star commited on
Commit
53f5d13
·
verified ·
1 Parent(s): 5d19a94

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -0
app.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ def generate_itinerary(destination, days, interests):
4
+ """
5
+ Generate a travel itinerary using GPT-2 from Hugging Face.
6
+ """
7
+ prompt = (f"Create a {days}-day travel itinerary for {destination}. "
8
+ f"Focus on activities related to {', '.join(interests)}. "
9
+ "Include a list of daily activities, landmarks, restaurants, and other travel suggestions.")
10
+
11
+ # Generate itinerary using GPT-2
12
+ itinerary = generator(prompt, max_length=300, num_return_sequences=1)
13
+
14
+ # Return the generated text
15
+ return itinerary[0]['generated_text'].strip()
16
+
17
+ def ai_travel_agent(destination, days, interests):
18
+ """
19
+ Process user input and generate a travel itinerary.
20
+ """
21
+ interests_list = interests.split(",") # Convert comma-separated string to list
22
+ return generate_itinerary(destination, days, interests_list)
23
+
24
+ # Create the Gradio interface
25
+ interface = gr.Interface(
26
+ fn=ai_travel_agent,
27
+ inputs=[
28
+ gr.Textbox(label="Destination", placeholder="Enter a city or country"),
29
+ gr.Slider(label="Number of Days", minimum=1, maximum=14, step=1, value=3),
30
+ gr.Textbox(label="Interests", placeholder="E.g., adventure, food, culture")
31
+ ],
32
+ outputs="textbox",
33
+ title="AI Travel Itinerary Generator",
34
+ description="Plan your next trip with AI! Enter your destination, duration, and interests, and get a personalized travel itinerary."
35
+ )
36
+
37
+ # Launch the interface
38
+ interface.launch()