AURA beta
Browse files- .streamlit/config.toml +6 -0
- app.py +99 -0
- img/Designer.png +0 -0
- requirements.txt +2 -0
.streamlit/config.toml
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[theme]
|
2 |
+
base="dark"
|
3 |
+
primaryColor="#4ba3ff"
|
4 |
+
backgroundColor="#0e1721"
|
5 |
+
secondaryBackgroundColor="#142433"
|
6 |
+
font = "sans serif"
|
app.py
ADDED
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import time
|
2 |
+
import os
|
3 |
+
import streamlit as st
|
4 |
+
from together import Together
|
5 |
+
|
6 |
+
# Set the Streamlit page configuration and theme
|
7 |
+
st.set_page_config(page_title="AURA", layout="centered")
|
8 |
+
|
9 |
+
# Display the logo image
|
10 |
+
col1, col2, col3 = st.columns([1, 30, 1])
|
11 |
+
with col2:
|
12 |
+
st.image("C:/Users/nikhi/PycharmProjects/AURA/img/Designer.png", use_column_width=True) # Adjusted the path to use the uploaded image
|
13 |
+
|
14 |
+
st.write("""
|
15 |
+
π **Greetings!** π I am **AURA**: your **Artificial Understanding and Responsive Assistant**.
|
16 |
+
Whether you're navigating stormy seas or dancing under starlit skies, I'm here to lend an empathetic ear,
|
17 |
+
offer thoughtful guidance, and illuminate your digital journey. Let's explore life's pathways together! π€β¨
|
18 |
+
""")
|
19 |
+
|
20 |
+
|
21 |
+
def hide_hamburger_menu():
|
22 |
+
st.markdown("""
|
23 |
+
<style>
|
24 |
+
#MainMenu {visibility: hidden;}
|
25 |
+
footer {visibility: hidden;}
|
26 |
+
</style>
|
27 |
+
""", unsafe_allow_html=True)
|
28 |
+
|
29 |
+
|
30 |
+
hide_hamburger_menu()
|
31 |
+
|
32 |
+
# Initialize Together client with API key
|
33 |
+
API_KEY = os.getenv('together_api')
|
34 |
+
client = Together(api_key=API_KEY)
|
35 |
+
|
36 |
+
|
37 |
+
def generate_response(messages):
|
38 |
+
try:
|
39 |
+
response = client.chat.completions.create(
|
40 |
+
model="meta-llama/Llama-3-70b-chat-hf",
|
41 |
+
messages=messages
|
42 |
+
)
|
43 |
+
return response.choices[0].message.content
|
44 |
+
except Exception as e:
|
45 |
+
print(f"Error generating response: {e}")
|
46 |
+
return None
|
47 |
+
|
48 |
+
|
49 |
+
# Initialize session state for messages
|
50 |
+
if "messages" not in st.session_state:
|
51 |
+
st.session_state.messages = [
|
52 |
+
{"role": "system",
|
53 |
+
"content": "You are an empathetic companion named AURA. Provide concise responses and use emojis to enhance the conversation."},
|
54 |
+
]
|
55 |
+
|
56 |
+
|
57 |
+
def reset_conversation():
|
58 |
+
st.session_state.messages = [
|
59 |
+
{"role": "system",
|
60 |
+
"content": "You are an empathetic companion named AURA. Provide concise responses and use emojis to enhance the conversation."},
|
61 |
+
]
|
62 |
+
|
63 |
+
|
64 |
+
# Display chat history
|
65 |
+
for message in st.session_state.messages:
|
66 |
+
if message["role"] != "system": # Skip system messages
|
67 |
+
with st.chat_message(message["role"]):
|
68 |
+
st.write(message["content"])
|
69 |
+
|
70 |
+
# User input
|
71 |
+
input_prompt = st.chat_input("Say something...")
|
72 |
+
if input_prompt:
|
73 |
+
with st.chat_message("user"):
|
74 |
+
st.markdown(f"**You:** {input_prompt}")
|
75 |
+
|
76 |
+
st.session_state.messages.append({"role": "user", "content": input_prompt})
|
77 |
+
with st.chat_message("assistant"):
|
78 |
+
with st.spinner("Thinking π‘..."):
|
79 |
+
# Include system message in the messages sent to the API but not in the displayed chat
|
80 |
+
messages_for_api = [msg for msg in st.session_state.messages if msg["role"] != "system"]
|
81 |
+
messages_for_api.insert(0, {"role": "system",
|
82 |
+
"content": "You are an empathetic companion named AURA. Provide concise responses and use emojis to enhance the conversation."})
|
83 |
+
|
84 |
+
response = generate_response(messages_for_api)
|
85 |
+
message_placeholder = st.empty()
|
86 |
+
answer = response or "Sorry, I couldn't generate a response."
|
87 |
+
|
88 |
+
# Initialize the response message
|
89 |
+
full_response = ""
|
90 |
+
for chunk in answer:
|
91 |
+
# Simulate typing by appending chunks of the response over time
|
92 |
+
full_response += chunk
|
93 |
+
time.sleep(0.02) # Adjust the sleep time to control the "typing" speed
|
94 |
+
message_placeholder.markdown(full_response + " |", unsafe_allow_html=True)
|
95 |
+
|
96 |
+
st.session_state.messages.append({"role": "assistant", "content": answer})
|
97 |
+
|
98 |
+
if st.button('ποΈ Reset All Chat', on_click=reset_conversation):
|
99 |
+
st.experimental_rerun()
|
img/Designer.png
ADDED
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
streamlit~=1.36.0
|
2 |
+
together~=1.2.1
|