NaimaAqeel commited on
Commit
1cace6b
·
verified ·
1 Parent(s): 8d36878

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -15
app.py CHANGED
@@ -4,9 +4,8 @@ from sentence_transformers import SentenceTransformer
4
  import faiss
5
  import numpy as np
6
  import pickle
7
- from langchain_community.llms import HuggingFaceEndpoint
8
- from langchain_community.vectorstores import FAISS
9
- from langchain_community.embeddings import HuggingFaceEmbeddings
10
  import gradio as gr
11
 
12
  # Initialize the embedding model
@@ -110,19 +109,25 @@ def query_text(text):
110
  print(f"Error querying text: {e}")
111
  return f"Error querying text: {e}"
112
 
113
- # Sample Gradio integration (for illustration)
114
  def main():
115
- gr.Interface(
116
- [
117
- upload_files,
118
- query_text
119
- ],
120
- [
121
- "files",
122
- "text"
123
- ],
124
- "text"
125
- ).launch()
 
 
 
 
 
 
 
126
 
127
  if __name__ == "__main__":
128
  main()
@@ -136,3 +141,4 @@ if __name__ == "__main__":
136
 
137
 
138
 
 
 
4
  import faiss
5
  import numpy as np
6
  import pickle
7
+ from langchain_huggingface.llms import HuggingFaceEndpoint
8
+ from langchain_huggingface.embeddings import HuggingFaceEmbeddings
 
9
  import gradio as gr
10
 
11
  # Initialize the embedding model
 
109
  print(f"Error querying text: {e}")
110
  return f"Error querying text: {e}"
111
 
 
112
  def main():
113
+ upload_interface = gr.Interface(
114
+ fn=upload_files,
115
+ inputs=gr.inputs.File(file_count="multiple", label="Upload DOCX files"),
116
+ outputs="text",
117
+ title="Upload DOCX Files",
118
+ description="Upload DOCX files to process and add to the FAISS index."
119
+ )
120
+
121
+ query_interface = gr.Interface(
122
+ fn=query_text,
123
+ inputs="text",
124
+ outputs="text",
125
+ title="Query Text",
126
+ description="Query the indexed text and get answers from the language model."
127
+ )
128
+
129
+ demo = gr.TabbedInterface([upload_interface, query_interface], ["Upload Files", "Query Text"])
130
+ demo.launch()
131
 
132
  if __name__ == "__main__":
133
  main()
 
141
 
142
 
143
 
144
+