cheremnm commited on
Commit
7e1edc7
·
verified ·
1 Parent(s): e5ae866

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -8
app.py CHANGED
@@ -84,10 +84,20 @@ embedding_model = HuggingFaceEmbeddings(
84
  #)
85
 
86
  # Initialize Hugging Face LLM
87
- llm = HuggingFaceHub(
88
- repo_id="meta-llama/Meta-Llama-3-8B-Instruct", # or mistralai/Mistral-7B-Instruct-v0.3
89
- huggingfacehub_api_token=os.environ["HF_TOKEN"],
90
- model_kwargs={"temperature": 0.2, "max_new_tokens": 512}
 
 
 
 
 
 
 
 
 
 
91
  )
92
 
93
  # This initializes the Chat OpenAI model with the provided endpoint, API key, deployment name, and a temperature setting of 0 (to control response variability).
@@ -569,12 +579,23 @@ class SpiritualBot:
569
  #)
570
 
571
  # Initialize Hugging Face client
572
- self.client = HuggingFaceHub(
573
- repo_id="meta-llama/Meta-Llama-3-8B-Instruct",
574
- huggingfacehub_api_token=os.environ["HF_TOKEN"],
575
- model_kwargs={"temperature": 0.0, "max_new_tokens": 512}
 
 
 
 
 
576
  )
577
 
 
 
 
 
 
 
578
  # Define tools available to the chatbot, such as web search
579
  tools = [agentic_rag]
580
 
 
84
  #)
85
 
86
  # Initialize Hugging Face LLM
87
+ from langchain_community.chat_models import ChatHuggingFace
88
+ from transformers import pipeline
89
+
90
+ pipe = pipeline(
91
+ "text-generation",
92
+ model="meta-llama/Meta-Llama-3-8B-Instruct",
93
+ token=os.environ["HF_TOKEN"],
94
+ max_new_tokens=512,
95
+ temperature=0.0
96
+ )
97
+
98
+ llm = ChatHuggingFace(
99
+ pipeline=pipe,
100
+ model_id="meta-llama/Meta-Llama-3-8B-Instruct"
101
  )
102
 
103
  # This initializes the Chat OpenAI model with the provided endpoint, API key, deployment name, and a temperature setting of 0 (to control response variability).
 
579
  #)
580
 
581
  # Initialize Hugging Face client
582
+ from langchain_community.chat_models import ChatHuggingFace
583
+ from transformers import pipeline
584
+
585
+ pipe = pipeline(
586
+ "text-generation",
587
+ model="meta-llama/Meta-Llama-3-8B-Instruct",
588
+ token=os.environ["HF_TOKEN"],
589
+ max_new_tokens=512,
590
+ temperature=0.0
591
  )
592
 
593
+ # Assign to self.client
594
+ self.client = ChatHuggingFace(
595
+ pipeline=pipe,
596
+ model_id="meta-llama/Meta-Llama-3-8B-Instruct"
597
+ )
598
+
599
  # Define tools available to the chatbot, such as web search
600
  tools = [agentic_rag]
601