Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -41,4 +41,67 @@ def get_top_chunks(query, chunk_embeddings, text_chunks):
|
|
| 41 |
for i in top_indices:
|
| 42 |
top_chunks.append(text_chunks[i])
|
| 43 |
|
| 44 |
-
return top_chunks
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
for i in top_indices:
|
| 42 |
top_chunks.append(text_chunks[i])
|
| 43 |
|
| 44 |
+
return top_chunks
|
| 45 |
+
|
| 46 |
+
def display_iframe():
|
| 47 |
+
return iframe
|
| 48 |
+
def display_image():
|
| 49 |
+
return "https://i.giphy.com/media/v1.Y2lkPTc5MGI3NjExZzdqMnkzcWpjbGhmM3hzcXp0MGpuaTF5djR4bjBxM3Biam5zbzNnMCZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9cw/GxMnTi3hV3qaIgbgQL/giphy.gif"
|
| 50 |
+
theme = gr.themes.Monochrome(
|
| 51 |
+
primary_hue="amber", #okay this did NOT work lmaoo
|
| 52 |
+
secondary_hue="rose",
|
| 53 |
+
).set(
|
| 54 |
+
background_fill_primary='#CBE9A2', # BACKGROUND
|
| 55 |
+
background_fill_primary_dark='#768550',
|
| 56 |
+
background_fill_secondary='#768550', # BUTTON HOVER
|
| 57 |
+
background_fill_secondary_dark='#99a381', #LOADING BAR
|
| 58 |
+
border_color_accent='#768550',
|
| 59 |
+
border_color_accent_dark='#768550',
|
| 60 |
+
border_color_accent_subdued='#768550',
|
| 61 |
+
border_color_primary='#03a9f4',
|
| 62 |
+
block_border_color='#b3e5fc',
|
| 63 |
+
button_primary_background_fill='#768550',
|
| 64 |
+
button_primary_background_fill_dark='#768550'
|
| 65 |
+
)
|
| 66 |
+
|
| 67 |
+
iframe = '''
|
| 68 |
+
<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d193595.2528001417!2d-74.1444872802558!3d40.69763123330436!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x89c24fa5d33f083b%3A0xc80b8f06e177fe62!2sNew%20York%2C%20NY!5e0!3m2!1sen!2sus!4v1722483445443!5m2!1sen!2sus" width="600" height="450" style="border:0;" allowfullscreen="" loading="lazy" referrerpolicy="no-referrer-when-downgrade"></iframe>
|
| 69 |
+
'''
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
# Define the welcome message and specific topics the chatbot can provide information about
|
| 73 |
+
welcome_message = """
|
| 74 |
+
# 🌱 Welcome to GreenGuide!
|
| 75 |
+
## Your AI-driven assistant for all eco-friendly travel-related queries in NYC. Created by Eva, Amy, and Ambur of the 2024 Kode With Klossy NYC AI/ML Camp.
|
| 76 |
+
## ... and updated by Ambur for the virtual 2026 KWK AI/ML IA Camp!
|
| 77 |
+
### wow, what a lot of acronyms!
|
| 78 |
+
"""
|
| 79 |
+
|
| 80 |
+
topics = """
|
| 81 |
+
### Feel free to ask me anything things to do in the city!
|
| 82 |
+
- Hotels (affordable, luxury)
|
| 83 |
+
- Restaurants (regular, vegetarian, vegan)
|
| 84 |
+
- Parks & Gardens
|
| 85 |
+
- Thrift Stores
|
| 86 |
+
- Attractions
|
| 87 |
+
"""
|
| 88 |
+
|
| 89 |
+
# Setup the Gradio Blocks interface with custom layout components
|
| 90 |
+
with gr.Blocks(theme=theme) as demo:
|
| 91 |
+
gr.Image("header2.png", show_label = False, show_share_button = False, show_download_button = False) #CHANGE !!
|
| 92 |
+
gr.Markdown(welcome_message) # Display the formatted welcome message
|
| 93 |
+
with gr.Row():
|
| 94 |
+
with gr.Column():
|
| 95 |
+
gr.Markdown(topics) # Show the topics on the left side
|
| 96 |
+
with gr.Row():
|
| 97 |
+
with gr.Column():
|
| 98 |
+
question = gr.Textbox(label="Your question", placeholder="What do you want to ask about?")
|
| 99 |
+
answer = gr.Textbox(label="GreenGuide Response", placeholder="GreenGuide will respond here...", interactive=False, lines=10)
|
| 100 |
+
submit_button = gr.Button("Submit")
|
| 101 |
+
submit_button.click(fn=query_model, inputs=question, outputs=answer)
|
| 102 |
+
|
| 103 |
+
gr.HTML(iframe)
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
# Launch the Gradio app to allow user interaction
|
| 107 |
+
demo.launch()
|