Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,10 +13,23 @@ import warnings
|
|
| 13 |
warnings.warn = warn
|
| 14 |
warnings.filterwarnings('ignore')
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
## LLM - Using an open-source model from Hugging Face
|
| 22 |
def get_llm():
|
|
|
|
| 13 |
warnings.warn = warn
|
| 14 |
warnings.filterwarnings('ignore')
|
| 15 |
|
| 16 |
+
from dotenv import load_dotenv
|
| 17 |
+
load_dotenv()
|
| 18 |
+
|
| 19 |
+
from langchain.prompts import PromptTemplate
|
| 20 |
+
from langchain_huggingface import (
|
| 21 |
+
HuggingFaceEmbeddings,
|
| 22 |
+
HuggingFaceEndpoint,
|
| 23 |
+
)
|
| 24 |
+
from langchain.schema.runnable import RunnablePassthrough
|
| 25 |
+
from langchain.schema.output_parser import StrOutputParser
|
| 26 |
+
|
| 27 |
+
# --- 1) CONFIG / SAFETY ---
|
| 28 |
+
|
| 29 |
+
if not os.getenv("HUGGINGFACEHUB_API_TOKEN"):
|
| 30 |
+
print("HUGGINGFACEHUB_API_TOKEN not found. Add it to your Space secrets.")
|
| 31 |
+
raise SystemExit(1)
|
| 32 |
+
|
| 33 |
|
| 34 |
## LLM - Using an open-source model from Hugging Face
|
| 35 |
def get_llm():
|