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-03 14:21:13 +0200
committerpablof7z <p@f7z.io>2023-07-03 14:21:13 +0200
commit67e950a2009e81df1b8c91b0a2ade0596e83f168 (patch)
tree5a7d5b89cd29b7db6a07fd172a3214017b6ff40a
parente0fc913719aae2ed1b10884e80f085218738f65d (diff)
wip
-rw-r--r--vending-machine.md163
1 files changed, 163 insertions, 0 deletions
diff --git a/vending-machine.md b/vending-machine.md
new file mode 100644
index 0000000..273aa28
--- /dev/null
+++ b/vending-machine.md
@@ -0,0 +1,163 @@
1# NIP-XX: Data Vending Machine
2Money in, data out.
3
4## Rationale
5Nostr can act as a marketplace for data processing, where users request jobs to be processed in certain ways (e.g. "speech-to-text", "summarization"), but where they don't necessarily care about "who" processes the data.
6
7This NIP is not to be confused with a 1:1 marketplace; but rather, a flow where user announces a desired output, willigness to pay, and service providers compete to fulfill the job requirement in the best way possible.
8
9### Actors
10There are two actors to the workflow described in this NIP:
11* Customers (npubs who request a job)
12* Service providers (npubs who fulfill jobs)
13
14## User flow
15* User publishes a job request
16`{ "kind": 68001, "tags": [ [ "j", "speech-to-text" ], ... ] }`
17
18* Service providers listen for the type of jobs they can perform
19`{"kinds":[68001], "#j": ["speech-to-text", "image-generation", ... ]}`
20
21* When a job comes in, the service providers who opt to attempt to fulfill the request begin processing it
22* Upon completion, the service provider publishes the result of the job with a `job-result` event.
23* Upon acceptance, the user zaps the service provider, tagging the job request
24
25## Kinds
26
27This NIP introduces two new kinds:
28
29* `kind:68001`: Job request -- a request to have a job be processed
30* `kind:68002`: Job result -- a proposal of the resulting job
31
32### Job request
33A request to have data processed -- published by a user
34
35```json
36{
37 "kind": 68001,
38 "content": "",
39 "tags": [
40 // The type data processing the user wants to be performed
41 // on the
42 [ "j", "<job-type>", "<model>" ],
43 [ "input", "<data>", "<input-type>", "<marker>" ],
44 [ "relays", "wss://..."],
45
46 // stringified sat amount that the user is offering to pay
47 // for this request
48 // should this include an optional max price or is it too
49 // ambiguous?
50 [ "bid", "<sat-amount>", ["<optional-max-price>"] ],
51
52 // max timestamp at which the job is no longer to be processed
53 [ "expiration", "<timestamp>" ]
54
55 // p tags
56 [ "p", "service-provider-1" ],
57 [ "p", "service-provider-2" ],
58
59 // NIP-33 d-tag
60 [ "d", "<unique-job-name>"]
61 ]
62}
63```
64
65#### `content` field
66An optional, human-readable description of what this job is for.
67
68#### `j` tag
69Specifies the job to be executed. A job request MUST have exactly one `j` tag.
70
71A `j` tag MIGHT name a specific model to be used for the computed with.
72
73#### `input` tag
74Specified the input that the job should be executed with.
75
76* `<data>`: The argument for the input
77* `<input-type>`: The way this argument should be interpreted
78 * Possible values:
79 * `url`: a URL to be fetched
80 * `event`: a different event ID
81 * `job`: the output of a previous job
82* `<marker>`:
83
84#### `relays` tag
85A list of relays the service provider should publish its job result to.
86
87#### `p` tags (optional)
88A user might want to explicitly request this job to be processed by specific service provider(s). Other service providers might still choose to compete for this job.
89
90#### `expiration` (optional)
91A user might specify that they will not be interested in results past a certain time (e.g. a time-sensitive job whos value is no longer relevant after some time, like a live transcription service)
92
93### Job result
94The output of processing the data -- published by the
95```json
96{
97 "pubkey": "service-provider",
98
99 // result
100 "content": "<payload>",
101 "tags" [
102 // stringified JSON request event
103 [ "request", "<2xxx1-event>" ],
104 [ "e", <id-of-2xxx1-event>],
105 [ "p", "<job-requester's pubkey>" ],
106 [ "status", "success", "<more-info>"],
107 [ "payment", "requested-payment-amount" ]
108 ]
109}
110```
111
112### `status` tag
113The service provider might want to return an error to the user in case the job could not be processed correctly
114
115### `payment`
116
117## Job types
118
119This NIP defines some job types, clients SHOULD specify these types for maximum compatibility with service providers. Other job types might be added to this NIP.
120
121### `speech-to-text`
122#### params
123| param | req? | description
124|--------------------------------|------|--------
125| `range` | opt | timestamp range (in seconds) of desired text to be transcribed
126
127### `summarization`
128| param | req? | description
129|--------------------------------|------|--------
130| `length` | opt | desired length
131
132### `translation` -- Translate text to a specific language
133#### params
134| param | req? | description
135|--------------------------------|------|--------
136| `language` | req | desired language in BCP 47 format.
137
138## Job chaining
139A customer CAN request multiple jobs to be chained, 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.
140
141Service providers might opt to start processing a subsequent job the moment they see the prior job's result, or they might choose to wait for a zap to have been published. This introduces the 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.
142
143## Job feedback
144> **Warning**
145> Is this hijacking/modifying the meaning of NIP-25 reactions too much?
146
147A user might choose to not accept a job result for any reason. A user can provide feedback via NIP-25 reactions.
148The `content` of the `kind:7` event SHOULD include a description of how the user reacted to the job result, either
149in the form of
150
151
152## Explicitly not addressed in this NIP
153
154### Reputation system
155Service providers are at 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, etc).
156
157It's out of scope (and undesirable) to have this NIP address this issue; the market should.
158
159## Notes
160
161### Multitple job acceptance
162* Nothing prevents a user from accepting multiple job results.
163