-
Notifications
You must be signed in to change notification settings - Fork 107
Staging #372
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Staging #372
Changes from all commits
367ce8e
9bf6497
ddfe7bc
71bb1cd
6489f85
1dbbc58
67d82b9
e1b8588
755a2f4
3f5e4d7
4c00d49
dddfbb5
31ba4ef
bfef44f
8af91e5
cddd3eb
444e271
ce084c2
870a0c2
784c386
989bac7
93df5c9
c2b3551
48eba40
904f859
d7d4d2a
dc8e04b
f060d88
b6d2b67
927675c
364bbc1
befe74e
351082b
40bf368
0103263
3dd4d13
9859c08
d767956
90c6a5c
de08a9a
b884bb9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -95,3 +95,4 @@ Sanitization | |
| JOINs | ||
| subqueries | ||
| subquery | ||
| TTL | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -19,6 +19,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ | |||||||||||||||||||||||||||||||||
| netcat-openbsd \ | ||||||||||||||||||||||||||||||||||
| git \ | ||||||||||||||||||||||||||||||||||
| build-essential \ | ||||||||||||||||||||||||||||||||||
| curl \ | ||||||||||||||||||||||||||||||||||
| ca-certificates \ | ||||||||||||||||||||||||||||||||||
| gnupg \ | ||||||||||||||||||||||||||||||||||
| && rm -rf /var/lib/apt/lists/* \ | ||||||||||||||||||||||||||||||||||
| && ln -sf /usr/local/bin/python3.12 /usr/bin/python3 \ | ||||||||||||||||||||||||||||||||||
| && ln -sf /usr/local/bin/python3.12 /usr/bin/python | ||||||||||||||||||||||||||||||||||
|
|
@@ -36,9 +39,15 @@ RUN PIP_BREAK_SYSTEM_PACKAGES=1 pipenv sync --system | |||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| # Install Node.js (Node 22) so we can build the frontend inside the image. | ||||||||||||||||||||||||||||||||||
| # Use NodeSource setup script to get a recent Node version on Debian-based images. | ||||||||||||||||||||||||||||||||||
| RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \ | ||||||||||||||||||||||||||||||||||
| && apt-get update && apt-get install -y nodejs \ | ||||||||||||||||||||||||||||||||||
| && rm -rf /var/lib/apt/lists/* | ||||||||||||||||||||||||||||||||||
| # Remove any pre-installed nodejs first to avoid conflicts. | ||||||||||||||||||||||||||||||||||
| RUN apt-get update \ | ||||||||||||||||||||||||||||||||||
| && apt-get remove -y nodejs || true \ | ||||||||||||||||||||||||||||||||||
| && rm -rf /var/lib/apt/lists/* \ | ||||||||||||||||||||||||||||||||||
| && curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \ | ||||||||||||||||||||||||||||||||||
| && apt-get update \ | ||||||||||||||||||||||||||||||||||
| && apt-get install -y nodejs \ | ||||||||||||||||||||||||||||||||||
| && rm -rf /var/lib/apt/lists/* \ | ||||||||||||||||||||||||||||||||||
| && node --version && npm --version | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+43
to
+50
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Operator precedence bug: In shell, Also, Proposed fix-RUN apt-get update \
- && apt-get remove -y nodejs || true \
- && rm -rf /var/lib/apt/lists/* \
- && curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
- && apt-get update \
- && apt-get install -y nodejs \
- && rm -rf /var/lib/apt/lists/* \
+RUN apt-get update \
+ && (apt-get remove -y nodejs || true) \
+ && rm -rf /var/lib/apt/lists/* \
+ && curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
+ && apt-get update \
+ && apt-get install -y --no-install-recommends nodejs \
+ && rm -rf /var/lib/apt/lists/* \
&& node --version && npm --version📝 Committable suggestion
Suggested change
🧰 Tools🪛 Trivy (0.69.1)[error] 43-50: 'apt-get' missing '--no-install-recommends' '--no-install-recommends' flag is missed: 'apt-get update && apt-get remove -y nodejs || true && rm -rf /var/lib/apt/lists/* && curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && apt-get update && apt-get install -y nodejs && rm -rf /var/lib/apt/lists/* && node --version && npm --version' Rule: DS-0029 (IaC/Dockerfile) 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| # Copy only frontend package files so Docker can cache npm installs when | ||||||||||||||||||||||||||||||||||
| # package.json / package-lock.json don't change. | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,8 @@ | |
| from typing import List, Dict, Any, Optional, Tuple | ||
| from datetime import datetime | ||
|
|
||
| from redis import RedisError | ||
|
|
||
| # Import Azure OpenAI components | ||
| from openai import AsyncAzureOpenAI | ||
|
|
||
|
|
@@ -47,10 +49,18 @@ def extract_embedding_model_name(full_model_name: str) -> str: | |
| class MemoryTool: | ||
| """Memory management tool for handling user memories and interactions.""" | ||
|
|
||
| # Optional TTL (in seconds) for the memory graph key. Set via MEMORY_TTL_SECONDS | ||
| # env var to enable automatic expiry (e.g. 604800 for 1 week). Unset = no expiry. | ||
| MEMORY_TTL_SECONDS: Optional[int] = ( | ||
| int(os.environ["MEMORY_TTL_SECONDS"]) | ||
| if os.environ.get("MEMORY_TTL_SECONDS") | ||
| else None | ||
| ) | ||
|
|
||
| def __init__(self, user_id: str, graph_id: str): | ||
| # Create FalkorDB driver with user-specific database | ||
| user_memory_db = f"{user_id}-memory" | ||
| falkor_driver = FalkorDriver(falkor_db=db, database=user_memory_db) | ||
| self.memory_db_name = f"{user_id}-memory" | ||
| falkor_driver = FalkorDriver(falkor_db=db, database=self.memory_db_name) | ||
|
|
||
|
|
||
| # Create Graphiti client with Azure OpenAI configuration | ||
|
|
@@ -60,6 +70,13 @@ def __init__(self, user_id: str, graph_id: str): | |
| self.graph_id = graph_id | ||
|
|
||
|
|
||
| async def _refresh_ttl(self) -> None: | ||
| """Set a TTL on the memory graph key using Redis EXPIRE.""" | ||
| try: | ||
| await db.execute_command("EXPIRE", self.memory_db_name, self.MEMORY_TTL_SECONDS) | ||
| except RedisError as e: | ||
| logging.warning("Failed to refresh TTL for %s: %s", self.memory_db_name, e) | ||
|
Comment on lines
+73
to
+78
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # Find all calls to _refresh_ttl
rg -n --type=py '_refresh_ttl' .Repository: FalkorDB/QueryWeaver Length of output: 209 🏁 Script executed: # Find all calls to create() on MemoryTool
rg -n --type=py 'create\(' . | grep -i memoryRepository: FalkorDB/QueryWeaver Length of output: 406 🏁 Script executed: # Check the graphiti_tool.py file to see the full implementation
cat -n api/memory/graphiti_tool.py | head -150Repository: FalkorDB/QueryWeaver Length of output: 6889 🏁 Script executed: # Find the README and check what it says about TTL
find . -name "README*" -type f | head -5Repository: FalkorDB/QueryWeaver Length of output: 114 🏁 Script executed: # Look for how MemoryTool is used - search for imports and instantiation
rg -n --type=py 'from.*graphiti_tool|import.*MemoryTool' .Repository: FalkorDB/QueryWeaver Length of output: 202 🏁 Script executed: # Check text2sql.py around the create() calls to understand the pattern
sed -n '235,250p' api/core/text2sql.pyRepository: FalkorDB/QueryWeaver Length of output: 697 🏁 Script executed: # Check text2sql.py around line 725
sed -n '720,735p' api/core/text2sql.pyRepository: FalkorDB/QueryWeaver Length of output: 761 🏁 Script executed: # List all public methods in MemoryTool
rg -n --type=py '^\s+async def|^\s+def' api/memory/graphiti_tool.pyRepository: FalkorDB/QueryWeaver Length of output: 1395 🏁 Script executed: # Check README for the TTL statement
rg -n --type=md 'TTL|refresh' README.md | head -20Repository: FalkorDB/QueryWeaver Length of output: 427 🏁 Script executed: # Get more context from the full MemoryTool implementation
sed -n '140,300p' api/memory/graphiti_tool.pyRepository: FalkorDB/QueryWeaver Length of output: 7796 TTL is only refreshed during The README (line 69) states "The TTL is refreshed on every user interaction, so active users keep their memory." However, Call 🤖 Prompt for AI Agents |
||
|
|
||
| @classmethod | ||
| async def create(cls, user_id: str, graph_id: str, use_direct_entities: bool = True) -> "MemoryTool": | ||
| """Async factory to construct and initialize the tool.""" | ||
|
|
@@ -72,6 +89,9 @@ async def create(cls, user_id: str, graph_id: str, use_direct_entities: bool = T | |
| driver = self.graphiti_client.driver | ||
| await driver.execute_query(f"CREATE VECTOR INDEX FOR (p:Query) ON (p.embeddings) OPTIONS {{dimension:{vector_size}, similarityFunction:'euclidean'}}") | ||
|
|
||
| if cls.MEMORY_TTL_SECONDS is not None: | ||
| await self._refresh_ttl() | ||
|
|
||
| return self | ||
|
|
||
| async def _ensure_entity_nodes_direct(self, user_id: str, database_name: str) -> bool: | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.