diff --git a/pandasai/responses/streamlit_response.py b/pandasai/responses/streamlit_response.py index e219d35d1..100d13696 100644 --- a/pandasai/responses/streamlit_response.py +++ b/pandasai/responses/streamlit_response.py @@ -1,13 +1,5 @@ from pandasai.responses.response_parser import ResponseParser -try: - import streamlit as st -except ImportError: - raise ImportError( - "The 'streamlit' module is required but not installed. " - "Please install it using pip: pip install streamlit" - ) - class StreamlitResponse(ResponseParser): def __init__(self, context): @@ -30,6 +22,14 @@ def format_plot(self, result) -> None: except OSError: raise ValueError(f"The file {result['value']} is not a valid image file.") + try: + import streamlit as st + except ImportError: + raise ImportError( + "The 'streamlit' module is required to use StreamLit Response. " + "Please install it using pip: pip install streamlit" + ) + # Display the image plt.imshow(image) fig = plt.gcf()