memgraph-toolbox 0.2.2__tar.gz → 0.2.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {memgraph_toolbox-0.2.2 → memgraph_toolbox-0.2.3}/.gitignore +3 -0
- {memgraph_toolbox-0.2.2 → memgraph_toolbox-0.2.3}/PKG-INFO +1 -1
- {memgraph_toolbox-0.2.2 → memgraph_toolbox-0.2.3}/pyproject.toml +1 -1
- {memgraph_toolbox-0.2.2 → memgraph_toolbox-0.2.3}/src/memgraph_toolbox/api/memgraph.py +14 -4
- {memgraph_toolbox-0.2.2 → memgraph_toolbox-0.2.3}/src/memgraph_toolbox/client/mcp_prompt.py +14 -8
- {memgraph_toolbox-0.2.2 → memgraph_toolbox-0.2.3}/src/memgraph_toolbox/tests/test_async_memgraph.py +5 -0
- memgraph_toolbox-0.2.2/uv.lock +0 -3399
- {memgraph_toolbox-0.2.2 → memgraph_toolbox-0.2.3}/LICENSE +0 -0
- {memgraph_toolbox-0.2.2 → memgraph_toolbox-0.2.3}/README.md +0 -0
- {memgraph_toolbox-0.2.2 → memgraph_toolbox-0.2.3}/src/memgraph_toolbox/__init__.py +0 -0
- {memgraph_toolbox-0.2.2 → memgraph_toolbox-0.2.3}/src/memgraph_toolbox/api/__init__.py +0 -0
- {memgraph_toolbox-0.2.2 → memgraph_toolbox-0.2.3}/src/memgraph_toolbox/api/tool.py +0 -0
- {memgraph_toolbox-0.2.2 → memgraph_toolbox-0.2.3}/src/memgraph_toolbox/api/toolbox.py +0 -0
- {memgraph_toolbox-0.2.2 → memgraph_toolbox-0.2.3}/src/memgraph_toolbox/client/__init__.py +0 -0
- {memgraph_toolbox-0.2.2 → memgraph_toolbox-0.2.3}/src/memgraph_toolbox/evals/__init__.py +0 -0
- {memgraph_toolbox-0.2.2 → memgraph_toolbox-0.2.3}/src/memgraph_toolbox/evals/coherence.py +0 -0
- {memgraph_toolbox-0.2.2 → memgraph_toolbox-0.2.3}/src/memgraph_toolbox/memgraph_toolbox.py +0 -0
- {memgraph_toolbox-0.2.2 → memgraph_toolbox-0.2.3}/src/memgraph_toolbox/py.typed +0 -0
- {memgraph_toolbox-0.2.2 → memgraph_toolbox-0.2.3}/src/memgraph_toolbox/tests/__init__.py +0 -0
- {memgraph_toolbox-0.2.2 → memgraph_toolbox-0.2.3}/src/memgraph_toolbox/tests/test_embedding.py +0 -0
- {memgraph_toolbox-0.2.2 → memgraph_toolbox-0.2.3}/src/memgraph_toolbox/tests/test_eval_coherence.py +0 -0
- {memgraph_toolbox-0.2.2 → memgraph_toolbox-0.2.3}/src/memgraph_toolbox/tests/test_mcp_prompt.py +0 -0
- {memgraph_toolbox-0.2.2 → memgraph_toolbox-0.2.3}/src/memgraph_toolbox/tests/test_memgraph_config.py +0 -0
- {memgraph_toolbox-0.2.2 → memgraph_toolbox-0.2.3}/src/memgraph_toolbox/tests/test_merge_with_retry.py +0 -0
- {memgraph_toolbox-0.2.2 → memgraph_toolbox-0.2.3}/src/memgraph_toolbox/tests/test_toolbox.py +0 -0
- {memgraph_toolbox-0.2.2 → memgraph_toolbox-0.2.3}/src/memgraph_toolbox/tests/test_tools.py +0 -0
- {memgraph_toolbox-0.2.2 → memgraph_toolbox-0.2.3}/src/memgraph_toolbox/tools/__init__.py +0 -0
- {memgraph_toolbox-0.2.2 → memgraph_toolbox-0.2.3}/src/memgraph_toolbox/tools/cypher.py +0 -0
- {memgraph_toolbox-0.2.2 → memgraph_toolbox-0.2.3}/src/memgraph_toolbox/tools/schema.py +0 -0
- {memgraph_toolbox-0.2.2 → memgraph_toolbox-0.2.3}/src/memgraph_toolbox/utils/embedding.py +0 -0
- {memgraph_toolbox-0.2.2 → memgraph_toolbox-0.2.3}/src/memgraph_toolbox/utils/logger.py +0 -0
- {memgraph_toolbox-0.2.2 → memgraph_toolbox-0.2.3}/src/memgraph_toolbox/utils/serialization.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: memgraph-toolbox
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.3
|
|
4
4
|
Summary: Memgraph toolbox library for Memgraph AI tools and utilities
|
|
5
5
|
Project-URL: Homepage, https://github.com/memgraph/ai-toolkit
|
|
6
6
|
Project-URL: Source, https://github.com/memgraph/ai-toolkit
|
|
@@ -112,6 +112,16 @@ def merge_with_retry(db: Any, query: str, params: dict | None = None, *, attempt
|
|
|
112
112
|
raise ValueError(f"attempts must be at least 1, got {attempts}")
|
|
113
113
|
|
|
114
114
|
|
|
115
|
+
def _driver_database(name: str) -> str | None:
|
|
116
|
+
"""The database to hand the driver: *name*, or None for an empty one (the login's main database).
|
|
117
|
+
|
|
118
|
+
Over a direct ``bolt://`` connection ``""`` and None both leave the database to the
|
|
119
|
+
server. A routing ``neo4j://`` driver instead asks the cluster for the routing table
|
|
120
|
+
of a database named ``""``, which has no writer, so every write fails.
|
|
121
|
+
"""
|
|
122
|
+
return name or None
|
|
123
|
+
|
|
124
|
+
|
|
115
125
|
class Memgraph:
|
|
116
126
|
"""
|
|
117
127
|
Base Memgraph client for interacting with Memgraph database.
|
|
@@ -141,7 +151,7 @@ class Memgraph:
|
|
|
141
151
|
url: The Memgraph connection URL
|
|
142
152
|
username: Username for authentication
|
|
143
153
|
password: Password for authentication
|
|
144
|
-
database: The database name to connect to (default: "memgraph")
|
|
154
|
+
database: The database name to connect to (default: "memgraph"); "" for the login's main database
|
|
145
155
|
driver_config: Additional Neo4j driver configuration
|
|
146
156
|
user_agent: Client name sent to the server (e.g. "mcp-memgraph", "langchain-memgraph", "sql2graph", etc.)
|
|
147
157
|
"""
|
|
@@ -157,7 +167,7 @@ class Memgraph:
|
|
|
157
167
|
|
|
158
168
|
self.driver = GraphDatabase.driver(url, auth=(username, password), **config)
|
|
159
169
|
|
|
160
|
-
self.database = env["MEMGRAPH_DATABASE"]
|
|
170
|
+
self.database = _driver_database(env["MEMGRAPH_DATABASE"])
|
|
161
171
|
|
|
162
172
|
try:
|
|
163
173
|
import neo4j
|
|
@@ -251,7 +261,7 @@ class AsyncMemgraph:
|
|
|
251
261
|
url: The Memgraph connection URL
|
|
252
262
|
username: Username for authentication
|
|
253
263
|
password: Password for authentication
|
|
254
|
-
database: The database name to connect to (default: "memgraph")
|
|
264
|
+
database: The database name to connect to (default: "memgraph"); "" for the login's main database
|
|
255
265
|
driver_config: Additional Neo4j driver configuration
|
|
256
266
|
user_agent: Client name sent to the server (e.g. "mcp-memgraph", "langchain-memgraph", "sql2graph", etc.)
|
|
257
267
|
"""
|
|
@@ -266,7 +276,7 @@ class AsyncMemgraph:
|
|
|
266
276
|
config.setdefault("user_agent", user_agent or self.DEFAULT_USER_AGENT)
|
|
267
277
|
|
|
268
278
|
self.driver = AsyncGraphDatabase.driver(url, auth=(username, password), **config)
|
|
269
|
-
self.database = env["MEMGRAPH_DATABASE"]
|
|
279
|
+
self.database = _driver_database(env["MEMGRAPH_DATABASE"])
|
|
270
280
|
|
|
271
281
|
async def verify_connectivity(self) -> None:
|
|
272
282
|
"""
|
|
@@ -6,7 +6,7 @@ import sys
|
|
|
6
6
|
from typing import cast
|
|
7
7
|
|
|
8
8
|
try:
|
|
9
|
-
from litellm import acompletion, experimental_mcp_client
|
|
9
|
+
from litellm import ModelResponse, acompletion, experimental_mcp_client
|
|
10
10
|
from mcp import ClientSession, StdioServerParameters
|
|
11
11
|
from mcp.client.stdio import stdio_client
|
|
12
12
|
except ImportError as e:
|
|
@@ -69,10 +69,13 @@ async def prompt_with_tools(
|
|
|
69
69
|
logger.info(f"{len(tools)} MCP tools loaded")
|
|
70
70
|
|
|
71
71
|
messages = [*tool_selection_system_messages, {"role": "user", "content": prompt}]
|
|
72
|
-
resp =
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
resp = cast(
|
|
73
|
+
"ModelResponse",
|
|
74
|
+
await acompletion(
|
|
75
|
+
model=tool_selection_model_name,
|
|
76
|
+
messages=messages,
|
|
77
|
+
tools=tools,
|
|
78
|
+
),
|
|
76
79
|
)
|
|
77
80
|
msg = resp["choices"][0]["message"]
|
|
78
81
|
tool_calls = msg.get("tool_calls", [])
|
|
@@ -147,9 +150,12 @@ async def prompt_with_tools(
|
|
|
147
150
|
)
|
|
148
151
|
|
|
149
152
|
messages = messages + response_system_messages
|
|
150
|
-
final_resp =
|
|
151
|
-
|
|
152
|
-
|
|
153
|
+
final_resp = cast(
|
|
154
|
+
"ModelResponse",
|
|
155
|
+
await acompletion(
|
|
156
|
+
model=response_model_name,
|
|
157
|
+
messages=messages,
|
|
158
|
+
),
|
|
153
159
|
)
|
|
154
160
|
return final_resp["choices"][0]["message"].content
|
|
155
161
|
|
{memgraph_toolbox-0.2.2 → memgraph_toolbox-0.2.3}/src/memgraph_toolbox/tests/test_async_memgraph.py
RENAMED
|
@@ -32,6 +32,11 @@ def test_async_memgraph_resolves_config_from_env(monkeypatch):
|
|
|
32
32
|
assert explicit.database == "arg-db"
|
|
33
33
|
|
|
34
34
|
|
|
35
|
+
def test_an_empty_database_reaches_the_driver_as_none():
|
|
36
|
+
"""An empty name means the login's main database; a routing driver would look up a database named ""."""
|
|
37
|
+
assert AsyncMemgraph(url="neo4j://localhost:7687", database="").database is None
|
|
38
|
+
|
|
39
|
+
|
|
35
40
|
def test_async_memgraph_mirrors_sync_defaults():
|
|
36
41
|
"""AsyncMemgraph shares the sync client's user-agent default."""
|
|
37
42
|
assert AsyncMemgraph.DEFAULT_USER_AGENT == Memgraph.DEFAULT_USER_AGENT
|