Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
import os
|
| 2 |
import gradio as gr
|
| 3 |
from langchain.agents import Agent
|
| 4 |
-
from
|
| 5 |
from langchain_community.vectorstores import FAISS
|
| 6 |
from langchain_community.embeddings import HuggingFaceEmbeddings
|
| 7 |
|
|
@@ -10,7 +10,7 @@ HUGGINGFACEHUB_API_TOKEN = os.getenv('HUGGINGFACEHUB_API_TOKEN', 'your_huggingfa
|
|
| 10 |
|
| 11 |
# Initialize the LLM from Hugging Face Hub
|
| 12 |
llm = HuggingFaceEndpoint(endpoint_url="https://api-inference.huggingface.co/models/gpt2",
|
| 13 |
-
|
| 14 |
|
| 15 |
# Initialize embeddings
|
| 16 |
embeddings = HuggingFaceEmbeddings(model_name="sentence-transformers/all-MiniLM-L6-v2")
|
|
|
|
| 1 |
import os
|
| 2 |
import gradio as gr
|
| 3 |
from langchain.agents import Agent
|
| 4 |
+
from langchain_huggingface.llms import HuggingFaceEndpoint
|
| 5 |
from langchain_community.vectorstores import FAISS
|
| 6 |
from langchain_community.embeddings import HuggingFaceEmbeddings
|
| 7 |
|
|
|
|
| 10 |
|
| 11 |
# Initialize the LLM from Hugging Face Hub
|
| 12 |
llm = HuggingFaceEndpoint(endpoint_url="https://api-inference.huggingface.co/models/gpt2",
|
| 13 |
+
model_kwargs={"headers": {"Authorization": f"Bearer {HUGGINGFACEHUB_API_TOKEN}"}})
|
| 14 |
|
| 15 |
# Initialize embeddings
|
| 16 |
embeddings = HuggingFaceEmbeddings(model_name="sentence-transformers/all-MiniLM-L6-v2")
|