Spaces:
Sleeping
Sleeping
Rename qachat.py to app.py
Browse files- qachat.py → app.py +5 -8
qachat.py → app.py
RENAMED
@@ -1,12 +1,10 @@
|
|
1 |
-
from dotenv import load_dotenv
|
2 |
-
load_dotenv()
|
3 |
-
|
4 |
import streamlit as st
|
5 |
import os
|
6 |
import google.generativeai as genai
|
7 |
|
8 |
-
#
|
9 |
-
genai.configure(api_key=os.getenv("GOOGLE_KEY"))
|
|
|
10 |
model = genai.GenerativeModel("gemini-pro")
|
11 |
chat = model.start_chat(history=[])
|
12 |
|
@@ -18,8 +16,8 @@ def get_gemini_response(prompt):
|
|
18 |
return f"An error occurred: {str(e)}"
|
19 |
|
20 |
# Streamlit app configuration
|
21 |
-
st.set_page_config(page_title
|
22 |
-
st.header
|
23 |
|
24 |
# Initialize session state for chat history
|
25 |
if "chat_history" not in st.session_state:
|
@@ -57,6 +55,5 @@ if submit and input_text:
|
|
57 |
st.session_state['chat_history'].append(("Bot", chunk.text))
|
58 |
|
59 |
st.subheader("The Chat History is")
|
60 |
-
|
61 |
for role, text in st.session_state['chat_history']:
|
62 |
st.write(f"{role}: {text}")
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
import os
|
3 |
import google.generativeai as genai
|
4 |
|
5 |
+
# Set your Google API Key directly or use Hugging Face Spaces' Secrets
|
6 |
+
genai.configure(api_key=os.getenv("GOOGLE_KEY")) # Make sure to set this in the Spaces secrets
|
7 |
+
|
8 |
model = genai.GenerativeModel("gemini-pro")
|
9 |
chat = model.start_chat(history=[])
|
10 |
|
|
|
16 |
return f"An error occurred: {str(e)}"
|
17 |
|
18 |
# Streamlit app configuration
|
19 |
+
st.set_page_config(page_title="Med ChatBot")
|
20 |
+
st.header("ChatBot App")
|
21 |
|
22 |
# Initialize session state for chat history
|
23 |
if "chat_history" not in st.session_state:
|
|
|
55 |
st.session_state['chat_history'].append(("Bot", chunk.text))
|
56 |
|
57 |
st.subheader("The Chat History is")
|
|
|
58 |
for role, text in st.session_state['chat_history']:
|
59 |
st.write(f"{role}: {text}")
|