mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-04-25 08:26:21 +02:00
Update docs for API/CLI changes in 1.0 (#421)
* Update some API basics for the 0.23/1.0 API change
This commit is contained in:
parent
f907ea7db8
commit
44bdd29f51
69 changed files with 19981 additions and 407 deletions
|
|
@ -21,7 +21,7 @@ Returned triples will match all of `s`, `p` and `o` where provided.
|
|||
|
||||
### Response
|
||||
|
||||
The request contains the following fields:
|
||||
The response contains the following fields:
|
||||
- `response`: A list of triples.
|
||||
|
||||
Each triple contains `s`, `p` and `o` fields describing the
|
||||
|
|
@ -33,15 +33,53 @@ Each triple element uses the same schema:
|
|||
- `is_uri`: A boolean value which is true if this is a graph entity i.e.
|
||||
`value` is a URI, not a literal value.
|
||||
|
||||
## Data Format Details
|
||||
|
||||
### Triple Element Format
|
||||
|
||||
To reduce the size of JSON messages, triple elements (subject, predicate, object) are encoded using a compact format:
|
||||
|
||||
- `v`: The value as a string (maps to `value` in the full schema)
|
||||
- `e`: Boolean indicating if this is an entity/URI (maps to `is_uri` in the full schema)
|
||||
|
||||
Each triple element (`s`, `p`, `o`) contains:
|
||||
- `v`: The actual value as a string
|
||||
- `e`: Boolean indicating the value type
|
||||
- `true`: The value is a URI/entity (e.g., `"http://example.com/Person1"`)
|
||||
- `false`: The value is a literal (e.g., `"John Doe"`, `"42"`, `"2023-01-01"`)
|
||||
|
||||
### Examples
|
||||
|
||||
**URI/Entity Element:**
|
||||
```json
|
||||
{
|
||||
"v": "http://trustgraph.ai/e/space-station-modules",
|
||||
"e": true
|
||||
}
|
||||
```
|
||||
|
||||
**Literal Element:**
|
||||
```json
|
||||
{
|
||||
"v": "space station modules",
|
||||
"e": false
|
||||
}
|
||||
```
|
||||
|
||||
**Numeric Literal:**
|
||||
```json
|
||||
{
|
||||
"v": "42",
|
||||
"e": false
|
||||
}
|
||||
```
|
||||
|
||||
## REST service
|
||||
|
||||
The REST service accepts a request object containing the `s`, `p`, `o`
|
||||
and `limit` fields.
|
||||
The response is a JSON object containing the `response` field.
|
||||
|
||||
To reduce the size of the JSON, the graph entities are encoded as an
|
||||
object with `value` and `is_uri` mapped to `v` and `e` respectively.
|
||||
|
||||
e.g.
|
||||
|
||||
This example query matches triples with a subject of
|
||||
|
|
@ -58,6 +96,7 @@ Request:
|
|||
{
|
||||
"id": "qgzw1287vfjc8wsk-4",
|
||||
"service": "triples-query",
|
||||
"flow": "default",
|
||||
"request": {
|
||||
"s": {
|
||||
"v": "http://trustgraph.ai/e/space-station-modules",
|
||||
|
|
@ -97,13 +136,9 @@ Response:
|
|||
|
||||
## Websocket
|
||||
|
||||
Requests have a `request` object containing the `system` and
|
||||
`prompt` fields.
|
||||
Requests have a `request` object containing the query fields (`s`, `p`, `o`, `limit`).
|
||||
Responses have a `response` object containing `response` field.
|
||||
|
||||
To reduce the size of the JSON, the graph entities are encoded as an
|
||||
object with `value` and `is_uri` mapped to `v` and `e` respectively.
|
||||
|
||||
e.g.
|
||||
|
||||
Request:
|
||||
|
|
@ -178,10 +213,3 @@ The client class is
|
|||
|
||||
https://github.com/trustgraph-ai/trustgraph/blob/master/trustgraph-base/trustgraph/clients/triples_query_client.py
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue