Add runtime gRPC server helpers and proto guard#18
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting
| def delete_triplet(self, subj: str, pred: str, obj: str) -> None: | ||
| predicate = self._sanitize_predicate(pred) | ||
| cypher = ( | ||
| "MATCH (a {uuid: $subj})-[r:`{predicate}`]->(b {uuid: $obj}) " | ||
| "DELETE r" | ||
| ) |
There was a problem hiding this comment.
Format dynamic predicate in Memgraph triplet deletion
The delete_triplet Cypher query embeds {predicate} inside backticks but the string is not an f-string, so {predicate} is never replaced with the sanitized relationship type. As written the driver sends MATCH (a {uuid: $subj})-[r:{predicate}]->(b {uuid: $obj}) DELETE r, which is invalid Cypher and the call fails for every predicate. This method therefore cannot delete any triplet. Format the string (or build it with parameters) before executing.
Useful? React with 👍 / 👎.
| def search(self, payload: SearchPayload) -> Sequence[Memory]: | ||
| proto = pb2.SearchPayload( | ||
| query=payload.query, | ||
| namespace=payload.namespace or "", | ||
| top_k=payload.top_k, | ||
| encoder=payload.encoder or "", | ||
| entity_labels=list(payload.entity_labels or []), | ||
| rerank_model=payload.rerank_model or "", | ||
| use_llm_rerank=payload.use_llm_rerank, | ||
| llm_models=dict(payload.llm_models or {}), | ||
| llm_base_urls=dict(payload.llm_base_urls or {}), | ||
| llm_api_key=payload.llm_api_key or "", |
There was a problem hiding this comment.
Filter None values before populating gRPC map fields
The convenience GrpcServiceStub.search forwards payload.llm_base_urls directly into pb2.SearchPayload. SearchPayload.llm_base_urls allows Dict[str, Optional[str]], so callers may include entries with None values, but protobuf map fields accept only concrete strings. Passing { "default": None } raises TypeError when the request is built, preventing gRPC calls that rely on the optional override keys. Drop keys with None values (or cast to empty strings) before constructing the protobuf message.
Useful? React with 👍 / 👎.
Summary
Testing
https://chatgpt.com/codex/tasks/task_b_68ee1c9ee92c83218cbbebce8b0667b8