ohalkhateeb commited on
Commit
e11b217
·
verified ·
1 Parent(s): 5489647

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -7
app.py CHANGED
@@ -24,15 +24,22 @@ retriever = vector_db.as_retriever(search_kwargs={"k": 3})
24
 
25
 
26
  # Load Jais-13B from Hugging Face
27
- llm = HuggingFaceHub(
28
- repo_id="inceptionai/jais-13b-chat",
29
- huggingfacehub_api_token=huggingfacehub_api_token,
30
- task="text-generation",
31
- model_kwargs={"temperature": 0.3, "max_new_tokens": 512}
32
-
33
- )
34
 
 
 
 
 
 
35
 
 
 
 
 
 
 
 
 
 
36
  # Create the RetrievalQA chain
37
  qa_chain = RetrievalQA(llm=llm, retriever=retriever)
38
 
 
24
 
25
 
26
  # Load Jais-13B from Hugging Face
 
 
 
 
 
 
 
27
 
28
+ def initialize_llm():
29
+ """Initializes the Hugging Face LLM using the HUGGINGFACEHUB_API_TOKEN environment variable."""
30
+ huggingfacehub_api_token = os.environ.get("HUGGINGFACEHUB_API_TOKEN")
31
+ if not huggingfacehub_api_token:
32
+ raise ValueError("HUGGINGFACEHUB_API_TOKEN environment variable not set.")
33
 
34
+ llm = HuggingFaceHub(
35
+ repo_id="jais-foundation/jais-13b-chat",
36
+ huggingfacehub_api_token=huggingfacehub_api_token,
37
+ task="text-generation",
38
+ model_kwargs={'temperature': 0.3, 'max_new_tokens': 512}
39
+ )
40
+ return llm
41
+
42
+
43
  # Create the RetrievalQA chain
44
  qa_chain = RetrievalQA(llm=llm, retriever=retriever)
45