acloudfan commited on
Commit
5c1dd5d
1 Parent(s): 8bb4143

Upload 2 files

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -23,10 +23,12 @@ from langchain_community.document_loaders import PyPDFLoader
23
  # Without this you will need to copy/paste the API key with every change
24
  try:
25
  # CHANGE the location of the file
26
- load_dotenv('C:\\Users\\raj\\.jupyter\\.env')
27
  # Add the API key to the session - use it for populating the interface
28
  if os.getenv('HUGGINGFACEHUB_API_TOKEN'):
29
  st.session_state['HUGGINGFACEHUB_API_TOKEN'] = os.getenv('HUGGINGFACEHUB_API_TOKEN')
 
 
30
  except:
31
  print("Environment file not found !! Copy & paste your HuggingFace API key.")
32
 
@@ -70,7 +72,7 @@ def generate_summary():
70
  llm = HuggingFaceEndpoint(
71
  repo_id=model_id,
72
  max_new_tokens=MAX_TOKENS,
73
- huggingfacehub_api_token = st.session_state['HUGGINGFACEHUB_API_TOKEN']
74
  )
75
 
76
  # Show spinner, while we are waiting for the response
@@ -115,9 +117,9 @@ def generate_summary():
115
  st.title('PDF Summarizer')
116
 
117
  if 'HUGGINGFACEHUB_API_TOKEN' in st.session_state:
118
- cohere_api_key = st.sidebar.text_input('HuggingFace API key',value=st.session_state['HUGGINGFACEHUB_API_TOKEN'])
119
  else:
120
- cohere_api_key = st.sidebar.text_input('HuggingFace API key',placeholder='copy & paste your API key')
121
 
122
 
123
  # draw the box for query
 
23
  # Without this you will need to copy/paste the API key with every change
24
  try:
25
  # CHANGE the location of the file
26
+ load_dotenv('C:\\Users\\raj\\.jupyter\\.env1')
27
  # Add the API key to the session - use it for populating the interface
28
  if os.getenv('HUGGINGFACEHUB_API_TOKEN'):
29
  st.session_state['HUGGINGFACEHUB_API_TOKEN'] = os.getenv('HUGGINGFACEHUB_API_TOKEN')
30
+ else:
31
+ st.session_state['HUGGINGFACEHUB_API_TOKEN'] = ''
32
  except:
33
  print("Environment file not found !! Copy & paste your HuggingFace API key.")
34
 
 
72
  llm = HuggingFaceEndpoint(
73
  repo_id=model_id,
74
  max_new_tokens=MAX_TOKENS,
75
+ huggingfacehub_api_token = hugging_face_api_key
76
  )
77
 
78
  # Show spinner, while we are waiting for the response
 
117
  st.title('PDF Summarizer')
118
 
119
  if 'HUGGINGFACEHUB_API_TOKEN' in st.session_state:
120
+ hugging_face_api_key = st.sidebar.text_input('HuggingFace API key',value=st.session_state['HUGGINGFACEHUB_API_TOKEN'])
121
  else:
122
+ hugging_face_api_key = st.sidebar.text_input('HuggingFace API key',placeholder='copy & paste your API key')
123
 
124
 
125
  # draw the box for query