{ "cells": [ { "cell_type": "markdown", "id": "424a9d8d", "metadata": {}, "source": [ "## Run Template\n", "\n", "In `server.py`, set -\n", "```\n", "add_routes(app, chain_rag_conv, path=\"/rag_conversation\")\n", "```" ] }, { "cell_type": "code", "execution_count": 2, "id": "5f521923", "metadata": {}, "outputs": [], "source": [ "from langserve.client import RemoteRunnable\n", "\n", "rag_app = RemoteRunnable(\"http://0.0.0.0:8001/rag_conversation\")" ] }, { "cell_type": "code", "execution_count": 5, "id": "679bd83b", "metadata": {}, "outputs": [], "source": [ "question = \"How does agent memory work?\"\n", "answer = rag_app.invoke(\n", " {\n", " \"question\": question,\n", " \"chat_history\": [],\n", " }\n", ")" ] }, { "cell_type": "code", "execution_count": 8, "id": "94a05616", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Based on the given context, it is mentioned that the design of generative agents combines LLM (which stands for language, learning, and memory) with memory mechanisms. However, the specific workings of agent memory are not explicitly described in the given context.'" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "answer" ] }, { "cell_type": "code", "execution_count": 9, "id": "ce206c8a", "metadata": {}, "outputs": [], "source": [ "chat_history = [(question, answer)]\n", "answer = rag_app.invoke(\n", " {\n", " \"question\": \"What are the different types?\",\n", " \"chat_history\": chat_history,\n", " }\n", ")" ] }, { "cell_type": "code", "execution_count": 10, "id": "4626f167", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "\"Based on the given context, two types of memory are mentioned: short-term memory and long-term memory. \\n\\n1. Short-term memory: It refers to the ability of the agent to retain and recall information for a short period. In the context, short-term memory is described as the in-context learning that allows the model to learn.\\n\\n2. Long-term memory: It refers to the capability of the agent to retain and recall information over extended periods. In the context, long-term memory is described as the ability to retain and recall infinite information by leveraging an external vector store and fast retrieval.\\n\\nIt's important to note that these are just the types of memory mentioned in the given context. There may be other types of memory as well, depending on the specific design and implementation of the agent.\"" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "answer" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.16" } }, "nbformat": 4, "nbformat_minor": 5 }