Spaces:
Sleeping
Sleeping
Commit
·
f5c64d0
1
Parent(s):
cd059dd
updates README
Browse files
README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
| 1 |
|
| 2 |
<picture>
|
| 3 |
<source srcset="./assets/macrocosmos-white.png" media="(prefers-color-scheme: dark)">
|
| 4 |
-
<img src="macrocosmos-white.png">
|
| 5 |
</picture>
|
| 6 |
|
| 7 |
<picture>
|
| 8 |
<source srcset="./assets/macrocosmos-black.png" media="(prefers-color-scheme: light)">
|
| 9 |
-
<img src="macrocosmos-black.png">
|
| 10 |
</picture>
|
| 11 |
|
| 12 |
|
|
@@ -75,28 +75,36 @@ EXPECTED_ACCESS_KEY=<ACCESS_KEY> pm2 start server.py --interpreter python3 --nam
|
|
| 75 |
## API Usage
|
| 76 |
At present, the API provides two endpoints: `/chat` (live) and `/echo` (test).
|
| 77 |
|
| 78 |
-
`/chat` is used to chat with the network and receive a response.
|
| 79 |
-
|
| 80 |
-
- `
|
| 81 |
-
- `
|
| 82 |
-
- `
|
| 83 |
-
- `
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
- `
|
| 87 |
-
- `
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
- `
|
| 92 |
-
- `
|
| 93 |
-
- `
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
|
| 95 |
> Note: The API is subject to change as the project evolves.
|
| 96 |
|
| 97 |
-
|
| 98 |
## Testing
|
| 99 |
-
|
| 100 |
To test the API locally, you can use the following curl command:
|
| 101 |
|
| 102 |
```bash
|
|
|
|
| 1 |
|
| 2 |
<picture>
|
| 3 |
<source srcset="./assets/macrocosmos-white.png" media="(prefers-color-scheme: dark)">
|
| 4 |
+
<img src="assets/macrocosmos-white.png">
|
| 5 |
</picture>
|
| 6 |
|
| 7 |
<picture>
|
| 8 |
<source srcset="./assets/macrocosmos-black.png" media="(prefers-color-scheme: light)">
|
| 9 |
+
<img src="assets/macrocosmos-black.png">
|
| 10 |
</picture>
|
| 11 |
|
| 12 |
|
|
|
|
| 75 |
## API Usage
|
| 76 |
At present, the API provides two endpoints: `/chat` (live) and `/echo` (test).
|
| 77 |
|
| 78 |
+
`/chat` is used to chat with the network and receive a response. It requires a JSON payload structured as per the QueryValidatorParams class.
|
| 79 |
+
The request payload requires the following parameters encapsulated within the [`QueryValidatorParams`](./validators/base.py) data class:
|
| 80 |
+
- `k_miners: int`: The number of miners from which to request responses.
|
| 81 |
+
- `exclude: List[str]`: A list of roles or agents to exclude from querying.
|
| 82 |
+
- `roles: List[str]`: The roles of the agents to query.
|
| 83 |
+
- `messages: List[str]`: The messages to be sent to the network.
|
| 84 |
+
- `timeout: int`: The time in seconds to wait for a response.
|
| 85 |
+
- `prefer: str`: The preferred response format, can be either `'longest'` or `'shortest'`.
|
| 86 |
+
- `request: Request`: The original request object encapsulating all request data.
|
| 87 |
+
- `sampling_mode: str`: The mode of sampling to use, defaults to `"random"`. Can be either `"random"` or `"top_incentive"`
|
| 88 |
+
|
| 89 |
+
Responses from the `/chat` endpoint are handled by two classes: `StreamChunk` and `StreamError`, with their attributes defined as follows:
|
| 90 |
+
- `StreamChunk`:
|
| 91 |
+
- `delta: str`: The new chunk of response received.
|
| 92 |
+
- `finish_reason: Optional[str]`: The reason for the response completion, if applicable Can be `None`, `finished` or `error` (check StreamError below).
|
| 93 |
+
- `accumulated_chunks: List[str]`: All chunks of responses accumulated thus far.
|
| 94 |
+
- `accumulated_chunks_timings: List[float]`: Timing for each chunk received.
|
| 95 |
+
- `timestamp: str`: The timestamp at which the chunk was processed.
|
| 96 |
+
- `sequence_number: int`: A sequential identifier for the response part.
|
| 97 |
+
- `selected_uid: int`: The identifier for the selected response source.
|
| 98 |
+
|
| 99 |
+
- `StreamError`:
|
| 100 |
+
- `error: str`: Description of the error occurred.
|
| 101 |
+
- `timestamp: str`: The timestamp of the error.
|
| 102 |
+
- `sequence_number: int`: A sequential identifier for the error.
|
| 103 |
+
- `finish_reason: str`: Always set to `'error'` to indicate an error completion.
|
| 104 |
|
| 105 |
> Note: The API is subject to change as the project evolves.
|
| 106 |
|
|
|
|
| 107 |
## Testing
|
|
|
|
| 108 |
To test the API locally, you can use the following curl command:
|
| 109 |
|
| 110 |
```bash
|