Skip to content

Commit 2fe7896

Browse files
authored
Add LLM util (#225)
1 parent 09e3354 commit 2fe7896

File tree

36 files changed

+297
-0
lines changed

36 files changed

+297
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ YIELD node, rank;
267267
| [katz_centrality_online](https://memgraph.com/docs/mage/query-modules/cpp/katz-centrality-online) | C++ | Online implementation of the Katz centrality. Outputs the approximate result for Katz centrality while maintaining the order of rankings. |
268268
| [kmeans](https://memgraph.com/docs/mage/query-modules/python/kmeans) | Python | An algorithm for clustering given data. |
269269
| [link_prediction_gnn](https://memgraph.com/docs/mage/query-modules/python/link-prediction-with-gnn) | Python | A module for predicting links in graphs using graph neural networks. |
270+
| [llm_util](https://memgraph.com/docs/mage/query-modules/python/llm-util) | Python | A module that contains procedures describing graphs in a format best suited for large language models (LLMs). |
270271
| [max_flow](https://memgraph.com/docs/mage/query-modules/python/max-flow) | Python | An algorithm for calculating maximum flow through a graph using capacity scaling |
271272
| [meta_util](https://memgraph.com/docs/mage/query-modules/python/meta-util) | Python | A module that contains procedures describing graphs on a meta-level. |
272273
| [node_classification_with_gnn](https://memgraph.com/docs/mage/query-modules/python/node-classification-with-gnn) | Python | A graph neural network-based node classification module. |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CREATE (n:Person {name: "Kate", age: 27})-[:IS_FRIENDS_WITH {since: "2023-06-21"}]->(m:Person:Student {name: "James", age: 30, year: "second"})-[:STUDIES_AT]->(:University {name: "University of Zagreb"}) CREATE (p:Person:Student {name: "Anthony", age: 25})-[:STUDIES_AT]->(:University {name: "University of Vienna"}) WITH n, m CREATE (n)-[:LIVES_IN]->(:City {name: "Zagreb"})<-[:LIVES_IN]-(m);
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
query: >
2+
CALL llm_util.schema() YIELD schema RETURN schema;
3+
output:
4+
- schema: "Node properties are the following:\nNode name: 'Person', Node properties: [{'property': 'name', 'type': 'str'}, {'property': 'age', 'type': 'int'}, {'property': 'year', 'type': 'str'}]\nNode name: 'Student', Node properties: [{'property': 'name', 'type': 'str'}, {'property': 'age', 'type': 'int'}, {'property': 'year', 'type': 'str'}]\nNode name: 'University', Node properties: [{'property': 'name', 'type': 'str'}]\nNode name: 'City', Node properties: [{'property': 'name', 'type': 'str'}]\n\nRelationship properties are the following:\nRelationship Name: 'IS_FRIENDS_WITH', Relationship Properties: [{'property': 'since', 'type': 'str'}]\n\nThe relationships are the following:\n['(:Person)-[:IS_FRIENDS_WITH]->(:Person)']\n['(:Person)-[:IS_FRIENDS_WITH]->(:Student)']\n['(:Person)-[:LIVES_IN]->(:City)']\n['(:Person)-[:STUDIES_AT]->(:University)']\n['(:Student)-[:STUDIES_AT]->(:University)']\n['(:Student)-[:LIVES_IN]->(:City)']\n"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CREATE (n:Person {name: "Kate", age: 27})-[:IS_FRIENDS_WITH]->(m:Person:Student {name: "James", age: 30, year: "second"})-[:STUDIES_AT]->(:University {name: "University of Zagreb"}) CREATE (p:Person:Student {name: "Anthony", age: 25})-[:STUDIES_AT]->(:University {name: "University of Vienna"}) WITH n, m CREATE (n)-[:LIVES_IN]->(:City {name: "Zagreb"})<-[:LIVES_IN]-(m);
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
query: >
2+
CALL llm_util.schema() YIELD schema RETURN schema;
3+
output:
4+
- schema: "Node properties are the following:\nNode name: 'Person', Node properties: [{'property': 'name', 'type': 'str'}, {'property': 'age', 'type': 'int'}, {'property': 'year', 'type': 'str'}]\nNode name: 'Student', Node properties: [{'property': 'name', 'type': 'str'}, {'property': 'age', 'type': 'int'}, {'property': 'year', 'type': 'str'}]\nNode name: 'University', Node properties: [{'property': 'name', 'type': 'str'}]\nNode name: 'City', Node properties: [{'property': 'name', 'type': 'str'}]\n\nRelationship properties are the following:\n\nThe relationships are the following:\n['(:Person)-[:IS_FRIENDS_WITH]->(:Person)']\n['(:Person)-[:IS_FRIENDS_WITH]->(:Student)']\n['(:Person)-[:LIVES_IN]->(:City)']\n['(:Person)-[:STUDIES_AT]->(:University)']\n['(:Student)-[:STUDIES_AT]->(:University)']\n['(:Student)-[:LIVES_IN]->(:City)']\n"
5+

e2e/llm_util_test/test_schema_empty/input.cyp

Whitespace-only changes.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
query: >
2+
CALL llm_util.schema() YIELD * RETURN *;
3+
exception:
4+
- Can't generate a graph schema since there is no data in the database.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CREATE (n);
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
query: >
2+
CALL llm_util.schema('wrong_arg') YIELD * RETURN *;
3+
exception:
4+
- Can't generate a graph schema since the provided output_type is not correct. Please choose raw or prompt_ready.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CREATE (n:Person {name: "Kate", age: 27})-[:IS_FRIENDS_WITH]->(m:Person:Student {name: "James", age: 30, year: "second"})-[:STUDIES_AT]->(:University {name: "University of Zagreb"}) CREATE (p:Person:Student {name: "Anthony", age: 25})-[:STUDIES_AT]->(:University {name: "University of Vienna"}) WITH n, m CREATE (n)-[:LIVES_IN]->(:City {name: "Zagreb"})<-[:LIVES_IN]-(m);

0 commit comments

Comments
 (0)