Skip to content

Commit

Permalink
adding message counter
Browse files Browse the repository at this point in the history
  • Loading branch information
beingkk committed Jan 2, 2024
1 parent bcb774b commit 0cc402b
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions signals_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,13 +280,13 @@ def signals_bot() -> None:
st.session_state["memory"].add_message(m)
# Keep count of the number of unique sessions
timestamp = current_time()
session_log = f"{timestamp}-{str(uuid.uuid4())}"
st.session_state["session_log"] = f"{timestamp}-{str(uuid.uuid4())}"
write_to_s3(
key=aws_key,
secret=aws_secret,
s3_path=f"{s3_path}/session-logs-signals",
filename="session_counter",
data={"session": session_log, "time": timestamp},
data={"session": st.session_state["session_log"], "time": timestamp},
how="a",
)

Expand Down Expand Up @@ -333,15 +333,6 @@ def signals_bot() -> None:
)
st.session_state.messages.append({"role": "assistant", "content": full_response})
st.session_state["memory"].add_message({"role": "assistant", "content": full_response})
# Keep count of the number of signals
write_to_s3(
key=aws_key,
secret=aws_secret,
s3_path=f"{s3_path}/session-logs-signals",
filename="signal_counter",
data={"signal": signal_to_explain, "time": current_time()},
how="a",
)

elif intent == "more_signals":
# Filter out signals that have already been covered
Expand Down Expand Up @@ -379,6 +370,21 @@ def signals_bot() -> None:
st.session_state.messages.append({"role": "assistant", "content": full_response})
st.session_state["memory"].add_message({"role": "assistant", "content": full_response})

# Keep track of the number of messages
write_to_s3(
key=aws_key,
secret=aws_secret,
s3_path=f"{s3_path}/session-logs-signals",
filename="message_counter",
data={
"session": st.session_state["session_log"],
"time": current_time(),
"intent": intent,
"signal": st.session_state.active_signal,
},
how="a",
)


def llm_call(selected_model: str, temperature: float, messages: MessageTemplate, messages_placeholders: dict) -> str:
"""Call the LLM"""
Expand Down

0 comments on commit 0cc402b

Please sign in to comment.