Spaces:
Running
Running
fix the flow
Browse files- streamlit_app.py +6 -7
streamlit_app.py
CHANGED
@@ -60,8 +60,9 @@ def init_qa(model):
|
|
60 |
elif model == 'llama-2-70b-chat':
|
61 |
chat = HuggingFaceHub(repo_id="meta-llama/Llama-2-70b-chat-hf",
|
62 |
model_kwargs={"temperature": 0.01, "max_length": 4096, "max_new_tokens": 2048})
|
63 |
-
embeddings = HuggingFaceEmbeddings(
|
64 |
-
|
|
|
65 |
|
66 |
return DocumentQAEngine(chat, embeddings, grobid_url=os.environ['GROBID_URL'])
|
67 |
|
@@ -102,16 +103,14 @@ model = st.sidebar.radio("Model (cannot be changed after selection or upload)",
|
|
102 |
disabled=is_api_key_provided)
|
103 |
|
104 |
if not st.session_state['api_key']:
|
105 |
-
if model == 'mistral-7b-instruct-v0.1' or 'llama-2-70b-chat':
|
106 |
-
api_key = st.sidebar.text_input('Huggingface API Key') if 'HUGGINGFACEHUB_API_TOKEN' not in os.environ else
|
107 |
-
os.environ['HUGGINGFACEHUB_API_TOKEN']
|
108 |
if api_key:
|
109 |
st.session_state['api_key'] = is_api_key_provided = True
|
110 |
os.environ["HUGGINGFACEHUB_API_TOKEN"] = api_key
|
111 |
st.session_state['rqa'] = init_qa(model)
|
112 |
elif model == 'chatgpt-3.5-turbo':
|
113 |
-
api_key = st.sidebar.text_input('OpenAI API Key') if 'OPENAI_API_KEY' not in os.environ else os.environ[
|
114 |
-
'OPENAI_API_KEY']
|
115 |
if api_key:
|
116 |
st.session_state['api_key'] = is_api_key_provided = True
|
117 |
os.environ['OPENAI_API_KEY'] = api_key
|
|
|
60 |
elif model == 'llama-2-70b-chat':
|
61 |
chat = HuggingFaceHub(repo_id="meta-llama/Llama-2-70b-chat-hf",
|
62 |
model_kwargs={"temperature": 0.01, "max_length": 4096, "max_new_tokens": 2048})
|
63 |
+
embeddings = HuggingFaceEmbeddings(model_name="all-MiniLM-L6-v2")
|
64 |
+
else:
|
65 |
+
st.error("The model was not loaded properly. Try reloading. ")
|
66 |
|
67 |
return DocumentQAEngine(chat, embeddings, grobid_url=os.environ['GROBID_URL'])
|
68 |
|
|
|
103 |
disabled=is_api_key_provided)
|
104 |
|
105 |
if not st.session_state['api_key']:
|
106 |
+
if model == 'mistral-7b-instruct-v0.1' or model == 'llama-2-70b-chat':
|
107 |
+
api_key = st.sidebar.text_input('Huggingface API Key')# if 'HUGGINGFACEHUB_API_TOKEN' not in os.environ else os.environ['HUGGINGFACEHUB_API_TOKEN']
|
|
|
108 |
if api_key:
|
109 |
st.session_state['api_key'] = is_api_key_provided = True
|
110 |
os.environ["HUGGINGFACEHUB_API_TOKEN"] = api_key
|
111 |
st.session_state['rqa'] = init_qa(model)
|
112 |
elif model == 'chatgpt-3.5-turbo':
|
113 |
+
api_key = st.sidebar.text_input('OpenAI API Key') #if 'OPENAI_API_KEY' not in os.environ else os.environ['OPENAI_API_KEY']
|
|
|
114 |
if api_key:
|
115 |
st.session_state['api_key'] = is_api_key_provided = True
|
116 |
os.environ['OPENAI_API_KEY'] = api_key
|