-
-
Notifications
You must be signed in to change notification settings - Fork 1k
fix(graphiti): remove OpenAI key requirement; add DB locking/indexing + dev backend source fixes #408
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
base: develop
Are you sure you want to change the base?
fix(graphiti): remove OpenAI key requirement; add DB locking/indexing + dev backend source fixes #408
Changes from all commits
2c89bc8
0d76103
af99570
3b12754
a7a617b
7799260
61acf0b
b86bf31
640de10
ab74f22
2d75d79
2a6e944
18660ef
8697ff9
8e124b8
6470c3f
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 | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,44 @@ | ||||||
| import asyncio | ||||||
| import os | ||||||
| from pathlib import Path | ||||||
| from datetime import datetime, timezone | ||||||
| from integrations.graphiti.memory import GraphitiMemory | ||||||
|
|
||||||
| spec_dir = Path.home() / ".auto-claude" / "agent_style_spec" | ||||||
| spec_dir.mkdir(parents=True, exist_ok=True) | ||||||
| project_dir_env = os.getenv("PROJECT_DIR") | ||||||
| # Prefer a portable PROJECT_DIR override; otherwise fall back to the repository root | ||||||
| # (…/apps/backend/agent_graphiti_test.py -> parents[2] == repo root). | ||||||
| project_dir = ( | ||||||
| Path(project_dir_env).expanduser().resolve() | ||||||
| if project_dir_env | ||||||
| else Path(__file__).resolve().parents[2] | ||||||
| ) | ||||||
| project_dir.mkdir(parents=True, exist_ok=True) | ||||||
|
|
||||||
| msg = f"agent-style write {datetime.now(timezone.utc).isoformat()}" | ||||||
|
|
||||||
| async def main(): | ||||||
| mem = GraphitiMemory(spec_dir=spec_dir, project_dir=project_dir) | ||||||
| print("is_enabled:", getattr(mem, "is_enabled", None)) | ||||||
|
|
||||||
| # Write (Agent-style) – with a timeout so it doesn't hang forever | ||||||
| ok = await asyncio.wait_for( | ||||||
| mem.save_session_insights( | ||||||
| session_num=int(datetime.now(timezone.utc).timestamp()), | ||||||
|
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. Potential session_num collision with timestamp-based ID. Using Consider using a UUID or adding millisecond precision. 🔎 Proposed fix- session_num=int(datetime.now(timezone.utc).timestamp()),
+ session_num=int(datetime.now(timezone.utc).timestamp() * 1000), # milliseconds📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| insights={"type":"agent_style_test","message":msg,"timestamp":datetime.now(timezone.utc).isoformat()}, | ||||||
| ), | ||||||
| timeout=120, | ||||||
| ) | ||||||
| print("write_ok:", ok) | ||||||
|
|
||||||
| # Read (Agent-style) | ||||||
| hits = await asyncio.wait_for(mem.get_relevant_context(query=msg, num_results=20), timeout=60) | ||||||
| print("hits:", len(hits) if hits else 0) | ||||||
| if hits: | ||||||
| print("first_hit:", hits[0]) | ||||||
|
|
||||||
| await mem.close() | ||||||
| print("spec_dir_used:", spec_dir) | ||||||
|
|
||||||
| asyncio.run(main()) | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick | 🔵 Trivial
Avoid creating project_dir if it doesn't exist.
Using
project_dir.mkdir(parents=True, exist_ok=True)on the project directory could inadvertently create unexpected directory structures if the path is misconfigured. Sinceproject_dirshould represent an existing project root (either fromPROJECT_DIRor the repository root), it should already exist.Consider removing this line or replacing it with a check that raises an error if the directory doesn't exist:
🔎 Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents