Update app.py
Browse files
app.py
CHANGED
|
@@ -8,6 +8,55 @@ API_KEY = os.getenv("Gemini_API_Key") # Ensure to set this in Hugging Face Secr
|
|
| 8 |
client = genai.Client(api_key=API_KEY)
|
| 9 |
MODEL_ID = "gemini-2.0-flash" # Replace with your desired model ID
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
def google_search_query(question):
|
| 12 |
try:
|
| 13 |
# Define the Google Search Tool
|
|
@@ -32,6 +81,7 @@ def google_search_query(question):
|
|
| 32 |
app = gr.Interface(
|
| 33 |
fn=google_search_query,
|
| 34 |
inputs=gr.Textbox(lines=2, label="Ask a Question"),
|
|
|
|
| 35 |
outputs=[
|
| 36 |
gr.Textbox(label="AI Response"),
|
| 37 |
gr.HTML(label="Search Results"),
|
|
|
|
| 8 |
client = genai.Client(api_key=API_KEY)
|
| 9 |
MODEL_ID = "gemini-2.0-flash" # Replace with your desired model ID
|
| 10 |
|
| 11 |
+
custom_ui = """
|
| 12 |
+
<style>
|
| 13 |
+
#search-btn {
|
| 14 |
+
background-color: #4f46e5;
|
| 15 |
+
color: white;
|
| 16 |
+
border: none;
|
| 17 |
+
padding: 12px 20px;
|
| 18 |
+
font-size: 16px;
|
| 19 |
+
border-radius: 10px;
|
| 20 |
+
cursor: pointer;
|
| 21 |
+
transition: opacity 0.6s ease, transform 0.2s ease;
|
| 22 |
+
display: flex;
|
| 23 |
+
align-items: center;
|
| 24 |
+
gap: 8px;
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
#search-btn:hover {
|
| 28 |
+
background-color: #4338ca;
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
#search-btn.fade {
|
| 32 |
+
opacity: 0.5;
|
| 33 |
+
transform: scale(0.97);
|
| 34 |
+
}
|
| 35 |
+
</style>
|
| 36 |
+
|
| 37 |
+
<button id="search-btn">
|
| 38 |
+
🔍 Search
|
| 39 |
+
</button>
|
| 40 |
+
|
| 41 |
+
<audio id="clap-sound">
|
| 42 |
+
<source src="https://www.soundjay.com/human/applause-8.mp3" type="audio/mpeg">
|
| 43 |
+
</audio>
|
| 44 |
+
|
| 45 |
+
<script>
|
| 46 |
+
const btn = document.getElementById("search-btn");
|
| 47 |
+
const clap = document.getElementById("clap-sound");
|
| 48 |
+
|
| 49 |
+
btn.addEventListener("click", () => {
|
| 50 |
+
clap.play();
|
| 51 |
+
btn.classList.add("fade");
|
| 52 |
+
|
| 53 |
+
setTimeout(() => {
|
| 54 |
+
btn.classList.remove("fade");
|
| 55 |
+
}, 1200);
|
| 56 |
+
});
|
| 57 |
+
</script>
|
| 58 |
+
"""
|
| 59 |
+
|
| 60 |
def google_search_query(question):
|
| 61 |
try:
|
| 62 |
# Define the Google Search Tool
|
|
|
|
| 81 |
app = gr.Interface(
|
| 82 |
fn=google_search_query,
|
| 83 |
inputs=gr.Textbox(lines=2, label="Ask a Question"),
|
| 84 |
+
gr.HTML(custom_ui),
|
| 85 |
outputs=[
|
| 86 |
gr.Textbox(label="AI Response"),
|
| 87 |
gr.HTML(label="Search Results"),
|