upleb.uk

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

summaryrefslogtreecommitdiff
path: root/vending-machine.md
diff options
context:
space:
mode:
authorpablof7z <p@f7z.io>2023-07-11 15:22:30 +0200
committerpablof7z <p@f7z.io>2023-07-11 15:22:30 +0200
commita9dd5574531229df065eb9df2212bb7510db1f61 (patch)
treee481ad6ab13c105e8b82b30bac7f11b09800c61e /vending-machine.md
parentc1b8d98b2625b0d27227bbddb7f25bbec1bf1b25 (diff)
get rid of the kind:7 stuff
Diffstat (limited to 'vending-machine.md')
-rw-r--r--vending-machine.md131
1 files changed, 61 insertions, 70 deletions
diff --git a/vending-machine.md b/vending-machine.md
index e64a667..0f0b003 100644
--- a/vending-machine.md
+++ b/vending-machine.md
@@ -33,6 +33,9 @@ A request to have data processed -- published by a customer
33 // input(s) for the job request 33 // input(s) for the job request
34 [ "i", "<data>", "<input-type>", "<marker>" ], 34 [ "i", "<data>", "<input-type>", "<marker>" ],
35 35
36 // expected output format
37 [ "output", "mimetype" ],
38
36 // relays where the job result should be published 39 // relays where the job result should be published
37 [ "relays", "wss://..."], 40 [ "relays", "wss://..."],
38 41
@@ -45,51 +48,36 @@ A request to have data processed -- published by a customer
45} 48}
46``` 49```
47 50
48### `content` field 51* `content` field: An optional, human-readable description of what this job is for.
49An optional, human-readable description of what this job is for. 52* `j` tag: Job-type to be executed.
50 53 * A job request MUST have exactly one `j` tag.
51### `j` tag 54 * It MAY include a second value specifying the name of a model to be used when computing the result.
52Specifies the job to be executed. A job request MUST have exactly one (1) `j` tag.
53
54A `j` tag MAY include a second value specifying the name of a model to be used when computing the result.
55
56### `i` (input) tag
57Specifies the input data that the job is to be executed against. The input is relay-indexable so that clients interested in the exact same job can find the input data and the result result (if it's already fulfilled).
58 55
59A job request CAN have zero or more inputs. 56* `i` tag: Input data for the job.
60 57 * A job request CAN have zero or more inputs.
61* `<data>`: The argument for the input 58 * Positional arguments: `["i", "<data>", "<input-type>", "<relay>", "<marker>"]`
62* `<input-type>`: The way this argument should be interpreted 59 * `<data>`: The argument for the input
63 * Possible values: 60 * `<input-type>`: The way this argument should be interpreted, one of:
64 * `url`: a URL to be fetched 61 * `url`: a URL to be fetched
65 * `event`: a nostr event ID 62 * `event`: a nostr event ID, include an optional relay-url extra param
66 * `job`: the output of a previous job with the specified event ID 63 * `job`: the output of a previous job with the specified event ID
67* `<marker>`: an optional field indicating where the data can be found if it is a subset of the provided values, for example the name of the key(s) in a key/value set, or the start and end positions of the data if it's a bytestream. 64 * `<relay>`: if `event` or `job` input-type, the relay where the event/job was published, otherwise optional or empty string.
68 65 * `<marker>`: an optional field indicating how this input should be used.
69### `bid` tag 66* `output` tag: MIME type. Expected output format. Service Providers SHOULD publish the result of the job in this format.
70The Customer MAY specify a maximum amount (in millisats) they are willing to pay for the job to be processed. 67* `bid` tag: Customer MAY specify a maximum amount (in millisats) they are willing to pay.
71 68* `relays` tag: relays where Service Providers SHOULD publish responses to.
72### `relays` tag 69* `p` tags: Service Providers the customer is interested in having process this job. Other SP MIGHT still choose to process the job.
73The Service Provider SHOULD publish job results to the relays specified in this this tag. 70* `exp`: Optional expiration timestamp. Service Providers SHOULD not send results after this timestamp.
74
75### `p` tags
76If a Customer has a preference for specific Service Provider(s) to process this job, they SHOULD indicate this by including the Service Provider(s) pubkey in a `p` tag. This is NOT intended to exclude other Service Providers and they MAY still choose to compete for jobs that have not tagged them.
77
78### `exp`
79A Customer MAY indicate that they will not pay for results produced after a specific Block height or Unix Timestamp. This is intended for time-sensitive jobs where the result is not relevant unless produced within a certain timeframe, e.g. a live transcription service.
80 71
81## Job result 72## Job result
82The output of processing the data -- published by the Service Provider. 73The output of processing the data -- published by the Service Provider.
83```json 74```json
84{ 75{
85 "pubkey": "service-provider pubkey in hex", 76 "pubkey": "service-provider pubkey in hex",
86 77 "content": "<payload>",
87 // result
88 "content": "string: <payload>",
89 "kind": 68002, 78 "kind": 68002,
90 "tags" [ 79 "tags" [
91 // stringified JSON request event 80 [ "request", "<68001-event>" ],
92 [ "request", "<68001-event-as-stringified JSON>" ],
93 [ "e", "<id-of-68001-event>" ], 81 [ "e", "<id-of-68001-event>" ],
94 [ "p", "<Customer's pubkey>" ], 82 [ "p", "<Customer's pubkey>" ],
95 [ "status", "success", "<more-info>" ], 83 [ "status", "success", "<more-info>" ],
@@ -98,36 +86,15 @@ The output of processing the data -- published by the Service Provider.
98} 86}
99``` 87```
100 88
101The result of the job SHOULD be included in the `content` field. If the output is not text, the `content` field SHOULD be empty and an `output` tag should be used instead as described below. 89## Job feedback
102 90Both customers and service providers can give feedback about a job.
103#### `status` tag
104The Service Provider MAY indicate errors during processing by including them in the `status` tag, these errors are intended to be consumed by the Customer.
105
106#### `amount`
107The amount (in millisats) that the Service Provider is requesting to be paid. This amount MAY differ to the amount specified by the Customer in the `bid` tag. The amount SHOULD be less than the maximum amount specified by the user in the `bid` tag.
108
109## Job types
110
111This 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.
112 91
113### `speech-to-text` 92The result of the job SHOULD be included in the `content` field. If the output is not text, the `content` field SHOULD be empty and an `output` tag should be used instead as described below.
114#### params
115| param | req? | description
116|--------------------------------|------|--------
117| `range` | opt | timestamp range (in seconds) of desired text to be transcribed
118| `alignment` | opt | word, segment, raw : word-level, segment-level or raw outputs
119 93
120### `summarization` 94* `status` tag: Service Providers MAY indicate errors or extra info about the results by including them in the `status` tag.
121| param | req? | description 95* `amount`: millisats that the Service Provider is requesting to be paid.
122|--------------------------------|------|--------
123| `length` | opt | desired length
124
125### `translation` -- Translate text to a specific language
126#### params
127| param | req? | description
128|--------------------------------|------|--------
129| `language` | req | requested language in BCP 47 format.
130 96
97##
131# Protocol Flow 98# Protocol Flow
132* Customer publishes a job request 99* Customer publishes a job request
133`{ "kind": 68001, "tags": [ [ "j", "speech-to-text" ], ... ] }` 100`{ "kind": 68001, "tags": [ [ "j", "speech-to-text" ], ... ] }`
@@ -142,15 +109,17 @@ This NIP defines some example job types, Customers SHOULD specify these types fo
142# Payment 109# Payment
143Customers SHOULD pay service providers whose job results they accept by zapping the Service Provider and tagging the `kind:68002` job result. 110Customers SHOULD pay service providers whose job results they accept by zapping the Service Provider and tagging the `kind:68002` job result.
144 111
112Additionally, if a service provider requests full or partial prepayment via a `kind:68003` job-feedback event, the customer SHOULD zap that event to pay the service provider.
113
114# Cancellation
115A `kind:68001` job request might be cancelled by publishing a `kind:5` delete request event tagging the job request event.
145 116
146# Job chaining 117# Job chaining
147A Customer MAY request multiple jobs to be processed in a chained form, so that the output of a job can be the input of the next job. (e.g. summarization of a podcast's transcription). This is done by specifying as `input` an eventID of a different job with the `job` marker. 118A Customer MAY request multiple jobs to be processed in a chained form, so that the output of a job can be the input of the next job. (e.g. summarization of a podcast's transcription). This is done by specifying as `input` an eventID of a different job with the `job` marker.
148 119
149Service 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.
150 121
151# Reactions 122# Job Feedback
152> **Warning**
153> Is this hijacking/modifying the meaning of NIP-25 reactions too much?
154 123
155## Job request reactions 124## Job request reactions
156Service Providers might opt to give feedback about a job. 125Service Providers might opt to give feedback about a job.
@@ -169,7 +138,6 @@ Service Providers might opt to give feedback about a job.
169``` 138```
170 139
171## Job feedback 140## Job feedback
172
173A user might choose to not accept a job result for any reason. A user can provide feedback via NIP-25 reactions. 141A user might choose to not accept a job result for any reason. A user can provide feedback via NIP-25 reactions.
174The `content` of the `kind:7` event SHOULD include a description of how the user reacted to the job result. 142The `content` of the `kind:7` event SHOULD include a description of how the user reacted to the job result.
175 143
@@ -197,21 +165,21 @@ It's out of scope (and undesirable) to have this NIP address this issue; the mar
197 "content": "I need a transcript of Bitcoin.review", 165 "content": "I need a transcript of Bitcoin.review",
198 "tags": [ 166 "tags": [
199 [ "j", "speech-to-text" ], 167 [ "j", "speech-to-text" ],
200 [ "params", "range", "900", "930" ],
201 [ "i", "https://bitcoin.review/episode1.mp3", "url" ], 168 [ "i", "https://bitcoin.review/episode1.mp3", "url" ],
202 [ "bid", "5000", "9000" ] 169 [ "params", "range", "900", "930" ],
170 [ "bid", "5000", "9000" ],
171 [ "output", "text/plain" ]
203 ] 172 ]
204} 173}
205``` 174```
206 175
207### `kind:1021`: Job fulfillment 176### `kind:68002`: Job fulfillment
208```json 177```json
209{ 178{
210 "content": "Person 1: blah blah blah", 179 "content": "blah blah blah",
211 "tags": [ 180 "tags": [
212 ["e", "12345"], 181 ["e", "12345"],
213 ["p", "abcdef"], 182 ["p", "abcdef"],
214 ["status", "success"]
215 ] 183 ]
216} 184}
217``` 185```
@@ -306,6 +274,29 @@ User publishes two job requests at the same time in the order they should be exe
306} 274}
307``` 275```
308 276
277# Appendix 2: Job types
278
279This 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.
280
281### `speech-to-text`
282#### params
283| param | req? | description
284|--------------------------------|------|--------
285| `range` | opt | timestamp range (in seconds) of desired text to be transcribed
286| `alignment` | opt | word, segment, raw : word-level, segment-level or raw outputs
287
288### `summarization`
289| param | req? | description
290|--------------------------------|------|--------
291| `length` | opt | desired length
292
293### `translation` -- Translate text to a specific language
294#### params
295| param | req? | description
296|--------------------------------|------|--------
297| `language` | req | requested language in BCP 47 format.
298
299
309# Notes 300# Notes
310 301
311* Should there be a possibility of getting the job result delivered encrypted? I don't like it but maybe it should be supported. 302* Should there be a possibility of getting the job result delivered encrypted? I don't like it but maybe it should be supported.