Spaces:
Runtime error
Runtime error
J.P. Pérez Tejada commited on
Commit ·
e84256c
1
Parent(s): 8794dc5
Apply pylint suggestions
Browse files- GnosisPages.py +5 -3
- gnosis/builder.py +3 -6
GnosisPages.py
CHANGED
|
@@ -1,15 +1,17 @@
|
|
| 1 |
# pylint: disable=invalid-name
|
| 2 |
""" A Streamlit app for GnosisPages. """
|
| 3 |
import os
|
| 4 |
-
|
|
|
|
| 5 |
import openai
|
|
|
|
|
|
|
|
|
|
| 6 |
from gnosis.chroma_client import ChromaDB
|
| 7 |
import gnosis.gui_messages as gm
|
| 8 |
from gnosis import settings
|
| 9 |
from gnosis.components.sidebar import sidebar
|
| 10 |
from gnosis.components.main import main
|
| 11 |
-
from pathlib import Path
|
| 12 |
-
from dotenv import load_dotenv
|
| 13 |
|
| 14 |
load_dotenv(Path(__file__).parent / ".env")
|
| 15 |
|
|
|
|
| 1 |
# pylint: disable=invalid-name
|
| 2 |
""" A Streamlit app for GnosisPages. """
|
| 3 |
import os
|
| 4 |
+
from pathlib import Path
|
| 5 |
+
|
| 6 |
import openai
|
| 7 |
+
import streamlit as st
|
| 8 |
+
from dotenv import load_dotenv
|
| 9 |
+
|
| 10 |
from gnosis.chroma_client import ChromaDB
|
| 11 |
import gnosis.gui_messages as gm
|
| 12 |
from gnosis import settings
|
| 13 |
from gnosis.components.sidebar import sidebar
|
| 14 |
from gnosis.components.main import main
|
|
|
|
|
|
|
| 15 |
|
| 16 |
load_dotenv(Path(__file__).parent / ".env")
|
| 17 |
|
gnosis/builder.py
CHANGED
|
@@ -1,10 +1,11 @@
|
|
| 1 |
"""Module for building the Langchain Agent"""
|
| 2 |
import os
|
|
|
|
| 3 |
import streamlit as st
|
| 4 |
-
from langchain_openai import ChatOpenAI
|
| 5 |
-
from gnosis.agent import PDFExplainer
|
| 6 |
from openai import AuthenticationError, APIConnectionError, BadRequestError
|
|
|
|
| 7 |
|
|
|
|
| 8 |
|
| 9 |
def build(key, client):
|
| 10 |
"""An Agent builder"""
|
|
@@ -21,8 +22,6 @@ def build(key, client):
|
|
| 21 |
client,
|
| 22 |
extra_tools=st.session_state.wk_button,
|
| 23 |
).agent
|
| 24 |
-
except Exception as e: # pylint: disable=broad-exception-caught
|
| 25 |
-
st.warning(f"Error building agent: {e}")
|
| 26 |
except AuthenticationError:
|
| 27 |
st.warning("Invalid OpenAI API Key. Check your credentials.")
|
| 28 |
except APIConnectionError:
|
|
@@ -31,7 +30,5 @@ def build(key, client):
|
|
| 31 |
st.warning(f"Bad request: {e}")
|
| 32 |
except ValueError as e:
|
| 33 |
st.warning(f"Configuration error: {e}")
|
| 34 |
-
except Exception as e: # pylint: disable=broad-exception-caught
|
| 35 |
-
st.warning(f"Unexpected error building agent: {e}")
|
| 36 |
|
| 37 |
return agent
|
|
|
|
| 1 |
"""Module for building the Langchain Agent"""
|
| 2 |
import os
|
| 3 |
+
|
| 4 |
import streamlit as st
|
|
|
|
|
|
|
| 5 |
from openai import AuthenticationError, APIConnectionError, BadRequestError
|
| 6 |
+
from langchain_openai import ChatOpenAI
|
| 7 |
|
| 8 |
+
from gnosis.agent import PDFExplainer
|
| 9 |
|
| 10 |
def build(key, client):
|
| 11 |
"""An Agent builder"""
|
|
|
|
| 22 |
client,
|
| 23 |
extra_tools=st.session_state.wk_button,
|
| 24 |
).agent
|
|
|
|
|
|
|
| 25 |
except AuthenticationError:
|
| 26 |
st.warning("Invalid OpenAI API Key. Check your credentials.")
|
| 27 |
except APIConnectionError:
|
|
|
|
| 30 |
st.warning(f"Bad request: {e}")
|
| 31 |
except ValueError as e:
|
| 32 |
st.warning(f"Configuration error: {e}")
|
|
|
|
|
|
|
| 33 |
|
| 34 |
return agent
|