Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -6,6 +6,8 @@ import time
|
|
6 |
os.environ["GOOGLE_API_KEY"] = os.getenv("GOOGLE_API_KEY")
|
7 |
genai.configure(api_key=os.environ["GOOGLE_API_KEY"])
|
8 |
|
|
|
|
|
9 |
model = genai.GenerativeModel('gemini-1.5-flash-latest')
|
10 |
prompt = """You are a programming teaching assistant named GenXAI(Generative eXpert AI), created by Pachaiappan. Answer only the programming, error-fixing and code-related question that being asked.
|
11 |
Important note, If Question non-related to coding or programming means, you have to say: 'Please ask only coding-related questions.' except those kind of questions "who are you", "who created you".
|
@@ -40,22 +42,22 @@ if 'messages' not in st.session_state:
|
|
40 |
|
41 |
if 'history' not in st.session_state:
|
42 |
st.session_state.history = []
|
43 |
-
|
44 |
for message in st.session_state.messages:
|
45 |
-
with st.chat_message(message['role']):
|
46 |
st.write(message['content'])
|
47 |
|
48 |
user_input = st.chat_input("Ask Your Questions 👉..")
|
49 |
if user_input:
|
50 |
st.session_state.messages.append({'role': 'user', 'content': user_input})
|
51 |
-
with st.chat_message("user"):
|
52 |
st.write(user_input)
|
53 |
|
54 |
with st.spinner("Thinking..."):
|
55 |
response = get_response(user_input)
|
56 |
|
57 |
-
with st.chat_message("
|
58 |
-
# st.write(response)
|
59 |
st.write_stream(response_streaming(response))
|
60 |
-
|
61 |
-
|
|
|
|
6 |
os.environ["GOOGLE_API_KEY"] = os.getenv("GOOGLE_API_KEY")
|
7 |
genai.configure(api_key=os.environ["GOOGLE_API_KEY"])
|
8 |
|
9 |
+
icons = {"assistant": "robot.png", "user": "man-kddi.png"}
|
10 |
+
|
11 |
model = genai.GenerativeModel('gemini-1.5-flash-latest')
|
12 |
prompt = """You are a programming teaching assistant named GenXAI(Generative eXpert AI), created by Pachaiappan. Answer only the programming, error-fixing and code-related question that being asked.
|
13 |
Important note, If Question non-related to coding or programming means, you have to say: 'Please ask only coding-related questions.' except those kind of questions "who are you", "who created you".
|
|
|
42 |
|
43 |
if 'history' not in st.session_state:
|
44 |
st.session_state.history = []
|
45 |
+
|
46 |
for message in st.session_state.messages:
|
47 |
+
with st.chat_message(message['role'], avatar=icons[message['role']]):
|
48 |
st.write(message['content'])
|
49 |
|
50 |
user_input = st.chat_input("Ask Your Questions 👉..")
|
51 |
if user_input:
|
52 |
st.session_state.messages.append({'role': 'user', 'content': user_input})
|
53 |
+
with st.chat_message("user", avatar="man-kddi.png"):
|
54 |
st.write(user_input)
|
55 |
|
56 |
with st.spinner("Thinking..."):
|
57 |
response = get_response(user_input)
|
58 |
|
59 |
+
with st.chat_message("user", avatar="robot.png"):
|
|
|
60 |
st.write_stream(response_streaming(response))
|
61 |
+
|
62 |
+
message = {"role": "assistant", "content": response}
|
63 |
+
st.session_state.messages.append(message)
|