GenAICoder commited on
Commit
a8554ee
1 Parent(s): 73948b2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -10
app.py CHANGED
@@ -1,5 +1,5 @@
1
  import streamlit as st
2
- from langchain_community.llms import HuggingFaceEndpoint
3
  from langchain_core.runnables import RunnablePassthrough
4
  from langchain_core.output_parsers import StrOutputParser
5
  from langchain.prompts import ChatPromptTemplate
@@ -17,22 +17,22 @@ from langchain_community.embeddings import HuggingFaceEmbeddings
17
  #from transformers import AutoModelForCausalLM
18
  #from langchain_community.llms.huggingface_pipeline import HuggingFacePipeline
19
  #from llama_index.core import StorageContext, load_index_from_storage, VectorStoreIndex, SimpleDirectoryReader, ChatPromptTemplate
20
- from llama_index.llms.huggingface import HuggingFaceInferenceAPI
21
  #from llama_index.embeddings.huggingface import HuggingFaceEmbedding
22
- from llama_index.core import Settings
23
 
24
 
25
  #access_token = os.getenv("HUGGINGFACE_API_KEY")
26
 
27
  # Configure the Llama index settings
28
- llm = HuggingFaceInferenceAPI(
29
- model_name="meta-llama/Meta-Llama-3-8B-Instruct",
30
- tokenizer_name="meta-llama/Meta-Llama-3-8B-Instruct",
31
- context_window=3900,
32
- token=os.getenv("HUGGINGFACE_API_KEY"),
33
  # max_new_tokens=1000,
34
- generate_kwargs={"temperature": 0.1},
35
- )
36
 
37
 
38
  #st.set_page_config(page_title="Document Genie", layout="wide")
@@ -112,7 +112,13 @@ def get_conversational_chain(retriever):
112
  #model_id="gpt2",
113
  #task="text-generation",
114
  #pipeline_kwargs={"max_new_tokens": 10})
 
115
 
 
 
 
 
 
116
  pt = ChatPromptTemplate.get_template(prompt_template)
117
  # Retrieve and generate using the relevant snippets of the blog.
118
  #retriever = db.as_retriever()
 
1
  import streamlit as st
2
+ from langchain_community.llms import HuggingFaceHub
3
  from langchain_core.runnables import RunnablePassthrough
4
  from langchain_core.output_parsers import StrOutputParser
5
  from langchain.prompts import ChatPromptTemplate
 
17
  #from transformers import AutoModelForCausalLM
18
  #from langchain_community.llms.huggingface_pipeline import HuggingFacePipeline
19
  #from llama_index.core import StorageContext, load_index_from_storage, VectorStoreIndex, SimpleDirectoryReader, ChatPromptTemplate
20
+ #from llama_index.llms.huggingface import HuggingFaceInferenceAPI
21
  #from llama_index.embeddings.huggingface import HuggingFaceEmbedding
22
+ #from llama_index.core import Settings
23
 
24
 
25
  #access_token = os.getenv("HUGGINGFACE_API_KEY")
26
 
27
  # Configure the Llama index settings
28
+ #llm = HuggingFaceInferenceAPI(
29
+ # model_name="meta-llama/Meta-Llama-3-8B-Instruct",
30
+ # tokenizer_name="meta-llama/Meta-Llama-3-8B-Instruct",
31
+ # context_window=3900,
32
+ # token=os.getenv("HUGGINGFACE_API_KEY"),
33
  # max_new_tokens=1000,
34
+ # generate_kwargs={"temperature": 0.1},
35
+ #)
36
 
37
 
38
  #st.set_page_config(page_title="Document Genie", layout="wide")
 
112
  #model_id="gpt2",
113
  #task="text-generation",
114
  #pipeline_kwargs={"max_new_tokens": 10})
115
+ #from langchain_community.llms import HuggingFaceHub
116
 
117
+ llm = HuggingFaceHub(
118
+ repo_id="HuggingFaceH4/zephyr-7b-beta",
119
+ huggingfacehub_api_token="<HF_TOKEN_HERE>",
120
+ task="text-generation",
121
+ )
122
  pt = ChatPromptTemplate.get_template(prompt_template)
123
  # Retrieve and generate using the relevant snippets of the blog.
124
  #retriever = db.as_retriever()