@@ -32,11 +32,46 @@ Before starting this guide, ensure you have:
3232- Python 3.10 or later with the TrustGraph CLI tools installed (` pip install trustgraph-cli ` )
3333- Sample documents or structured data files to process
3434
35+ ## Workbench
36+
37+ The Structured Query page on the workbench UI allows you to run the
38+ queries we'll be running here. Make sure:
39+
40+ - You have set the collection parameter correctly in the session state
41+ popover, top-right.
42+ - Be sure to set a flow which has object processing enabled e.g. the
43+ ` obj-ex ` flow which you created if you are following this guide.
44+
45+ <img src =" nlp-query.png " alt =" NLP query " />
46+
47+ <img src =" structured-query.png " alt =" Structured query " />
48+
3549## NLP query operation
3650
3751This operation takes a natural language query, and uses an LLM prompt
3852to convert to a GraphQL query. This uses defined schema, so you need
39- to have the pies schema loaded:
53+ to have the schemas loaded in the previous guide steps.
54+
55+ This is a building block for more complete functionality, but it may
56+ be useful for you to be able to look at converted queries to check that
57+ your application is performing well.
58+
59+ ``` bash
60+ tg-invoke-nlp-query -f obj-ex -q ' Cities with more than 22.8m people'
61+ ```
62+
63+ If successful the output is something like...
64+
65+ ```
66+ Generated GraphQL Query:
67+ ----------------------------------------
68+ query { cities(where: {population: {gt: 22800000}}) { city country population } }
69+ ----------------------------------------
70+ Detected Schemas: cities
71+ Confidence: 95.00%
72+ ```
73+
74+ Querying the pies data:
4075
4176```
4277tg-invoke-nlp-query -f obj-ex \
@@ -59,6 +94,31 @@ Confidence: 95.00%
5994This operation takes a GraphQL query, and executes it on the object
6095store.
6196
97+ City example:
98+
99+ ```
100+ tg-invoke-objects-query -f obj-ex --collection cities -q '
101+ {
102+ cities(where: {population: {gt: 22800000}}) { city country population }
103+ }
104+ '
105+ ```
106+
107+ ```
108+ +-----------+------------+------------+
109+ | city | country | population |
110+ +-----------+------------+------------+
111+ | Shanghai | China | 30482140 |
112+ | São Paulo | Brazil | 22990007 |
113+ | Delhi | India | 34665569 |
114+ | Tokyo | Japan | 37036204 |
115+ | Dhaka | Bangladesh | 24652864 |
116+ | Cairo | Egypt | 23074225 |
117+ +-----------+------------+------------+
118+ ```
119+
120+ Pies example:
121+
62122```
63123tg-invoke-objects-query -f obj-ex \
64124 --collection uk-pies \
@@ -86,6 +146,28 @@ You can use `--format` to request CSV or JSON output.
86146
87147This is an API which uses the above two operations in sequence.
88148
149+ Cities example:
150+
151+ ```
152+ tg-invoke-structure-query -f obj-ex --collection cities \
153+ -q 'Cities with more than 22.8m people'
154+ ```
155+
156+ ```
157+ +-----------+------------+------------+
158+ | city | country | population |
159+ +-----------+------------+------------+
160+ | Shanghai | China | 30482140 |
161+ | São Paulo | Brazil | 22990007 |
162+ | Delhi | India | 34665569 |
163+ | Tokyo | Japan | 37036204 |
164+ | Dhaka | Bangladesh | 24652864 |
165+ | Cairo | Egypt | 23074225 |
166+ +-----------+------------+------------+
167+ ```
168+
169+ Pies example:
170+
89171```
90172tg-invoke-structured-query -f obj-ex \
91173 --collection uk-pies \
@@ -107,6 +189,9 @@ You can use `--format` to request CSV or JSON output.
107189
108190## With collections
109191
192+ Using the same schema with different collections allows you to group
193+ data:
194+
110195```
111196tg-invoke-structured-query -f obj-ex \
112197 --collection fr-pies \
0 commit comments