Spaces:
Build error
Build error
Pradeep Kumar commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -19,7 +19,7 @@ install_packages()
|
|
| 19 |
|
| 20 |
import os
|
| 21 |
import streamlit as st
|
| 22 |
-
from
|
| 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":
|
| 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 |
-
|
| 61 |
-
|
|
|
|
|
|
|
|
|
|
| 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."""
|