upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/90.md
diff options
context:
space:
mode:
authorfiatjaf <fiatjaf@gmail.com>2023-11-18 09:13:12 -0300
committerfiatjaf <fiatjaf@gmail.com>2023-11-18 09:13:12 -0300
commit5dcfe85306434f21ecb1e7a47edd92b2e3e64f9a (patch)
tree4fff8694238b3ae5e692a8480869ad1266b95be4 /90.md
parentb0df71824f9967130b54150b64cc70fa94bffec2 (diff)
reformat a bunch of json things and small nitpicks.
Diffstat (limited to '90.md')
-rw-r--r--90.md147
1 files changed, 76 insertions, 71 deletions
diff --git a/90.md b/90.md
index c498cdd..6017c98 100644
--- a/90.md
+++ b/90.md
@@ -13,11 +13,11 @@ Money in, data out.
13## Kinds 13## Kinds
14This NIP reserves the range `5000-7000` for data vending machine use. 14This NIP reserves the range `5000-7000` for data vending machine use.
15 15
16| Kind | Description | 16| Kind | Description |
17| ---- | ----------- | 17| ---- | ----------- |
18| 5000-5999 | Job request kinds | 18| 5000-5999 | Job request kinds |
19| 6000-6999 | Job result | 19| 6000-6999 | Job result |
20| 7000 | Job feedback | 20| 7000 | Job feedback |
21 21
22Job results always use a kind number that is `1000` higher than the job request kind. (e.g. request: `kind:5001` gets a result: `kind:6001`). 22Job results always use a kind number that is `1000` higher than the job request kind. (e.g. request: `kind:5001` gets a result: `kind:6001`).
23 23
@@ -67,34 +67,34 @@ All tags are optional.
67* `relays`: List of relays where Service Providers SHOULD publish responses to 67* `relays`: List of relays where Service Providers SHOULD publish responses to
68* `p`: Service Providers the customer is interested in. Other SPs MIGHT still choose to process the job 68* `p`: Service Providers the customer is interested in. Other SPs MIGHT still choose to process the job
69 69
70## Encrypted Params 70## Encrypted Params
71 71
72If the user wants to keep the input parameters a secret, they can encrypt the `i` and `param` tags with the service provider's 'p' tag and add it to the content field. Add a tag `encrypted` as tags. Encryption for private tags will use [NIP-04 - Encrypted Direct Message encryption](https://github.com/nostr-protocol/nips/blob/master/04.md), using the user's private and service provider's public key for the shared secret 72If the user wants to keep the input parameters a secret, they can encrypt the `i` and `param` tags with the service provider's 'p' tag and add it to the content field. Add a tag `encrypted` as tags. Encryption for private tags will use [NIP-04 - Encrypted Direct Message encryption](https://github.com/nostr-protocol/nips/blob/master/04.md), using the user's private and service provider's public key for the shared secret
73 73
74```json 74```json
75[ 75[
76 [ "i", "what is the capital of France? ", "text" ], 76 ["i", "what is the capital of France? ", "text"],
77 [ "param", "model", "LLaMA-2" ], 77 ["param", "model", "LLaMA-2"],
78 [ "param", "max_tokens", "512" ], 78 ["param", "max_tokens", "512"],
79 [ "param", "temperature", "0.5" ], 79 ["param", "temperature", "0.5"],
80 [ "param", "top-k", "50" ], 80 ["param", "top-k", "50"],
81 [ "param", "top-p", "0.7" ], 81 ["param", "top-p", "0.7"],
82 [ "param", "frequency_penalty", "1" ] 82 ["param", "frequency_penalty", "1"]
83
84] 83]
85 84
86``` 85```
87 86
88This param data will be encrypted and added to the `content` field and `p` tag should be present 87This param data will be encrypted and added to the `content` field and `p` tag should be present
89
90```
91"content": "BE2Y4xvS6HIY7TozIgbEl3sAHkdZoXyLRRkZv4fLPh3R7LtviLKAJM5qpkC7D6VtMbgIt4iNcMpLtpo...",
92 "tags": [
93 ["p", "04f74530a6ede6b24731b976b8e78fb449ea61f40ff10e3d869a3030c4edc91f"],
94 ["encrypted"]
95 ]
96
97 88
89```json
90{
91 "content": "BE2Y4xvS6HIY7TozIgbEl3sAHkdZoXyLRRkZv4fLPh3R7LtviLKAJM5qpkC7D6VtMbgIt4iNcMpLtpo...",
92 "tags": [
93 ["p", "04f74530a6ede6b24731b976b8e78fb449ea61f40ff10e3d869a3030c4edc91f"],
94 ["encrypted"]
95 ],
96 ...
97}
98``` 98```
99 99
100 100
@@ -104,16 +104,17 @@ Service providers publish job results, providing the output of the job result. T
104 104
105```json 105```json
106{ 106{
107 "pubkey": "<service-provider pubkey>", 107 "pubkey": "<service-provider pubkey>",
108 "content": "<payload>", 108 "content": "<payload>",
109 "kind": 6xxx, 109 "kind": 6xxx,
110 "tags": [ 110 "tags": [
111 [ "request", "<job-request>" ], 111 ["request", "<job-request>"],
112 [ "e", "<job-request-id>", "<relay-hint>" ], 112 ["e", "<job-request-id>", "<relay-hint>"],
113 [ "i", "<input-data>" ], 113 ["i", "<input-data>"],
114 [ "p", "<customer's-pubkey>" ], 114 ["p", "<customer's-pubkey>"],
115 [ "amount", "requested-payment-amount", "<optional-bolt11>" ] 115 ["amount", "requested-payment-amount", "<optional-bolt11>"]
116 ] 116 ],
117 ...
117} 118}
118``` 119```
119 120
@@ -123,38 +124,40 @@ Service providers publish job results, providing the output of the job result. T
123 124
124## Encrypted Output 125## Encrypted Output
125 126
126If the request has encrypted params, then output should be encrypted and placed in `content` field. If the output is encrypted, then avoid including `i` tag with input-data as clear text. 127If the request has encrypted params, then output should be encrypted and placed in `content` field. If the output is encrypted, then avoid including `i` tag with input-data as clear text.
127Add a tag encrypted to mark the output content as `encrypted` 128Add a tag encrypted to mark the output content as `encrypted`
129
128```json 130```json
129{ 131{
130 "pubkey": "<service-provider pubkey>", 132 "pubkey": "<service-provider pubkey>",
131 "content": "<encrypted payload>", 133 "content": "<encrypted payload>",
132 "kind": 6xxx, 134 "kind": 6xxx,
133 "tags": [ 135 "tags": [
134 [ "request", "<job-request>" ], 136 ["request", "<job-request>"],
135 [ "e", "<job-request-id>", "<relay-hint>" ], 137 ["e", "<job-request-id>", "<relay-hint>"],
136 [ "p", "<customer's-pubkey>" ], 138 ["p", "<customer's-pubkey>"],
137 [ "amount", "requested-payment-amount", "<optional-bolt11>" ], 139 ["amount", "requested-payment-amount", "<optional-bolt11>"],
138 ["encrypted"] 140 ["encrypted"]
139 141 ],
140 ] 142 ...
141} 143}
142``` 144```
143
144 145
145## Job feedback 146## Job feedback
147
146Service providers can give feedback about a job back to the customer. 148Service providers can give feedback about a job back to the customer.
147 149
148```json 150```json
149{ 151{
150 "kind": 7000, 152 "kind": 7000,
151 "content": "<empty-or-payload>", 153 "content": "<empty-or-payload>",
152 "tags": [ 154 "tags": [
153 [ "status", "<status>", "<extra-info>" ], 155 ["status", "<status>", "<extra-info>"],
154 [ "amount", "requested-payment-amount", "<bolt11>" ], 156 ["amount", "requested-payment-amount", "<bolt11>"],
155 [ "e", "<job-request-id>", "<relay-hint>" ], 157 ["e", "<job-request-id>", "<relay-hint>"],
156 [ "p", "<customer's-pubkey>" ], 158 ["p", "<customer's-pubkey>"],
157 ] 159 ],
160 ...
158} 161}
159``` 162```
160 163
@@ -166,18 +169,19 @@ Service providers can give feedback about a job back to the customer.
166 169
167### Job feedback status 170### Job feedback status
168 171
169| status | description | 172| status | description |
170|--------|-------------| 173| -------- | ------------- |
171| `payment-required` | Service Provider requires payment before continuing. | 174| `payment-required` | Service Provider requires payment before continuing. |
172| `processing` | Service Provider is processing the job. | 175| `processing` | Service Provider is processing the job. |
173| `error` | Service Provider was unable to process the job. | 176| `error` | Service Provider was unable to process the job. |
174| `success` | Service Provider successfully processed the job. | 177| `success` | Service Provider successfully processed the job. |
175| `partial` | Service Provider partially processed the job. The `.content` might include a sample of the partial results. | 178| `partial` | Service Provider partially processed the job. The `.content` might include a sample of the partial results. |
176 179
177Any job feedback event MIGHT include results in the `.content` field, as described in the [Job Result](#job-result) section. This is useful for service providers to provide a sample of the results that have been processed so far. 180Any job feedback event MIGHT include results in the `.content` field, as described in the [Job Result](#job-result) section. This is useful for service providers to provide a sample of the results that have been processed so far.
178 181
179 182
180# Protocol Flow 183# Protocol Flow
184
181* Customer publishes a job request (e.g. `kind:5000` speech-to-text). 185* Customer publishes a job request (e.g. `kind:5000` speech-to-text).
182* Service Providers MAY submit `kind:7000` job-feedback events (e.g. `payment-required`, `processing`, `error`, etc.). 186* Service Providers MAY submit `kind:7000` job-feedback events (e.g. `payment-required`, `processing`, `error`, etc.).
183* Upon completion, the service provider publishes the result of the job with a `kind:6000` job-result event. 187* Upon completion, the service provider publishes the result of the job with a `kind:6000` job-result event.
@@ -207,18 +211,19 @@ This gives a higher level of flexibility to service providers (which sophisticat
207# Appendix 2: Service provider discoverability 211# Appendix 2: Service provider discoverability
208Service Providers MAY use NIP-89 announcements to advertise their support for job kinds: 212Service Providers MAY use NIP-89 announcements to advertise their support for job kinds:
209 213
210```json 214```js
211{ 215{
212 "kind": 31990, 216 "kind": 31990,
213 "pubkey": "<pubkey>", 217 "pubkey": "<pubkey>",
214 "content": "{ 218 "content": "{
215 \"name\": \"Translating DVM\", 219 \"name\": \"Translating DVM\",
216 \"about\": \"I'm a DVM specialized in translating Bitcoin content.\" 220 \"about\": \"I'm a DVM specialized in translating Bitcoin content.\"
217 }", 221 }",
218 "tags": [ 222 "tags": [
219 [ "k", "5005" ], // e.g. translation 223 ["k", "5005"], // e.g. translation
220 [ "t", "bitcoin" ] // e.g. optionally advertises it specializes in bitcoin audio transcription that won't confuse "Drivechains" with "Ridechains" 224 ["t", "bitcoin"] // e.g. optionally advertises it specializes in bitcoin audio transcription that won't confuse "Drivechains" with "Ridechains"
221 ] 225 ],
226 ...
222} 227}
223``` 228```
224 229