docs: check for format violations with ruff (#1967)

This commit is contained in:
Eugene Yurtsev
2024-10-02 14:40:33 +00:00
committed by GitHub
parent a3cb9c1a94
commit 2f7da90a38
3 changed files with 20 additions and 12 deletions
+1
View File
@@ -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:
+9 -4
View File
@@ -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()))"
]
},
@@ -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",
" \"<core_memory>\\n\" + \"\\n\".join(core_memories) + \"\\n</core_memory>\"\n",
" )\n",
" core_memories = [\n",
" item.value[\"memory\"] for item in core_memory_store.search((\"memories\", user_id))\n",
" ]\n",
" core_str = \"<core_memory>\\n\" + \"\\n\".join(core_memories) + \"\\n</core_memory>\"\n",
" recall_str = (\n",
" \"<recall_memory>\\n\" + \"\\n\".join(state[\"recall_memories\"]) + \"\\n</recall_memory>\"\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",