Pradeep Kumar commited on
Commit
4df9ed4
·
verified ·
1 Parent(s): 5577c0e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -19,7 +19,7 @@ install_packages()
19
 
20
  import os
21
  import streamlit as st
22
- from langchain.llms import HuggingFaceHub
23
  from langchain.schema import SystemMessage, HumanMessage, AIMessage
24
  import dotenv
25
 
@@ -34,7 +34,7 @@ if not token:
34
 
35
  llm = HuggingFaceHub(
36
  repo_id=repo_id,
37
- model_kwargs={"max_length": 128, "temperature": 0.8}, # Adjust the temperature for response style
38
  huggingfacehub_api_token=token,
39
  )
40
 
@@ -57,8 +57,11 @@ def init_messages() -> None:
57
  ]
58
 
59
  def get_answer(llm, user_input: str) -> str:
60
- """Generates an answer from the model."""
61
- return llm(user_input)
 
 
 
62
 
63
  def main() -> None:
64
  """Main function for the Streamlit app."""
 
19
 
20
  import os
21
  import streamlit as st
22
+ from langchain_community.llms import HuggingFaceHub
23
  from langchain.schema import SystemMessage, HumanMessage, AIMessage
24
  import dotenv
25
 
 
34
 
35
  llm = HuggingFaceHub(
36
  repo_id=repo_id,
37
+ model_kwargs={"max_length": 512, "temperature": 0.8}, # Adjust the temperature for response style
38
  huggingfacehub_api_token=token,
39
  )
40
 
 
57
  ]
58
 
59
  def get_answer(llm, user_input: str) -> str:
60
+ try:
61
+ return llm(user_input)
62
+ except Exception as e:
63
+ return f"An error occurred: {str(e)}"
64
+
65
 
66
  def main() -> None:
67
  """Main function for the Streamlit app."""