Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -8,8 +8,14 @@ from gradio_multimodalchatbot import MultimodalChatbot
|
|
8 |
from gradio.data_classes import FileData
|
9 |
|
10 |
# For better security practices, retrieve sensitive information like API keys from environment variables.
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
-
#
|
13 |
GOOGLE_API_KEY = os.environ.get('GOOGLE_API_KEY')
|
14 |
genai.configure(api_key=GOOGLE_API_KEY)
|
15 |
|
@@ -80,20 +86,23 @@ def gemini(input, file, chatbot=[]):
|
|
80 |
|
81 |
return chatbot, "", None
|
82 |
|
83 |
-
#
|
84 |
-
|
85 |
-
|
86 |
-
|
|
|
|
|
|
|
|
|
87 |
|
88 |
# Initialize the MultimodalChatbot component
|
89 |
-
multi = MultimodalChatbot(value=[], height=
|
90 |
|
91 |
with gr.Row():
|
92 |
# Textbox for user input with increased scale for better visibility
|
93 |
-
tb = gr.Textbox(scale=4, placeholder='Message CortexChatV...')
|
94 |
-
|
95 |
# Upload button for image files
|
96 |
-
up = gr.UploadButton("Attach File", file_types=["image"], scale=1)
|
97 |
|
98 |
# Define the behavior on text submission
|
99 |
tb.submit(gemini, [tb, up, multi], [multi, tb, up])
|
|
|
8 |
from gradio.data_classes import FileData
|
9 |
|
10 |
# For better security practices, retrieve sensitive information like API keys from environment variables.
|
11 |
+
import google.generativeai as genai
|
12 |
+
import os
|
13 |
+
import PIL.Image
|
14 |
+
import gradio as gr
|
15 |
+
from gradio_multimodalchatbot import MultimodalChatbot
|
16 |
+
from gradio.data_classes import FileData
|
17 |
|
18 |
+
# Retrieve API key from environment variable for security
|
19 |
GOOGLE_API_KEY = os.environ.get('GOOGLE_API_KEY')
|
20 |
genai.configure(api_key=GOOGLE_API_KEY)
|
21 |
|
|
|
86 |
|
87 |
return chatbot, "", None
|
88 |
|
89 |
+
# Custom theme with flexible height for the embedded Gradio component
|
90 |
+
custom_theme = gr.themes.Default().add_class(
|
91 |
+
"gradio-app",
|
92 |
+
"height: 100vh; /* or vh for viewport height */"
|
93 |
+
)
|
94 |
+
|
95 |
+
# Define the Gradio Blocks interface with flexible component heights
|
96 |
+
with gr.Blocks(theme=custom_theme) as demo:
|
97 |
|
98 |
# Initialize the MultimodalChatbot component
|
99 |
+
multi = MultimodalChatbot(value=[], height=250) # Adjust height as needed
|
100 |
|
101 |
with gr.Row():
|
102 |
# Textbox for user input with increased scale for better visibility
|
103 |
+
tb = gr.Textbox(scale=4, placeholder='Message CortexChatV...', height=60) # Adjust height
|
|
|
104 |
# Upload button for image files
|
105 |
+
up = gr.UploadButton("Attach File", file_types=["image"], scale=1, height=40) # Adjust height
|
106 |
|
107 |
# Define the behavior on text submission
|
108 |
tb.submit(gemini, [tb, up, multi], [multi, tb, up])
|