-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
swagger.json
764 lines (764 loc) · 22.4 KB
/
swagger.json
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
{
"openapi": "3.1.0",
"info": {
"title": "Voyager APIs",
"contact": {
"email": "[email protected]"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
},
"version": "1.0.0"
},
"servers": [
{
"url": "http://localhost:8000"
}
],
"tags": [
{
"name": "Index",
"description": "Index of Voyager project"
},
{
"name": "Chat",
"description": "v1 Chat APIs"
},
{
"name": "Embedding",
"description": "v1 Embedding APIs"
},
{
"name": "Token",
"description": "v1 Token APIs"
},
{
"name": "Version",
"description": "v1 Version APIs"
}
],
"paths": {
"/": {
"get": {
"tags": [
"Index"
],
"summary" : "Route of this page",
"description": "Route to get this page"
}
},
"/healthy": {
"get": {
"tags": [
"Index"
],
"summary": "Route for healthy check",
"description": "If got response, means the server is running normally",
"responses": {
"200": {
"description": "Server works normally",
"content": {
"text/plain; charset=utf-8": {
"examples": {
"ok": {"value": "ok"}
}
}
}
},
"500": {
"description": "The server is not running normally, please check your server."
}
}
}
},
"/stats": {
"get": {
"tags": ["Index"],
"summary" : "Route to check stats",
"description": "Graphical server stats, Click [here](/stats) to get the page.",
"responses": {
"200": {
"description": "Returns The page of checking stats",
"content":{
"text/html": {}
}
}
}
}
},
"/chatbox": {
"get": {
"tags": ["Index"],
"summary" : "Route to embed chatbot",
"description": "Please see this [README](https://github.com/SkywardAI/voyager?tab=readme-ov-file#embed-your-chatbot-into-website).",
"parameters": [
{
"in": "query",
"name": "base_url",
"type": "string",
"description": "The base url of request, usually the url of this page you are looking at. Default http://localhost:8000."
}
],
"responses": {
"200": {
"description": "Returns the load script, usually load with script tag in HTML",
"content":{
"application/json; charset=utf-8": {}
}
}
}
}
},
"/v1/chat/completions": {
"post": {
"tags": [
"Chat"
],
"summary": "AI chat completion",
"description": "Start a conversation with given messages as context",
"requestBody": {
"required": true,
"content": {
"application/json": {
"description": "Request body of AI chat completion",
"schema": {
"$ref": "#/components/schemas/CompletionRequest"
},
"example": {
"messages": [
{ "role": "system", "content": "You are a helpful assistant who helps users solve their questions." },
{ "role": "user", "content": "Hello, tell me more about you!" }
]
}
}
}
},
"responses": {
"200": {
"description": "OpenAI like response",
"content": {
"application/json": {
"schema": {
"oneOf": [
{"$ref": "#/components/schemas/CompletionResponseStream"},
{"$ref": "#/components/schemas/CompletionResponseEntire"}
]
}
}
}
},
"400": {
"description": "Some errors occured"
},
"401": {
"description": "Not authorized"
}
},
"security": [
{"api_key": []}
]
}
},
"/v1/chat/rag-completions": {
"post": {
"tags": ["Chat"],
"summary": "AI chat completion with RAG dataset.",
"description": "Start a conversation with given messages and QAs from dataset as context. Please load dataset and pass the correct dataset name to make it work.",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CompletionRequest"
},
"example": {
"messages": [
{ "role": "system", "content": "You are a helpful assistant who helps users solve their questions." },
{ "role": "user", "content": "tell me something interest about massachusetts" }
],
"dataset_name": "aisuko/squad01-v2"
}
}
}
},
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"properties": {
"content": {
"$ref": "#/components/schemas/CompletionResponseEntire"
},
"rag_context": {
"type": "object",
"properties": {
"context": {
"type": "string",
"examples": ["Questioin:In what year did Massachusetts first require children to be educated in schools? Answer:1852"]
},
"identifier": {
"type": "string",
"examples": ["Private_school"]
},
"_distance": {
"type": "number",
"examples": [0.4810483455657959]
}
}
}
}
}
}
}
},
"400": {
"description": "Some errors occured"
},
"401": {
"description": "Not authorized"
}
},
"security": [
{"api_key": []}
]
}
},
"/v1/embeddings": {
"post": {
"tags": ["Embedding"],
"summary": "Get embedding of input",
"description": "Get the embedding value of given input, in OpenAI format",
"requestBody": {
"content": {
"application/json": {
"schema": {
"properties": {
"input": {
"type": "string",
"examples": ["Hello, world!"]
},
"model": {
"type": "string",
"description": "You can pass model, but this won't work at current stage",
"examples": ["all-MiniLM-L6-v2"]
},
"encoding_format": {
"type": "string",
"description": "You can pass encoding_format, but this won't work as we currently only support float.",
"examples": ["float"]
}
},
"required": [
"input"
],
"example": {
"input": "Hello, world!",
"model": "all-MiniLM-L6-v2"
}
}
}
}
},
"responses": {
"200": {
"description": "Everything works normal, get embedding result in OpenAI format",
"content": {
"application/json": {
"schema": {
"properties": {
"object": {
"type": "string",
"examples": ["list"]
},
"data": {
"type": "array",
"items": {
"type": "object",
"properties": {
"object": {
"type": "string",
"examples": ["embedding"]
},
"embedding": {
"type": "array",
"items": {
"type": "number",
"examples": [-0.02184351161122322, 0.049017686396837234, 0.06728602200746536]
},
"description": "The length should be exactly 384 items",
"example": [
-0.02184351161122322,
0.049017686396837234,
0.06728602200746536,
0.06581537425518036,
-0.05950690433382988,
-0.08613293617963791,
"*** totally 384 floats ***"
]
},
"index": {
"type": "integer",
"examples": [0]
}
}
}
},
"model": {
"type": "string",
"examples": ["all-MiniLM-L6-v2"]
},
"usage": {
"type": "array",
"items": {
"type": "object",
"properties": {
"prompt_tokens": {
"type": "integer",
"examples": [0]
},
"total_tokens": {
"type": "integer",
"examples": [0]
}
}
}
}
}
}
}
}
},
"400": {
"description": "Some errors occured"
},
"401": {
"description": "Not authorized"
},
"500": {
"description": "Internal server error"
}
},
"security": [
{"api_key": []}
]
}
},
"/v1/embeddings/dataset": {
"post": {
"tags": ["Embedding"],
"summary": "Loads dataset into database",
"description": "Load a dataset from url or directly pass a dataset array. Requires either url or json specified.",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/UploadDatasetRequest",
"required": [
"name"
],
"example":{
"name": "aisuko/squad01-v2",
"url": "https://datasets-server.huggingface.co/rows?dataset=aisuko%2Fsquad01-v2&config=default&split=validation&offset=0&length=100"
}
}
}
}
},
"responses": {
"200": {
"description": "Successfully loaded dataset"
},
"401": {
"description": "Not authorized"
},
"422": {
"description": "`Name` or neither `url` nor `json` not specified."
}
},
"security": [
{"api_key": []}
]
}
},
"/v1/token/api-key": {
"get": {
"tags": [ "Token" ],
"summary": "Get api key",
"description": "The route to get api key, please keep it yourself.",
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"properties": {
"api-key": {
"type": "string",
"examples": [
"voy-5uh12i196p8rqqgo3pbdmoaj1teit9clgk9ujkk0n91o"
]
}
}
}
}
}
}
}
}
},
"/v1/version": {
"get": {
"summary": "Get engine versions",
"description": "Get version of various engines used by this project",
"tags": ["Version"],
"responses": {
"200": {
"description": "Get a json of versions",
"content": {
"application/json": {
"schema": {
"properties": {
"inference_engine_version": {
"type": "string",
"examples": ["server--b1-2321a5e"]
}
}
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"CompletionRequest": {
"properties": {
"messages": {
"type": "array",
"items": {
"type": "object",
"properties":{
"role": {
"type": "string",
"examples": [
"system", "user", "assistant"
]
},
"content": {
"type": "string",
"examples": [
"You are a helpful assistant who helps users solve their questions.",
"Hi, what can you do?"
]
}
}
}
},
"max_tokens": {
"type": "integer",
"examples": [ 32, 128, 512 ]
},
"end": {
"type": "array",
"description": "When AI outputs the end pattern, end response.",
"items": {
"type": "string",
"examples": ["<|user|>"]
}
},
"stream": {
"type": "boolean",
"description": "If set to `true`, AI will response streamed."
}
},
"required": [
"messages"
]
},
"RAGCompletionRequest": {
"properties": {
"messages": {
"type": "array",
"items": {
"type": "object",
"properties":{
"role": {
"type": "string",
"examples": [
"system", "user", "assistant"
]
},
"content": {
"type": "string",
"examples": [
"You are a helpful assistant who helps users solve their questions.",
"Hi, what can you do?"
]
}
}
}
},
"max_tokens": {
"type": "integer",
"examples": [ 32, 128, 512 ]
},
"end": {
"type": "array",
"description": "When AI outputs the end pattern, end response.",
"items": {
"type": "string",
"examples": ["<|user|>"]
}
},
"stream": {
"type": "boolean",
"description": "If set to `true`, AI will response streamed."
},
"dataset_name": {
"type": "string",
"examples": [
"aisuko/squad01-v2"
]
}
},
"required": [
"messages",
"dataset_name"
]
},
"UploadDatasetRequest": {
"properties": {
"name": {
"type": "string",
"description": "Dataset name",
"examples": ["aisuko/squad01-v2"]
},
"url": {
"type": "string",
"description": "URL to download dataset",
"examples": [
"https://datasets-server.huggingface.co/rows?dataset=aisuko%2Fsquad01-v2&config=default&split=validation&offset=0&length=100"
]
},
"json": {
"type": "array",
"items": {
"type": "object",
"properties": {
"identifier": {
"type": "string",
"description": "Identifier of the row, not necessarily unique",
"examples":[
"Chloroplast"
]
},
"context": {
"type": "string",
"description": "Context to store in vector DB and pass to inference engine.",
"examples": [
"Questioin:When were stromules discovered? Answer:1962"
]
}
}
}
},
"force": {
"type": "boolean",
"description": "If specified, delete previous records of current dataset and load dataset into database.",
"examples": [
false
]
},
"keep_records": {
"type": "boolean",
"description": "If `force` is specified and `keep_records` is `true`, keeps records and load data into database. This can cause duplicate data in DB.",
"examples": [
false
]
}
}
},
"CompletionResponseEntire": {
"description": "Response of completion, where `stream=false`",
"properties": {
"id": {
"type": "string",
"description": "The id passed through `Authorization` header",
"examples": [
"voy-5uh12i196p8rqqgo3pbdmoaj1teit9clgk9ujkk0n91o"
]
},
"object": {
"type": "string",
"examples": [
"chat.completion"
]
},
"created": {
"type": "integer",
"examples": [
1722576434241
]
},
"model": {
"type": "string",
"examples": [
"Phi3-mini-4k-instruct-Q4.gguf"
]
},
"system_fingerprint": {
"type": "fp_2flh9v7kboo"
},
"choices": {
"type": "array",
"items": {
"type": "object",
"properties": {
"index": {
"type": "integer"
},
"message": {
"type": "array",
"items": {
"type": "object",
"properties": {
"role": {
"type": "string",
"examples": [
"assistant"
]
},
"message": {
"content": "string",
"examples": [
"Hi, I'm here to help!"
]
}
}
}
},
"logprobs": {
"type": "number",
"nullable": true,
"examples": [null]
},
"finish_reason": {
"type": "string",
"examples": [
"stop"
]
}
}
}
},
"usage": {
"type": "array",
"items": {
"type": "object",
"properties": {
"prompt_tokens": {
"type": "integer",
"examples":[0]
},
"completion_tokens": {
"type": "integer",
"examples":[0]
},
"total_tokens": {
"type": "integer",
"examples":[0]
}
}
}
}
}
},
"CompletionResponseStream": {
"description": "Response of completion, where `stream=true`",
"properties": {
"id": {
"type": "string",
"description": "The id passed through `Authorization` header",
"examples": [
"voy-5uh12i196p8rqqgo3pbdmoaj1teit9clgk9ujkk0n91o"
]
},
"object": {
"type": "string",
"examples": [
"chat.completion"
]
},
"created": {
"type": "integer",
"examples": [
1722576434241
]
},
"model": {
"type": "string",
"examples": [
"Phi3-mini-4k-instruct-Q4.gguf"
]
},
"system_fingerprint": {
"type": "fp_2flh9v7kboo"
},
"choices": {
"type": "array",
"items": {
"type": "object",
"properties": {
"index": {
"type": "integer"
},
"delta": {
"type": "array",
"items": {
"type": "object",
"properties": {
"role": {
"type": "string",
"examples": [
"assistant"
]
},
"content": {
"content": "string",
"examples": [
"Hi, "
]
}
}
}
},
"logprobs": {
"type": "number",
"nullable": true,
"examples": [null]
},
"finish_reason": {
"type": "string",
"examples": [
null, "stop"
]
}
}
}
}
}
}
},
"securitySchemes": {
"api_key": {
"type": "http",
"scheme": "bearer",
"bearerFormat": "JWT",
"description": "Please input your api key here. You can get it from GET /v1/token/api-key"
}
}
}
}