mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-03 20:16:52 +00:00
@@ -7,38 +7,26 @@
|
||||
"source": [
|
||||
"## Run Template\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"As shown in the README, add template and start server:\n",
|
||||
"In `server.py`, set -\n",
|
||||
"```\n",
|
||||
"langchain serve add rag-conversation\n",
|
||||
"langchain start\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"We can now look at the endpoints:\n",
|
||||
"\n",
|
||||
"http://127.0.0.1:8000/docs#\n",
|
||||
"\n",
|
||||
"And specifically at our loaded template:\n",
|
||||
"\n",
|
||||
"http://127.0.0.1:8000/docs#/default/invoke_rag_conversation_invoke_post\n",
|
||||
" \n",
|
||||
"We can also use remote runnable to call it."
|
||||
"add_routes(app, chain_rag_conv, path=\"/rag_conversation\")\n",
|
||||
"```"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 24,
|
||||
"execution_count": 2,
|
||||
"id": "5f521923",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from langserve.client import RemoteRunnable\n",
|
||||
"rag_app = RemoteRunnable('http://localhost:8000/rag-conversation')"
|
||||
"rag_app = RemoteRunnable('http://0.0.0.0:8001/rag_conversation')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 26,
|
||||
"execution_count": 5,
|
||||
"id": "679bd83b",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
@@ -52,17 +40,17 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 27,
|
||||
"execution_count": 8,
|
||||
"id": "94a05616",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"AIMessage(content=\"Agent memory works by utilizing both short-term memory and long-term memory mechanisms. \\n\\nShort-term memory allows the agent to learn and retain information within the current context or task. This in-context learning helps the agent handle complex tasks efficiently. \\n\\nOn the other hand, long-term memory enables the agent to retain and recall an unlimited amount of information over extended periods. This is achieved by leveraging an external vector store, such as a memory stream, which serves as a comprehensive database of the agent's past experiences in natural language. The memory stream records observations and events directly provided by the agent, and inter-agent communication can also trigger new natural language statements to be added to the memory.\\n\\nTo access and utilize the stored information, a retrieval model is employed. This model determines the context that is most relevant, recent, and important to inform the agent's behavior. By retrieving information from memory, the agent can reflect on past actions, learn from mistakes, and refine its behavior for future steps, ultimately improving the quality of its results.\")"
|
||||
"'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": 27,
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@@ -73,12 +61,12 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 29,
|
||||
"execution_count": 9,
|
||||
"id": "ce206c8a",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"chat_history = [(question, answer.content)]\n",
|
||||
"chat_history = [(question, answer)]\n",
|
||||
"answer = rag_app.invoke({\n",
|
||||
" \"question\": \"What are the different types?\",\n",
|
||||
" \"chat_history\": chat_history,\n",
|
||||
@@ -87,17 +75,17 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 30,
|
||||
"execution_count": 10,
|
||||
"id": "4626f167",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"AIMessage(content='The different types of memory utilized by the agent are sensory memory, short-term memory, and long-term memory.')"
|
||||
"\"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": 30,
|
||||
"execution_count": 10,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
|
Reference in New Issue
Block a user