From 2f7da90a380164cd6aff503b5bcc6e737680cfaa Mon Sep 17 00:00:00 2001 From: Eugene Yurtsev Date: Wed, 2 Oct 2024 10:40:33 -0400 Subject: [PATCH] docs: check for format violations with ruff (#1967) --- Makefile | 1 + docs/docs/how-tos/memory/shared-state.ipynb | 13 +++++++++---- .../memory/long_term_memory_agent.ipynb | 18 ++++++++++-------- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index f1b781c8c..0be07e405 100644 --- a/Makefile +++ b/Makefile @@ -26,6 +26,7 @@ format-docs: # Check the docs for linting violations lint-docs: + poetry run ruff format --check docs/docs poetry run ruff check docs/docs codespell: diff --git a/docs/docs/how-tos/memory/shared-state.ipynb b/docs/docs/how-tos/memory/shared-state.ipynb index 254c7bbaf..cd1228e7c 100644 --- a/docs/docs/how-tos/memory/shared-state.ipynb +++ b/docs/docs/how-tos/memory/shared-state.ipynb @@ -189,10 +189,14 @@ " {\"role\": \"tool\", \"content\": \"Saved!\", \"tool_call_id\": tc[\"id\"]}\n", " )\n", " # We create a new memory from this tool call\n", - " store.put((\"memories\", user_id), memory_id, {\n", - " \"fact\": tc[\"args\"][\"fact\"],\n", - " \"topic\": tc[\"args\"][\"topic\"],\n", - " })\n", + " store.put(\n", + " (\"memories\", user_id),\n", + " memory_id,\n", + " {\n", + " \"fact\": tc[\"args\"][\"fact\"],\n", + " \"topic\": tc[\"args\"][\"topic\"],\n", + " },\n", + " )\n", " # Return the messages and memories to update the state with\n", " return {\"messages\": tool_calls}\n", "\n", @@ -233,6 +237,7 @@ ], "source": [ "from IPython.display import Image, display\n", + "\n", "display(Image(graph.get_graph().draw_mermaid_png()))" ] }, diff --git a/docs/docs/tutorials/memory/long_term_memory_agent.ipynb b/docs/docs/tutorials/memory/long_term_memory_agent.ipynb index 0b3b613ee..bc8dca7f2 100644 --- a/docs/docs/tutorials/memory/long_term_memory_agent.ipynb +++ b/docs/docs/tutorials/memory/long_term_memory_agent.ipynb @@ -174,7 +174,9 @@ "\n", "\n", "@tool\n", - "def save_core_memory(memory: str, index: Optional[int] = None, config: RunnableConfig = None) -> str:\n", + "def save_core_memory(\n", + " memory: str, index: Optional[int] = None, config: RunnableConfig = None\n", + ") -> str:\n", " \"\"\"Store a core memory in the database.\n", "\n", " Args:\n", @@ -192,7 +194,7 @@ " memory_key = memories[index].key\n", " else:\n", " memory_key = str(uuid.uuid4())\n", - " \n", + "\n", " core_memory_store.put((\"memories\", user_id), memory_key, {\"memory\": memory})\n", " return memory\n", "\n", @@ -325,7 +327,7 @@ " \" do call tools, all text preceding the tool call is an internal\"\n", " \" message. Respond AFTER calling the tool, once you have\"\n", " \" confirmation that the tool completed successfully.\"\n", - " \" REMEMBER: Use save_core_memories for key information like name, location, etc.\\n\\n\"\n", + " \" REMEMBER: Use save_core_memories for key information like name, location, etc.\\n\\n\",\n", " ),\n", " (\"placeholder\", \"{messages}\"),\n", " ]\n", @@ -359,10 +361,10 @@ " bound = prompt | model_with_tools\n", " # we can directly load core memories from the store parameter passed to the `agent` node\n", " user_id = get_user_id(config)\n", - " core_memories = [item.value[\"memory\"] for item in core_memory_store.search((\"memories\", user_id))]\n", - " core_str = (\n", - " \"\\n\" + \"\\n\".join(core_memories) + \"\\n\"\n", - " )\n", + " core_memories = [\n", + " item.value[\"memory\"] for item in core_memory_store.search((\"memories\", user_id))\n", + " ]\n", + " core_str = \"\\n\" + \"\\n\".join(core_memories) + \"\\n\"\n", " recall_str = (\n", " \"\\n\" + \"\\n\".join(state[\"recall_memories\"]) + \"\\n\"\n", " )\n", @@ -370,7 +372,7 @@ " {\n", " \"messages\": state[\"messages\"],\n", " \"recall_memories\": recall_str,\n", - " \"core_memories\": core_str\n", + " \"core_memories\": core_str,\n", " }\n", " )\n", " return {\n",