Spaces:
Runtime error
Runtime error
Deprecated old openai access test
Browse files- knowledge_gpt/main.py +3 -4
- knowledge_gpt/ui.py +0 -24
knowledge_gpt/main.py
CHANGED
|
@@ -2,6 +2,7 @@ import os
|
|
| 2 |
os.environ["OPENAI_API_TYPE"] = "azure" # configure API to Azure OpenAI
|
| 3 |
|
| 4 |
import streamlit as st
|
|
|
|
| 5 |
|
| 6 |
# add all secrets into environmental variables
|
| 7 |
try:
|
|
@@ -33,10 +34,6 @@ from knowledge_gpt.core.qa import query_folder
|
|
| 33 |
from langchain.chat_models import AzureChatOpenAI
|
| 34 |
|
| 35 |
|
| 36 |
-
st.set_page_config(page_title="ReferenceBot", page_icon="📖", layout="wide")
|
| 37 |
-
st.header("📖ReferenceBot")
|
| 38 |
-
|
| 39 |
-
|
| 40 |
def main():
|
| 41 |
EMBEDDING = "openai"
|
| 42 |
VECTOR_STORE = "faiss"
|
|
@@ -45,6 +42,8 @@ def main():
|
|
| 45 |
# Uncomment to enable debug mode
|
| 46 |
# MODEL_LIST.insert(0, "debug")
|
| 47 |
|
|
|
|
|
|
|
| 48 |
# Enable caching for expensive functions
|
| 49 |
bootstrap_caching()
|
| 50 |
|
|
|
|
| 2 |
os.environ["OPENAI_API_TYPE"] = "azure" # configure API to Azure OpenAI
|
| 3 |
|
| 4 |
import streamlit as st
|
| 5 |
+
st.set_page_config(page_title="ReferenceBot", page_icon="📖", layout="wide")
|
| 6 |
|
| 7 |
# add all secrets into environmental variables
|
| 8 |
try:
|
|
|
|
| 34 |
from langchain.chat_models import AzureChatOpenAI
|
| 35 |
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
def main():
|
| 38 |
EMBEDDING = "openai"
|
| 39 |
VECTOR_STORE = "faiss"
|
|
|
|
| 42 |
# Uncomment to enable debug mode
|
| 43 |
# MODEL_LIST.insert(0, "debug")
|
| 44 |
|
| 45 |
+
st.header("📖ReferenceBot")
|
| 46 |
+
|
| 47 |
# Enable caching for expensive functions
|
| 48 |
bootstrap_caching()
|
| 49 |
|
knowledge_gpt/ui.py
CHANGED
|
@@ -2,7 +2,6 @@ from typing import List
|
|
| 2 |
import streamlit as st
|
| 3 |
from langchain.docstore.document import Document
|
| 4 |
from knowledge_gpt.core.parsing import File
|
| 5 |
-
#import openai
|
| 6 |
from streamlit.logger import get_logger
|
| 7 |
from typing import NoReturn
|
| 8 |
|
|
@@ -40,26 +39,3 @@ def display_file_read_error(e: Exception, file_name: str) -> NoReturn:
|
|
| 40 |
st.error("Error reading file. Make sure the file is not corrupted or encrypted")
|
| 41 |
logger.error(f"{e.__class__.__name__}: {e}. Extension: {file_name.split('.')[-1]}")
|
| 42 |
st.stop()
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
@st.cache_data(show_spinner=False)
|
| 46 |
-
def is_open_ai_key_valid(openai_api_key, model: str) -> bool:
|
| 47 |
-
if model == "debug":
|
| 48 |
-
return True
|
| 49 |
-
|
| 50 |
-
if not openai_api_key:
|
| 51 |
-
st.error("Please enter your OpenAI API key in the sidebar!")
|
| 52 |
-
return False
|
| 53 |
-
try:
|
| 54 |
-
pass
|
| 55 |
-
#openai.ChatCompletion.create(
|
| 56 |
-
# engine="chatbot-streamlit",#model,
|
| 57 |
-
# messages=[{"role": "user", "content": "test"}],
|
| 58 |
-
# #api_key=openai_api_key,
|
| 59 |
-
#)
|
| 60 |
-
except Exception as e:
|
| 61 |
-
st.error(f"{e.__class__.__name__}: {e}")
|
| 62 |
-
logger.error(f"{e.__class__.__name__}: {e}")
|
| 63 |
-
return False
|
| 64 |
-
|
| 65 |
-
return True
|
|
|
|
| 2 |
import streamlit as st
|
| 3 |
from langchain.docstore.document import Document
|
| 4 |
from knowledge_gpt.core.parsing import File
|
|
|
|
| 5 |
from streamlit.logger import get_logger
|
| 6 |
from typing import NoReturn
|
| 7 |
|
|
|
|
| 39 |
st.error("Error reading file. Make sure the file is not corrupted or encrypted")
|
| 40 |
logger.error(f"{e.__class__.__name__}: {e}. Extension: {file_name.split('.')[-1]}")
|
| 41 |
st.stop()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|