menikev commited on
Commit
d1cc23e
·
verified ·
1 Parent(s): 10b806e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -4
app.py CHANGED
@@ -13,10 +13,23 @@ import warnings
13
  warnings.warn = warn
14
  warnings.filterwarnings('ignore')
15
 
16
- # Set your Hugging Face API token here.
17
- # For deployment on Hugging Face, you can set this as an environment variable.
18
- import os
19
- os.environ["HUGGINGFACEHUB_API_TOKEN"] = "hf_YOUR_HUGGINGFACE_TOKEN"
 
 
 
 
 
 
 
 
 
 
 
 
 
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():