Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
chore: normalize operation ids (#1739)
Shubham Naik60d5899a8c78
diff --git a/memgpt/autogen/interface.py b/memgpt/autogen/interface.pyindex bff04f716..9d8ea17e8 100644--- a/memgpt/autogen/interface.py+++ b/memgpt/autogen/interface.py@@ -1,4 +1,3 @@-import jsonimport refrom typing import Optionaldiff --git a/memgpt/interface.py b/memgpt/interface.pyindex 7206c53ba..cb0f7be0a 100644--- a/memgpt/interface.py+++ b/memgpt/interface.py@@ -1,4 +1,3 @@-import jsonimport refrom abc import ABC, abstractmethodfrom typing import List, Optionaldiff --git a/memgpt/llm_api/google_ai.py b/memgpt/llm_api/google_ai.pyindex 4cf496426..50b1f4b22 100644--- a/memgpt/llm_api/google_ai.py+++ b/memgpt/llm_api/google_ai.py@@ -1,4 +1,3 @@-import jsonimport uuidfrom typing import List, Optionaldiff --git a/memgpt/local_llm/grammars/gbnf_grammar_generator.py b/memgpt/local_llm/grammars/gbnf_grammar_generator.pyindex 59da81bc4..6b4515853 100644--- a/memgpt/local_llm/grammars/gbnf_grammar_generator.py+++ b/memgpt/local_llm/grammars/gbnf_grammar_generator.py@@ -21,7 +21,7 @@ from typing import (from docstring_parser import parsefrom pydantic import BaseModel, create_model-from memgpt.utils import json_dumps, json_loads+from memgpt.utils import json_dumpsclass PydanticDataType(Enum):diff --git a/memgpt/local_llm/llm_chat_completion_wrappers/dolphin.py b/memgpt/local_llm/llm_chat_completion_wrappers/dolphin.pyindex 00e06de6c..674ddc96d 100644--- a/memgpt/local_llm/llm_chat_completion_wrappers/dolphin.py+++ b/memgpt/local_llm/llm_chat_completion_wrappers/dolphin.py@@ -1,5 +1,3 @@-import json-from memgpt.utils import json_dumps, json_loadsfrom ...errors import LLMJSONParsingErrordiff --git a/memgpt/local_llm/llm_chat_completion_wrappers/llama3.py b/memgpt/local_llm/llm_chat_completion_wrappers/llama3.pyindex 867cedfdc..4a05859b8 100644--- a/memgpt/local_llm/llm_chat_completion_wrappers/llama3.py+++ b/memgpt/local_llm/llm_chat_completion_wrappers/llama3.py@@ -1,5 +1,3 @@-import json-from memgpt.errors import LLMJSONParsingErrorfrom memgpt.local_llm.json_parser import clean_jsonfrom memgpt.local_llm.llm_chat_completion_wrappers.wrapper_base import (diff --git a/memgpt/local_llm/llm_chat_completion_wrappers/simple_summary_wrapper.py b/memgpt/local_llm/llm_chat_completion_wrappers/simple_summary_wrapper.pyindex 600320bbe..e9c58ea74 100644--- a/memgpt/local_llm/llm_chat_completion_wrappers/simple_summary_wrapper.py+++ b/memgpt/local_llm/llm_chat_completion_wrappers/simple_summary_wrapper.py@@ -1,5 +1,3 @@-import json-from memgpt.utils import json_dumps, json_loadsfrom .wrapper_base import LLMChatCompletionWrapperdiff --git a/memgpt/local_llm/llm_chat_completion_wrappers/zephyr.py b/memgpt/local_llm/llm_chat_completion_wrappers/zephyr.pyindex 924f22884..88918d509 100644--- a/memgpt/local_llm/llm_chat_completion_wrappers/zephyr.py+++ b/memgpt/local_llm/llm_chat_completion_wrappers/zephyr.py@@ -1,5 +1,3 @@-import json-from memgpt.utils import json_dumps, json_loadsfrom ...errors import LLMJSONParsingErrordiff --git a/memgpt/server/rest_api/routers/v1/agents.py b/memgpt/server/rest_api/routers/v1/agents.pyindex 38d52bf38..fd8acdf89 100644--- a/memgpt/server/rest_api/routers/v1/agents.py+++ b/memgpt/server/rest_api/routers/v1/agents.py@@ -31,7 +31,7 @@ from memgpt.utils import deduplicaterouter = APIRouter(prefix="/agents", tags=["agents"])[email protected]("/", response_model=List[AgentState])[email protected]("/", response_model=List[AgentState], operation_id="list_agents")def list_agents(server: "SyncServer" = Depends(get_memgpt_server),):@@ -44,7 +44,7 @@ def list_agents(return server.list_agents(user_id=actor.id)[email protected]("/", response_model=AgentState)[email protected]("/", response_model=AgentState, operation_id="create_agent")def create_agent(agent: CreateAgent = Body(...),server: "SyncServer" = Depends(get_memgpt_server),@@ -58,7 +58,7 @@ def create_agent(return server.create_agent(agent, user_id=actor.id)[email protected]("/{agent_id}", response_model=AgentState)[email protected]("/{agent_id}", response_model=AgentState, operation_id="update_agent")def update_agent(agent_id: str,update_agent: UpdateAgentState = Body(...),@@ -71,7 +71,7 @@ def update_agent(return server.update_agent(update_agent, user_id=actor.id)[email protected]("/{agent_id}", response_model=AgentState)[email protected]("/{agent_id}", response_model=AgentState, operation_id="get_agent")def get_agent_state(agent_id: str,server: "SyncServer" = Depends(get_memgpt_server),@@ -88,7 +88,7 @@ def get_agent_state(return server.get_agent_state(user_id=actor.id, agent_id=agent_id)[email protected]("/{agent_id}")[email protected]("/{agent_id}", response_model=None, operation_id="delete_agent")def delete_agent(agent_id: str,server: "SyncServer" = Depends(get_memgpt_server),@@ -101,7 +101,7 @@ def delete_agent(return server.delete_agent(user_id=actor.id, agent_id=agent_id)[email protected]("/{agent_id}/sources", response_model=List[Source])[email protected]("/{agent_id}/sources", response_model=List[Source], operation_id="get_agent_sources")def get_agent_sources(agent_id: str,server: "SyncServer" = Depends(get_memgpt_server),@@ -114,7 +114,7 @@ def get_agent_sources(return server.list_attached_sources(agent_id)[email protected]("/{agent_id}/memory/messages", response_model=List[Message])[email protected]("/{agent_id}/memory/messages", response_model=List[Message], operation_id="list_agent_in_context_messages")def get_agent_in_context_messages(agent_id: str,server: "SyncServer" = Depends(get_memgpt_server),@@ -126,7 +126,7 @@ def get_agent_in_context_messages(return server.get_in_context_messages(agent_id=agent_id)[email protected]("/{agent_id}/memory", response_model=Memory)[email protected]("/{agent_id}/memory", response_model=Memory, operation_id="get_agent_memory")def get_agent_memory(agent_id: str,server: "SyncServer" = Depends(get_memgpt_server),@@ -139,7 +139,7 @@ def get_agent_memory(return server.get_agent_memory(agent_id=agent_id)[email protected]("/{agent_id}/memory", response_model=Memory)[email protected]("/{agent_id}/memory", response_model=Memory, operation_id="update_agent_memory")def update_agent_memory(agent_id: str,request: Dict = Body(...),@@ -155,7 +155,7 @@ def update_agent_memory(return memory[email protected]("/{agent_id}/memory/recall", response_model=RecallMemorySummary)[email protected]("/{agent_id}/memory/recall", response_model=RecallMemorySummary, operation_id="get_agent_recall_memory_summary")def get_agent_recall_memory_summary(agent_id: str,server: "SyncServer" = Depends(get_memgpt_server),@@ -167,7 +167,7 @@ def get_agent_recall_memory_summary(return server.get_recall_memory_summary(agent_id=agent_id)[email protected]("/{agent_id}/memory/archival", response_model=ArchivalMemorySummary)[email protected]("/{agent_id}/memory/archival", response_model=ArchivalMemorySummary, operation_id="get_agent_archival_memory_summary")def get_agent_archival_memory_summary(agent_id: str,server: "SyncServer" = Depends(get_memgpt_server),@@ -179,7 +179,7 @@ def get_agent_archival_memory_summary(return server.get_archival_memory_summary(agent_id=agent_id)[email protected]("/{agent_id}/archival", response_model=List[Passage])[email protected]("/{agent_id}/archival", response_model=List[Passage], operation_id="list_agent_archival_memory")def get_agent_archival_memory(agent_id: str,server: "SyncServer" = Depends(get_memgpt_server),@@ -205,7 +205,7 @@ def get_agent_archival_memory()[email protected]("/{agent_id}/archival", response_model=List[Passage])[email protected]("/{agent_id}/archival", response_model=List[Passage], operation_id="create_agent_archival_memory")def insert_agent_archival_memory(agent_id: str,request: CreateArchivalMemory = Body(...),@@ -221,7 +221,7 @@ def insert_agent_archival_memory(# TODO(ethan): query or path parameter for memory_id?# @router.delete("/{agent_id}/archival")[email protected]("/{agent_id}/archival/{memory_id}")[email protected]("/{agent_id}/archival/{memory_id}", response_model=None, operation_id="delete_agent_archival_memory")def delete_agent_archival_memory(agent_id: str,memory_id: str,@@ -237,7 +237,7 @@ def delete_agent_archival_memory(return JSONResponse(status_code=status.HTTP_200_OK, content={"message": f"Memory id={memory_id} successfully deleted"})[email protected]("/{agent_id}/messages", response_model=List[Message])[email protected]("/{agent_id}/messages", response_model=List[Message], operation_id="list_agent_messages")def get_agent_messages(agent_id: str,server: "SyncServer" = Depends(get_memgpt_server),@@ -260,7 +260,7 @@ def get_agent_messages()[email protected]("/{agent_id}/messages/{message_id}", response_model=Message)[email protected]("/{agent_id}/messages/{message_id}", response_model=Message, operation_id="update_agent_message")def update_message(agent_id: str,message_id: str,@@ -274,7 +274,7 @@ def update_message(return server.update_agent_message(agent_id=agent_id, request=request)[email protected]("/{agent_id}/messages", response_model=MemGPTResponse)[email protected]("/{agent_id}/messages", response_model=MemGPTResponse, operation_id="create_agent_message")async def send_message(agent_id: str,server: SyncServer = Depends(get_memgpt_server),diff --git a/memgpt/server/rest_api/routers/v1/blocks.py b/memgpt/server/rest_api/routers/v1/blocks.pyindex 23091d705..3d309029d 100644--- a/memgpt/server/rest_api/routers/v1/blocks.py+++ b/memgpt/server/rest_api/routers/v1/blocks.py@@ -12,7 +12,7 @@ if TYPE_CHECKING:router = APIRouter(prefix="/blocks", tags=["blocks"])[email protected]("/", response_model=List[Block])[email protected]("/", response_model=List[Block], operation_id="list_memory_blocks")def list_blocks(# query parameterslabel: Optional[str] = Query(None, description="Labels to include (e.g. human, persona)"),@@ -28,7 +28,7 @@ def list_blocks(return blocks[email protected]("/", response_model=Block)[email protected]("/", response_model=Block, operation_id="create_memory_block")def create_block(create_block: CreateBlock = Body(...),server: SyncServer = Depends(get_memgpt_server),@@ -39,7 +39,7 @@ def create_block(return server.create_block(user_id=actor.id, request=create_block)[email protected]("/{block_id}", response_model=Block)[email protected]("/{block_id}", response_model=Block, operation_id="update_memory_block")def update_block(block_id: str,updated_block: UpdateBlock = Body(...),@@ -52,7 +52,7 @@ def update_block(# TODO: delete should not return anything[email protected]("/{block_id}", response_model=Block)[email protected]("/{block_id}", response_model=Block, operation_id="delete_memory_block")def delete_block(block_id: str,server: SyncServer = Depends(get_memgpt_server),@@ -61,7 +61,7 @@ def delete_block(return server.delete_block(block_id=block_id)[email protected]("/{block_id}", response_model=Block)[email protected]("/{block_id}", response_model=Block, operation_id="get_memory_block")def get_block(block_id: str,server: SyncServer = Depends(get_memgpt_server),diff --git a/memgpt/server/rest_api/routers/v1/jobs.py b/memgpt/server/rest_api/routers/v1/jobs.pyindex 633d493ae..522c91d32 100644--- a/memgpt/server/rest_api/routers/v1/jobs.py+++ b/memgpt/server/rest_api/routers/v1/jobs.py@@ -9,7 +9,7 @@ from memgpt.server.server import SyncServerrouter = APIRouter(prefix="/jobs", tags=["jobs"])[email protected]("/", response_model=List[Job])[email protected]("/", response_model=List[Job], operation_id="list_jobs")def list_jobs(server: "SyncServer" = Depends(get_memgpt_server),):@@ -22,7 +22,7 @@ def list_jobs(return server.list_jobs(user_id=actor.id)[email protected]("/active", response_model=List[Job])[email protected]("/active", response_model=List[Job], operation_id="list_active_jobs")def list_active_jobs(server: "SyncServer" = Depends(get_memgpt_server),):@@ -34,7 +34,7 @@ def list_active_jobs(return server.list_active_jobs(user_id=actor.id)[email protected]("/{job_id}", response_model=Job)[email protected]("/{job_id}", response_model=Job, operation_id="get_job")def get_job(job_id: str,server: "SyncServer" = Depends(get_memgpt_server),diff --git a/memgpt/server/rest_api/routers/v1/llms.py b/memgpt/server/rest_api/routers/v1/llms.pyindex 5b5e8d2ad..47e117b8e 100644--- a/memgpt/server/rest_api/routers/v1/llms.py+++ b/memgpt/server/rest_api/routers/v1/llms.py@@ -12,7 +12,7 @@ if TYPE_CHECKING:router = APIRouter(prefix="/models", tags=["models", "llms"])[email protected]("/", response_model=List[LLMConfig])[email protected]("/", response_model=List[LLMConfig], operation_id="list_models")def list_llm_backends(server: "SyncServer" = Depends(get_memgpt_server),):@@ -20,7 +20,7 @@ def list_llm_backends(return server.list_models()[email protected]("/embedding", response_model=List[EmbeddingConfig])[email protected]("/embedding", response_model=List[EmbeddingConfig], operation_id="list_embedding_models")def list_embedding_backends(server: "SyncServer" = Depends(get_memgpt_server),):diff --git a/memgpt/server/rest_api/routers/v1/sources.py b/memgpt/server/rest_api/routers/v1/sources.pyindex eeb1fc6c9..def663eb1 100644--- a/memgpt/server/rest_api/routers/v1/sources.py+++ b/memgpt/server/rest_api/routers/v1/sources.py@@ -17,7 +17,7 @@ from memgpt.server.server import SyncServerrouter = APIRouter(prefix="/sources", tags=["sources"])[email protected]("/{source_id}", response_model=Source)[email protected]("/{source_id}", response_model=Source, operation_id="get_source")def get_source(source_id: str,server: "SyncServer" = Depends(get_memgpt_server),@@ -30,7 +30,7 @@ def get_source(return server.get_source(source_id=source_id, user_id=actor.id)[email protected]("/name/{source_name}", response_model=str)[email protected]("/name/{source_name}", response_model=str, operation_id="get_source_id_by_name")def get_source_id_by_name(source_name: str,server: "SyncServer" = Depends(get_memgpt_server),@@ -40,11 +40,11 @@ def get_source_id_by_name("""actor = server.get_current_user()- source = server.get_source_id(source_name=source_name, user_id=actor.id)- return source+ source_id = server.get_source_id(source_name=source_name, user_id=actor.id)+ return source_id[email protected]("/", response_model=List[Source])[email protected]("/", response_model=List[Source], operation_id="list_sources")def list_sources(server: "SyncServer" = Depends(get_memgpt_server),):@@ -56,7 +56,7 @@ def list_sources(return server.list_all_sources(user_id=actor.id)[email protected]("/", response_model=Source)[email protected]("/", response_model=Source, operation_id="create_source")def create_source(source: SourceCreate,server: "SyncServer" = Depends(get_memgpt_server),@@ -69,7 +69,7 @@ def create_source(return server.create_source(request=source, user_id=actor.id)[email protected]("/{source_id}", response_model=Source)[email protected]("/{source_id}", response_model=Source, operation_id="update_source")def update_source(source_id: str,source: SourceUpdate,@@ -84,7 +84,7 @@ def update_source(return server.update_source(request=source, user_id=actor.id)[email protected]("/{source_id}")[email protected]("/{source_id}", response_model=None, operation_id="delete_source")def delete_source(source_id: str,server: "SyncServer" = Depends(get_memgpt_server),@@ -97,7 +97,7 @@ def delete_source(server.delete_source(source_id=source_id, user_id=actor.id)[email protected]("/{source_id}/attach", response_model=Source)[email protected]("/{source_id}/attach", response_model=Source, operation_id="attach_agent_to_source")def attach_source_to_agent(source_id: str,agent_id: str = Query(..., description="The unique identifier of the agent to attach the source to."),@@ -114,7 +114,7 @@ def attach_source_to_agent(return source[email protected]("/{source_id}/detach")[email protected]("/{source_id}/detach", response_model=None, operation_id="detach_agent_from_source")def detach_source_from_agent(source_id: str,agent_id: str = Query(..., description="The unique identifier of the agent to detach the source from."),@@ -128,7 +128,7 @@ def detach_source_from_agent(server.detach_source_from_agent(source_id=source_id, agent_id=agent_id, user_id=actor.id)[email protected]("/{source_id}/upload", response_model=Job)[email protected]("/{source_id}/upload", response_model=Job, operation_id="upload_file_to_source")def upload_file_to_source(file: UploadFile,source_id: str,@@ -162,7 +162,7 @@ def upload_file_to_source(return job[email protected]("/{source_id}/passages", response_model=List[Passage])[email protected]("/{source_id}/passages", response_model=List[Passage], operation_id="list_source_passages")def list_passages(source_id: str,server: SyncServer = Depends(get_memgpt_server),@@ -175,7 +175,7 @@ def list_passages(return passages[email protected]("/{source_id}/documents", response_model=List[Document])[email protected]("/{source_id}/documents", response_model=List[Document], operation_id="list_source_documents")def list_documents(source_id: str,server: "SyncServer" = Depends(get_memgpt_server),diff --git a/memgpt/server/rest_api/routers/v1/tools.py b/memgpt/server/rest_api/routers/v1/tools.pyindex 7c2d803b1..528e680bf 100644--- a/memgpt/server/rest_api/routers/v1/tools.py+++ b/memgpt/server/rest_api/routers/v1/tools.py@@ -9,7 +9,7 @@ from memgpt.server.server import SyncServerrouter = APIRouter(prefix="/tools", tags=["tools"])[email protected]("/{tool_id}")[email protected]("/{tool_id}", operation_id="delete_tool")def delete_tool(tool_id: str,server: SyncServer = Depends(get_memgpt_server),@@ -21,7 +21,7 @@ def delete_tool(server.delete_tool(tool_id=tool_id)[email protected]("/{tool_id}", response_model=Tool)[email protected]("/{tool_id}", response_model=Tool, operation_id="get_tool")def get_tool(tool_id: str,server: SyncServer = Depends(get_memgpt_server),@@ -38,7 +38,7 @@ def get_tool(return tool[email protected]("/name/{tool_name}", response_model=str)[email protected]("/name/{tool_name}", response_model=str, operation_id="get_tool_id_by_name")def get_tool_id(tool_name: str,server: SyncServer = Depends(get_memgpt_server),@@ -55,7 +55,7 @@ def get_tool_id(return tool_id[email protected]("/", response_model=List[Tool])[email protected]("/", response_model=List[Tool], operation_id="list_tools")def list_all_tools(server: SyncServer = Depends(get_memgpt_server),):@@ -70,7 +70,7 @@ def list_all_tools(# return server.ms.list_tools(user_id=None)[email protected]("/", response_model=Tool)[email protected]("/", response_model=Tool, operation_id="create_tool")def create_tool(tool: ToolCreate = Body(...),update: bool = False,@@ -89,7 +89,7 @@ def create_tool()[email protected]("/{tool_id}", response_model=Tool)[email protected]("/{tool_id}", response_model=Tool, operation_id="update_tool")def update_tool(tool_id: str,request: ToolUpdate = Body(...),diff --git a/memgpt/server/rest_api/routers/v1/users.py b/memgpt/server/rest_api/routers/v1/users.pyindex 6e197e1ac..4ce1911ed 100644--- a/memgpt/server/rest_api/routers/v1/users.py+++ b/memgpt/server/rest_api/routers/v1/users.py@@ -25,7 +25,7 @@ if TYPE_CHECKING:router = APIRouter(prefix="/users", tags=["users", "admin"])[email protected]("/", tags=["admin"], response_model=List[User])[email protected]("/", tags=["admin"], response_model=List[User], operation_id="list_users")def get_all_users(cursor: Optional[str] = Query(None),limit: Optional[int] = Query(50),@@ -44,7 +44,7 @@ def get_all_users(return users[email protected]("/", tags=["admin"], response_model=User)[email protected]("/", tags=["admin"], response_model=User, operation_id="create_user")def create_user(request: UserCreate = Body(...),server: "SyncServer" = Depends(get_memgpt_server),@@ -57,7 +57,7 @@ def create_user(return user[email protected]("/", tags=["admin"], response_model=User)[email protected]("/", tags=["admin"], response_model=User, operation_id="delete_user")def delete_user(user_id: str = Query(..., description="The user_id key to be deleted."),server: "SyncServer" = Depends(get_memgpt_server),@@ -75,7 +75,7 @@ def delete_user(return user[email protected]("/keys", response_model=APIKey)[email protected]("/keys", response_model=APIKey, operation_id="create_api_key")def create_new_api_key(create_key: APIKeyCreate = Body(...),server: "SyncServer" = Depends(get_memgpt_server),@@ -87,7 +87,7 @@ def create_new_api_key(return api_key[email protected]("/keys", response_model=List[APIKey])[email protected]("/keys", response_model=List[APIKey], operation_id="list_api_keys")def get_api_keys(user_id: str = Query(..., description="The unique identifier of the user."),server: "SyncServer" = Depends(get_memgpt_server),@@ -101,7 +101,7 @@ def get_api_keys(return api_keys[email protected]("/keys", response_model=APIKey)[email protected]("/keys", response_model=APIKey, operation_id="delete_api_key")def delete_api_key(api_key: str = Query(..., description="The API key to be deleted."),server: "SyncServer" = Depends(get_memgpt_server),diff --git a/memgpt/server/ws_api/example_client.py b/memgpt/server/ws_api/example_client.pyindex 377dc6ffd..80bdfb811 100644--- a/memgpt/server/ws_api/example_client.py+++ b/memgpt/server/ws_api/example_client.py@@ -1,5 +1,4 @@import asyncio-import jsonimport websocketsdiff --git a/memgpt/server/ws_api/protocol.py b/memgpt/server/ws_api/protocol.pyindex 0ee0a52d9..601447753 100644--- a/memgpt/server/ws_api/protocol.py+++ b/memgpt/server/ws_api/protocol.py@@ -1,5 +1,3 @@-import json-from memgpt.utils import json_dumps# Server -> clientdiff --git a/memgpt/server/ws_api/server.py b/memgpt/server/ws_api/server.pyindex 833d103f3..14944a97a 100644--- a/memgpt/server/ws_api/server.py+++ b/memgpt/server/ws_api/server.py@@ -1,5 +1,4 @@import asyncio-import jsonimport signalimport sysimport tracebackdiff --git a/tests/test_function_parser.py b/tests/test_function_parser.pyindex eebc1074f..f899835a7 100644--- a/tests/test_function_parser.py+++ b/tests/test_function_parser.py@@ -1,5 +1,3 @@-import json-import memgpt.system as systemfrom memgpt.local_llm.function_parser import patch_functionfrom memgpt.utils import json_dumps