-
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathopenapi.yaml
More file actions
928 lines (880 loc) · 22.8 KB
/
Copy pathopenapi.yaml
File metadata and controls
928 lines (880 loc) · 22.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
openapi: "3.1.0"
info:
title: Distill API
version: 0.9.0
description: |
Context intelligence layer for LLM agents. Distill deduplicates, compresses,
and caches context before it reaches the model, and provides persistent memory
with sensitivity tagging and conflict detection.
license:
name: MIT
url: https://github.com/Siddhant-K-code/distill/blob/main/LICENSE
servers:
- url: http://localhost:8080
description: Local development server
tags:
- name: Dedupe
description: Semantic deduplication of context chunks
- name: Pipeline
description: Full dedup + compress + cache pipeline
- name: Batch
description: Async batch processing
- name: Memory
description: Persistent context memory store
- name: Session
description: Stateful context window management
- name: Health
description: Server health and metrics
paths:
/v1/dedupe:
post:
tags: [Dedupe]
summary: Deduplicate chunks
description: |
Clusters semantically similar chunks and returns one representative per cluster.
Supports MMR re-ranking for relevance + diversity balance.
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/DedupeRequest"
responses:
"200":
description: Deduplicated chunks
content:
application/json:
schema:
$ref: "#/components/schemas/DedupeResponse"
"400":
description: Invalid request
/v1/dedupe/stream:
post:
tags: [Dedupe]
summary: Deduplicate chunks (SSE stream)
description: |
Same as `/v1/dedupe` but returns results as Server-Sent Events with
per-stage progress updates.
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/DedupeRequest"
responses:
"200":
description: SSE stream of dedup progress and results
content:
text/event-stream: {}
/v1/pipeline:
post:
tags: [Pipeline]
summary: Run full pipeline
description: |
Runs the complete dedup → compress → summarize → cache pipeline.
Returns processed chunks with per-stage statistics.
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/PipelineRequest"
responses:
"200":
description: Pipeline results
content:
application/json:
schema:
$ref: "#/components/schemas/PipelineResponse"
"400":
description: Invalid request
/v1/batch:
post:
tags: [Batch]
summary: Submit batch job
description: Submit a batch of chunks for async processing.
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/BatchSubmitRequest"
responses:
"202":
description: Job accepted
content:
application/json:
schema:
$ref: "#/components/schemas/BatchSubmitResponse"
/v1/batch/{job_id}:
get:
tags: [Batch]
summary: Get batch job status
parameters:
- name: job_id
in: path
required: true
schema:
type: string
responses:
"200":
description: Job status
content:
application/json:
schema:
$ref: "#/components/schemas/BatchStatusResponse"
"404":
description: Job not found
/v1/batch/{job_id}/results:
get:
tags: [Batch]
summary: Get batch job results
parameters:
- name: job_id
in: path
required: true
schema:
type: string
responses:
"200":
description: Job results
content:
application/json:
schema:
$ref: "#/components/schemas/BatchResultsResponse"
"404":
description: Job not found
/v1/memory/store:
post:
tags: [Memory]
summary: Store memories
description: |
Store one or more memory entries with write-time deduplication.
Supports sensitivity tagging (explicit or auto-classified) and
conflict detection against existing entries.
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/StoreRequest"
responses:
"200":
description: Store result with conflict information
content:
application/json:
schema:
$ref: "#/components/schemas/StoreResult"
/v1/memory/recall:
post:
tags: [Memory]
summary: Recall memories
description: |
Retrieve memories ranked by relevance and recency. Supports tag boosting,
task context matching, and minimum relevance filtering.
Expired entries are excluded by default.
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/RecallRequest"
responses:
"200":
description: Recalled memories with sensitivity metadata
content:
application/json:
schema:
$ref: "#/components/schemas/RecallResult"
/v1/memory/forget:
post:
tags: [Memory]
summary: Forget memories
description: Permanently remove memories by ID, tag, or age.
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/ForgetRequest"
responses:
"200":
description: Forget result
content:
application/json:
schema:
$ref: "#/components/schemas/ForgetResult"
/v1/memory/expire:
post:
tags: [Memory]
summary: Expire memories
description: |
Mark memories as expired. Expired entries are excluded from recall
by default but remain in the store for auditing.
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/ExpireRequest"
responses:
"200":
description: Expire result
content:
application/json:
schema:
$ref: "#/components/schemas/ExpireResult"
/v1/memory/supersede:
post:
tags: [Memory]
summary: Supersede a memory
description: |
Mark a memory as superseded by a newer entry. The old entry is expired
and a forward pointer to the replacement is stored.
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/SupersedeRequest"
responses:
"200":
description: Supersede result
content:
application/json:
schema:
$ref: "#/components/schemas/SupersedeResult"
"404":
description: Old entry not found
"409":
description: Old entry already expired
/v1/memory/stats:
get:
tags: [Memory]
summary: Memory store statistics
responses:
"200":
description: Store statistics
content:
application/json:
schema:
$ref: "#/components/schemas/MemoryStats"
/v1/session/create:
post:
tags: [Session]
summary: Create a session
description: Create a new context window session with a token budget.
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/SessionCreateRequest"
responses:
"200":
description: Created session
content:
application/json:
schema:
$ref: "#/components/schemas/Session"
"409":
description: Session already exists
/v1/session/push:
post:
tags: [Session]
summary: Push entries to a session
description: |
Add context entries to a session. Distill deduplicates and compresses
to stay within the token budget.
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/SessionPushRequest"
responses:
"200":
description: Push result
content:
application/json:
schema:
$ref: "#/components/schemas/SessionPushResult"
"404":
description: Session not found
"413":
description: Over token budget
/v1/session/context:
post:
tags: [Session]
summary: Get session context
description: Retrieve the current context window for a session.
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/SessionContextRequest"
responses:
"200":
description: Session context
content:
application/json:
schema:
$ref: "#/components/schemas/SessionContextResult"
"404":
description: Session not found
/v1/session/get:
get:
tags: [Session]
summary: Get session metadata
parameters:
- name: session_id
in: query
required: true
schema:
type: string
responses:
"200":
description: Session metadata
content:
application/json:
schema:
$ref: "#/components/schemas/Session"
"404":
description: Session not found
/v1/session/delete:
post:
tags: [Session]
summary: Delete a session
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [session_id]
properties:
session_id:
type: string
responses:
"200":
description: Delete result
"404":
description: Session not found
/health:
get:
tags: [Health]
summary: Health check
responses:
"200":
description: Server is healthy
content:
application/json:
schema:
type: object
properties:
status:
type: string
example: ok
/metrics:
get:
tags: [Health]
summary: Prometheus metrics
responses:
"200":
description: Prometheus-formatted metrics
content:
text/plain: {}
components:
schemas:
DedupeChunk:
type: object
required: [text]
properties:
id:
type: string
text:
type: string
embedding:
type: array
items:
type: number
format: float
score:
type: number
format: float
cache_control:
type: string
description: Anthropic cache_control marker
DedupeRequest:
type: object
required: [chunks]
properties:
chunks:
type: array
items:
$ref: "#/components/schemas/DedupeChunk"
threshold:
type: number
format: double
description: Cosine distance threshold for clustering
lambda:
type: number
format: double
description: MMR lambda (0=diversity, 1=relevance)
target_k:
type: integer
description: Target number of output chunks
options:
type: object
properties:
preserve_cache_prefix:
type: boolean
description: Freeze chunks before the last cache_control marker
DedupeResponse:
type: object
properties:
chunks:
type: array
items:
type: object
properties:
id:
type: string
text:
type: string
score:
type: number
format: float
cluster_id:
type: integer
cache_control:
type: string
stats:
type: object
properties:
input_chunks:
type: integer
output_chunks:
type: integer
reduction_pct:
type: number
clusters:
type: integer
latency_ms:
type: number
PipelineRequest:
type: object
required: [chunks]
properties:
chunks:
type: array
items:
$ref: "#/components/schemas/DedupeChunk"
options:
type: object
properties:
dedup:
type: boolean
compress:
type: boolean
summarize:
type: boolean
cache:
type: boolean
PipelineResponse:
type: object
properties:
chunks:
type: array
items:
$ref: "#/components/schemas/DedupeChunk"
stats:
type: object
properties:
total_input_tokens:
type: integer
total_output_tokens:
type: integer
total_reduction:
type: number
total_latency_ms:
type: number
stages:
type: object
additionalProperties:
type: object
properties:
enabled:
type: boolean
input_tokens:
type: integer
output_tokens:
type: integer
reduction:
type: number
latency_ms:
type: number
BatchSubmitRequest:
type: object
required: [chunks]
properties:
chunks:
type: array
items:
$ref: "#/components/schemas/DedupeChunk"
options:
$ref: "#/components/schemas/PipelineRequest/properties/options"
BatchSubmitResponse:
type: object
properties:
job_id:
type: string
status:
type: string
BatchStatusResponse:
type: object
properties:
job_id:
type: string
status:
type: string
enum: [pending, running, completed, failed]
progress:
type: number
error:
type: string
created_at:
type: string
started_at:
type: string
completed_at:
type: string
BatchResultsResponse:
type: object
properties:
job_id:
type: string
status:
type: string
chunks:
type: array
items:
$ref: "#/components/schemas/DedupeChunk"
stats:
$ref: "#/components/schemas/PipelineResponse/properties/stats"
StoreRequest:
type: object
required: [entries]
properties:
session_id:
type: string
entries:
type: array
items:
type: object
required: [text]
properties:
text:
type: string
embedding:
type: array
items:
type: number
format: float
source:
type: string
tags:
type: array
items:
type: string
metadata:
type: object
additionalProperties: true
expires_at:
type: string
format: date-time
sensitivity:
type: integer
description: "0=none, 1=pii, 2=internal, 3=credentials"
auto_classify:
type: boolean
description: Run pattern-based sensitivity classification
StoreResult:
type: object
properties:
stored:
type: integer
merged:
type: integer
deduplicated:
type: integer
total_memories:
type: integer
conflicts:
type: array
items:
$ref: "#/components/schemas/Conflict"
Conflict:
type: object
properties:
new_id:
type: string
new_text:
type: string
existing_id:
type: string
existing_text:
type: string
distance:
type: number
format: double
RecallRequest:
type: object
required: [query]
properties:
query:
type: string
query_embedding:
type: array
items:
type: number
format: float
tags:
type: array
items:
type: string
max_tokens:
type: integer
max_results:
type: integer
recency_weight:
type: number
format: double
description: Weight for recency vs relevance (0-1)
include_expired:
type: boolean
task_context:
type: string
description: Task description for source-matching boost
boost_tags:
type: array
items:
type: string
description: Tags that receive a relevance boost
min_relevance:
type: number
format: double
description: Filter out memories below this score (0-1)
RecallResult:
type: object
properties:
memories:
type: array
items:
type: object
properties:
id:
type: string
text:
type: string
source:
type: string
tags:
type: array
items:
type: string
relevance:
type: number
format: double
decay_level:
type: integer
sensitivity:
type: integer
last_referenced:
type: string
format: date-time
stats:
type: object
properties:
candidates:
type: integer
deduplicated:
type: integer
returned:
type: integer
token_count:
type: integer
max_sensitivity:
type: integer
description: Highest sensitivity level across returned memories
sensitive_chunks:
type: array
items:
type: object
properties:
chunk_id:
type: string
sensitivity:
type: integer
ForgetRequest:
type: object
properties:
ids:
type: array
items:
type: string
tags:
type: array
items:
type: string
before:
type: string
format: date-time
ForgetResult:
type: object
properties:
forgotten:
type: integer
ExpireRequest:
type: object
required: [ids]
properties:
ids:
type: array
items:
type: string
ExpireResult:
type: object
properties:
expired:
type: integer
SupersedeRequest:
type: object
required: [old_id]
properties:
old_id:
type: string
new_id:
type: string
SupersedeResult:
type: object
properties:
superseded:
type: boolean
MemoryStats:
type: object
properties:
total_memories:
type: integer
expired_count:
type: integer
active_count:
type: integer
by_decay_level:
type: object
additionalProperties:
type: integer
by_source:
type: object
additionalProperties:
type: integer
oldest_memory:
type: string
format: date-time
newest_memory:
type: string
format: date-time
SessionCreateRequest:
type: object
required: [max_tokens]
properties:
session_id:
type: string
description: Auto-generated if empty
max_tokens:
type: integer
dedup_threshold:
type: number
format: double
preserve_recent:
type: integer
description: Always keep last N entries at full fidelity
Session:
type: object
properties:
id:
type: string
max_tokens:
type: integer
used_tokens:
type: integer
entry_count:
type: integer
created_at:
type: string
format: date-time
SessionPushRequest:
type: object
required: [session_id, entries]
properties:
session_id:
type: string
entries:
type: array
items:
type: object
required: [role, content]
properties:
role:
type: string
content:
type: string
embedding:
type: array
items:
type: number
format: float
SessionPushResult:
type: object
properties:
added:
type: integer
deduplicated:
type: integer
compressed:
type: integer
tokens_used:
type: integer
tokens_remaining:
type: integer
SessionContextRequest:
type: object
required: [session_id]
properties:
session_id:
type: string
max_tokens:
type: integer
description: "0 = return full window"
role:
type: string
description: Filter by role
SessionContextResult:
type: object
properties:
entries:
type: array
items:
type: object
properties:
role:
type: string
content:
type: string
compression_level:
type: string
tokens:
type: integer
total_tokens:
type: integer