You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/server/usage.mdx
+73Lines changed: 73 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -232,6 +232,79 @@ docker run -p 8000:8000 open-interpreter
232
232
233
233
This will expose the server on port 8000 of your host machine.
234
234
235
+
## Acknowledgment Feature
236
+
237
+
When the `INTERPRETER_REQUIRE_ACKNOWLEDGE` environment variable is set to `"True"`, the server requires clients to acknowledge each message received. This feature ensures reliable message delivery in environments where network stability might be a concern.
238
+
239
+
### How it works
240
+
241
+
1. When this feature is enabled, each message sent by the server will include an `id` field.
242
+
2. The client must send an acknowledgment message back to the server for each received message.
243
+
3. The server will wait for this acknowledgment before sending the next message.
244
+
245
+
### Client Implementation
246
+
247
+
To implement this on the client side:
248
+
249
+
1. Check if each received message contains an `id` field.
250
+
2. If an `id` is present, send an acknowledgment message back to the server.
251
+
252
+
Here's an example of how to handle this in your WebSocket client:
253
+
254
+
```python
255
+
import json
256
+
import websockets
257
+
258
+
asyncdefhandle_messages(websocket):
259
+
asyncfor message in websocket:
260
+
data = json.loads(message)
261
+
262
+
# Process the message as usual
263
+
print(f"Received: {data}")
264
+
265
+
# Check if the message has an ID that needs to be acknowledged
266
+
if"id"in data:
267
+
ack_message = {
268
+
"ack": data["id"]
269
+
}
270
+
await websocket.send(json.dumps(ack_message))
271
+
print(f"Sent acknowledgment for message {data['id']}")
272
+
273
+
asyncdefmain():
274
+
uri ="ws://localhost:8000"
275
+
asyncwith websockets.connect(uri) as websocket:
276
+
await handle_messages(websocket)
277
+
278
+
# Run the async function
279
+
import asyncio
280
+
asyncio.run(main())
281
+
```
282
+
283
+
### Server Behavior
284
+
285
+
- If the server doesn't receive an acknowledgment within a certain timeframe, it will attempt to resend the message.
286
+
- The server will make multiple attempts to send a message before considering it failed.
287
+
288
+
### Enabling the Feature
289
+
290
+
To enable this feature, set the `INTERPRETER_REQUIRE_ACKNOWLEDGE` environment variable to `"True"` before starting the server:
0 commit comments