Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,10 @@
|
|
1 |
import gradio as gr
|
2 |
from huggingface_hub import InferenceClient, login
|
|
|
|
|
3 |
import os
|
|
|
|
|
4 |
"""
|
5 |
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|
6 |
"""
|
@@ -8,6 +12,14 @@ login(token=os.getenv('TOKEN'))
|
|
8 |
client = InferenceClient("meta-llama/Llama-3.2-1B-Instruct")
|
9 |
#client = InferenceClient("mistralai/Mistral-7B-Instruct-v0.3")
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
def respond(
|
12 |
message,
|
13 |
history: list[tuple[str, str]],
|
|
|
1 |
import gradio as gr
|
2 |
from huggingface_hub import InferenceClient, login
|
3 |
+
from langchain_community.vectorstores import FAISS
|
4 |
+
from langchain_huggingface import HuggingFaceEmbeddings
|
5 |
import os
|
6 |
+
|
7 |
+
|
8 |
"""
|
9 |
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|
10 |
"""
|
|
|
12 |
client = InferenceClient("meta-llama/Llama-3.2-1B-Instruct")
|
13 |
#client = InferenceClient("mistralai/Mistral-7B-Instruct-v0.3")
|
14 |
|
15 |
+
folder = snapshot_download(repo_id="umaiku/faiss_index", repo_type="dataset", local_dir=os.getcwd())
|
16 |
+
|
17 |
+
embeddings = HuggingFaceEmbeddings(model_name="intfloat/multilingual-e5-small")
|
18 |
+
|
19 |
+
vector_db = FAISS.load_local("faiss_index", embeddings, allow_dangerous_deserialization=True)
|
20 |
+
retriever = vector_db.as_retriever()
|
21 |
+
|
22 |
+
|
23 |
def respond(
|
24 |
message,
|
25 |
history: list[tuple[str, str]],
|