shukdevdatta123 commited on
Commit
d60058e
·
verified ·
1 Parent(s): e6cee82

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -3,10 +3,10 @@ import openai
3
  import fitz # PyMuPDF for PDF processing
4
  import base64
5
 
6
- # Variable to store the API key
7
  api_key = ""
8
 
9
- # Function to update the API key
10
  def set_api_key(key):
11
  global api_key
12
  api_key = key
@@ -87,9 +87,9 @@ def pdf_chat(pdf_file, text_query, temperature, top_p, max_output_tokens):
87
  ]
88
  return query_openai(messages, temperature, top_p, max_output_tokens)
89
 
90
- # Function to clear the chat (Resets input and output)
91
  def clear_chat():
92
- return "", "", "", "", "", "", "", 1.0, 1.0, 1024
93
 
94
  # Gradio UI Layout
95
  with gr.Blocks() as demo:
@@ -140,14 +140,14 @@ with gr.Blocks() as demo:
140
  image_button.click(image_chat, [image_upload, image_text_query, temperature, top_p, max_output_tokens], image_output)
141
  pdf_button.click(pdf_chat, [pdf_upload, pdf_text_query, temperature, top_p, max_output_tokens], pdf_output)
142
 
143
- # Fix: Clear button resets only necessary fields
144
  clear_button.click(
145
  clear_chat,
146
  outputs=[
147
  image_url, image_query, image_url_output,
148
  text_query, text_output,
149
  image_text_query, image_output,
150
- pdf_text_query, pdf_output,
151
  temperature, top_p, max_output_tokens
152
  ]
153
  )
 
3
  import fitz # PyMuPDF for PDF processing
4
  import base64
5
 
6
+ # Variable to store API key
7
  api_key = ""
8
 
9
+ # Function to update API key
10
  def set_api_key(key):
11
  global api_key
12
  api_key = key
 
87
  ]
88
  return query_openai(messages, temperature, top_p, max_output_tokens)
89
 
90
+ # Function to clear the chat (Fix: Returns the correct number of outputs)
91
  def clear_chat():
92
+ return "", "", "", "", "", "", "", None, "", None, "", 1.0, 1.0, 1024
93
 
94
  # Gradio UI Layout
95
  with gr.Blocks() as demo:
 
140
  image_button.click(image_chat, [image_upload, image_text_query, temperature, top_p, max_output_tokens], image_output)
141
  pdf_button.click(pdf_chat, [pdf_upload, pdf_text_query, temperature, top_p, max_output_tokens], pdf_output)
142
 
143
+ # Fix: Clear button resets all necessary fields correctly
144
  clear_button.click(
145
  clear_chat,
146
  outputs=[
147
  image_url, image_query, image_url_output,
148
  text_query, text_output,
149
  image_text_query, image_output,
150
+ pdf_upload, pdf_text_query, pdf_output,
151
  temperature, top_p, max_output_tokens
152
  ]
153
  )