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