Skip to content

Commit d1cd5ed

Browse files
committed
Add conversation history
1 parent 1a2490b commit d1cd5ed

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

components/history.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@
44
import re
55

66

7-
def get_history(agent_name):
7+
def get_history(agent_name, conversation_name):
88
st.markdown("### Agent History")
99
st.markdown(
1010
"The history of the agent's interactions. The latest responses are at the top."
1111
)
1212

1313
# Add a button to delete agent history
14-
if st.button("Delete Agent History"):
15-
ApiClient.delete_agent_history(agent_name=agent_name)
14+
if st.button("Delete Conversation"):
15+
ApiClient.delete_conversation(
16+
agent_name=agent_name, conversation_name=conversation_name
17+
)
1618
st.success("Agent history deleted successfully.")
1719

1820
# Define CSS rules for message container
@@ -48,7 +50,12 @@ def get_history(agent_name):
4850
with st.container():
4951
message_container = "<div class='message-container'>"
5052
try:
51-
history = ApiClient.get_chat_history(agent_name=agent_name)
53+
history = ApiClient.get_conversation(
54+
agent_name=agent_name,
55+
conversation_name=conversation_name,
56+
limit=100,
57+
page=1,
58+
)
5259
history = reversed(history)
5360

5461
for item in history:

pages/0-Agent_Settings.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@ def render_extension_settings(extension_settings, agent_settings):
252252
except Exception as e:
253253
st.error(f"Error loading agent configuration: {str(e)}")
254254

255-
if not new_agent and agent_name:
256255
# Trigger actions on form submit
257256
if update_agent_settings_button:
258257
try:

pages/3-Interact.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@
3030

3131
with st.container():
3232
if agent_name:
33-
st.session_state["chat_history"] = get_history(agent_name=agent_name)
33+
st.session_state["conversation"] = st.selectbox(
34+
"Choose a conversation", ApiClient.get_conversations(agent_name=agent_name)
35+
)
36+
st.session_state["chat_history"] = get_history(
37+
agent_name=agent_name, conversation_name=st.session_state["conversation"]
38+
)
3439

3540

3641
# If the user selects Prompt, then show the prompt functionality

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
streamlit==1.24.0
2-
agixtsdk==0.0.10
2+
agixtsdk==0.0.12
33
python-dotenv==1.0.0

0 commit comments

Comments
 (0)