upleb.uk

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

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpablof7z <p@f7z.io>2023-07-23 23:58:12 +0300
committerpablof7z <p@f7z.io>2023-07-23 23:58:12 +0300
commit280483adc5b2299886e1e15e369557001e8807af (patch)
tree2898163ea2e28559a0b9fd2862171e4d62c97ac6
parentd8b0e7d757206098f65b8ff868e8c59a9ac92ea6 (diff)
more clarifications
-rw-r--r--vending-machine.md68
1 files changed, 52 insertions, 16 deletions
diff --git a/vending-machine.md b/vending-machine.md
index 4934d4c..c4fdc18 100644
--- a/vending-machine.md
+++ b/vending-machine.md
@@ -17,6 +17,8 @@ This NIP reserves the range `65000-66000` for data vending machine use.
17| 65001 | Job result | 17| 65001 | Job result |
18| 65002-66000 | Job request kinds | 18| 65002-66000 | Job request kinds |
19 19
20[Appendix 2](#appendix-2-job-types) defines the job types.
21
20## Rationale 22## Rationale
21Nostr can act as a marketplace for data processing, where users request jobs to be processed in certain ways (e.g. "speech-to-text", "summarization", etc.), but where they don't necessarily care about "who" processes the data. 23Nostr can act as a marketplace for data processing, where users request jobs to be processed in certain ways (e.g. "speech-to-text", "summarization", etc.), but where they don't necessarily care about "who" processes the data.
22 24
@@ -33,7 +35,7 @@ A request to have data processed -- published by a customer
33 35
34```json 36```json
35{ 37{
36 "kind": <65002-66000>, 38 "kind": xxx, // kind in 65002-66000 range
37 "content": "", 39 "content": "",
38 "tags": [ 40 "tags": [
39 [ "i", "<data>", "<input-type>", "<marker>", "<relay>" ], 41 [ "i", "<data>", "<input-type>", "<marker>", "<relay>" ],
@@ -54,8 +56,8 @@ All tags are optional.
54 * `url`: a URL to be fetched 56 * `url`: a URL to be fetched
55 * `event`: a nostr event ID, include an optional relay-url extra param 57 * `event`: a nostr event ID, include an optional relay-url extra param
56 * `job`: the output of a previous job with the specified event ID 58 * `job`: the output of a previous job with the specified event ID
57 * `content`: 59 * `text`: `<data>` is the value of the input, no resolution is needed
58 * `<marker>`: an optional field indicating how this input should be used. 60 * `<marker>`: an optional field indicating how this input should be used within the context of the job.
59 * `<relay>`: if `event` or `job` input-type, the relay where the event/job was published, otherwise optional or empty string. 61 * `<relay>`: if `event` or `job` input-type, the relay where the event/job was published, otherwise optional or empty string.
60* `output`: MIME type. Expected output format. Service Providers SHOULD publish the result of the job in this format if it has been specified. 62* `output`: MIME type. Expected output format. Service Providers SHOULD publish the result of the job in this format if it has been specified.
61* `bid`: Customer MAY specify a maximum amount (in millisats) they are willing to pay. 63* `bid`: Customer MAY specify a maximum amount (in millisats) they are willing to pay.
@@ -97,7 +99,7 @@ The result of the job SHOULD be included in the `content` field.
97* Upon completion, the service provider publishes the result of the job with a `kind:65001` job-result event. 99* Upon completion, the service provider publishes the result of the job with a `kind:65001` job-result event.
98* At any point, the user can pay the included `bolt11` or zap any of the events the service provider has sent to the user. 100* At any point, the user can pay the included `bolt11` or zap any of the events the service provider has sent to the user.
99 101
100`kind:65000` and `kind:65001` events MAY include an `amount` tag, this can be interpreted as a suggestion to pay. Service Providers SHOULD use the `payment-required` feedback event to signal that a payment is required and no further actions will be performed until the payment is sent. Custeroms are can always either pay the included `bolt11` invoice or zap the event requesting the payment and service providers should monitor for both if they choose to include a bolt11 invoice. 102`kind:65000` and `kind:65001` events MAY include an `amount` tag, this can be interpreted as a suggestion to pay. Service Providers SHOULD use the `payment-required` feedback event to signal that a payment is required and no further actions will be performed until the payment is sent. Customers are can always either pay the included `bolt11` invoice or zap the event requesting the payment and service providers should monitor for both if they choose to include a bolt11 invoice.
101 103
102## Notes about the protocol flow 104## Notes about the protocol flow
103The flow is deliverately ambiguos, allowing vast flexibility for the interaction between customers and service providers so that service providers can model their behavior based on their own decisions. Some service providers might choose to submit a `payment-required` as the first reaction before sending an `processing` or before delivering `kind:65001` results, some might choose to serve partial results for the job (e.g. as a sample), send a `payment-required`to deliver the rest of the results, and some service providers might choose to assess likelyhood of payment based on an npub's past behavior and thus serve the job results before requesting payment for the best possible UX. 105The flow is deliverately ambiguos, allowing vast flexibility for the interaction between customers and service providers so that service providers can model their behavior based on their own decisions. Some service providers might choose to submit a `payment-required` as the first reaction before sending an `processing` or before delivering `kind:65001` results, some might choose to serve partial results for the job (e.g. as a sample), send a `payment-required`to deliver the rest of the results, and some service providers might choose to assess likelyhood of payment based on an npub's past behavior and thus serve the job results before requesting payment for the best possible UX.
@@ -117,6 +119,8 @@ A Customer MAY request multiple jobs to be processed in a chained form, so that
117 119
118Service Providers MAY begin processing a subsequent job the moment they see the prior job's result, but they will likely wait for a zap to be published first. This introduces a risk that Service Provider of job #1 might delay publishing the zap event in order to have an advantage. This risk is up to Service Providers to mitigate or to decide whether the service provider of job #1 tends to have good-enough results so as to not wait for a explicit zap to assume the job was accepted. 120Service Providers MAY begin processing a subsequent job the moment they see the prior job's result, but they will likely wait for a zap to be published first. This introduces a risk that Service Provider of job #1 might delay publishing the zap event in order to have an advantage. This risk is up to Service Providers to mitigate or to decide whether the service provider of job #1 tends to have good-enough results so as to not wait for a explicit zap to assume the job was accepted.
119 121
122Consult [Appendix 1: Example](#appendix-1-examples)'s [Summarization of a podcast](#summarization-of-a-podcast)
123
120# Job Feedback 124# Job Feedback
121The parties to a job request can use `kind:65000` to provide feedback about the job, using a `status` tag to indicate the type of feedback. 125The parties to a job request can use `kind:65000` to provide feedback about the job, using a `status` tag to indicate the type of feedback.
122 126
@@ -215,7 +219,9 @@ Not to be included in the first draft of this NIP, but encrypted job requests sh
215``` 219```
216 220
217## Summarization of a podcast 221## Summarization of a podcast
218User publishes two job requests at the same time. 222User publishes two job requests at the same time. A job that transcribes an audio and a job that summarizes the transcription (output of job #1).
223
224User publishes event #1 and #2 together.
219 225
220### `kind:65002`: Job Request #1: speech-to-text 226### `kind:65002`: Job Request #1: speech-to-text
221```json 227```json
@@ -223,7 +229,7 @@ User publishes two job requests at the same time.
223 "id": "12345", 229 "id": "12345",
224 "pubkey": "abcdef", 230 "pubkey": "abcdef",
225 "kinds" 65002, 231 "kinds" 65002,
226 "content": "I need a transcript of Bitcoin.review from second 900 to 930", 232 "content": "",
227 "tags": [ 233 "tags": [
228 [ "i", "https://bitcoin.review/episode1.mp3", "url" ], 234 [ "i", "https://bitcoin.review/episode1.mp3", "url" ],
229 [ "output", "text/plain" ], 235 [ "output", "text/plain" ],
@@ -233,7 +239,7 @@ User publishes two job requests at the same time.
233} 239}
234``` 240```
235 241
236### `kind:65003`: Job Request #2: summarization of job #1's result 242### `kind:65002`: Job Request #2: summarization of job #1's result
237```json 243```json
238{ 244{
239 "id": "12346", 245 "id": "12346",
@@ -241,7 +247,7 @@ User publishes two job requests at the same time.
241 "kinds": 65003, 247 "kinds": 65003,
242 "content": "", 248 "content": "",
243 "tags": [ 249 "tags": [
244 [ "i", "12346", "job" ], 250 [ "i", "12345", "job" ], // input is the output of job with id 12345
245 [ "output", "text/plain" ], 251 [ "output", "text/plain" ],
246 [ "params", "length", "3 paragraphs" ], 252 [ "params", "length", "3 paragraphs" ],
247 [ "bid", "10000" ] 253 [ "bid", "10000" ]
@@ -317,30 +323,60 @@ User publishes two job requests at the same time.
317 ] 323 ]
318} 324}
319``` 325```
326## AI-image of embedded input
320 327
321# Appendix 2: Job types 328### `kind:65005`: Job request
329```json
330{
331 "kind": 65004,
332 "tags": [
333 [ "i", "Millions of vending machines, interconnected with tubes with eah other", "text" ],
334 [ "param", "prompt", "photorealistic" ],
335 [ "bid", "500000" ]
336 ]
337}
338```
322 339
323This NIP defines some example job types, Customers SHOULD specify these types for maximum compatibility with Service Providers. Other job types MAY be added to this NIP after being observed in the wild. 340### `kind:65006`: Job request #4 (generate image based on the summary)
341```json
342{
343 "id": "126",
344 "kind": 65004,
345 "tags": [
346 [ "i", "125", "job" ],
347 [ "param", "prompt", "photorealistic" ],
348 [ "param", "size", "4000x4000" ],
349 [ "bid", "500000" ]
350 ]
351}
352```
353
354# Appendix 2: Job types
324 355
325### speech-to-text: `kind:65002` 356This is a list of all the supported job requests
326#### params 357.
358## speech-to-text: `kind:65002`
359### params
327| param | req? | description 360| param | req? | description
328|--------------------------------|------|-------- 361|--------------------------------|------|--------
329| `range` | opt | timestamp range (in seconds) of desired text to be transcribed 362| `range` | opt | timestamp range (in seconds) of desired text to be transcribed
330| `alignment` | opt | word, segment, raw: word-level, segment-level or raw outputs 363| `alignment` | opt | word, segment, raw: word-level, segment-level or raw outputs
331 364
332### summarization: `kind:65003` 365## summarization: `kind:65003`
333| param | req? | description 366| param | req? | description
334|--------------------------------|------|-------- 367|--------------------------------|------|--------
335| `length` | opt | desired length 368| `length` | opt | desired length
336 369
337### translation: `kind:65004` 370## translation: `kind:65004`
338| param | req? | description 371| param | req? | description
339|--------------------------------|------|-------- 372|--------------------------------|------|--------
340| `lang` | req | desired language in BCP 47 format. 373| `lang` | req | desired language in BCP 47 format.
341 374
342### image generation: `kind:65005` 375## image generation: `kind:65005`
343* `input` 376| param | req? | description
377|--------------------------------|------|--------
378| `prompt` | opt | extra prompt to be used for the image generation
379| `size` | opt | desired size of the image
344 380
345# Notes 381# Notes
346 382