dammy commited on
Commit
868e2fc
·
1 Parent(s): 5f3fdac

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -16
app.py CHANGED
@@ -68,11 +68,19 @@ def run_query(history, query):
68
  ids=ids
69
  )
70
 
 
 
71
 
72
  context = get_context(query, collection)
 
 
 
73
  result = local_query(query, context)
 
74
 
75
  history = history.append(query)
 
 
76
  return history, result
77
 
78
 
@@ -108,12 +116,8 @@ def run_query(history, query):
108
 
109
  def upload_pdf(file):
110
  try:
111
- # Check if the file is not None before accessing its attributes
112
- if file is not None:
113
- # Save the uploaded file
114
  file_name = file.name
115
-
116
- # messsage = load_document(file_name)
117
  return 'Successfully uploaded!'
118
  else:
119
  return "No file uploaded."
@@ -141,7 +145,7 @@ with gr.Blocks() as demo:
141
 
142
  # Event handler for uploading a PDF
143
  btn.upload(fn=upload_pdf, inputs=[btn], outputs=[output])
144
- txt.submit(run_query, [chatbot, txt], [chatbot, txt])
145
  #.then(
146
  # generate_response, inputs =[chatbot,],outputs = chatbot,)
147
 
@@ -150,13 +154,3 @@ with gr.Blocks() as demo:
150
  demo.launch()
151
 
152
 
153
- # iface = gr.Interface(
154
- # fn=upload_pdf,
155
- # inputs="file",
156
- # outputs="text",
157
- # title="PDF File Uploader",
158
- # description="Upload a PDF file and get its filename.",
159
- # )
160
-
161
-
162
-
 
68
  ids=ids
69
  )
70
 
71
+ print('calling get contct function')
72
+ print(collection)
73
 
74
  context = get_context(query, collection)
75
+
76
+ print(context)
77
+ print('calling local query')
78
  result = local_query(query, context)
79
+ print(result)
80
 
81
  history = history.append(query)
82
+
83
+ print(history)
84
  return history, result
85
 
86
 
 
116
 
117
  def upload_pdf(file):
118
  try:
119
+ if file is not None:
 
 
120
  file_name = file.name
 
 
121
  return 'Successfully uploaded!'
122
  else:
123
  return "No file uploaded."
 
145
 
146
  # Event handler for uploading a PDF
147
  btn.upload(fn=upload_pdf, inputs=[btn], outputs=[output])
148
+ txt.submit(run_query, [chatbot, txt], [chatbot,])
149
  #.then(
150
  # generate_response, inputs =[chatbot,],outputs = chatbot,)
151
 
 
154
  demo.launch()
155
 
156