aiqcamp commited on
Commit
5fa1c3b
·
verified ·
1 Parent(s): 77104eb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -6
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.utils.SerializableData): #gr.File directly won't be recognized correctly after gr v4.x, use SerializableData instead.
40
  input_file = message_input.name # Access the temporary file path
41
- file_type = message_input.orig_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,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{current_chunk}")
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", "file"], scale=2) # Allow image and any file type
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 - unchanged
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
  ---