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-25 01:29:02 +0300
committerpablof7z <p@f7z.io>2023-07-25 01:29:02 +0300
commit723103506030749fc2bba9d5b4ddaf607dd24da3 (patch)
tree7b5883ab568134da43b9aedf6c77c891b6bf34d9
parent4cb3ac871f1c54d2e845ec8655bf564072377a46 (diff)
feed-generation kind and some more stuff
-rw-r--r--vending-machine.md104
1 files changed, 74 insertions, 30 deletions
diff --git a/vending-machine.md b/vending-machine.md
index 276132d..c41ccce 100644
--- a/vending-machine.md
+++ b/vending-machine.md
@@ -19,7 +19,7 @@ This NIP reserves the range `65000-66000` for data vending machine use.
19| 65001 | Job result | 19| 65001 | Job result |
20| 65002-66000 | Job request kinds | 20| 65002-66000 | Job request kinds |
21 21
22[Appendix 2](#appendix-2-job-types) defines the job types. 22[Appendix 2](#appendix-2-job-types) defines the job request types.
23 23
24## Rationale 24## Rationale
25Nostr 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 they don't necessarily care about "who" processes the data. 25Nostr 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 they don't necessarily care about "who" processes the data.
@@ -32,19 +32,23 @@ There are two actors in the workflow described in this NIP:
32* Service providers (npubs who fulfill jobs) 32* Service providers (npubs who fulfill jobs)
33 33
34# Event Kinds 34# Event Kinds
35
36* `kind:65000`: job feedback
37* `kind:65001`: job result
38* `kind:65002`-`kind:66000`: job requests
39
35## Job request 40## Job request
36A request to have data processed, published by a customer 41A request to have data processed, published by a customer. This event signals that an npub is interested in receiving the result of some kind of compute.
37 42
38```json 43```json
39{ 44{
40 "kind": xxx, // kind in 65002-66000 range 45 "kind": 65xxx, // kind in 65002-66000 range
41 "content": "", 46 "content": "",
42 "tags": [ 47 "tags": [
43 [ "i", "<data>", "<input-type>", "<marker>", "<relay>" ], 48 [ "i", "<data>", "<input-type>", "<marker>", "<relay>" ],
44 [ "output", "<mime-type>" ], 49 [ "output", "<mime-type>" ],
45 [ "relays", "wss://..."], 50 [ "relays", "wss://..."],
46 [ "bid", "<msat-amount>" ], 51 [ "bid", "<msat-amount>" ],
47 [ "exp", "<timestamp>" ],
48 [ "t", "bitcoin" ] 52 [ "t", "bitcoin" ]
49 ] 53 ]
50} 54}
@@ -52,24 +56,25 @@ A request to have data processed, published by a customer
52 56
53All tags are optional. 57All tags are optional.
54 58
55* `i` tag: Input data for the job (zero or more inputs may exist) 59* `i` tag: Input data for the job (zero or more inputs)
56 * `<data>`: The argument for the input 60 * `<data>`: The argument for the input
57 * `<input-type>`: The way this argument should be interpreted, MUST be one of: 61 * `<input-type>`: The way this argument should be interpreted. MUST be one of:
58 * `url`: A URL to be fetched 62 * `url`: A URL to be fetched
59 * `event`: A Nostr event ID, include an optional relay-url extra param 63 * `event`: A Nostr event ID.
60 * `job`: The output of a previous job with the specified event ID 64 * `job`: The output of a previous job with the specified event ID
61 * `text`: `<data>` is the value of the input, no resolution is needed 65 * `text`: `<data>` is the value of the input, no resolution is needed
62 * `<marker>`: An optional field indicating how this input should be used within the context of the job 66 * `<marker>`: An optional field indicating how this input should be used within the context of the job
63 * `<relay>`: If `event` or `job` input-type, the relay where the event/job was published, otherwise optional or empty string 67 * `<relay>`: If `event` or `job` input-type, the relay where the event/job was published, otherwise optional or empty string
64* `output`: MIME type. Expected output format. Service Providers SHOULD publish the result of the job in this format if it has been specified 68* `output`: Expected output format. (e.g. MIME type)
69 * Service Providers MUST publish the result of the job in this format if it has been specified.
70 * Each job-type ([Appendix 2](#appendix-2-job-types)) might define the output format more narrowly.
65* `bid`: Customer MAY specify a maximum amount (in millisats) they are willing to pay 71* `bid`: Customer MAY specify a maximum amount (in millisats) they are willing to pay
66* `relays`: Relays where Service Providers SHOULD publish responses to 72* `relays`: List of relays where Service Providers SHOULD publish responses to
67* `p`: Service Providers the customer is interested in. Other SPs MIGHT still choose to process the job 73* `p`: Service Providers the customer is interested in. Other SPs MIGHT still choose to process the job
68* `exp`: Expiration timestamp. Service Providers SHOULD not send results after this timestamp
69 74
70## Job result 75## Job result
71 76
72The output of processing the data -- published by the Service Provider. 77Service providers publish job results, providing the output of the job result. They should tag the original job request event id as well as the customer's pubkey.
73 78
74```json 79```json
75{ 80{
@@ -79,28 +84,40 @@ The output of processing the data -- published by the Service Provider.
79 "tags": [ 84 "tags": [
80 [ "request", "<job-request>" ], 85 [ "request", "<job-request>" ],
81 [ "e", "<job-request-id>", "<relay-hint>" ], 86 [ "e", "<job-request-id>", "<relay-hint>" ],
82 [ "p", "<Customer's pubkey>" ], 87 [ "p", "<customer's-pubkey>" ],
83 [ "amount", "requested-payment-amount", "<optional-bolt11>" ] 88 [ "amount", "requested-payment-amount", "<optional-bolt11>" ]
84 ] 89 ]
85} 90}
86``` 91```
87 92
88* `request` tag: The job request event ID. 93* `request`: The job request event stringified-JSON.
89* `amount`: millisats that the Service Provider is requesting to be paid. An optional third value can be a bolt11 invoice. 94* `amount`: millisats that the Service Provider is requesting to be paid. An optional third value can be a bolt11 invoice.
90 95
91## Job feedback 96## Job feedback
92Both customers and service providers can give feedback about a job. 97Service providers can give feedback about a job back to the customer.
93 98
94The result of the job SHOULD be included in the `content` field. 99```json
100{
101 "kind": 65000,
102 "content": "<empty-or-payload>",
103 "tags": [
104 [ "status", "<status>", "<extra-info>" ],
105 [ "amount", "requested-payment-amount", "<bolt11>" ],
106 [ "e", "<job-request-id>", "<relay-hint>" ],
107 [ "p", "<customer's-pubkey>" ],
108 ]
109}
110```
95 111
96* `status` tag: Service Providers MAY indicate errors or extra info about the results by including them in the `status` tag. 112* `content`: Either empty or a job-result (e.g. for partial-result samples)
97* `amount`: as defined in the [Job Result](#job-result) section. 113* `status` tag: Service Providers SHOULD indicate what this feedback status refers to. [Appendix 3](#appendix-3-job-feedback-status) defines status. Extra human-readable information can be added as an extra argument.
114* `amount` tag: as defined in the [Job Result](#job-result) section.
98 115
99# Protocol Flow 116# Protocol Flow
100* Customer publishes a job request (e.g. `kind:65002`). 117* Customer publishes a job request (e.g. `kind:65002` speech-to-text).
101* Service Providers can submit `kind:65000` job-feedback events (e.g. `payment-required`, `processing`, `error`, etc.). 118* Service Providers can submit `kind:65000` job-feedback events (e.g. `payment-required`, `processing`, `error`, etc.).
102* Upon completion, the service provider publishes the result of the job with a `kind:65001` job-result event. 119* Upon completion, the service provider publishes the result of the job with a `kind:65001` job-result event.
103* At any point, the user can pay the included `bolt11` or zap any of the events the service provider has sent to the user. 120* At any point, if there is an `amount` pending to be paid as instructed by the service provider, the user can pay the included `bolt11` or zap the job result event the service provider has sent to the user
104 121
105`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 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. 122`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 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.
106 123
@@ -137,16 +154,6 @@ Consult [Appendix 1: Example](#appendix-1-examples)'s [Summarization of a podcas
137} 154}
138``` 155```
139 156
140## Not addressed in this NIP
141
142### Reputation system
143Service providers are at an obvious risk of having their results not compensated. Mitigation of this risk is up to service providers to figure out (i.e., building reputation systems, requiring npub "balances", etc.). It's out of scope (and undesirable) to have this NIP address this issue; the market should.
144
145### Encrypted job requests
146Not to be included in the first draft of this NIP, but encrypted job requests should be added. A few ways:
147 * publish job requests with some useful metadata of the job "e.g., length of audio to be transcribed", service providers offer to do the job, the customer replies with a NIP-04-like encrypted job requested encrypted with the service provider's pubkey.
148
149
150# Appendix 1: Examples 157# Appendix 1: Examples
151 158
152## Transcript of a podcast from second `900` to `930`. 159## Transcript of a podcast from second `900` to `930`.
@@ -316,7 +323,7 @@ User publishes event #1 and #2 together.
316 [ "bid", "500000" ] 323 [ "bid", "500000" ]
317 ] 324 ]
318} 325}
319`` 326```
320 327
321## AI-image of embedded input 328## AI-image of embedded input
322 329
@@ -364,6 +371,43 @@ This is a list of all the supported job requests.
364| `prompt` | opt | extra prompt to be used for the image generation | 371| `prompt` | opt | extra prompt to be used for the image generation |
365| `size` | opt | desired size of the image | 372| `size` | opt | desired size of the image |
366 373
374## event list generation: `kind:65006`
375
376Generates a list of event ids, (e.g. algorithmic feeds, spam-free notifications, trending topics)
377
378Output should be a stringified array of elements usually find in a nostr event' `tags`, e.g.:
379
380```json
381{ "content": "[
382 [\"e\", \"<id>\"],
383 [\"a\", \"30023:pubkey:id\"],
384 [\"t\", \"tag\"],
385 [\"p\", \"pubkey\"],
386]" }
387```
388
389| param | req? | description |
390|-----------|------|-------------------------------------------------------|
391| `filter` | opt | JSON-stringified `REQ`-like filter
392| `prompt` | opt | A human-readable description of the desired results. Which might be used with e.g. an LLM to tune the results.
393| `p` | opt | Array of pubkeys to generate a feed from someone else's point-of-view. This param allows for a client to choose to generate the feeds and incur the costs of its users.
394
395### example job-request
396
397Generate an algorithmic feed of the most interesting `kind:1`s related to the topic "bitcoin", tagging service providers specializing in safe-for-work content
398that would interest pubkey `pubkey1`.
399
400```json
401{
402 "kind": 65006,
403 "tags": [
404 [ "param", "filter", "{ \"kinds\": [1], \"#t\": [\"bitcoin\"] }" ],
405 [ "param", "p", "[\"pubkey1\"]"]
406 [ "bid", "5000" ],
407 [ "t", "sfw" ]
408 ]
409}
410```
367 411
368# Appendix 3: Job feedback status 412# Appendix 3: Job feedback status
369 413