Loading Events

« All Events

  • This event has passed.

7 PM – AI Agent – Darin

October 15 @ 8:00 pm - 9:00 pm

Today We Did

  1. Got started on the grep method for local file search

 

Homework: Adding Memory to Your AI Chatbot

Background

Your chatbot already displays previous messages in the conversation. However, the AI agent only receives the latest message, meaning it cannot remember what was said earlier.

Your task is to modify the existing code so that the AI agent can access the entire conversation history.

Part 1: Reading

Before starting, review:

  1. OpenAI Agents SDK — Running Agents (focus on conversation history).
  2. Streamlit Session State.
  3. The existing query_agent() function and how st.session_state.messages works.

Part 2: Coding

Task 1 — Modify the agent function

In ai_file_search_sdk.py:

  • Modify query_agent() so it accepts a list of messages instead of a string.
  • Pass this list to Runner.run().

Task 2 — Update the chatbot

In ai_chatbot_lesson_2.py:

  • Change the assistant’s message role from "ai" to "assistant" so that the history uses the correct roles for the agent.
  • Modify the call to query_agent() so that it receives the entire st.session_state.messages list rather than only the latest prompt.

Part 3: Testing

Start the chatbot and send these messages in order:

  1. “My favorite animal is a penguin.”
  2. “What is my favorite animal?”

Verify that the agent remembers your answer.

Submission

Submit your modified Python files and a screenshot showing that your AI agent remembers a previous message.

 

Notes:

You can reach me at ddjapri@ayclogic.com.

All class notes can be found here.

Details