Spaces:
Sleeping
Sleeping
NaimaAqeel
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -4,8 +4,8 @@ from sentence_transformers import SentenceTransformer
|
|
4 |
import faiss
|
5 |
import numpy as np
|
6 |
import pickle
|
7 |
-
from
|
8 |
-
from
|
9 |
import gradio as gr
|
10 |
|
11 |
# Initialize the embedding model
|
@@ -14,7 +14,7 @@ embedding_model = SentenceTransformer('all-MiniLM-L6-v2')
|
|
14 |
# Initialize the HuggingFace LLM
|
15 |
llm = HuggingFaceEndpoint(
|
16 |
endpoint_url="https://api-inference.huggingface.co/models/gpt2",
|
17 |
-
api_key
|
18 |
)
|
19 |
|
20 |
# Initialize the HuggingFace embeddings
|
@@ -112,7 +112,7 @@ def query_text(text):
|
|
112 |
def main():
|
113 |
upload_interface = gr.Interface(
|
114 |
fn=upload_files,
|
115 |
-
inputs=gr.
|
116 |
outputs="text",
|
117 |
title="Upload DOCX Files",
|
118 |
description="Upload DOCX files to process and add to the FAISS index."
|
@@ -143,3 +143,5 @@ if __name__ == "__main__":
|
|
143 |
|
144 |
|
145 |
|
|
|
|
|
|
4 |
import faiss
|
5 |
import numpy as np
|
6 |
import pickle
|
7 |
+
from langchain_community.llms import HuggingFaceEndpoint
|
8 |
+
from langchain_community.embeddings import HuggingFaceEmbeddings
|
9 |
import gradio as gr
|
10 |
|
11 |
# Initialize the embedding model
|
|
|
14 |
# Initialize the HuggingFace LLM
|
15 |
llm = HuggingFaceEndpoint(
|
16 |
endpoint_url="https://api-inference.huggingface.co/models/gpt2",
|
17 |
+
model_kwargs={"api_key": os.getenv('HUGGINGFACEHUB_API_TOKEN')}
|
18 |
)
|
19 |
|
20 |
# Initialize the HuggingFace embeddings
|
|
|
112 |
def main():
|
113 |
upload_interface = gr.Interface(
|
114 |
fn=upload_files,
|
115 |
+
inputs=gr.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."
|
|
|
143 |
|
144 |
|
145 |
|
146 |
+
|
147 |
+
|