mirror of
https://github.com/nostr-protocol/nips.git
synced 2025-08-31 21:40:48 -04:00
reformat a bunch of json things and small nitpicks.
This commit is contained in:
147
90.md
147
90.md
@@ -13,11 +13,11 @@ Money in, data out.
|
||||
## Kinds
|
||||
This NIP reserves the range `5000-7000` for data vending machine use.
|
||||
|
||||
| Kind | Description |
|
||||
| ---- | ----------- |
|
||||
| Kind | Description |
|
||||
| ---- | ----------- |
|
||||
| 5000-5999 | Job request kinds |
|
||||
| 6000-6999 | Job result |
|
||||
| 7000 | Job feedback |
|
||||
| 6000-6999 | Job result |
|
||||
| 7000 | Job feedback |
|
||||
|
||||
Job 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`).
|
||||
|
||||
@@ -67,34 +67,34 @@ All tags are optional.
|
||||
* `relays`: List of relays where Service Providers SHOULD publish responses to
|
||||
* `p`: Service Providers the customer is interested in. Other SPs MIGHT still choose to process the job
|
||||
|
||||
## Encrypted Params
|
||||
## Encrypted Params
|
||||
|
||||
If 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
|
||||
|
||||
```json
|
||||
[
|
||||
[ "i", "what is the capital of France? ", "text" ],
|
||||
[ "param", "model", "LLaMA-2" ],
|
||||
[ "param", "max_tokens", "512" ],
|
||||
[ "param", "temperature", "0.5" ],
|
||||
[ "param", "top-k", "50" ],
|
||||
[ "param", "top-p", "0.7" ],
|
||||
[ "param", "frequency_penalty", "1" ]
|
||||
|
||||
["i", "what is the capital of France? ", "text"],
|
||||
["param", "model", "LLaMA-2"],
|
||||
["param", "max_tokens", "512"],
|
||||
["param", "temperature", "0.5"],
|
||||
["param", "top-k", "50"],
|
||||
["param", "top-p", "0.7"],
|
||||
["param", "frequency_penalty", "1"]
|
||||
]
|
||||
|
||||
```
|
||||
|
||||
This param data will be encrypted and added to the `content` field and `p` tag should be present
|
||||
|
||||
```
|
||||
"content": "BE2Y4xvS6HIY7TozIgbEl3sAHkdZoXyLRRkZv4fLPh3R7LtviLKAJM5qpkC7D6VtMbgIt4iNcMpLtpo...",
|
||||
"tags": [
|
||||
["p", "04f74530a6ede6b24731b976b8e78fb449ea61f40ff10e3d869a3030c4edc91f"],
|
||||
["encrypted"]
|
||||
]
|
||||
|
||||
This param data will be encrypted and added to the `content` field and `p` tag should be present
|
||||
|
||||
```json
|
||||
{
|
||||
"content": "BE2Y4xvS6HIY7TozIgbEl3sAHkdZoXyLRRkZv4fLPh3R7LtviLKAJM5qpkC7D6VtMbgIt4iNcMpLtpo...",
|
||||
"tags": [
|
||||
["p", "04f74530a6ede6b24731b976b8e78fb449ea61f40ff10e3d869a3030c4edc91f"],
|
||||
["encrypted"]
|
||||
],
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -104,16 +104,17 @@ Service providers publish job results, providing the output of the job result. T
|
||||
|
||||
```json
|
||||
{
|
||||
"pubkey": "<service-provider pubkey>",
|
||||
"content": "<payload>",
|
||||
"kind": 6xxx,
|
||||
"tags": [
|
||||
[ "request", "<job-request>" ],
|
||||
[ "e", "<job-request-id>", "<relay-hint>" ],
|
||||
[ "i", "<input-data>" ],
|
||||
[ "p", "<customer's-pubkey>" ],
|
||||
[ "amount", "requested-payment-amount", "<optional-bolt11>" ]
|
||||
]
|
||||
"pubkey": "<service-provider pubkey>",
|
||||
"content": "<payload>",
|
||||
"kind": 6xxx,
|
||||
"tags": [
|
||||
["request", "<job-request>"],
|
||||
["e", "<job-request-id>", "<relay-hint>"],
|
||||
["i", "<input-data>"],
|
||||
["p", "<customer's-pubkey>"],
|
||||
["amount", "requested-payment-amount", "<optional-bolt11>"]
|
||||
],
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
@@ -123,38 +124,40 @@ Service providers publish job results, providing the output of the job result. T
|
||||
|
||||
## Encrypted Output
|
||||
|
||||
If 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.
|
||||
If 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.
|
||||
Add a tag encrypted to mark the output content as `encrypted`
|
||||
|
||||
```json
|
||||
{
|
||||
"pubkey": "<service-provider pubkey>",
|
||||
"content": "<encrypted payload>",
|
||||
"kind": 6xxx,
|
||||
"tags": [
|
||||
[ "request", "<job-request>" ],
|
||||
[ "e", "<job-request-id>", "<relay-hint>" ],
|
||||
[ "p", "<customer's-pubkey>" ],
|
||||
[ "amount", "requested-payment-amount", "<optional-bolt11>" ],
|
||||
["encrypted"]
|
||||
|
||||
]
|
||||
"pubkey": "<service-provider pubkey>",
|
||||
"content": "<encrypted payload>",
|
||||
"kind": 6xxx,
|
||||
"tags": [
|
||||
["request", "<job-request>"],
|
||||
["e", "<job-request-id>", "<relay-hint>"],
|
||||
["p", "<customer's-pubkey>"],
|
||||
["amount", "requested-payment-amount", "<optional-bolt11>"],
|
||||
["encrypted"]
|
||||
],
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## Job feedback
|
||||
|
||||
Service providers can give feedback about a job back to the customer.
|
||||
|
||||
```json
|
||||
{
|
||||
"kind": 7000,
|
||||
"content": "<empty-or-payload>",
|
||||
"tags": [
|
||||
[ "status", "<status>", "<extra-info>" ],
|
||||
[ "amount", "requested-payment-amount", "<bolt11>" ],
|
||||
[ "e", "<job-request-id>", "<relay-hint>" ],
|
||||
[ "p", "<customer's-pubkey>" ],
|
||||
]
|
||||
"kind": 7000,
|
||||
"content": "<empty-or-payload>",
|
||||
"tags": [
|
||||
["status", "<status>", "<extra-info>"],
|
||||
["amount", "requested-payment-amount", "<bolt11>"],
|
||||
["e", "<job-request-id>", "<relay-hint>"],
|
||||
["p", "<customer's-pubkey>"],
|
||||
],
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
@@ -166,18 +169,19 @@ Service providers can give feedback about a job back to the customer.
|
||||
|
||||
### Job feedback status
|
||||
|
||||
| status | description |
|
||||
|--------|-------------|
|
||||
| `payment-required` | Service Provider requires payment before continuing. |
|
||||
| `processing` | Service Provider is processing the job. |
|
||||
| `error` | Service Provider was unable to process the job. |
|
||||
| `success` | Service Provider successfully processed the job. |
|
||||
| `partial` | Service Provider partially processed the job. The `.content` might include a sample of the partial results. |
|
||||
| status | description |
|
||||
| -------- | ------------- |
|
||||
| `payment-required` | Service Provider requires payment before continuing. |
|
||||
| `processing` | Service Provider is processing the job. |
|
||||
| `error` | Service Provider was unable to process the job. |
|
||||
| `success` | Service Provider successfully processed the job. |
|
||||
| `partial` | Service Provider partially processed the job. The `.content` might include a sample of the partial results. |
|
||||
|
||||
Any 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.
|
||||
|
||||
|
||||
# Protocol Flow
|
||||
|
||||
* Customer publishes a job request (e.g. `kind:5000` speech-to-text).
|
||||
* Service Providers MAY submit `kind:7000` job-feedback events (e.g. `payment-required`, `processing`, `error`, etc.).
|
||||
* 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
|
||||
# Appendix 2: Service provider discoverability
|
||||
Service Providers MAY use NIP-89 announcements to advertise their support for job kinds:
|
||||
|
||||
```json
|
||||
```js
|
||||
{
|
||||
"kind": 31990,
|
||||
"pubkey": "<pubkey>",
|
||||
"content": "{
|
||||
\"name\": \"Translating DVM\",
|
||||
\"about\": \"I'm a DVM specialized in translating Bitcoin content.\"
|
||||
}",
|
||||
"tags": [
|
||||
[ "k", "5005" ], // e.g. translation
|
||||
[ "t", "bitcoin" ] // e.g. optionally advertises it specializes in bitcoin audio transcription that won't confuse "Drivechains" with "Ridechains"
|
||||
]
|
||||
"kind": 31990,
|
||||
"pubkey": "<pubkey>",
|
||||
"content": "{
|
||||
\"name\": \"Translating DVM\",
|
||||
\"about\": \"I'm a DVM specialized in translating Bitcoin content.\"
|
||||
}",
|
||||
"tags": [
|
||||
["k", "5005"], // e.g. translation
|
||||
["t", "bitcoin"] // e.g. optionally advertises it specializes in bitcoin audio transcription that won't confuse "Drivechains" with "Ridechains"
|
||||
],
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
|
Reference in New Issue
Block a user