Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -36,9 +36,9 @@ def stream_gemini_response(message_input: str|gr.File, messages: list) -> Iterat
|
|
36 |
user_message = message_input
|
37 |
print(f"\n=== New Request (Text) ===")
|
38 |
print(f"User message: {user_message}")
|
39 |
-
elif isinstance(message_input, gr.
|
40 |
input_file = message_input.name # Access the temporary file path
|
41 |
-
file_type = message_input.
|
42 |
print(f"\n=== New Request (File) ===")
|
43 |
print(f"File uploaded: {input_file}, type: {file_type}")
|
44 |
|
@@ -126,7 +126,7 @@ def stream_gemini_response(message_input: str|gr.File, messages: list) -> Iterat
|
|
126 |
else:
|
127 |
# Stream thinking
|
128 |
thought_buffer += current_chunk
|
129 |
-
print(f"\n=== Thinking Chunk ===\n{
|
130 |
|
131 |
messages[-1] = ChatMessage(
|
132 |
role="assistant",
|
@@ -174,8 +174,7 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="teal", secondary_hue="slate", n
|
|
174 |
placeholder="Type your message here...",
|
175 |
scale=3
|
176 |
)
|
177 |
-
file_upload = gr.File(label="Upload File", file_types=["image", "
|
178 |
-
|
179 |
|
180 |
clear_button = gr.Button("Clear Chat", scale=1)
|
181 |
|
@@ -212,7 +211,7 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="teal", secondary_hue="slate", n
|
|
212 |
queue=False
|
213 |
)
|
214 |
|
215 |
-
gr.Markdown( # Description moved to the bottom
|
216 |
"""
|
217 |
<br><br><br> <!-- Add some vertical space -->
|
218 |
---
|
|
|
36 |
user_message = message_input
|
37 |
print(f"\n=== New Request (Text) ===")
|
38 |
print(f"User message: {user_message}")
|
39 |
+
elif isinstance(message_input, gr.data_classes.File): #gr.File directly should be used with newer gradio versions (v4+)
|
40 |
input_file = message_input.name # Access the temporary file path
|
41 |
+
file_type = message_input.original_name.split('.')[-1].lower() #Get original filename's extension
|
42 |
print(f"\n=== New Request (File) ===")
|
43 |
print(f"File uploaded: {input_file}, type: {file_type}")
|
44 |
|
|
|
126 |
else:
|
127 |
# Stream thinking
|
128 |
thought_buffer += current_chunk
|
129 |
+
print(f"\n=== Thinking Chunk ===\n{current_buffer}")
|
130 |
|
131 |
messages[-1] = ChatMessage(
|
132 |
role="assistant",
|
|
|
174 |
placeholder="Type your message here...",
|
175 |
scale=3
|
176 |
)
|
177 |
+
file_upload = gr.File(label="Upload File", file_types=["image", ".csv"], scale=2) # Allow image and CSV files
|
|
|
178 |
|
179 |
clear_button = gr.Button("Clear Chat", scale=1)
|
180 |
|
|
|
211 |
queue=False
|
212 |
)
|
213 |
|
214 |
+
gr.Markdown( # Description moved to the bottom
|
215 |
"""
|
216 |
<br><br><br> <!-- Add some vertical space -->
|
217 |
---
|