bohmian commited on
Commit
25eb7ef
·
verified ·
1 Parent(s): 69a2b8a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -8
app.py CHANGED
@@ -2,9 +2,10 @@ import streamlit as st
2
  from streamlit_option_menu import option_menu
3
 
4
  import os
5
- from langchain.llms import HuggingFaceHub # for calling HuggingFace Inference API (free for our use case)
 
6
  from langchain.embeddings import HuggingFaceEmbeddings # to let program know what embeddings the vector store was embedded in earlier
7
-
8
  # to set up the agent and tools which will be used to answer questions later
9
  from langchain.agents import initialize_agent
10
  from langchain.agents import tool # decorator so each function will be recognized as a tool
@@ -171,12 +172,19 @@ countries = [
171
  def get_llm():
172
  # This is an inference endpoint API from huggingface, the model is not run locally, it is run on huggingface
173
  # It is a free API that is very good for deploying online for quick testing without users having to deploy a local LLM
174
- llm = HuggingFaceHub(repo_id=st.session_state['model'],
175
- model_kwargs={
176
- 'temperature': st.session_state['temperature'],
177
- "max_new_tokens": st.session_state['max_new_tokens']
178
- },
179
- )
 
 
 
 
 
 
 
180
  return llm
181
 
182
  # for chromadb vectore store
 
2
  from streamlit_option_menu import option_menu
3
 
4
  import os
5
+ # from langchain.llms import HuggingFaceHub # old, for calling HuggingFace Inference API (free for our use case)
6
+ from langchain_community.llms import HuggingFaceEndpoint # for calling HuggingFace Inference API (free for our use case)
7
  from langchain.embeddings import HuggingFaceEmbeddings # to let program know what embeddings the vector store was embedded in earlier
8
+ from langchain_community.llms import HuggingFaceEndpoint
9
  # to set up the agent and tools which will be used to answer questions later
10
  from langchain.agents import initialize_agent
11
  from langchain.agents import tool # decorator so each function will be recognized as a tool
 
172
  def get_llm():
173
  # This is an inference endpoint API from huggingface, the model is not run locally, it is run on huggingface
174
  # It is a free API that is very good for deploying online for quick testing without users having to deploy a local LLM
175
+ # llm = HuggingFaceHub(repo_id=st.session_state['model'],
176
+ # model_kwargs={
177
+ # 'temperature': st.session_state['temperature'],
178
+ # "max_new_tokens": st.session_state['max_new_tokens']
179
+ # },
180
+ # )
181
+ llm = HuggingFaceEndpoint(
182
+ endpoint_url=st.session_state['model'],
183
+ huggingfacehub_api_token=os.environ['HUGGINGFACEHUB_API_TOKEN'],
184
+ task="text-generation",
185
+ "temperature": st.session_state['temperature'],
186
+ "max_new_tokens": st.session_state['max_new_tokens']
187
+ )
188
  return llm
189
 
190
  # for chromadb vectore store