Spaces:
Running
Running
david-oplatka
commited on
Commit
β’
687edd3
1
Parent(s):
3a6675c
Add Amplitude Analytics Tracking
Browse files
app.py
CHANGED
@@ -12,7 +12,10 @@ from datasets import load_dataset
|
|
12 |
from vectara_agent.agent import AgentStatusType
|
13 |
from agent import initialize_agent, get_agent_config
|
14 |
|
|
|
|
|
15 |
initial_prompt = "How can I help you today?"
|
|
|
16 |
|
17 |
def toggle_logs():
|
18 |
st.session_state.show_logs = not st.session_state.show_logs
|
@@ -76,7 +79,7 @@ def launch_bot():
|
|
76 |
|
77 |
if "messages" not in st.session_state.keys():
|
78 |
reset()
|
79 |
-
|
80 |
# Display chat messages
|
81 |
for message in st.session_state.messages:
|
82 |
with st.chat_message(message["role"], avatar=message["avatar"]):
|
@@ -97,6 +100,14 @@ def launch_bot():
|
|
97 |
if prompt:
|
98 |
st.session_state.messages.append({"role": "user", "content": prompt, "avatar": 'π§βπ»'})
|
99 |
st.session_state.prompt = prompt # Save the prompt in session state
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
st.session_state.log_messages = []
|
101 |
st.session_state.show_logs = False
|
102 |
with st.chat_message("user", avatar='π§βπ»'):
|
|
|
12 |
from vectara_agent.agent import AgentStatusType
|
13 |
from agent import initialize_agent, get_agent_config
|
14 |
|
15 |
+
from amplitude import Amplitude, BaseEvent
|
16 |
+
|
17 |
initial_prompt = "How can I help you today?"
|
18 |
+
client = Amplitude("2a706490a2e8d62cdabf007d25408d34")
|
19 |
|
20 |
def toggle_logs():
|
21 |
st.session_state.show_logs = not st.session_state.show_logs
|
|
|
79 |
|
80 |
if "messages" not in st.session_state.keys():
|
81 |
reset()
|
82 |
+
|
83 |
# Display chat messages
|
84 |
for message in st.session_state.messages:
|
85 |
with st.chat_message(message["role"], avatar=message["avatar"]):
|
|
|
100 |
if prompt:
|
101 |
st.session_state.messages.append({"role": "user", "content": prompt, "avatar": 'π§βπ»'})
|
102 |
st.session_state.prompt = prompt # Save the prompt in session state
|
103 |
+
client.track(
|
104 |
+
BaseEvent(
|
105 |
+
event_type="submitted_query",
|
106 |
+
event_properties={
|
107 |
+
"query": prompt
|
108 |
+
}
|
109 |
+
)
|
110 |
+
)
|
111 |
st.session_state.log_messages = []
|
112 |
st.session_state.show_logs = False
|
113 |
with st.chat_message("user", avatar='π§βπ»'):
|