mirror of
https://github.com/hwchase17/langchain
synced 2024-11-06 03:20:49 +00:00
150 lines
4.6 KiB
Plaintext
150 lines
4.6 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "232fd40d-cf6a-402d-bcb8-414184a8e924",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Run Template\n",
|
|
"\n",
|
|
"In `server.py`, set -\n",
|
|
"```\n",
|
|
"add_routes(app, chain_private, path=\"/rag_chroma_private\")\n",
|
|
"```"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 1,
|
|
"id": "78fb41d3-d2aa-40a6-b144-491f38a7cf88",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"from langserve.client import RemoteRunnable\n",
|
|
"\n",
|
|
"rag_app = RemoteRunnable(\"http://0.0.0.0:8001/rag_chroma_private/\")\n",
|
|
"for item in rag_app.stream(\"How does agent memory work?\"):\n",
|
|
" print(item)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 3,
|
|
"id": "ce39d358-1934-4404-bd3e-3fd497974aff",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
" Based on the provided context, agent memory is a long-term memory module that records a comprehensive list of agents' experiences in natural language. Each element is an observation or event directly provided by the agent, and inter-agent communication can trigger new natural language statements. The agent memory is complemented by several key components, including LLM (large language model) as the agent's brain, planning, reflection, and memory mechanisms. The design of generative agents combines LLM with memory, planning, and reflection mechanisms to enable agents to behave conditioned on past experiences and interact with other agents. The agent learns to call external APIs for missing information, including current information, code execution capability, access to proprietary information sources, and more. In summary, the agent memory works by recording and storing observations and events in natural language, allowing the agent to retrieve and use this information to inform its behavior.\n"
|
|
]
|
|
}
|
|
],
|
|
"source": []
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "a554971a-e724-4c99-84d1-5d646ae4ac3e",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 2,
|
|
"id": "6891d028-43ac-4a70-b2ad-6fbd3d937283",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"<generator object RemoteRunnable.stream at 0x1245d25f0>"
|
|
]
|
|
},
|
|
"execution_count": 2,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"rag_app.stream(\"How does agent memory work?\")"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 8,
|
|
"id": "888494ca-0509-4070-b36f-600a042f352c",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
" Based on the provided context, agent memory is a long-term memory module that records a comprehensive list of agents' experiences in natural language. Each element is an observation, an event directly provided by the agent, and inter-agent communication can trigger new natural language statements. The memory module surfaces the context to inform the agent's behavior according to relevance, recency, and importance.\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"\n",
|
|
"stream = \n",
|
|
"for i in stream:\n",
|
|
" print(i)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 5,
|
|
"id": "ff2169c9-dab2-41c4-8f38-1f8aebb16814",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"Collecting httpx_sse\n",
|
|
" Obtaining dependency information for httpx_sse from https://files.pythonhosted.org/packages/62/33/d35b4ccf8c1ac7266bd1d068c48f842d3c7392cca87e32751c79ee553d7a/httpx_sse-0.3.1-py3-none-any.whl.metadata\n",
|
|
" Using cached httpx_sse-0.3.1-py3-none-any.whl.metadata (8.6 kB)\n",
|
|
"Using cached httpx_sse-0.3.1-py3-none-any.whl (7.7 kB)\n",
|
|
"Installing collected packages: httpx_sse\n",
|
|
"Successfully installed httpx_sse-0.3.1\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"! pip install httpx_sse"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "3d843f23-686a-4138-8a9d-087bb00b2e13",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
}
|
|
],
|
|
"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
|
|
}
|