Elffuss BraidHub

kikocis/llama-stack public

move openapi from rfcs->docs
Changeset63b596ec7c5f08965e261e092395e29f098c66c18219f3864fbb137d43ac3d66
AuthorXi Yan <xiyan@meta.com> · 2024-09-18 16:09 -07:00
CommitterXi Yan <xiyan@meta.com> · 2024-09-18 16:09 -07:00
Parents364a20119140

Browse the files at this changeset

27 files changed

modified docs/getting_started.md +1 −1
@@ -149,7 +149,7 @@
149149 llama stack build --list-templates
150150 ```
151151
152-![alt text](list-templates.png)
152+![alt text](resources/list-templates.png)
153153
154154 You may then pick a template to build your distribution with providers fitted to your liking.
155155
deleted docs/list-templates.png +0 −0

Binary content is not shown. View the file.

added docs/llama-stack-spec.html +5842 −0

The diff of this file is cut short. View the file.

@@ -0,0 +1,5000 @@
1+<!DOCTYPE html>
2+<html>
3+
4+<head>
5+ <meta charset="utf-8" />
6+ <meta name="viewport" content="width=device-width, initial-scale=1">
7+ <title>OpenAPI specification</title>
8+ <link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700" rel="stylesheet">
9+ <style>
10+ body {
11+ margin: 0;
12+ padding: 0;
13+ }
14+
15+ </style>
16+ <script defer="defer" src="https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js"></script>
17+ <script defer="defer">
18+ document.addEventListener("DOMContentLoaded", function () {
19+ spec = {
20+ "openapi": "3.1.0",
21+ "info": {
22+ "title": "[DRAFT] Llama Stack Specification",
23+ "version": "0.0.1",
24+ "description": "This is the specification of the llama stack that provides\n a set of endpoints and their corresponding interfaces that are tailored to\n best leverage Llama Models. The specification is still in draft and subject to change.\n Generated at 2024-09-17 12:55:45.538053"
25+ },
26+ "servers": [
27+ {
28+ "url": "http://any-hosted-llama-stack.com"
29+ }
30+ ],
31+ "paths": {
32+ "/batch_inference/chat_completion": {
33+ "post": {
34+ "responses": {
35+ "200": {
36+ "description": "OK",
37+ "content": {
38+ "application/json": {
39+ "schema": {
40+ "$ref": "#/components/schemas/BatchChatCompletionResponse"
41+ }
42+ }
43+ }
44+ }
45+ },
46+ "tags": [
47+ "BatchInference"
48+ ],
49+ "parameters": [],
50+ "requestBody": {
51+ "content": {
52+ "application/json": {
53+ "schema": {
54+ "$ref": "#/components/schemas/BatchChatCompletionRequest"
55+ }
56+ }
57+ },
58+ "required": true
59+ }
60+ }
61+ },
62+ "/batch_inference/completion": {
63+ "post": {
64+ "responses": {
65+ "200": {
66+ "description": "OK",
67+ "content": {
68+ "application/json": {
69+ "schema": {
70+ "$ref": "#/components/schemas/BatchCompletionResponse"
71+ }
72+ }
73+ }
74+ }
75+ },
76+ "tags": [
77+ "BatchInference"
78+ ],
79+ "parameters": [],
80+ "requestBody": {
81+ "content": {
82+ "application/json": {
83+ "schema": {
84+ "$ref": "#/components/schemas/BatchCompletionRequest"
85+ }
86+ }
87+ },
88+ "required": true
89+ }
90+ }
91+ },
92+ "/evaluate/job/cancel": {
93+ "post": {
94+ "responses": {
95+ "200": {
96+ "description": "OK"
97+ }
98+ },
99+ "tags": [
100+ "Evaluations"
101+ ],
102+ "parameters": [],
103+ "requestBody": {
104+ "content": {
105+ "application/json": {
106+ "schema": {
107+ "$ref": "#/components/schemas/CancelEvaluationJobRequest"
108+ }
109+ }
110+ },
111+ "required": true
112+ }
113+ }
114+ },
115+ "/post_training/job/cancel": {
116+ "post": {
117+ "responses": {
118+ "200": {
119+ "description": "OK"
120+ }
121+ },
122+ "tags": [
123+ "PostTraining"
124+ ],
125+ "parameters": [],
126+ "requestBody": {
127+ "content": {
128+ "application/json": {
129+ "schema": {
130+ "$ref": "#/components/schemas/CancelTrainingJobRequest"
131+ }
132+ }
133+ },
134+ "required": true
135+ }
136+ }
137+ },
138+ "/inference/chat_completion": {
139+ "post": {
140+ "responses": {
141+ "200": {
142+ "description": "Chat completion response. **OR** SSE-stream of these events.",
143+ "content": {
144+ "text/event-stream": {
145+ "schema": {
146+ "oneOf": [
147+ {
148+ "$ref": "#/components/schemas/ChatCompletionResponse"
149+ },
150+ {
151+ "$ref": "#/components/schemas/ChatCompletionResponseStreamChunk"
152+ }
153+ ]
154+ }
155+ }
156+ }
157+ }
158+ },
159+ "tags": [
160+ "Inference"
161+ ],
162+ "parameters": [],
163+ "requestBody": {
164+ "content": {
165+ "application/json": {
166+ "schema": {
167+ "$ref": "#/components/schemas/ChatCompletionRequest"
168+ }
169+ }
170+ },
171+ "required": true
172+ }
173+ }
174+ },
175+ "/inference/completion": {
176+ "post": {
177+ "responses": {
178+ "200": {
179+ "description": "Completion response. **OR** streamed completion response.",
180+ "content": {
181+ "application/json": {
182+ "schema": {
183+ "oneOf": [
184+ {
185+ "$ref": "#/components/schemas/CompletionResponse"
186+ },
187+ {
188+ "$ref": "#/components/schemas/CompletionResponseStreamChunk"
189+ }
190+ ]
191+ }
192+ }
193+ }
194+ }
195+ },
196+ "tags": [
197+ "Inference"
198+ ],
199+ "parameters": [],
200+ "requestBody": {
201+ "content": {
202+ "application/json": {
203+ "schema": {
204+ "$ref": "#/components/schemas/CompletionRequest"
205+ }
206+ }
207+ },
208+ "required": true
209+ }
210+ }
211+ },
212+ "/agents/create": {
213+ "post": {
214+ "responses": {
215+ "200": {
216+ "description": "OK",
217+ "content": {
218+ "application/json": {
219+ "schema": {
220+ "$ref": "#/components/schemas/AgentCreateResponse"
221+ }
222+ }
223+ }
224+ }
225+ },
226+ "tags": [
227+ "Agents"
228+ ],
229+ "parameters": [],
230+ "requestBody": {
231+ "content": {
232+ "application/json": {
233+ "schema": {
234+ "$ref": "#/components/schemas/CreateAgentRequest"
235+ }
236+ }
237+ },
238+ "required": true
239+ }
240+ }
241+ },
242+ "/agents/session/create": {
243+ "post": {
244+ "responses": {
245+ "200": {
246+ "description": "OK",
247+ "content": {
248+ "application/json": {
249+ "schema": {
250+ "$ref": "#/components/schemas/AgentSessionCreateResponse"
251+ }
252+ }
253+ }
254+ }
255+ },
256+ "tags": [
257+ "Agents"
258+ ],
259+ "parameters": [],
260+ "requestBody": {
261+ "content": {
262+ "application/json": {
263+ "schema": {
264+ "$ref": "#/components/schemas/CreateAgentSessionRequest"
265+ }
266+ }
267+ },
268+ "required": true
269+ }
270+ }
271+ },
272+ "/agents/turn/create": {
273+ "post": {
274+ "responses": {
275+ "200": {
276+ "description": "OK",
277+ "content": {
278+ "application/json": {
279+ "schema": {
280+ "$ref": "#/components/schemas/AgentTurnResponseStreamChunk"
281+ }
282+ }
283+ }
284+ }
285+ },
286+ "tags": [
287+ "Agents"
288+ ],
289+ "parameters": [],
290+ "requestBody": {
291+ "content": {
292+ "application/json": {
293+ "schema": {
294+ "$ref": "#/components/schemas/CreateAgentTurnRequest"
295+ }
296+ }
297+ },
298+ "required": true
299+ }
300+ }
301+ },
302+ "/datasets/create": {
303+ "post": {
304+ "responses": {
305+ "200": {
306+ "description": "OK"
307+ }
308+ },
309+ "tags": [
310+ "Datasets"
311+ ],
312+ "parameters": [],
313+ "requestBody": {
314+ "content": {
315+ "application/json": {
316+ "schema": {
317+ "$ref": "#/components/schemas/CreateDatasetRequest"
318+ }
319+ }
320+ },
321+ "required": true
322+ }
323+ }
324+ },
325+ "/memory_banks/create": {
326+ "post": {
327+ "responses": {
328+ "200": {
329+ "description": "OK",
330+ "content": {
331+ "application/json": {
332+ "schema": {
333+ "$ref": "#/components/schemas/MemoryBank"
334+ }
335+ }
336+ }
337+ }
338+ },
339+ "tags": [
340+ "Memory"
341+ ],
342+ "parameters": [],
343+ "requestBody": {
344+ "content": {
345+ "application/json": {
346+ "schema": {
347+ "$ref": "#/components/schemas/CreateMemoryBankRequest"
348+ }
349+ }
350+ },
351+ "required": true
352+ }
353+ }
354+ },
355+ "/agents/delete": {
356+ "post": {
357+ "responses": {
358+ "200": {
359+ "description": "OK"
360+ }
361+ },
362+ "tags": [
363+ "Agents"
364+ ],
365+ "parameters": [],
366+ "requestBody": {
367+ "content": {
368+ "application/json": {
369+ "schema": {
370+ "$ref": "#/components/schemas/DeleteAgentsRequest"
371+ }
372+ }
373+ },
374+ "required": true
375+ }
376+ }
377+ },
378+ "/agents/session/delete": {
379+ "post": {
380+ "responses": {
381+ "200": {
382+ "description": "OK"
383+ }
384+ },
385+ "tags": [
386+ "Agents"
387+ ],
388+ "parameters": [],
389+ "requestBody": {
390+ "content": {
391+ "application/json": {
392+ "schema": {
393+ "$ref": "#/components/schemas/DeleteAgentsSessionRequest"
394+ }
395+ }
396+ },
397+ "required": true
398+ }
399+ }
400+ },
401+ "/datasets/delete": {
402+ "post": {
403+ "responses": {
404+ "200": {
405+ "description": "OK"
406+ }
407+ },
408+ "tags": [
409+ "Datasets"
410+ ],
411+ "parameters": [],
412+ "requestBody": {
413+ "content": {
414+ "application/json": {
415+ "schema": {
416+ "$ref": "#/components/schemas/DeleteDatasetRequest"
417+ }
418+ }
419+ },
420+ "required": true
421+ }
422+ }
423+ },
424+ "/memory_bank/documents/delete": {
425+ "post": {
426+ "responses": {
427+ "200": {
428+ "description": "OK"
429+ }
430+ },
431+ "tags": [
432+ "Memory"
433+ ],
434+ "parameters": [],
435+ "requestBody": {
436+ "content": {
437+ "application/json": {
438+ "schema": {
439+ "$ref": "#/components/schemas/DeleteDocumentsRequest"
440+ }
441+ }
442+ },
443+ "required": true
444+ }
445+ }
446+ },
447+ "/memory_banks/drop": {
448+ "post": {
449+ "responses": {
450+ "200": {
451+ "description": "OK",
452+ "content": {
453+ "application/json": {
454+ "schema": {
455+ "type": "string"
456+ }
457+ }
458+ }
459+ }
460+ },
461+ "tags": [
462+ "Memory"
463+ ],
464+ "parameters": [],
465+ "requestBody": {
466+ "content": {
467+ "application/json": {
468+ "schema": {
469+ "$ref": "#/components/schemas/DropMemoryBankRequest"
470+ }
471+ }
472+ },
473+ "required": true
474+ }
475+ }
476+ },
477+ "/inference/embeddings": {
478+ "post": {
479+ "responses": {
480+ "200": {
481+ "description": "OK",
482+ "content": {
483+ "application/json": {
484+ "schema": {
485+ "$ref": "#/components/schemas/EmbeddingsResponse"
486+ }
487+ }
488+ }
489+ }
490+ },
491+ "tags": [
492+ "Inference"
493+ ],
494+ "parameters": [],
495+ "requestBody": {
496+ "content": {
497+ "application/json": {
498+ "schema": {
499+ "$ref": "#/components/schemas/EmbeddingsRequest"
500+ }
501+ }
502+ },
503+ "required": true
504+ }
505+ }
506+ },
507+ "/evaluate/question_answering/": {
508+ "post": {
509+ "responses": {
510+ "200": {
511+ "description": "OK",
512+ "content": {
513+ "application/json": {
514+ "schema": {
515+ "$ref": "#/components/schemas/EvaluationJob"
516+ }
517+ }
518+ }
519+ }
520+ },
521+ "tags": [
522+ "Evaluations"
523+ ],
524+ "parameters": [],
525+ "requestBody": {
526+ "content": {
527+ "application/json": {
528+ "schema": {
529+ "$ref": "#/components/schemas/EvaluateQuestionAnsweringRequest"
530+ }
531+ }
532+ },
533+ "required": true
534+ }
535+ }
536+ },
537+ "/evaluate/summarization/": {
538+ "post": {
539+ "responses": {
540+ "200": {
541+ "description": "OK",
542+ "content": {
543+ "application/json": {
544+ "schema": {
545+ "$ref": "#/components/schemas/EvaluationJob"
546+ }
547+ }
548+ }
549+ }
550+ },
551+ "tags": [
552+ "Evaluations"
553+ ],
554+ "parameters": [],
555+ "requestBody": {
556+ "content": {
557+ "application/json": {
558+ "schema": {
559+ "$ref": "#/components/schemas/EvaluateSummarizationRequest"
560+ }
561+ }
562+ },
563+ "required": true
564+ }
565+ }
566+ },
567+ "/evaluate/text_generation/": {
568+ "post": {
569+ "responses": {
570+ "200": {
571+ "description": "OK",
572+ "content": {
573+ "application/json": {
574+ "schema": {
575+ "$ref": "#/components/schemas/EvaluationJob"
576+ }
577+ }
578+ }
579+ }
580+ },
581+ "tags": [
582+ "Evaluations"
583+ ],
584+ "parameters": [],
585+ "requestBody": {
586+ "content": {
587+ "application/json": {
588+ "schema": {
589+ "$ref": "#/components/schemas/EvaluateTextGenerationRequest"
590+ }
591+ }
592+ },
593+ "required": true
594+ }
595+ }
596+ },
597+ "/agents/session/get": {
598+ "post": {
599+ "responses": {
600+ "200": {
601+ "description": "OK",
602+ "content": {
603+ "application/json": {
604+ "schema": {
605+ "$ref": "#/components/schemas/Session"
606+ }
607+ }
608+ }
609+ }
610+ },
611+ "tags": [
612+ "Agents"
613+ ],
614+ "parameters": [
615+ {
616+ "name": "agent_id",
617+ "in": "query",
618+ "required": true,
619+ "schema": {
620+ "type": "string"
621+ }
622+ },
623+ {
624+ "name": "session_id",
625+ "in": "query",
626+ "required": true,
627+ "schema": {
628+ "type": "string"
629+ }
630+ }
631+ ],
632+ "requestBody": {
633+ "content": {
634+ "application/json": {
635+ "schema": {
636+ "$ref": "#/components/schemas/GetAgentsSessionRequest"
637+ }
638+ }
639+ },
640+ "required": true
641+ }
642+ }
643+ },
644+ "/agents/step/get": {
645+ "get": {
646+ "responses": {
647+ "200": {
648+ "description": "OK",
649+ "content": {
650+ "application/json": {
651+ "schema": {
652+ "$ref": "#/components/schemas/AgentStepResponse"
653+ }
654+ }
655+ }
656+ }
657+ },
658+ "tags": [
659+ "Agents"
660+ ],
661+ "parameters": [
662+ {
663+ "name": "agent_id",
664+ "in": "query",
665+ "required": true,
666+ "schema": {
667+ "type": "string"
668+ }
669+ },
670+ {
671+ "name": "turn_id",
672+ "in": "query",
673+ "required": true,
674+ "schema": {
675+ "type": "string"
676+ }
677+ },
678+ {
679+ "name": "step_id",
680+ "in": "query",
681+ "required": true,
682+ "schema": {
683+ "type": "string"
684+ }
685+ }
686+ ]
687+ }
688+ },
689+ "/agents/turn/get": {
690+ "get": {
691+ "responses": {
692+ "200": {
693+ "description": "OK",
694+ "content": {
695+ "application/json": {
696+ "schema": {
697+ "$ref": "#/components/schemas/Turn"
698+ }
699+ }
700+ }
701+ }
702+ },
703+ "tags": [
704+ "Agents"
705+ ],
706+ "parameters": [
707+ {
708+ "name": "agent_id",
709+ "in": "query",
710+ "required": true,
711+ "schema": {
712+ "type": "string"
713+ }
714+ },
715+ {
716+ "name": "turn_id",
717+ "in": "query",
718+ "required": true,
719+ "schema": {
720+ "type": "string"
721+ }
722+ }
723+ ]
724+ }
725+ },
726+ "/datasets/get": {
727+ "get": {
728+ "responses": {
729+ "200": {
730+ "description": "OK",
731+ "content": {
732+ "application/json": {
733+ "schema": {
734+ "$ref": "#/components/schemas/TrainEvalDataset"
735+ }
736+ }
737+ }
738+ }
739+ },
740+ "tags": [
741+ "Datasets"
742+ ],
743+ "parameters": [
744+ {
745+ "name": "dataset_uuid",
746+ "in": "query",
747+ "required": true,
748+ "schema": {
749+ "type": "string"
750+ }
751+ }
752+ ]
753+ }
754+ },
755+ "/memory_bank/documents/get": {
756+ "post": {
757+ "responses": {
758+ "200": {
759+ "description": "OK",
760+ "content": {
761+ "application/jsonl": {
762+ "schema": {
763+ "$ref": "#/components/schemas/MemoryBankDocument"
764+ }
765+ }
766+ }
767+ }
768+ },
769+ "tags": [
770+ "Memory"
771+ ],
772+ "parameters": [
773+ {
774+ "name": "bank_id",
775+ "in": "query",
776+ "required": true,
777+ "schema": {
778+ "type": "string"
779+ }
780+ }
781+ ],
782+ "requestBody": {
783+ "content": {
784+ "application/json": {
785+ "schema": {
786+ "$ref": "#/components/schemas/GetDocumentsRequest"
787+ }
788+ }
789+ },
790+ "required": true
791+ }
792+ }
793+ },
794+ "/evaluate/job/artifacts": {
795+ "get": {
796+ "responses": {
797+ "200": {
798+ "description": "OK",
799+ "content": {
800+ "application/json": {
801+ "schema": {
802+ "$ref": "#/components/schemas/EvaluationJobArtifactsResponse"
803+ }
804+ }
805+ }
806+ }
807+ },
808+ "tags": [
809+ "Evaluations"
810+ ],
811+ "parameters": [
812+ {
813+ "name": "job_uuid",
814+ "in": "query",
815+ "required": true,
816+ "schema": {
817+ "type": "string"
818+ }
819+ }
820+ ]
821+ }
822+ },
823+ "/evaluate/job/logs": {
824+ "get": {
825+ "responses": {
826+ "200": {
827+ "description": "OK",
828+ "content": {
829+ "application/json": {
830+ "schema": {
831+ "$ref": "#/components/schemas/EvaluationJobLogStream"
832+ }
833+ }
834+ }
835+ }
836+ },
837+ "tags": [
838+ "Evaluations"
839+ ],
840+ "parameters": [
841+ {
842+ "name": "job_uuid",
843+ "in": "query",
844+ "required": true,
845+ "schema": {
846+ "type": "string"
847+ }
848+ }
849+ ]
850+ }
851+ },
852+ "/evaluate/job/status": {
853+ "get": {
854+ "responses": {
855+ "200": {
856+ "description": "OK",
857+ "content": {
858+ "application/json": {
859+ "schema": {
860+ "$ref": "#/components/schemas/EvaluationJobStatusResponse"
861+ }
862+ }
863+ }
864+ }
865+ },
866+ "tags": [
867+ "Evaluations"
868+ ],
869+ "parameters": [
870+ {
871+ "name": "job_uuid",
872+ "in": "query",
873+ "required": true,
874+ "schema": {
875+ "type": "string"
876+ }
877+ }
878+ ]
879+ }
880+ },
881+ "/evaluate/jobs": {
882+ "get": {
883+ "responses": {
884+ "200": {
885+ "description": "OK",
886+ "content": {
887+ "application/jsonl": {
888+ "schema": {
889+ "$ref": "#/components/schemas/EvaluationJob"
890+ }
891+ }
892+ }
893+ }
894+ },
895+ "tags": [
896+ "Evaluations"
897+ ],
898+ "parameters": []
899+ }
900+ },
901+ "/memory_banks/get": {
902+ "get": {
903+ "responses": {
904+ "200": {
905+ "description": "OK",
906+ "content": {
907+ "application/json": {
908+ "schema": {
909+ "oneOf": [
910+ {
911+ "$ref": "#/components/schemas/MemoryBank"
912+ },
913+ {
914+ "type": "null"
915+ }
916+ ]
917+ }
918+ }
919+ }
920+ }
921+ },
922+ "tags": [
923+ "Memory"
924+ ],
925+ "parameters": [
926+ {
927+ "name": "bank_id",
928+ "in": "query",
929+ "required": true,
930+ "schema": {
931+ "type": "string"
932+ }
933+ }
934+ ]
935+ }
936+ },
937+ "/telemetry/get_trace": {
938+ "get": {
939+ "responses": {
940+ "200": {
941+ "description": "OK",
942+ "content": {
943+ "application/json": {
944+ "schema": {
945+ "$ref": "#/components/schemas/Trace"
946+ }
947+ }
948+ }
949+ }
950+ },
951+ "tags": [
952+ "Telemetry"
953+ ],
954+ "parameters": [
955+ {
956+ "name": "trace_id",
957+ "in": "query",
958+ "required": true,
959+ "schema": {
960+ "type": "string"
961+ }
962+ }
963+ ]
964+ }
965+ },
966+ "/post_training/job/artifacts": {
967+ "get": {
968+ "responses": {
969+ "200": {
970+ "description": "OK",
971+ "content": {
972+ "application/json": {
973+ "schema": {
974+ "$ref": "#/components/schemas/PostTrainingJobArtifactsResponse"
975+ }
976+ }
977+ }
978+ }
979+ },
980+ "tags": [
981+ "PostTraining"
982+ ],
983+ "parameters": [
984+ {
985+ "name": "job_uuid",
986+ "in": "query",
987+ "required": true,
988+ "schema": {
989+ "type": "string"
990+ }
991+ }
992+ ]
993+ }
994+ },
995+ "/post_training/job/logs": {
996+ "get": {
997+ "responses": {
998+ "200": {
999+ "description": "OK",
1000+ "content": {
1001+ "application/json": {
1002+ "schema": {
1003+ "$ref": "#/components/schemas/PostTrainingJobLogStream"
1004+ }
1005+ }
1006+ }
1007+ }
1008+ },
1009+ "tags": [
1010+ "PostTraining"
1011+ ],
1012+ "parameters": [
1013+ {
1014+ "name": "job_uuid",
1015+ "in": "query",
1016+ "required": true,
1017+ "schema": {
1018+ "type": "string"
1019+ }
1020+ }
1021+ ]
1022+ }
1023+ },
1024+ "/post_training/job/status": {
1025+ "get": {
1026+ "responses": {
1027+ "200": {
1028+ "description": "OK",
1029+ "content": {
1030+ "application/json": {
1031+ "schema": {
1032+ "$ref": "#/components/schemas/PostTrainingJobStatusResponse"
1033+ }
1034+ }
1035+ }
1036+ }
1037+ },
1038+ "tags": [
1039+ "PostTraining"
1040+ ],
1041+ "parameters": [
1042+ {
1043+ "name": "job_uuid",
1044+ "in": "query",
1045+ "required": true,
1046+ "schema": {
1047+ "type": "string"
1048+ }
1049+ }
1050+ ]
1051+ }
1052+ },
1053+ "/post_training/jobs": {
1054+ "get": {
1055+ "responses": {
1056+ "200": {
1057+ "description": "OK",
1058+ "content": {
1059+ "application/jsonl": {
1060+ "schema": {
1061+ "$ref": "#/components/schemas/PostTrainingJob"
1062+ }
1063+ }
1064+ }
1065+ }
1066+ },
1067+ "tags": [
1068+ "PostTraining"
1069+ ],
1070+ "parameters": []
1071+ }
1072+ },
1073+ "/memory_bank/insert": {
1074+ "post": {
1075+ "responses": {
1076+ "200": {
1077+ "description": "OK"
1078+ }
1079+ },
1080+ "tags": [
1081+ "Memory"
1082+ ],
1083+ "parameters": [],
1084+ "requestBody": {
1085+ "content": {
1086+ "application/json": {
1087+ "schema": {
1088+ "$ref": "#/components/schemas/InsertDocumentsRequest"
1089+ }
1090+ }
1091+ },
1092+ "required": true
1093+ }
1094+ }
1095+ },
1096+ "/memory_banks/list": {
1097+ "get": {
1098+ "responses": {
1099+ "200": {
1100+ "description": "OK",
1101+ "content": {
1102+ "application/jsonl": {
1103+ "schema": {
1104+ "$ref": "#/components/schemas/MemoryBank"
1105+ }
1106+ }
1107+ }
1108+ }
1109+ },
1110+ "tags": [
1111+ "Memory"
1112+ ],
1113+ "parameters": []
1114+ }
1115+ },
1116+ "/telemetry/log_event": {
1117+ "post": {
1118+ "responses": {
1119+ "200": {
1120+ "description": "OK"
1121+ }
1122+ },
1123+ "tags": [
1124+ "Telemetry"
1125+ ],
1126+ "parameters": [],
1127+ "requestBody": {
1128+ "content": {
1129+ "application/json": {
1130+ "schema": {
1131+ "$ref": "#/components/schemas/LogEventRequest"
1132+ }
1133+ }
1134+ },
1135+ "required": true
1136+ }
1137+ }
1138+ },
1139+ "/post_training/preference_optimize": {
1140+ "post": {
1141+ "responses": {
1142+ "200": {
1143+ "description": "OK",
1144+ "content": {
1145+ "application/json": {
1146+ "schema": {
1147+ "$ref": "#/components/schemas/PostTrainingJob"
1148+ }
1149+ }
1150+ }
1151+ }
1152+ },
1153+ "tags": [
1154+ "PostTraining"
1155+ ],
1156+ "parameters": [],
1157+ "requestBody": {
1158+ "content": {
1159+ "application/json": {
1160+ "schema": {
1161+ "$ref": "#/components/schemas/PreferenceOptimizeRequest"
1162+ }
1163+ }
1164+ },
1165+ "required": true
1166+ }
1167+ }
1168+ },
1169+ "/memory_bank/query": {
1170+ "post": {
1171+ "responses": {
1172+ "200": {
1173+ "description": "OK",
1174+ "content": {
1175+ "application/json": {
1176+ "schema": {
1177+ "$ref": "#/components/schemas/QueryDocumentsResponse"
1178+ }
1179+ }
1180+ }
1181+ }
1182+ },
1183+ "tags": [
1184+ "Memory"
1185+ ],
1186+ "parameters": [],
1187+ "requestBody": {
1188+ "content": {
1189+ "application/json": {
1190+ "schema": {
1191+ "$ref": "#/components/schemas/QueryDocumentsRequest"
1192+ }
1193+ }
1194+ },
1195+ "required": true
1196+ }
1197+ }
1198+ },
1199+ "/reward_scoring/score": {
1200+ "post": {
1201+ "responses": {
1202+ "200": {
1203+ "description": "OK",
1204+ "content": {
1205+ "application/json": {
1206+ "schema": {
1207+ "$ref": "#/components/schemas/RewardScoringResponse"
1208+ }
1209+ }
1210+ }
1211+ }
1212+ },
1213+ "tags": [
1214+ "RewardScoring"
1215+ ],
1216+ "parameters": [],
1217+ "requestBody": {
1218+ "content": {
1219+ "application/json": {
1220+ "schema": {
1221+ "$ref": "#/components/schemas/RewardScoreRequest"
1222+ }
1223+ }
1224+ },
1225+ "required": true
1226+ }
1227+ }
1228+ },
1229+ "/safety/run_shields": {
1230+ "post": {
1231+ "responses": {
1232+ "200": {
1233+ "description": "OK",
1234+ "content": {
1235+ "application/json": {
1236+ "schema": {
1237+ "$ref": "#/components/schemas/RunShieldResponse"
1238+ }
1239+ }
1240+ }
1241+ }
1242+ },
1243+ "tags": [
1244+ "Safety"
1245+ ],
1246+ "parameters": [],
1247+ "requestBody": {
1248+ "content": {
1249+ "application/json": {
1250+ "schema": {
1251+ "$ref": "#/components/schemas/RunShieldsRequest"
1252+ }
1253+ }
1254+ },
1255+ "required": true
1256+ }
1257+ }
1258+ },
1259+ "/post_training/supervised_fine_tune": {
1260+ "post": {
1261+ "responses": {
1262+ "200": {
1263+ "description": "OK",
1264+ "content": {
1265+ "application/json": {
1266+ "schema": {
1267+ "$ref": "#/components/schemas/PostTrainingJob"
1268+ }
1269+ }
1270+ }
1271+ }
1272+ },
1273+ "tags": [
1274+ "PostTraining"
1275+ ],
1276+ "parameters": [],
1277+ "requestBody": {
1278+ "content": {
1279+ "application/json": {
1280+ "schema": {
1281+ "$ref": "#/components/schemas/SupervisedFineTuneRequest"
1282+ }
1283+ }
1284+ },
1285+ "required": true
1286+ }
1287+ }
1288+ },
1289+ "/synthetic_data_generation/generate": {
1290+ "post": {
1291+ "responses": {
1292+ "200": {
1293+ "description": "OK",
1294+ "content": {
1295+ "application/json": {
1296+ "schema": {
1297+ "$ref": "#/components/schemas/SyntheticDataGenerationResponse"
1298+ }
1299+ }
1300+ }
1301+ }
1302+ },
1303+ "tags": [
1304+ "SyntheticDataGeneration"
1305+ ],
1306+ "parameters": [],
1307+ "requestBody": {
1308+ "content": {
1309+ "application/json": {
1310+ "schema": {
1311+ "$ref": "#/components/schemas/SyntheticDataGenerateRequest"
1312+ }
1313+ }
1314+ },
1315+ "required": true
1316+ }
1317+ }
1318+ },
1319+ "/memory_bank/update": {
1320+ "post": {
1321+ "responses": {
1322+ "200": {
1323+ "description": "OK"
1324+ }
1325+ },
1326+ "tags": [
1327+ "Memory"
1328+ ],
1329+ "parameters": [],
1330+ "requestBody": {
1331+ "content": {
1332+ "application/json": {
1333+ "schema": {
1334+ "$ref": "#/components/schemas/UpdateDocumentsRequest"
1335+ }
1336+ }
1337+ },
1338+ "required": true
1339+ }
1340+ }
1341+ }
1342+ },
1343+ "jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
1344+ "components": {
1345+ "schemas": {
1346+ "BuiltinTool": {
1347+ "type": "string",
1348+ "enum": [
1349+ "brave_search",
1350+ "wolfram_alpha",
1351+ "photogen",
1352+ "code_interpreter"
1353+ ]
1354+ },
1355+ "CompletionMessage": {
1356+ "type": "object",
1357+ "properties": {
1358+ "role": {
1359+ "type": "string",
1360+ "const": "assistant"
1361+ },
1362+ "content": {
1363+ "oneOf": [
1364+ {
1365+ "type": "string"
1366+ },
1367+ {
1368+ "type": "array",
1369+ "items": {
1370+ "type": "string"
1371+ }
1372+ }
1373+ ]
1374+ },
1375+ "stop_reason": {
1376+ "$ref": "#/components/schemas/StopReason"
1377+ },
1378+ "tool_calls": {
1379+ "type": "array",
1380+ "items": {
1381+ "$ref": "#/components/schemas/ToolCall"
1382+ }
1383+ }
1384+ },
1385+ "additionalProperties": false,
1386+ "required": [
1387+ "role",
1388+ "content",
1389+ "stop_reason",
1390+ "tool_calls"
1391+ ]
1392+ },
1393+ "SamplingParams": {
1394+ "type": "object",
1395+ "properties": {
1396+ "strategy": {
1397+ "$ref": "#/components/schemas/SamplingStrategy"
1398+ },
1399+ "temperature": {
1400+ "type": "number"
1401+ },
1402+ "top_p": {
1403+ "type": "number"
1404+ },
1405+ "top_k": {
1406+ "type": "integer"
1407+ },
1408+ "max_tokens": {
1409+ "type": "integer"
1410+ },
1411+ "repetition_penalty": {
1412+ "type": "number"
1413+ }
1414+ },
1415+ "additionalProperties": false,
1416+ "required": [
1417+ "strategy"
1418+ ]
1419+ },
1420+ "SamplingStrategy": {
1421+ "type": "string",
1422+ "enum": [
1423+ "greedy",
1424+ "top_p",
1425+ "top_k"
1426+ ]
1427+ },
1428+ "StopReason": {
1429+ "type": "string",
1430+ "enum": [
1431+ "end_of_turn",
1432+ "end_of_message",
1433+ "out_of_tokens"
1434+ ]
1435+ },
1436+ "SystemMessage": {
1437+ "type": "object",
1438+ "properties": {
1439+ "role": {
1440+ "type": "string",
1441+ "const": "system"
1442+ },
1443+ "content": {
1444+ "oneOf": [
1445+ {
1446+ "type": "string"
1447+ },
1448+ {
1449+ "type": "array",
1450+ "items": {
1451+ "type": "string"
1452+ }
1453+ }
1454+ ]
1455+ }
1456+ },
1457+ "additionalProperties": false,
1458+ "required": [
1459+ "role",
1460+ "content"
1461+ ]
1462+ },
1463+ "ToolCall": {
1464+ "type": "object",
1465+ "properties": {
1466+ "call_id": {
1467+ "type": "string"
1468+ },
1469+ "tool_name": {
1470+ "oneOf": [
1471+ {
1472+ "$ref": "#/components/schemas/BuiltinTool"
1473+ },
1474+ {
1475+ "type": "string"
1476+ }
1477+ ]
1478+ },
1479+ "arguments": {
1480+ "type": "object",
1481+ "additionalProperties": {
1482+ "oneOf": [
1483+ {
1484+ "type": "string"
1485+ },
1486+ {
1487+ "type": "integer"
1488+ },
1489+ {
1490+ "type": "number"
1491+ },
1492+ {
1493+ "type": "boolean"
1494+ },
1495+ {
1496+ "type": "null"
1497+ },
1498+ {
1499+ "type": "array",
1500+ "items": {
1501+ "oneOf": [
1502+ {
1503+ "type": "string"
1504+ },
1505+ {
1506+ "type": "integer"
1507+ },
1508+ {
1509+ "type": "number"
1510+ },
1511+ {
1512+ "type": "boolean"
1513+ },
1514+ {
1515+ "type": "null"
1516+ }
1517+ ]
1518+ }
1519+ },
1520+ {
1521+ "type": "object",
1522+ "additionalProperties": {
1523+ "oneOf": [
1524+ {
1525+ "type": "string"
1526+ },
1527+ {
1528+ "type": "integer"
1529+ },
1530+ {
1531+ "type": "number"
1532+ },
1533+ {
1534+ "type": "boolean"
1535+ },
1536+ {
1537+ "type": "null"
1538+ }
1539+ ]
1540+ }
1541+ }
1542+ ]
1543+ }
1544+ }
1545+ },
1546+ "additionalProperties": false,
1547+ "required": [
1548+ "call_id",
1549+ "tool_name",
1550+ "arguments"
1551+ ]
1552+ },
1553+ "ToolChoice": {
1554+ "type": "string",
1555+ "enum": [
1556+ "auto",
1557+ "required"
1558+ ]
1559+ },
1560+ "ToolDefinition": {
1561+ "type": "object",
1562+ "properties": {
1563+ "tool_name": {
1564+ "oneOf": [
1565+ {
1566+ "$ref": "#/components/schemas/BuiltinTool"
1567+ },
1568+ {
1569+ "type": "string"
1570+ }
1571+ ]
1572+ },
1573+ "description": {
1574+ "type": "string"
1575+ },
1576+ "parameters": {
1577+ "type": "object",
1578+ "additionalProperties": {
1579+ "$ref": "#/components/schemas/ToolParamDefinition"
1580+ }
1581+ }
1582+ },
1583+ "additionalProperties": false,
1584+ "required": [
1585+ "tool_name"
1586+ ]
1587+ },
1588+ "ToolParamDefinition": {
1589+ "type": "object",
1590+ "properties": {
1591+ "param_type": {
1592+ "type": "string"
1593+ },
1594+ "description": {
1595+ "type": "string"
1596+ },
1597+ "required": {
1598+ "type": "boolean"
1599+ }
1600+ },
1601+ "additionalProperties": false,
1602+ "required": [
1603+ "param_type"
1604+ ]
1605+ },
1606+ "ToolPromptFormat": {
1607+ "type": "string",
1608+ "enum": [
1609+ "json",
1610+ "function_tag"
1611+ ],
1612+ "title": "This Enum refers to the prompt format for calling custom / zero shot tools",
1613+ "description": "`json` --\n Refers to the json format for calling tools.\n The json format takes the form like\n {\n \"type\": \"function\",\n \"function\" : {\n \"name\": \"function_name\",\n \"description\": \"function_description\",\n \"parameters\": {...}\n }\n }\n\n`function_tag` --\n This is an example of how you could define\n your own user defined format for making tool calls.\n The function_tag format looks like this,\n <function=function_name>(parameters)</function>\n\nThe detailed prompts for each of these formats are added to llama cli"
1614+ },
1615+ "ToolResponseMessage": {
1616+ "type": "object",
1617+ "properties": {
1618+ "role": {
1619+ "type": "string",
1620+ "const": "ipython"
1621+ },
1622+ "call_id": {
1623+ "type": "string"
1624+ },
1625+ "tool_name": {
1626+ "oneOf": [
1627+ {
1628+ "$ref": "#/components/schemas/BuiltinTool"
1629+ },
1630+ {
1631+ "type": "string"
1632+ }
1633+ ]
1634+ },
1635+ "content": {
1636+ "oneOf": [
1637+ {
1638+ "type": "string"
1639+ },
1640+ {
1641+ "type": "array",
1642+ "items": {
1643+ "type": "string"
1644+ }
1645+ }
1646+ ]
1647+ }
1648+ },
1649+ "additionalProperties": false,
1650+ "required": [
1651+ "role",
1652+ "call_id",
1653+ "tool_name",
1654+ "content"
1655+ ]
1656+ },
1657+ "UserMessage": {
1658+ "type": "object",
1659+ "properties": {
1660+ "role": {
1661+ "type": "string",
1662+ "const": "user"
1663+ },
1664+ "content": {
1665+ "oneOf": [
1666+ {
1667+ "type": "string"
1668+ },
1669+ {
1670+ "type": "array",
1671+ "items": {
1672+ "type": "string"
1673+ }
1674+ }
1675+ ]
1676+ },
1677+ "context": {
1678+ "oneOf": [
1679+ {
1680+ "type": "string"
1681+ },
1682+ {
1683+ "type": "array",
1684+ "items": {
1685+ "type": "string"
1686+ }
1687+ }
1688+ ]
1689+ }
1690+ },
1691+ "additionalProperties": false,
1692+ "required": [
1693+ "role",
1694+ "content"
1695+ ]
1696+ },
1697+ "BatchChatCompletionRequest": {
1698+ "type": "object",
1699+ "properties": {
1700+ "model": {
1701+ "type": "string"
1702+ },
1703+ "messages_batch": {
1704+ "type": "array",
1705+ "items": {
1706+ "type": "array",
1707+ "items": {
1708+ "oneOf": [
1709+ {
1710+ "$ref": "#/components/schemas/UserMessage"
1711+ },
1712+ {
1713+ "$ref": "#/components/schemas/SystemMessage"
1714+ },
1715+ {
1716+ "$ref": "#/components/schemas/ToolResponseMessage"
1717+ },
1718+ {
1719+ "$ref": "#/components/schemas/CompletionMessage"
1720+ }
1721+ ]
1722+ }
1723+ }
1724+ },
1725+ "sampling_params": {
1726+ "$ref": "#/components/schemas/SamplingParams"
1727+ },
1728+ "tools": {
1729+ "type": "array",
1730+ "items": {
1731+ "$ref": "#/components/schemas/ToolDefinition"
1732+ }
1733+ },
1734+ "tool_choice": {
1735+ "$ref": "#/components/schemas/ToolChoice"
1736+ },
1737+ "tool_prompt_format": {
1738+ "$ref": "#/components/schemas/ToolPromptFormat"
1739+ },
1740+ "logprobs": {
1741+ "type": "object",
1742+ "properties": {
1743+ "top_k": {
1744+ "type": "integer"
1745+ }
1746+ },
1747+ "additionalProperties": false
1748+ }
1749+ },
1750+ "additionalProperties": false,
1751+ "required": [
1752+ "model",
1753+ "messages_batch"
1754+ ]
1755+ },
1756+ "BatchChatCompletionResponse": {
1757+ "type": "object",
1758+ "properties": {
1759+ "completion_message_batch": {
1760+ "type": "array",
1761+ "items": {
1762+ "$ref": "#/components/schemas/CompletionMessage"
1763+ }
1764+ }
1765+ },
1766+ "additionalProperties": false,
1767+ "required": [
1768+ "completion_message_batch"
1769+ ]
1770+ },
1771+ "BatchCompletionRequest": {
1772+ "type": "object",
1773+ "properties": {
1774+ "model": {
1775+ "type": "string"
1776+ },
1777+ "content_batch": {
1778+ "type": "array",
1779+ "items": {
1780+ "oneOf": [
1781+ {
1782+ "type": "string"
1783+ },
1784+ {
1785+ "type": "array",
1786+ "items": {
1787+ "type": "string"
1788+ }
1789+ }
1790+ ]
1791+ }
1792+ },
1793+ "sampling_params": {
1794+ "$ref": "#/components/schemas/SamplingParams"
1795+ },
1796+ "logprobs": {
1797+ "type": "object",
1798+ "properties": {
1799+ "top_k": {
1800+ "type": "integer"
1801+ }
1802+ },
1803+ "additionalProperties": false
1804+ }
1805+ },
1806+ "additionalProperties": false,
1807+ "required": [
1808+ "model",
1809+ "content_batch"
1810+ ]
1811+ },
1812+ "BatchCompletionResponse": {
1813+ "type": "object",
1814+ "properties": {
1815+ "completion_message_batch": {
1816+ "type": "array",
1817+ "items": {
1818+ "$ref": "#/components/schemas/CompletionMessage"
1819+ }
1820+ }
1821+ },
1822+ "additionalProperties": false,
1823+ "required": [
1824+ "completion_message_batch"
1825+ ]
1826+ },
1827+ "CancelEvaluationJobRequest": {
1828+ "type": "object",
1829+ "properties": {
1830+ "job_uuid": {
1831+ "type": "string"
1832+ }
1833+ },
1834+ "additionalProperties": false,
1835+ "required": [
1836+ "job_uuid"
1837+ ]
1838+ },
1839+ "CancelTrainingJobRequest": {
1840+ "type": "object",
1841+ "properties": {
1842+ "job_uuid": {
1843+ "type": "string"
1844+ }
1845+ },
1846+ "additionalProperties": false,
1847+ "required": [
1848+ "job_uuid"
1849+ ]
1850+ },
1851+ "ChatCompletionRequest": {
1852+ "type": "object",
1853+ "properties": {
1854+ "model": {
1855+ "type": "string"
1856+ },
1857+ "messages": {
1858+ "type": "array",
1859+ "items": {
1860+ "oneOf": [
1861+ {
1862+ "$ref": "#/components/schemas/UserMessage"
1863+ },
1864+ {
1865+ "$ref": "#/components/schemas/SystemMessage"
1866+ },
1867+ {
1868+ "$ref": "#/components/schemas/ToolResponseMessage"
1869+ },
1870+ {
1871+ "$ref": "#/components/schemas/CompletionMessage"
1872+ }
1873+ ]
1874+ }
1875+ },
1876+ "sampling_params": {
1877+ "$ref": "#/components/schemas/SamplingParams"
1878+ },
1879+ "tools": {
1880+ "type": "array",
1881+ "items": {
1882+ "$ref": "#/components/schemas/ToolDefinition"
1883+ }
1884+ },
1885+ "tool_choice": {
1886+ "$ref": "#/components/schemas/ToolChoice"
1887+ },
1888+ "tool_prompt_format": {
1889+ "$ref": "#/components/schemas/ToolPromptFormat"
1890+ },
1891+ "stream": {
1892+ "type": "boolean"
1893+ },
1894+ "logprobs": {
1895+ "type": "object",
1896+ "properties": {
1897+ "top_k": {
1898+ "type": "integer"
1899+ }
1900+ },
1901+ "additionalProperties": false
1902+ }
1903+ },
1904+ "additionalProperties": false,
1905+ "required": [
1906+ "model",
1907+ "messages"
1908+ ]
1909+ },
1910+ "ChatCompletionResponse": {
1911+ "type": "object",
1912+ "properties": {
1913+ "completion_message": {
1914+ "$ref": "#/components/schemas/CompletionMessage"
1915+ },
1916+ "logprobs": {
1917+ "type": "array",
1918+ "items": {
1919+ "$ref": "#/components/schemas/TokenLogProbs"
1920+ }
1921+ }
1922+ },
1923+ "additionalProperties": false,
1924+ "required": [
1925+ "completion_message"
1926+ ],
1927+ "title": "Chat completion response."
1928+ },
1929+ "ChatCompletionResponseEvent": {
1930+ "type": "object",
1931+ "properties": {
1932+ "event_type": {
1933+ "$ref": "#/components/schemas/ChatCompletionResponseEventType"
1934+ },
1935+ "delta": {
1936+ "oneOf": [
1937+ {
1938+ "type": "string"
1939+ },
1940+ {
1941+ "$ref": "#/components/schemas/ToolCallDelta"
1942+ }
1943+ ]
1944+ },
1945+ "logprobs": {
1946+ "type": "array",
1947+ "items": {
1948+ "$ref": "#/components/schemas/TokenLogProbs"
1949+ }
1950+ },
1951+ "stop_reason": {
1952+ "$ref": "#/components/schemas/StopReason"
1953+ }
1954+ },
1955+ "additionalProperties": false,
1956+ "required": [
1957+ "event_type",
1958+ "delta"
1959+ ],
1960+ "title": "Chat completion response event."
1961+ },
1962+ "ChatCompletionResponseEventType": {
1963+ "type": "string",
1964+ "enum": [
1965+ "start",
1966+ "complete",
1967+ "progress"
1968+ ]
1969+ },
1970+ "ChatCompletionResponseStreamChunk": {
1971+ "type": "object",
1972+ "properties": {
1973+ "event": {
1974+ "$ref": "#/components/schemas/ChatCompletionResponseEvent"
1975+ }
1976+ },
1977+ "additionalProperties": false,
1978+ "required": [
1979+ "event"
1980+ ],
1981+ "title": "SSE-stream of these events."
1982+ },
1983+ "TokenLogProbs": {
1984+ "type": "object",
1985+ "properties": {
1986+ "logprobs_by_token": {
1987+ "type": "object",
1988+ "additionalProperties": {
1989+ "type": "number"
1990+ }
1991+ }
1992+ },
1993+ "additionalProperties": false,
1994+ "required": [
1995+ "logprobs_by_token"
1996+ ]
1997+ },
1998+ "ToolCallDelta": {
1999+ "type": "object",
2000+ "properties": {
2001+ "content": {
2002+ "oneOf": [
2003+ {
2004+ "type": "string"
2005+ },
2006+ {
2007+ "$ref": "#/components/schemas/ToolCall"
2008+ }
2009+ ]
2010+ },
2011+ "parse_status": {
2012+ "$ref": "#/components/schemas/ToolCallParseStatus"
2013+ }
2014+ },
2015+ "additionalProperties": false,
2016+ "required": [
2017+ "content",
2018+ "parse_status"
2019+ ]
2020+ },
2021+ "ToolCallParseStatus": {
2022+ "type": "string",
2023+ "enum": [
2024+ "started",
2025+ "in_progress",
2026+ "failure",
2027+ "success"
2028+ ]
2029+ },
2030+ "CompletionRequest": {
2031+ "type": "object",
2032+ "properties": {
2033+ "model": {
2034+ "type": "string"
2035+ },
2036+ "content": {
2037+ "oneOf": [
2038+ {
2039+ "type": "string"
2040+ },
2041+ {
2042+ "type": "array",
2043+ "items": {
2044+ "type": "string"
2045+ }
2046+ }
2047+ ]
2048+ },
2049+ "sampling_params": {
2050+ "$ref": "#/components/schemas/SamplingParams"
2051+ },
2052+ "stream": {
2053+ "type": "boolean"
2054+ },
2055+ "logprobs": {
2056+ "type": "object",
2057+ "properties": {
2058+ "top_k": {
2059+ "type": "integer"
2060+ }
2061+ },
2062+ "additionalProperties": false
2063+ }
2064+ },
2065+ "additionalProperties": false,
2066+ "required": [
2067+ "model",
2068+ "content"
2069+ ]
2070+ },
2071+ "CompletionResponse": {
2072+ "type": "object",
2073+ "properties": {
2074+ "completion_message": {
2075+ "$ref": "#/components/schemas/CompletionMessage"
2076+ },
2077+ "logprobs": {
2078+ "type": "array",
2079+ "items": {
2080+ "$ref": "#/components/schemas/TokenLogProbs"
2081+ }
2082+ }
2083+ },
2084+ "additionalProperties": false,
2085+ "required": [
2086+ "completion_message"
2087+ ],
2088+ "title": "Completion response."
2089+ },
2090+ "CompletionResponseStreamChunk": {
2091+ "type": "object",
2092+ "properties": {
2093+ "delta": {
2094+ "type": "string"
2095+ },
2096+ "stop_reason": {
2097+ "$ref": "#/components/schemas/StopReason"
2098+ },
2099+ "logprobs": {
2100+ "type": "array",
2101+ "items": {
2102+ "$ref": "#/components/schemas/TokenLogProbs"
2103+ }
2104+ }
2105+ },
2106+ "additionalProperties": false,
2107+ "required": [
2108+ "delta"
2109+ ],
2110+ "title": "streamed completion response."
2111+ },
2112+ "AgentConfig": {
2113+ "type": "object",
2114+ "properties": {
2115+ "sampling_params": {
2116+ "$ref": "#/components/schemas/SamplingParams"
2117+ },
2118+ "input_shields": {
2119+ "type": "array",
2120+ "items": {
2121+ "$ref": "#/components/schemas/ShieldDefinition"
2122+ }
2123+ },
2124+ "output_shields": {
2125+ "type": "array",
2126+ "items": {
2127+ "$ref": "#/components/schemas/ShieldDefinition"
2128+ }
2129+ },
2130+ "tools": {
2131+ "type": "array",
2132+ "items": {
2133+ "oneOf": [
2134+ {
2135+ "$ref": "#/components/schemas/SearchToolDefinition"
2136+ },
2137+ {
2138+ "$ref": "#/components/schemas/WolframAlphaToolDefinition"
2139+ },
2140+ {
2141+ "$ref": "#/components/schemas/PhotogenToolDefinition"
2142+ },
2143+ {
2144+ "$ref": "#/components/schemas/CodeInterpreterToolDefinition"
2145+ },
2146+ {
2147+ "$ref": "#/components/schemas/FunctionCallToolDefinition"
2148+ },
2149+ {
2150+ "type": "object",
2151+ "properties": {
2152+ "input_shields": {
2153+ "type": "array",
2154+ "items": {
2155+ "$ref": "#/components/schemas/ShieldDefinition"
2156+ }
2157+ },
2158+ "output_shields": {
2159+ "type": "array",
2160+ "items": {
2161+ "$ref": "#/components/schemas/ShieldDefinition"
2162+ }
2163+ },
2164+ "type": {
2165+ "type": "string",
2166+ "const": "memory"
2167+ },
2168+ "memory_bank_configs": {
2169+ "type": "array",
2170+ "items": {
2171+ "oneOf": [
2172+ {
2173+ "type": "object",
2174+ "properties": {
2175+ "bank_id": {
2176+ "type": "string"
2177+ },
2178+ "type": {
2179+ "type": "string",
2180+ "const": "vector"
2181+ }
2182+ },
2183+ "additionalProperties": false,
2184+ "required": [
2185+ "bank_id",
2186+ "type"
2187+ ]
2188+ },
2189+ {
2190+ "type": "object",
2191+ "properties": {
2192+ "bank_id": {
2193+ "type": "string"
2194+ },
2195+ "type": {
2196+ "type": "string",
2197+ "const": "keyvalue"
2198+ },
2199+ "keys": {
2200+ "type": "array",
2201+ "items": {
2202+ "type": "string"
2203+ }
2204+ }
2205+ },
2206+ "additionalProperties": false,
2207+ "required": [
2208+ "bank_id",
2209+ "type",
2210+ "keys"
2211+ ]
2212+ },
2213+ {
2214+ "type": "object",
2215+ "properties": {
2216+ "bank_id": {
2217+ "type": "string"
2218+ },
2219+ "type": {
2220+ "type": "string",
2221+ "const": "keyword"
2222+ }
2223+ },
2224+ "additionalProperties": false,
2225+ "required": [
2226+ "bank_id",
2227+ "type"
2228+ ]
2229+ },
2230+ {
2231+ "type": "object",
2232+ "properties": {
2233+ "bank_id": {
2234+ "type": "string"
2235+ },
2236+ "type": {
2237+ "type": "string",
2238+ "const": "graph"
2239+ },
2240+ "entities": {
2241+ "type": "array",
2242+ "items": {
2243+ "type": "string"
2244+ }
2245+ }
2246+ },
2247+ "additionalProperties": false,
2248+ "required": [
2249+ "bank_id",
2250+ "type",
2251+ "entities"
2252+ ]
2253+ }
2254+ ]
2255+ }
2256+ },
2257+ "query_generator_config": {
2258+ "oneOf": [
2259+ {
2260+ "type": "object",
2261+ "properties": {
2262+ "type": {
2263+ "type": "string",
2264+ "const": "default"
2265+ },
2266+ "sep": {
2267+ "type": "string"
2268+ }
2269+ },
2270+ "additionalProperties": false,
2271+ "required": [
2272+ "type",
2273+ "sep"
2274+ ]
2275+ },
2276+ {
2277+ "type": "object",
2278+ "properties": {
2279+ "type": {
2280+ "type": "string",
2281+ "const": "llm"
2282+ },
2283+ "model": {
2284+ "type": "string"
2285+ },
2286+ "template": {
2287+ "type": "string"
2288+ }
2289+ },
2290+ "additionalProperties": false,
2291+ "required": [
2292+ "type",
2293+ "model",
2294+ "template"
2295+ ]
2296+ },
2297+ {
2298+ "type": "object",
2299+ "properties": {
2300+ "type": {
2301+ "type": "string",
2302+ "const": "custom"
2303+ }
2304+ },
2305+ "additionalProperties": false,
2306+ "required": [
2307+ "type"
2308+ ]
2309+ }
2310+ ]
2311+ },
2312+ "max_tokens_in_context": {
2313+ "type": "integer"
2314+ },
2315+ "max_chunks": {
2316+ "type": "integer"
2317+ }
2318+ },
2319+ "additionalProperties": false,
2320+ "required": [
2321+ "type",
2322+ "memory_bank_configs",
2323+ "query_generator_config",
2324+ "max_tokens_in_context",
2325+ "max_chunks"
2326+ ]
2327+ }
2328+ ]
2329+ }
2330+ },
2331+ "tool_choice": {
2332+ "$ref": "#/components/schemas/ToolChoice"
2333+ },
2334+ "tool_prompt_format": {
2335+ "$ref": "#/components/schemas/ToolPromptFormat"
2336+ },
2337+ "model": {
2338+ "type": "string"
2339+ },
2340+ "instructions": {
2341+ "type": "string"
2342+ }
2343+ },
2344+ "additionalProperties": false,
2345+ "required": [
2346+ "model",
2347+ "instructions"
2348+ ]
2349+ },
2350+ "BuiltinShield": {
2351+ "type": "string",
2352+ "enum": [
2353+ "llama_guard",
2354+ "code_scanner_guard",
2355+ "third_party_shield",
2356+ "injection_shield",
2357+ "jailbreak_shield"
2358+ ]
2359+ },
2360+ "CodeInterpreterToolDefinition": {
2361+ "type": "object",
2362+ "properties": {
2363+ "input_shields": {
2364+ "type": "array",
2365+ "items": {
2366+ "$ref": "#/components/schemas/ShieldDefinition"
2367+ }
2368+ },
2369+ "output_shields": {
2370+ "type": "array",
2371+ "items": {
2372+ "$ref": "#/components/schemas/ShieldDefinition"
2373+ }
2374+ },
2375+ "type": {
2376+ "type": "string",
2377+ "const": "code_interpreter"
2378+ },
2379+ "enable_inline_code_execution": {
2380+ "type": "boolean"
2381+ },
2382+ "remote_execution": {
2383+ "$ref": "#/components/schemas/RestAPIExecutionConfig"
2384+ }
2385+ },
2386+ "additionalProperties": false,
2387+ "required": [
2388+ "type",
2389+ "enable_inline_code_execution"
2390+ ]
2391+ },
2392+ "FunctionCallToolDefinition": {
2393+ "type": "object",
2394+ "properties": {
2395+ "input_shields": {
2396+ "type": "array",
2397+ "items": {
2398+ "$ref": "#/components/schemas/ShieldDefinition"
2399+ }
2400+ },
2401+ "output_shields": {
2402+ "type": "array",
2403+ "items": {
2404+ "$ref": "#/components/schemas/ShieldDefinition"
2405+ }
2406+ },
2407+ "type": {
2408+ "type": "string",
2409+ "const": "function_call"
2410+ },
2411+ "function_name": {
2412+ "type": "string"
2413+ },
2414+ "description": {
2415+ "type": "string"
2416+ },
2417+ "parameters": {
2418+ "type": "object",
2419+ "additionalProperties": {
2420+ "$ref": "#/components/schemas/ToolParamDefinition"
2421+ }
2422+ },
2423+ "remote_execution": {
2424+ "$ref": "#/components/schemas/RestAPIExecutionConfig"
2425+ }
2426+ },
2427+ "additionalProperties": false,
2428+ "required": [
2429+ "type",
2430+ "function_name",
2431+ "description",
2432+ "parameters"
2433+ ]
2434+ },
2435+ "OnViolationAction": {
2436+ "type": "integer",
2437+ "enum": [
2438+ 0,
2439+ 1,
2440+ 2
2441+ ]
2442+ },
2443+ "PhotogenToolDefinition": {
2444+ "type": "object",
2445+ "properties": {
2446+ "input_shields": {
2447+ "type": "array",
2448+ "items": {
2449+ "$ref": "#/components/schemas/ShieldDefinition"
2450+ }
2451+ },
2452+ "output_shields": {
2453+ "type": "array",
2454+ "items": {
2455+ "$ref": "#/components/schemas/ShieldDefinition"
2456+ }
2457+ },
2458+ "type": {
2459+ "type": "string",
2460+ "const": "photogen"
2461+ },
2462+ "remote_execution": {
2463+ "$ref": "#/components/schemas/RestAPIExecutionConfig"
2464+ }
2465+ },
2466+ "additionalProperties": false,
2467+ "required": [
2468+ "type"
2469+ ]
2470+ },
2471+ "RestAPIExecutionConfig": {
2472+ "type": "object",
2473+ "properties": {
2474+ "url": {
2475+ "$ref": "#/components/schemas/URL"
2476+ },
2477+ "method": {
2478+ "$ref": "#/components/schemas/RestAPIMethod"
2479+ },
2480+ "params": {
2481+ "type": "object",
2482+ "additionalProperties": {
2483+ "oneOf": [
2484+ {
2485+ "type": "null"
2486+ },
2487+ {
2488+ "type": "boolean"
2489+ },
2490+ {
2491+ "type": "number"
2492+ },
2493+ {
2494+ "type": "string"
2495+ },
2496+ {
2497+ "type": "array"
2498+ },
2499+ {
2500+ "type": "object"
2501+ }
2502+ ]
2503+ }
2504+ },
2505+ "headers": {
2506+ "type": "object",
2507+ "additionalProperties": {
2508+ "oneOf": [
2509+ {
2510+ "type": "null"
2511+ },
2512+ {
2513+ "type": "boolean"
2514+ },
2515+ {
2516+ "type": "number"
2517+ },
2518+ {
2519+ "type": "string"
2520+ },
2521+ {
2522+ "type": "array"
2523+ },
2524+ {
2525+ "type": "object"
2526+ }
2527+ ]
2528+ }
2529+ },
2530+ "body": {
2531+ "type": "object",
2532+ "additionalProperties": {
2533+ "oneOf": [
2534+ {
2535+ "type": "null"
2536+ },
2537+ {
2538+ "type": "boolean"
2539+ },
2540+ {
2541+ "type": "number"
2542+ },
2543+ {
2544+ "type": "string"
2545+ },
2546+ {
2547+ "type": "array"
2548+ },
2549+ {
2550+ "type": "object"
2551+ }
2552+ ]
2553+ }
2554+ }
2555+ },
2556+ "additionalProperties": false,
2557+ "required": [
2558+ "url",
2559+ "method"
2560+ ]
2561+ },
2562+ "RestAPIMethod": {
2563+ "type": "string",
2564+ "enum": [
2565+ "GET",
2566+ "POST",
2567+ "PUT",
2568+ "DELETE"
2569+ ]
2570+ },
2571+ "SearchToolDefinition": {
2572+ "type": "object",
2573+ "properties": {
2574+ "input_shields": {
2575+ "type": "array",
2576+ "items": {
2577+ "$ref": "#/components/schemas/ShieldDefinition"
2578+ }
2579+ },
2580+ "output_shields": {
2581+ "type": "array",
2582+ "items": {
2583+ "$ref": "#/components/schemas/ShieldDefinition"
2584+ }
2585+ },
2586+ "type": {
2587+ "type": "string",
2588+ "const": "brave_search"
2589+ },
2590+ "engine": {
2591+ "type": "string",
2592+ "enum": [
2593+ "bing",
2594+ "brave"
2595+ ]
2596+ },
2597+ "remote_execution": {
2598+ "$ref": "#/components/schemas/RestAPIExecutionConfig"
2599+ }
2600+ },
2601+ "additionalProperties": false,
2602+ "required": [
2603+ "type",
2604+ "engine"
2605+ ]
2606+ },
2607+ "ShieldDefinition": {
2608+ "type": "object",
2609+ "properties": {
2610+ "shield_type": {
2611+ "oneOf": [
2612+ {
2613+ "$ref": "#/components/schemas/BuiltinShield"
2614+ },
2615+ {
2616+ "type": "string"
2617+ }
2618+ ]
2619+ },
2620+ "description": {
2621+ "type": "string"
2622+ },
2623+ "parameters": {
2624+ "type": "object",
2625+ "additionalProperties": {
2626+ "$ref": "#/components/schemas/ToolParamDefinition"
2627+ }
2628+ },
2629+ "on_violation_action": {
2630+ "$ref": "#/components/schemas/OnViolationAction"
2631+ },
2632+ "execution_config": {
2633+ "$ref": "#/components/schemas/RestAPIExecutionConfig"
2634+ }
2635+ },
2636+ "additionalProperties": false,
2637+ "required": [
2638+ "shield_type",
2639+ "on_violation_action"
2640+ ]
2641+ },
2642+ "URL": {
2643+ "type": "string",
2644+ "format": "uri",
2645+ "pattern": "^(https?://|file://|data:)"
2646+ },
2647+ "WolframAlphaToolDefinition": {
2648+ "type": "object",
2649+ "properties": {
2650+ "input_shields": {
2651+ "type": "array",
2652+ "items": {
2653+ "$ref": "#/components/schemas/ShieldDefinition"
2654+ }
2655+ },
2656+ "output_shields": {
2657+ "type": "array",
2658+ "items": {
2659+ "$ref": "#/components/schemas/ShieldDefinition"
2660+ }
2661+ },
2662+ "type": {
2663+ "type": "string",
2664+ "const": "wolfram_alpha"
2665+ },
2666+ "remote_execution": {
2667+ "$ref": "#/components/schemas/RestAPIExecutionConfig"
2668+ }
2669+ },
2670+ "additionalProperties": false,
2671+ "required": [
2672+ "type"
2673+ ]
2674+ },
2675+ "CreateAgentRequest": {
2676+ "type": "object",
2677+ "properties": {
2678+ "agent_config": {
2679+ "$ref": "#/components/schemas/AgentConfig"
2680+ }
2681+ },
2682+ "additionalProperties": false,
2683+ "required": [
2684+ "agent_config"
2685+ ]
2686+ },
2687+ "AgentCreateResponse": {
2688+ "type": "object",
2689+ "properties": {
2690+ "agent_id": {
2691+ "type": "string"
2692+ }
2693+ },
2694+ "additionalProperties": false,
2695+ "required": [
2696+ "agent_id"
2697+ ]
2698+ },
2699+ "CreateAgentSessionRequest": {
2700+ "type": "object",
2701+ "properties": {
2702+ "agent_id": {
2703+ "type": "string"
2704+ },
2705+ "session_name": {
2706+ "type": "string"
2707+ }
2708+ },
2709+ "additionalProperties": false,
2710+ "required": [
2711+ "agent_id",
2712+ "session_name"
2713+ ]
2714+ },
2715+ "AgentSessionCreateResponse": {
2716+ "type": "object",
2717+ "properties": {
2718+ "session_id": {
2719+ "type": "string"
2720+ }
2721+ },
2722+ "additionalProperties": false,
2723+ "required": [
2724+ "session_id"
2725+ ]
2726+ },
2727+ "Attachment": {
2728+ "type": "object",
2729+ "properties": {
2730+ "content": {
2731+ "oneOf": [
2732+ {
2733+ "type": "string"
2734+ },
2735+ {
2736+ "type": "array",
2737+ "items": {
2738+ "type": "string"
2739+ }
2740+ },
2741+ {
2742+ "$ref": "#/components/schemas/URL"
2743+ }
2744+ ]
2745+ },
2746+ "mime_type": {
2747+ "type": "string"
2748+ }
2749+ },
2750+ "additionalProperties": false,
2751+ "required": [
2752+ "content",
2753+ "mime_type"
2754+ ]
2755+ },
2756+ "CreateAgentTurnRequest": {
2757+ "type": "object",
2758+ "properties": {
2759+ "agent_id": {
2760+ "type": "string"
2761+ },
2762+ "session_id": {
2763+ "type": "string"
2764+ },
2765+ "messages": {
2766+ "type": "array",
2767+ "items": {
2768+ "oneOf": [
2769+ {
2770+ "$ref": "#/components/schemas/UserMessage"
2771+ },
2772+ {
2773+ "$ref": "#/components/schemas/ToolResponseMessage"
2774+ }
2775+ ]
2776+ }
2777+ },
2778+ "attachments": {
2779+ "type": "array",
2780+ "items": {
2781+ "$ref": "#/components/schemas/Attachment"
2782+ }
2783+ },
2784+ "stream": {
2785+ "type": "boolean"
2786+ }
2787+ },
2788+ "additionalProperties": false,
2789+ "required": [
2790+ "agent_id",
2791+ "session_id",
2792+ "messages"
2793+ ]
2794+ },
2795+ "AgentTurnResponseEvent": {
2796+ "type": "object",
2797+ "properties": {
2798+ "payload": {
2799+ "oneOf": [
2800+ {
2801+ "$ref": "#/components/schemas/AgentTurnResponseStepStartPayload"
2802+ },
2803+ {
2804+ "$ref": "#/components/schemas/AgentTurnResponseStepProgressPayload"
2805+ },
2806+ {
2807+ "$ref": "#/components/schemas/AgentTurnResponseStepCompletePayload"
2808+ },
2809+ {
2810+ "$ref": "#/components/schemas/AgentTurnResponseTurnStartPayload"
2811+ },
2812+ {
2813+ "$ref": "#/components/schemas/AgentTurnResponseTurnCompletePayload"
2814+ }
2815+ ]
2816+ }
2817+ },
2818+ "additionalProperties": false,
2819+ "required": [
2820+ "payload"
2821+ ],
2822+ "title": "Streamed agent execution response."
2823+ },
2824+ "AgentTurnResponseStepCompletePayload": {
2825+ "type": "object",
2826+ "properties": {
2827+ "event_type": {
2828+ "type": "string",
2829+ "const": "step_complete"
2830+ },
2831+ "step_type": {
2832+ "type": "string",
2833+ "enum": [
2834+ "inference",
2835+ "tool_execution",
2836+ "shield_call",
2837+ "memory_retrieval"
2838+ ]
2839+ },
2840+ "step_details": {
2841+ "oneOf": [
2842+ {
2843+ "$ref": "#/components/schemas/InferenceStep"
2844+ },
2845+ {
2846+ "$ref": "#/components/schemas/ToolExecutionStep"
2847+ },
2848+ {
2849+ "$ref": "#/components/schemas/ShieldCallStep"
2850+ },
2851+ {
2852+ "$ref": "#/components/schemas/MemoryRetrievalStep"
2853+ }
2854+ ]
2855+ }
2856+ },
2857+ "additionalProperties": false,
2858+ "required": [
2859+ "event_type",
2860+ "step_type",
2861+ "step_details"
2862+ ]
2863+ },
2864+ "AgentTurnResponseStepProgressPayload": {
2865+ "type": "object",
2866+ "properties": {
2867+ "event_type": {
2868+ "type": "string",
2869+ "const": "step_progress"
2870+ },
2871+ "step_type": {
2872+ "type": "string",
2873+ "enum": [
2874+ "inference",
2875+ "tool_execution",
2876+ "shield_call",
2877+ "memory_retrieval"
2878+ ]
2879+ },
2880+ "step_id": {
2881+ "type": "string"
2882+ },
2883+ "model_response_text_delta": {
2884+ "type": "string"
2885+ },
2886+ "tool_call_delta": {
2887+ "$ref": "#/components/schemas/ToolCallDelta"
2888+ },
2889+ "tool_response_text_delta": {
2890+ "type": "string"
2891+ }
2892+ },
2893+ "additionalProperties": false,
2894+ "required": [
2895+ "event_type",
2896+ "step_type",
2897+ "step_id"
2898+ ]
2899+ },
2900+ "AgentTurnResponseStepStartPayload": {
2901+ "type": "object",
2902+ "properties": {
2903+ "event_type": {
2904+ "type": "string",
2905+ "const": "step_start"
2906+ },
2907+ "step_type": {
2908+ "type": "string",
2909+ "enum": [
2910+ "inference",
2911+ "tool_execution",
2912+ "shield_call",
2913+ "memory_retrieval"
2914+ ]
2915+ },
2916+ "step_id": {
2917+ "type": "string"
2918+ },
2919+ "metadata": {
2920+ "type": "object",
2921+ "additionalProperties": {
2922+ "oneOf": [
2923+ {
2924+ "type": "null"
2925+ },
2926+ {
2927+ "type": "boolean"
2928+ },
2929+ {
2930+ "type": "number"
2931+ },
2932+ {
2933+ "type": "string"
2934+ },
2935+ {
2936+ "type": "array"
2937+ },
2938+ {
2939+ "type": "object"
2940+ }
2941+ ]
2942+ }
2943+ }
2944+ },
2945+ "additionalProperties": false,
2946+ "required": [
2947+ "event_type",
2948+ "step_type",
2949+ "step_id"
2950+ ]
2951+ },
2952+ "AgentTurnResponseStreamChunk": {
2953+ "type": "object",
2954+ "properties": {
2955+ "event": {
2956+ "$ref": "#/components/schemas/AgentTurnResponseEvent"
2957+ }
2958+ },
2959+ "additionalProperties": false,
2960+ "required": [
2961+ "event"
2962+ ]
2963+ },
2964+ "AgentTurnResponseTurnCompletePayload": {
2965+ "type": "object",
2966+ "properties": {
2967+ "event_type": {
2968+ "type": "string",
2969+ "const": "turn_complete"
2970+ },
2971+ "turn": {
2972+ "$ref": "#/components/schemas/Turn"
2973+ }
2974+ },
2975+ "additionalProperties": false,
2976+ "required": [
2977+ "event_type",
2978+ "turn"
2979+ ]
2980+ },
2981+ "AgentTurnResponseTurnStartPayload": {
2982+ "type": "object",
2983+ "properties": {
2984+ "event_type": {
2985+ "type": "string",
2986+ "const": "turn_start"
2987+ },
2988+ "turn_id": {
2989+ "type": "string"
2990+ }
2991+ },
2992+ "additionalProperties": false,
2993+ "required": [
2994+ "event_type",
2995+ "turn_id"
2996+ ]
2997+ },
2998+ "InferenceStep": {
2999+ "type": "object",
3000+ "properties": {
3001+ "turn_id": {
3002+ "type": "string"
3003+ },
3004+ "step_id": {
3005+ "type": "string"
3006+ },
3007+ "started_at": {
3008+ "type": "string",
3009+ "format": "date-time"
3010+ },
3011+ "completed_at": {
3012+ "type": "string",
3013+ "format": "date-time"
3014+ },
3015+ "step_type": {
3016+ "type": "string",
3017+ "const": "inference"
3018+ },
3019+ "model_response": {
3020+ "$ref": "#/components/schemas/CompletionMessage"
3021+ }
3022+ },
3023+ "additionalProperties": false,
3024+ "required": [
3025+ "turn_id",
3026+ "step_id",
3027+ "step_type",
3028+ "model_response"
3029+ ]
3030+ },
3031+ "MemoryRetrievalStep": {
3032+ "type": "object",
3033+ "properties": {
3034+ "turn_id": {
3035+ "type": "string"
3036+ },
3037+ "step_id": {
3038+ "type": "string"
3039+ },
3040+ "started_at": {
3041+ "type": "string",
3042+ "format": "date-time"
3043+ },
3044+ "completed_at": {
3045+ "type": "string",
3046+ "format": "date-time"
3047+ },
3048+ "step_type": {
3049+ "type": "string",
3050+ "const": "memory_retrieval"
3051+ },
3052+ "memory_bank_ids": {
3053+ "type": "array",
3054+ "items": {
3055+ "type": "string"
3056+ }
3057+ },
3058+ "inserted_context": {
3059+ "oneOf": [
3060+ {
3061+ "type": "string"
3062+ },
3063+ {
3064+ "type": "array",
3065+ "items": {
3066+ "type": "string"
3067+ }
3068+ }
3069+ ]
3070+ }
3071+ },
3072+ "additionalProperties": false,
3073+ "required": [
3074+ "turn_id",
3075+ "step_id",
3076+ "step_type",
3077+ "memory_bank_ids",
3078+ "inserted_context"
3079+ ]
3080+ },
3081+ "ShieldCallStep": {
3082+ "type": "object",
3083+ "properties": {
3084+ "turn_id": {
3085+ "type": "string"
3086+ },
3087+ "step_id": {
3088+ "type": "string"
3089+ },
3090+ "started_at": {
3091+ "type": "string",
3092+ "format": "date-time"
3093+ },
3094+ "completed_at": {
3095+ "type": "string",
3096+ "format": "date-time"
3097+ },
3098+ "step_type": {
3099+ "type": "string",
3100+ "const": "shield_call"
3101+ },
3102+ "response": {
3103+ "$ref": "#/components/schemas/ShieldResponse"
3104+ }
3105+ },
3106+ "additionalProperties": false,
3107+ "required": [
3108+ "turn_id",
3109+ "step_id",
3110+ "step_type",
3111+ "response"
3112+ ]
3113+ },
3114+ "ShieldResponse": {
3115+ "type": "object",
3116+ "properties": {
3117+ "shield_type": {
3118+ "oneOf": [
3119+ {
3120+ "$ref": "#/components/schemas/BuiltinShield"
3121+ },
3122+ {
3123+ "type": "string"
3124+ }
3125+ ]
3126+ },
3127+ "is_violation": {
3128+ "type": "boolean"
3129+ },
3130+ "violation_type": {
3131+ "type": "string"
3132+ },
3133+ "violation_return_message": {
3134+ "type": "string"
3135+ }
3136+ },
3137+ "additionalProperties": false,
3138+ "required": [
3139+ "shield_type",
3140+ "is_violation"
3141+ ]
3142+ },
3143+ "ToolExecutionStep": {
3144+ "type": "object",
3145+ "properties": {
3146+ "turn_id": {
3147+ "type": "string"
3148+ },
3149+ "step_id": {
3150+ "type": "string"
3151+ },
3152+ "started_at": {
3153+ "type": "string",
3154+ "format": "date-time"
3155+ },
3156+ "completed_at": {
3157+ "type": "string",
3158+ "format": "date-time"
3159+ },
3160+ "step_type": {
3161+ "type": "string",
3162+ "const": "tool_execution"
3163+ },
3164+ "tool_calls": {
3165+ "type": "array",
3166+ "items": {
3167+ "$ref": "#/components/schemas/ToolCall"
3168+ }
3169+ },
3170+ "tool_responses": {
3171+ "type": "array",
3172+ "items": {
3173+ "$ref": "#/components/schemas/ToolResponse"
3174+ }
3175+ }
3176+ },
3177+ "additionalProperties": false,
3178+ "required": [
3179+ "turn_id",
3180+ "step_id",
3181+ "step_type",
3182+ "tool_calls",
3183+ "tool_responses"
3184+ ]
3185+ },
3186+ "ToolResponse": {
3187+ "type": "object",
3188+ "properties": {
3189+ "call_id": {
3190+ "type": "string"
3191+ },
3192+ "tool_name": {
3193+ "oneOf": [
3194+ {
3195+ "$ref": "#/components/schemas/BuiltinTool"
3196+ },
3197+ {
3198+ "type": "string"
3199+ }
3200+ ]
3201+ },
3202+ "content": {
3203+ "oneOf": [
3204+ {
3205+ "type": "string"
3206+ },
3207+ {
3208+ "type": "array",
3209+ "items": {
3210+ "type": "string"
3211+ }
3212+ }
3213+ ]
3214+ }
3215+ },
3216+ "additionalProperties": false,
3217+ "required": [
3218+ "call_id",
3219+ "tool_name",
3220+ "content"
3221+ ]
3222+ },
3223+ "Turn": {
3224+ "type": "object",
3225+ "properties": {
3226+ "turn_id": {
3227+ "type": "string"
3228+ },
3229+ "session_id": {
3230+ "type": "string"
3231+ },
3232+ "input_messages": {
3233+ "type": "array",
3234+ "items": {
3235+ "oneOf": [
3236+ {
3237+ "$ref": "#/components/schemas/UserMessage"
3238+ },
3239+ {
3240+ "$ref": "#/components/schemas/ToolResponseMessage"
3241+ }
3242+ ]
3243+ }
3244+ },
3245+ "steps": {
3246+ "type": "array",
3247+ "items": {
3248+ "oneOf": [
3249+ {
3250+ "$ref": "#/components/schemas/InferenceStep"
3251+ },
3252+ {
3253+ "$ref": "#/components/schemas/ToolExecutionStep"
3254+ },
3255+ {
3256+ "$ref": "#/components/schemas/ShieldCallStep"
3257+ },
3258+ {
3259+ "$ref": "#/components/schemas/MemoryRetrievalStep"
3260+ }
3261+ ]
3262+ }
3263+ },
3264+ "output_message": {
3265+ "$ref": "#/components/schemas/CompletionMessage"
3266+ },
3267+ "output_attachments": {
3268+ "type": "array",
3269+ "items": {
3270+ "$ref": "#/components/schemas/Attachment"
3271+ }
3272+ },
3273+ "started_at": {
3274+ "type": "string",
3275+ "format": "date-time"
3276+ },
3277+ "completed_at": {
3278+ "type": "string",
3279+ "format": "date-time"
3280+ }
3281+ },
3282+ "additionalProperties": false,
3283+ "required": [
3284+ "turn_id",
3285+ "session_id",
3286+ "input_messages",
3287+ "steps",
3288+ "output_message",
3289+ "output_attachments",
3290+ "started_at"
3291+ ],
3292+ "title": "A single turn in an interaction with an Agentic System."
3293+ },
3294+ "TrainEvalDataset": {
3295+ "type": "object",
3296+ "properties": {
3297+ "columns": {
3298+ "type": "object",
3299+ "additionalProperties": {
3300+ "$ref": "#/components/schemas/TrainEvalDatasetColumnType"
3301+ }
3302+ },
3303+ "content_url": {
3304+ "$ref": "#/components/schemas/URL"
3305+ },
3306+ "metadata": {
3307+ "type": "object",
3308+ "additionalProperties": {
3309+ "oneOf": [
3310+ {
3311+ "type": "null"
3312+ },
3313+ {
3314+ "type": "boolean"
3315+ },
3316+ {
3317+ "type": "number"
3318+ },
3319+ {
3320+ "type": "string"
3321+ },
3322+ {
3323+ "type": "array"
3324+ },
3325+ {
3326+ "type": "object"
3327+ }
3328+ ]
3329+ }
3330+ }
3331+ },
3332+ "additionalProperties": false,
3333+ "required": [
3334+ "columns",
3335+ "content_url"
3336+ ],
3337+ "title": "Dataset to be used for training or evaluating language models."
3338+ },
3339+ "TrainEvalDatasetColumnType": {
3340+ "type": "string",
3341+ "enum": [
3342+ "dialog",
3343+ "text",
3344+ "media",
3345+ "number",
3346+ "json"
3347+ ]
3348+ },
3349+ "CreateDatasetRequest": {
3350+ "type": "object",
3351+ "properties": {
3352+ "uuid": {
3353+ "type": "string"
3354+ },
3355+ "dataset": {
3356+ "$ref": "#/components/schemas/TrainEvalDataset"
3357+ }
3358+ },
3359+ "additionalProperties": false,
3360+ "required": [
3361+ "uuid",
3362+ "dataset"
3363+ ]
3364+ },
3365+ "CreateMemoryBankRequest": {
3366+ "type": "object",
3367+ "properties": {
3368+ "name": {
3369+ "type": "string"
3370+ },
3371+ "config": {
3372+ "oneOf": [
3373+ {
3374+ "type": "object",
3375+ "properties": {
3376+ "type": {
3377+ "type": "string",
3378+ "const": "vector"
3379+ },
3380+ "embedding_model": {
3381+ "type": "string"
3382+ },
3383+ "chunk_size_in_tokens": {
3384+ "type": "integer"
3385+ },
3386+ "overlap_size_in_tokens": {
3387+ "type": "integer"
3388+ }
3389+ },
3390+ "additionalProperties": false,
3391+ "required": [
3392+ "type",
3393+ "embedding_model",
3394+ "chunk_size_in_tokens"
3395+ ]
3396+ },
3397+ {
3398+ "type": "object",
3399+ "properties": {
3400+ "type": {
3401+ "type": "string",
3402+ "const": "keyvalue"
3403+ }
3404+ },
3405+ "additionalProperties": false,
3406+ "required": [
3407+ "type"
3408+ ]
3409+ },
3410+ {
3411+ "type": "object",
3412+ "properties": {
3413+ "type": {
3414+ "type": "string",
3415+ "const": "keyword"
3416+ }
3417+ },
3418+ "additionalProperties": false,
3419+ "required": [
3420+ "type"
3421+ ]
3422+ },
3423+ {
3424+ "type": "object",
3425+ "properties": {
3426+ "type": {
3427+ "type": "string",
3428+ "const": "graph"
3429+ }
3430+ },
3431+ "additionalProperties": false,
3432+ "required": [
3433+ "type"
3434+ ]
3435+ }
3436+ ]
3437+ },
3438+ "url": {
3439+ "$ref": "#/components/schemas/URL"
3440+ }
3441+ },
3442+ "additionalProperties": false,
3443+ "required": [
3444+ "name",
3445+ "config"
3446+ ]
3447+ },
3448+ "MemoryBank": {
3449+ "type": "object",
3450+ "properties": {
3451+ "bank_id": {
3452+ "type": "string"
3453+ },
3454+ "name": {
3455+ "type": "string"
3456+ },
3457+ "config": {
3458+ "oneOf": [
3459+ {
3460+ "type": "object",
3461+ "properties": {
3462+ "type": {
3463+ "type": "string",
3464+ "const": "vector"
3465+ },
3466+ "embedding_model": {
3467+ "type": "string"
3468+ },
3469+ "chunk_size_in_tokens": {
3470+ "type": "integer"
3471+ },
3472+ "overlap_size_in_tokens": {
3473+ "type": "integer"
3474+ }
3475+ },
3476+ "additionalProperties": false,
3477+ "required": [
3478+ "type",
3479+ "embedding_model",
3480+ "chunk_size_in_tokens"
3481+ ]
3482+ },
3483+ {
3484+ "type": "object",
3485+ "properties": {
3486+ "type": {
3487+ "type": "string",
3488+ "const": "keyvalue"
3489+ }
3490+ },
3491+ "additionalProperties": false,
3492+ "required": [
3493+ "type"
3494+ ]
3495+ },
3496+ {
3497+ "type": "object",
3498+ "properties": {
3499+ "type": {
3500+ "type": "string",
3501+ "const": "keyword"
3502+ }
3503+ },
3504+ "additionalProperties": false,
3505+ "required": [
3506+ "type"
3507+ ]
3508+ },
3509+ {
3510+ "type": "object",
3511+ "properties": {
3512+ "type": {
3513+ "type": "string",
3514+ "const": "graph"
3515+ }
3516+ },
3517+ "additionalProperties": false,
3518+ "required": [
3519+ "type"
3520+ ]
3521+ }
3522+ ]
3523+ },
3524+ "url": {
3525+ "$ref": "#/components/schemas/URL"
3526+ }
3527+ },
3528+ "additionalProperties": false,
3529+ "required": [
3530+ "bank_id",
3531+ "name",
3532+ "config"
3533+ ]
3534+ },
3535+ "DeleteAgentsRequest": {
3536+ "type": "object",
3537+ "properties": {
3538+ "agent_id": {
3539+ "type": "string"
3540+ }
3541+ },
3542+ "additionalProperties": false,
3543+ "required": [
3544+ "agent_id"
3545+ ]
3546+ },
3547+ "DeleteAgentsSessionRequest": {
3548+ "type": "object",
3549+ "properties": {
3550+ "agent_id": {
3551+ "type": "string"
3552+ },
3553+ "session_id": {
3554+ "type": "string"
3555+ }
3556+ },
3557+ "additionalProperties": false,
3558+ "required": [
3559+ "agent_id",
3560+ "session_id"
3561+ ]
3562+ },
3563+ "DeleteDatasetRequest": {
3564+ "type": "object",
3565+ "properties": {
3566+ "dataset_uuid": {
3567+ "type": "string"
3568+ }
3569+ },
3570+ "additionalProperties": false,
3571+ "required": [
3572+ "dataset_uuid"
3573+ ]
3574+ },
3575+ "DeleteDocumentsRequest": {
3576+ "type": "object",
3577+ "properties": {
3578+ "bank_id": {
3579+ "type": "string"
3580+ },
3581+ "document_ids": {
3582+ "type": "array",
3583+ "items": {
3584+ "type": "string"
3585+ }
3586+ }
3587+ },
3588+ "additionalProperties": false,
3589+ "required": [
3590+ "bank_id",
3591+ "document_ids"
3592+ ]
3593+ },
3594+ "DropMemoryBankRequest": {
3595+ "type": "object",
3596+ "properties": {
3597+ "bank_id": {
3598+ "type": "string"
3599+ }
3600+ },
3601+ "additionalProperties": false,
3602+ "required": [
3603+ "bank_id"
3604+ ]
3605+ },
3606+ "EmbeddingsRequest": {
3607+ "type": "object",
3608+ "properties": {
3609+ "model": {
3610+ "type": "string"
3611+ },
3612+ "contents": {
3613+ "type": "array",
3614+ "items": {
3615+ "oneOf": [
3616+ {
3617+ "type": "string"
3618+ },
3619+ {
3620+ "type": "array",
3621+ "items": {
3622+ "type": "string"
3623+ }
3624+ }
3625+ ]
3626+ }
3627+ }
3628+ },
3629+ "additionalProperties": false,
3630+ "required": [
3631+ "model",
3632+ "contents"
3633+ ]
3634+ },
3635+ "EmbeddingsResponse": {
3636+ "type": "object",
3637+ "properties": {
3638+ "embeddings": {
3639+ "type": "array",
3640+ "items": {
3641+ "type": "array",
3642+ "items": {
3643+ "type": "number"
3644+ }
3645+ }
3646+ }
3647+ },
3648+ "additionalProperties": false,
3649+ "required": [
3650+ "embeddings"
3651+ ]
3652+ },
3653+ "EvaluateQuestionAnsweringRequest": {
3654+ "type": "object",
3655+ "properties": {
3656+ "metrics": {
3657+ "type": "array",
3658+ "items": {
3659+ "type": "string",
3660+ "enum": [
3661+ "em",
3662+ "f1"
3663+ ]
3664+ }
3665+ }
3666+ },
3667+ "additionalProperties": false,
3668+ "required": [
3669+ "metrics"
3670+ ]
3671+ },
3672+ "EvaluationJob": {
3673+ "type": "object",
3674+ "properties": {
3675+ "job_uuid": {
3676+ "type": "string"
3677+ }
3678+ },
3679+ "additionalProperties": false,
3680+ "required": [
3681+ "job_uuid"
3682+ ]
3683+ },
3684+ "EvaluateSummarizationRequest": {
3685+ "type": "object",
3686+ "properties": {
3687+ "metrics": {
3688+ "type": "array",
3689+ "items": {
3690+ "type": "string",
3691+ "enum": [
3692+ "rouge",
3693+ "bleu"
3694+ ]
3695+ }
3696+ }
3697+ },
3698+ "additionalProperties": false,
3699+ "required": [
3700+ "metrics"
3701+ ]
3702+ },
3703+ "EvaluateTextGenerationRequest": {
3704+ "type": "object",
3705+ "properties": {
3706+ "metrics": {
3707+ "type": "array",
3708+ "items": {
3709+ "type": "string",
3710+ "enum": [
3711+ "perplexity",
3712+ "rouge",
3713+ "bleu"
3714+ ]
3715+ }
3716+ }
3717+ },
3718+ "additionalProperties": false,
3719+ "required": [
3720+ "metrics"
3721+ ]
3722+ },
3723+ "GetAgentsSessionRequest": {
3724+ "type": "object",
3725+ "properties": {
3726+ "turn_ids": {
3727+ "type": "array",
3728+ "items": {
3729+ "type": "string"
3730+ }
3731+ }
3732+ },
3733+ "additionalProperties": false
3734+ },
3735+ "Session": {
3736+ "type": "object",
3737+ "properties": {
3738+ "session_id": {
3739+ "type": "string"
3740+ },
3741+ "session_name": {
3742+ "type": "string"
3743+ },
3744+ "turns": {
3745+ "type": "array",
3746+ "items": {
3747+ "$ref": "#/components/schemas/Turn"
3748+ }
3749+ },
3750+ "started_at": {
3751+ "type": "string",
3752+ "format": "date-time"
3753+ },
3754+ "memory_bank": {
3755+ "$ref": "#/components/schemas/MemoryBank"
3756+ }
3757+ },
3758+ "additionalProperties": false,
3759+ "required": [
3760+ "session_id",
3761+ "session_name",
3762+ "turns",
3763+ "started_at"
3764+ ],
3765+ "title": "A single session of an interaction with an Agentic System."
3766+ },
3767+ "AgentStepResponse": {
3768+ "type": "object",
3769+ "properties": {
3770+ "step": {
3771+ "oneOf": [
3772+ {
3773+ "$ref": "#/components/schemas/InferenceStep"
3774+ },
3775+ {
3776+ "$ref": "#/components/schemas/ToolExecutionStep"
3777+ },
3778+ {
3779+ "$ref": "#/components/schemas/ShieldCallStep"
3780+ },
3781+ {
3782+ "$ref": "#/components/schemas/MemoryRetrievalStep"
3783+ }
3784+ ]
3785+ }
3786+ },
3787+ "additionalProperties": false,
3788+ "required": [
3789+ "step"
3790+ ]
3791+ },
3792+ "GetDocumentsRequest": {
3793+ "type": "object",
3794+ "properties": {
3795+ "document_ids": {
3796+ "type": "array",
3797+ "items": {
3798+ "type": "string"
3799+ }
3800+ }
3801+ },
3802+ "additionalProperties": false,
3803+ "required": [
3804+ "document_ids"
3805+ ]
3806+ },
3807+ "MemoryBankDocument": {
3808+ "type": "object",
3809+ "properties": {
3810+ "document_id": {
3811+ "type": "string"
3812+ },
3813+ "content": {
3814+ "oneOf": [
3815+ {
3816+ "type": "string"
3817+ },
3818+ {
3819+ "type": "array",
3820+ "items": {
3821+ "type": "string"
3822+ }
3823+ },
3824+ {
3825+ "$ref": "#/components/schemas/URL"
3826+ }
3827+ ]
3828+ },
3829+ "mime_type": {
3830+ "type": "string"
3831+ },
3832+ "metadata": {
3833+ "type": "object",
3834+ "additionalProperties": {
3835+ "oneOf": [
3836+ {
3837+ "type": "null"
3838+ },
3839+ {
3840+ "type": "boolean"
3841+ },
3842+ {
3843+ "type": "number"
3844+ },
3845+ {
3846+ "type": "string"
3847+ },
3848+ {
3849+ "type": "array"
3850+ },
3851+ {
3852+ "type": "object"
3853+ }
3854+ ]
3855+ }
3856+ }
3857+ },
3858+ "additionalProperties": false,
3859+ "required": [
3860+ "document_id",
3861+ "content",
3862+ "metadata"
3863+ ]
3864+ },
3865+ "EvaluationJobArtifactsResponse": {
3866+ "type": "object",
3867+ "properties": {
3868+ "job_uuid": {
3869+ "type": "string"
3870+ }
3871+ },
3872+ "additionalProperties": false,
3873+ "required": [
3874+ "job_uuid"
3875+ ],
3876+ "title": "Artifacts of a evaluation job."
3877+ },
3878+ "EvaluationJobLogStream": {
3879+ "type": "object",
3880+ "properties": {
3881+ "job_uuid": {
3882+ "type": "string"
3883+ }
3884+ },
3885+ "additionalProperties": false,
3886+ "required": [
3887+ "job_uuid"
3888+ ]
3889+ },
3890+ "EvaluationJobStatusResponse": {
3891+ "type": "object",
3892+ "properties": {
3893+ "job_uuid": {
3894+ "type": "string"
3895+ }
3896+ },
3897+ "additionalProperties": false,
3898+ "required": [
3899+ "job_uuid"
3900+ ]
3901+ },
3902+ "Trace": {
3903+ "type": "object",
3904+ "properties": {
3905+ "trace_id": {
3906+ "type": "string"
3907+ },
3908+ "root_span_id": {
3909+ "type": "string"
3910+ },
3911+ "start_time": {
3912+ "type": "string",
3913+ "format": "date-time"
3914+ },
3915+ "end_time": {
3916+ "type": "string",
3917+ "format": "date-time"
3918+ }
3919+ },
3920+ "additionalProperties": false,
3921+ "required": [
3922+ "trace_id",
3923+ "root_span_id",
3924+ "start_time"
3925+ ]
3926+ },
3927+ "Checkpoint": {
3928+ "description": "Checkpoint created during training runs"
3929+ },
3930+ "PostTrainingJobArtifactsResponse": {
3931+ "type": "object",
3932+ "properties": {
3933+ "job_uuid": {
3934+ "type": "string"
3935+ },
3936+ "checkpoints": {
3937+ "type": "array",
3938+ "items": {
3939+ "$ref": "#/components/schemas/Checkpoint"
3940+ }
3941+ }
3942+ },
3943+ "additionalProperties": false,
3944+ "required": [
3945+ "job_uuid",
3946+ "checkpoints"
3947+ ],
3948+ "title": "Artifacts of a finetuning job."
3949+ },
3950+ "PostTrainingJobLogStream": {
3951+ "type": "object",
3952+ "properties": {
3953+ "job_uuid": {
3954+ "type": "string"
3955+ },
3956+ "log_lines": {
3957+ "type": "array",
3958+ "items": {
3959+ "type": "string"
3960+ }
3961+ }
3962+ },
3963+ "additionalProperties": false,
3964+ "required": [
3965+ "job_uuid",
3966+ "log_lines"
3967+ ],
3968+ "title": "Stream of logs from a finetuning job."
3969+ },
3970+ "PostTrainingJobStatus": {
3971+ "type": "string",
3972+ "enum": [
3973+ "running",
3974+ "completed",
3975+ "failed",
3976+ "scheduled"
3977+ ]
3978+ },
3979+ "PostTrainingJobStatusResponse": {
3980+ "type": "object",
3981+ "properties": {
3982+ "job_uuid": {
3983+ "type": "string"
3984+ },
3985+ "status": {
3986+ "$ref": "#/components/schemas/PostTrainingJobStatus"
3987+ },
3988+ "scheduled_at": {
3989+ "type": "string",
3990+ "format": "date-time"
3991+ },
3992+ "started_at": {
3993+ "type": "string",
3994+ "format": "date-time"
3995+ },
3996+ "completed_at": {
3997+ "type": "string",
3998+ "format": "date-time"
3999+ },
4000+ "resources_allocated": {
4001+ "type": "object",
4002+ "additionalProperties": {
4003+ "oneOf": [
4004+ {
4005+ "type": "null"
4006+ },
4007+ {
4008+ "type": "boolean"
4009+ },
4010+ {
4011+ "type": "number"
4012+ },
4013+ {
4014+ "type": "string"
4015+ },
4016+ {
4017+ "type": "array"
4018+ },
4019+ {
4020+ "type": "object"
4021+ }
4022+ ]
4023+ }
4024+ },
4025+ "checkpoints": {
4026+ "type": "array",
4027+ "items": {
4028+ "$ref": "#/components/schemas/Checkpoint"
4029+ }
4030+ }
4031+ },
4032+ "additionalProperties": false,
4033+ "required": [
4034+ "job_uuid",
4035+ "status",
4036+ "checkpoints"
4037+ ],
4038+ "title": "Status of a finetuning job."
4039+ },
4040+ "PostTrainingJob": {
4041+ "type": "object",
4042+ "properties": {
4043+ "job_uuid": {
4044+ "type": "string"
4045+ }
4046+ },
4047+ "additionalProperties": false,
4048+ "required": [
4049+ "job_uuid"
4050+ ]
4051+ },
4052+ "InsertDocumentsRequest": {
4053+ "type": "object",
4054+ "properties": {
4055+ "bank_id": {
4056+ "type": "string"
4057+ },
4058+ "documents": {
4059+ "type": "array",
4060+ "items": {
4061+ "$ref": "#/components/schemas/MemoryBankDocument"
4062+ }
4063+ },
4064+ "ttl_seconds": {
4065+ "type": "integer"
4066+ }
4067+ },
4068+ "additionalProperties": false,
4069+ "required": [
4070+ "bank_id",
4071+ "documents"
4072+ ]
4073+ },
4074+ "LogSeverity": {
4075+ "type": "string",
4076+ "enum": [
4077+ "verbose",
4078+ "debug",
4079+ "info",
4080+ "warn",
4081+ "error",
4082+ "critical"
4083+ ]
4084+ },
4085+ "MetricEvent": {
4086+ "type": "object",
4087+ "properties": {
4088+ "trace_id": {
4089+ "type": "string"
4090+ },
4091+ "span_id": {
4092+ "type": "string"
4093+ },
4094+ "timestamp": {
4095+ "type": "string",
4096+ "format": "date-time"
4097+ },
4098+ "attributes": {
4099+ "type": "object",
4100+ "additionalProperties": {
4101+ "oneOf": [
4102+ {
4103+ "type": "null"
4104+ },
4105+ {
4106+ "type": "boolean"
4107+ },
4108+ {
4109+ "type": "number"
4110+ },
4111+ {
4112+ "type": "string"
4113+ },
4114+ {
4115+ "type": "array"
4116+ },
4117+ {
4118+ "type": "object"
4119+ }
4120+ ]
4121+ }
4122+ },
4123+ "type": {
4124+ "type": "string",
4125+ "const": "metric"
4126+ },
4127+ "metric": {
4128+ "type": "string"
4129+ },
4130+ "value": {
4131+ "oneOf": [
4132+ {
4133+ "type": "integer"
4134+ },
4135+ {
4136+ "type": "number"
4137+ }
4138+ ]
4139+ },
4140+ "unit": {
4141+ "type": "string"
4142+ }
4143+ },
4144+ "additionalProperties": false,
4145+ "required": [
4146+ "trace_id",
4147+ "span_id",
4148+ "timestamp",
4149+ "type",
4150+ "metric",
4151+ "value",
4152+ "unit"
4153+ ]
4154+ },
4155+ "SpanEndPayload": {
4156+ "type": "object",
4157+ "properties": {
4158+ "type": {
4159+ "type": "string",
4160+ "const": "span_end"
4161+ },
4162+ "status": {
4163+ "$ref": "#/components/schemas/SpanStatus"
4164+ }
4165+ },
4166+ "additionalProperties": false,
4167+ "required": [
4168+ "type",
4169+ "status"
4170+ ]
4171+ },
4172+ "SpanStartPayload": {
4173+ "type": "object",
4174+ "properties": {
4175+ "type": {
4176+ "type": "string",
4177+ "const": "span_start"
4178+ },
4179+ "name": {
4180+ "type": "string"
4181+ },
4182+ "parent_span_id": {
4183+ "type": "string"
4184+ }
4185+ },
4186+ "additionalProperties": false,
4187+ "required": [
4188+ "type",
4189+ "name"
4190+ ]
4191+ },
4192+ "SpanStatus": {
4193+ "type": "string",
4194+ "enum": [
4195+ "ok",
4196+ "error"
4197+ ]
4198+ },
4199+ "StructuredLogEvent": {
4200+ "type": "object",
4201+ "properties": {
4202+ "trace_id": {
4203+ "type": "string"
4204+ },
4205+ "span_id": {
4206+ "type": "string"
4207+ },
4208+ "timestamp": {
4209+ "type": "string",
4210+ "format": "date-time"
4211+ },
4212+ "attributes": {
4213+ "type": "object",
4214+ "additionalProperties": {
4215+ "oneOf": [
4216+ {
4217+ "type": "null"
4218+ },
4219+ {
4220+ "type": "boolean"
4221+ },
4222+ {
4223+ "type": "number"
4224+ },
4225+ {
4226+ "type": "string"
4227+ },
4228+ {
4229+ "type": "array"
4230+ },
4231+ {
4232+ "type": "object"
4233+ }
4234+ ]
4235+ }
4236+ },
4237+ "type": {
4238+ "type": "string",
4239+ "const": "structured_log"
4240+ },
4241+ "payload": {
4242+ "oneOf": [
4243+ {
4244+ "$ref": "#/components/schemas/SpanStartPayload"
4245+ },
4246+ {
4247+ "$ref": "#/components/schemas/SpanEndPayload"
4248+ }
4249+ ]
4250+ }
4251+ },
4252+ "additionalProperties": false,
4253+ "required": [
4254+ "trace_id",
4255+ "span_id",
4256+ "timestamp",
4257+ "type",
4258+ "payload"
4259+ ]
4260+ },
4261+ "UnstructuredLogEvent": {
4262+ "type": "object",
4263+ "properties": {
4264+ "trace_id": {
4265+ "type": "string"
4266+ },
4267+ "span_id": {
4268+ "type": "string"
4269+ },
4270+ "timestamp": {
4271+ "type": "string",
4272+ "format": "date-time"
4273+ },
4274+ "attributes": {
4275+ "type": "object",
4276+ "additionalProperties": {
4277+ "oneOf": [
4278+ {
4279+ "type": "null"
4280+ },
4281+ {
4282+ "type": "boolean"
4283+ },
4284+ {
4285+ "type": "number"
4286+ },
4287+ {
4288+ "type": "string"
4289+ },
4290+ {
4291+ "type": "array"
4292+ },
4293+ {
4294+ "type": "object"
4295+ }
4296+ ]
4297+ }
4298+ },
4299+ "type": {
4300+ "type": "string",
4301+ "const": "unstructured_log"
4302+ },
4303+ "message": {
4304+ "type": "string"
4305+ },
4306+ "severity": {
4307+ "$ref": "#/components/schemas/LogSeverity"
4308+ }
4309+ },
4310+ "additionalProperties": false,
4311+ "required": [
4312+ "trace_id",
4313+ "span_id",
4314+ "timestamp",
4315+ "type",
4316+ "message",
4317+ "severity"
4318+ ]
4319+ },
4320+ "LogEventRequest": {
4321+ "type": "object",
4322+ "properties": {
4323+ "event": {
4324+ "oneOf": [
4325+ {
4326+ "$ref": "#/components/schemas/UnstructuredLogEvent"
4327+ },
4328+ {
4329+ "$ref": "#/components/schemas/MetricEvent"
4330+ },
4331+ {
4332+ "$ref": "#/components/schemas/StructuredLogEvent"
4333+ }
4334+ ]
4335+ }
4336+ },
4337+ "additionalProperties": false,
4338+ "required": [
4339+ "event"
4340+ ]
4341+ },
4342+ "DPOAlignmentConfig": {
4343+ "type": "object",
4344+ "properties": {
4345+ "reward_scale": {
4346+ "type": "number"
4347+ },
4348+ "reward_clip": {
4349+ "type": "number"
4350+ },
4351+ "epsilon": {
4352+ "type": "number"
4353+ },
4354+ "gamma": {
4355+ "type": "number"
4356+ }
4357+ },
4358+ "additionalProperties": false,
4359+ "required": [
4360+ "reward_scale",
4361+ "reward_clip",
4362+ "epsilon",
4363+ "gamma"
4364+ ]
4365+ },
4366+ "OptimizerConfig": {
4367+ "type": "object",
4368+ "properties": {
4369+ "optimizer_type": {
4370+ "type": "string",
4371+ "enum": [
4372+ "adam",
4373+ "adamw",
4374+ "sgd"
4375+ ]
4376+ },
4377+ "lr": {
4378+ "type": "number"
4379+ },
4380+ "lr_min": {
4381+ "type": "number"
4382+ },
4383+ "weight_decay": {
4384+ "type": "number"
4385+ }
4386+ },
4387+ "additionalProperties": false,
4388+ "required": [
4389+ "optimizer_type",
4390+ "lr",
4391+ "lr_min",
4392+ "weight_decay"
4393+ ]
4394+ },
4395+ "RLHFAlgorithm": {
4396+ "type": "string",
4397+ "enum": [
4398+ "dpo"
4399+ ]
4400+ },
4401+ "TrainingConfig": {
4402+ "type": "object",
4403+ "properties": {
4404+ "n_epochs": {
4405+ "type": "integer"
4406+ },
4407+ "batch_size": {
4408+ "type": "integer"
4409+ },
4410+ "shuffle": {
4411+ "type": "boolean"
4412+ },
4413+ "n_iters": {
4414+ "type": "integer"
4415+ },
4416+ "enable_activation_checkpointing": {
4417+ "type": "boolean"
4418+ },
4419+ "memory_efficient_fsdp_wrap": {
4420+ "type": "boolean"
4421+ },
4422+ "fsdp_cpu_offload": {
4423+ "type": "boolean"
4424+ }
4425+ },
4426+ "additionalProperties": false,
4427+ "required": [
4428+ "n_epochs",
4429+ "batch_size",
4430+ "shuffle",
4431+ "n_iters",
4432+ "enable_activation_checkpointing",
4433+ "memory_efficient_fsdp_wrap",
4434+ "fsdp_cpu_offload"
4435+ ]
4436+ },
4437+ "PreferenceOptimizeRequest": {
4438+ "type": "object",
4439+ "properties": {
4440+ "job_uuid": {
4441+ "type": "string"
4442+ },
4443+ "finetuned_model": {
4444+ "$ref": "#/components/schemas/URL"
4445+ },
4446+ "dataset": {
4447+ "$ref": "#/components/schemas/TrainEvalDataset"
4448+ },
4449+ "validation_dataset": {
4450+ "$ref": "#/components/schemas/TrainEvalDataset"
4451+ },
4452+ "algorithm": {
4453+ "$ref": "#/components/schemas/RLHFAlgorithm"
4454+ },
4455+ "algorithm_config": {
4456+ "$ref": "#/components/schemas/DPOAlignmentConfig"
4457+ },
4458+ "optimizer_config": {
4459+ "$ref": "#/components/schemas/OptimizerConfig"
4460+ },
4461+ "training_config": {
4462+ "$ref": "#/components/schemas/TrainingConfig"
4463+ },
4464+ "hyperparam_search_config": {
4465+ "type": "object",
4466+ "additionalProperties": {
4467+ "oneOf": [
4468+ {
4469+ "type": "null"
4470+ },
4471+ {
4472+ "type": "boolean"
4473+ },
4474+ {
4475+ "type": "number"
4476+ },
4477+ {
4478+ "type": "string"
4479+ },
4480+ {
4481+ "type": "array"
4482+ },
4483+ {
4484+ "type": "object"
4485+ }
4486+ ]
4487+ }
4488+ },
4489+ "logger_config": {
4490+ "type": "object",
4491+ "additionalProperties": {
4492+ "oneOf": [
4493+ {
4494+ "type": "null"
4495+ },
4496+ {
4497+ "type": "boolean"
4498+ },
4499+ {
4500+ "type": "number"
4501+ },
4502+ {
4503+ "type": "string"
4504+ },
4505+ {
4506+ "type": "array"
4507+ },
4508+ {
4509+ "type": "object"
4510+ }
4511+ ]
4512+ }
4513+ }
4514+ },
4515+ "additionalProperties": false,
4516+ "required": [
4517+ "job_uuid",
4518+ "finetuned_model",
4519+ "dataset",
4520+ "validation_dataset",
4521+ "algorithm",
4522+ "algorithm_config",
4523+ "optimizer_config",
4524+ "training_config",
4525+ "hyperparam_search_config",
4526+ "logger_config"
4527+ ]
4528+ },
4529+ "QueryDocumentsRequest": {
4530+ "type": "object",
4531+ "properties": {
4532+ "bank_id": {
4533+ "type": "string"
4534+ },
4535+ "query": {
4536+ "oneOf": [
4537+ {
4538+ "type": "string"
4539+ },
4540+ {
4541+ "type": "array",
4542+ "items": {
4543+ "type": "string"
4544+ }
4545+ }
4546+ ]
4547+ },
4548+ "params": {
4549+ "type": "object",
4550+ "additionalProperties": {
4551+ "oneOf": [
4552+ {
4553+ "type": "null"
4554+ },
4555+ {
4556+ "type": "boolean"
4557+ },
4558+ {
4559+ "type": "number"
4560+ },
4561+ {
4562+ "type": "string"
4563+ },
4564+ {
4565+ "type": "array"
4566+ },
4567+ {
4568+ "type": "object"
4569+ }
4570+ ]
4571+ }
4572+ }
4573+ },
4574+ "additionalProperties": false,
4575+ "required": [
4576+ "bank_id",
4577+ "query"
4578+ ]
4579+ },
4580+ "QueryDocumentsResponse": {
4581+ "type": "object",
4582+ "properties": {
4583+ "chunks": {
4584+ "type": "array",
4585+ "items": {
4586+ "type": "object",
4587+ "properties": {
4588+ "content": {
4589+ "oneOf": [
4590+ {
4591+ "type": "string"
4592+ },
4593+ {
4594+ "type": "array",
4595+ "items": {
4596+ "type": "string"
4597+ }
4598+ }
4599+ ]
4600+ },
4601+ "token_count": {
4602+ "type": "integer"
4603+ },
4604+ "document_id": {
4605+ "type": "string"
4606+ }
4607+ },
4608+ "additionalProperties": false,
4609+ "required": [
4610+ "content",
4611+ "token_count",
4612+ "document_id"
4613+ ]
4614+ }
4615+ },
4616+ "scores": {
4617+ "type": "array",
4618+ "items": {
4619+ "type": "number"
4620+ }
4621+ }
4622+ },
4623+ "additionalProperties": false,
4624+ "required": [
4625+ "chunks",
4626+ "scores"
4627+ ]
4628+ },
4629+ "DialogGenerations": {
4630+ "type": "object",
4631+ "properties": {
4632+ "dialog": {
4633+ "type": "array",
4634+ "items": {
4635+ "oneOf": [
4636+ {
4637+ "$ref": "#/components/schemas/UserMessage"
4638+ },
4639+ {
4640+ "$ref": "#/components/schemas/SystemMessage"
4641+ },
4642+ {
4643+ "$ref": "#/components/schemas/ToolResponseMessage"
4644+ },
4645+ {
4646+ "$ref": "#/components/schemas/CompletionMessage"
4647+ }
4648+ ]
4649+ }
4650+ },
4651+ "sampled_generations": {
4652+ "type": "array",
4653+ "items": {
4654+ "oneOf": [
4655+ {
4656+ "$ref": "#/components/schemas/UserMessage"
4657+ },
4658+ {
4659+ "$ref": "#/components/schemas/SystemMessage"
4660+ },
4661+ {
4662+ "$ref": "#/components/schemas/ToolResponseMessage"
4663+ },
4664+ {
4665+ "$ref": "#/components/schemas/CompletionMessage"
4666+ }
4667+ ]
4668+ }
4669+ }
4670+ },
4671+ "additionalProperties": false,
4672+ "required": [
4673+ "dialog",
4674+ "sampled_generations"
4675+ ]
4676+ },
4677+ "RewardScoreRequest": {
4678+ "type": "object",
4679+ "properties": {
4680+ "dialog_generations": {
4681+ "type": "array",
4682+ "items": {
4683+ "$ref": "#/components/schemas/DialogGenerations"
4684+ }
4685+ },
4686+ "model": {
4687+ "type": "string"
4688+ }
4689+ },
4690+ "additionalProperties": false,
4691+ "required": [
4692+ "dialog_generations",
4693+ "model"
4694+ ]
4695+ },
4696+ "RewardScoringResponse": {
4697+ "type": "object",
4698+ "properties": {
4699+ "scored_generations": {
4700+ "type": "array",
4701+ "items": {
4702+ "$ref": "#/components/schemas/ScoredDialogGenerations"
4703+ }
4704+ }
4705+ },
4706+ "additionalProperties": false,
4707+ "required": [
4708+ "scored_generations"
4709+ ],
4710+ "title": "Response from the reward scoring. Batch of (prompt, response, score) tuples that pass the threshold."
4711+ },
4712+ "ScoredDialogGenerations": {
4713+ "type": "object",
4714+ "properties": {
4715+ "dialog": {
4716+ "type": "array",
4717+ "items": {
4718+ "oneOf": [
4719+ {
4720+ "$ref": "#/components/schemas/UserMessage"
4721+ },
4722+ {
4723+ "$ref": "#/components/schemas/SystemMessage"
4724+ },
4725+ {
4726+ "$ref": "#/components/schemas/ToolResponseMessage"
4727+ },
4728+ {
4729+ "$ref": "#/components/schemas/CompletionMessage"
4730+ }
4731+ ]
4732+ }
4733+ },
4734+ "scored_generations": {
4735+ "type": "array",
4736+ "items": {
4737+ "$ref": "#/components/schemas/ScoredMessage"
4738+ }
4739+ }
4740+ },
4741+ "additionalProperties": false,
4742+ "required": [
4743+ "dialog",
4744+ "scored_generations"
4745+ ]
4746+ },
4747+ "ScoredMessage": {
4748+ "type": "object",
4749+ "properties": {
4750+ "message": {
4751+ "oneOf": [
4752+ {
4753+ "$ref": "#/components/schemas/UserMessage"
4754+ },
4755+ {
4756+ "$ref": "#/components/schemas/SystemMessage"
4757+ },
4758+ {
4759+ "$ref": "#/components/schemas/ToolResponseMessage"
4760+ },
4761+ {
4762+ "$ref": "#/components/schemas/CompletionMessage"
4763+ }
4764+ ]
4765+ },
4766+ "score": {
4767+ "type": "number"
4768+ }
4769+ },
4770+ "additionalProperties": false,
4771+ "required": [
4772+ "message",
4773+ "score"
4774+ ]
4775+ },
4776+ "RunShieldsRequest": {
4777+ "type": "object",
4778+ "properties": {
4779+ "messages": {
4780+ "type": "array",
4781+ "items": {
4782+ "oneOf": [
4783+ {
4784+ "$ref": "#/components/schemas/UserMessage"
4785+ },
4786+ {
4787+ "$ref": "#/components/schemas/SystemMessage"
4788+ },
4789+ {
4790+ "$ref": "#/components/schemas/ToolResponseMessage"
4791+ },
4792+ {
4793+ "$ref": "#/components/schemas/CompletionMessage"
4794+ }
4795+ ]
4796+ }
4797+ },
4798+ "shields": {
4799+ "type": "array",
4800+ "items": {
4801+ "$ref": "#/components/schemas/ShieldDefinition"
4802+ }
4803+ }
4804+ },
4805+ "additionalProperties": false,
4806+ "required": [
4807+ "messages",
4808+ "shields"
4809+ ]
4810+ },
4811+ "RunShieldResponse": {
4812+ "type": "object",
4813+ "properties": {
4814+ "responses": {
4815+ "type": "array",
4816+ "items": {
4817+ "$ref": "#/components/schemas/ShieldResponse"
4818+ }
4819+ }
4820+ },
4821+ "additionalProperties": false,
4822+ "required": [
4823+ "responses"
4824+ ]
4825+ },
4826+ "DoraFinetuningConfig": {
4827+ "type": "object",
4828+ "properties": {
4829+ "lora_attn_modules": {
4830+ "type": "array",
4831+ "items": {
4832+ "type": "string"
4833+ }
4834+ },
4835+ "apply_lora_to_mlp": {
4836+ "type": "boolean"
4837+ },
4838+ "apply_lora_to_output": {
4839+ "type": "boolean"
4840+ },
4841+ "rank": {
4842+ "type": "integer"
4843+ },
4844+ "alpha": {
4845+ "type": "integer"
4846+ }
4847+ },
4848+ "additionalProperties": false,
4849+ "required": [
4850+ "lora_attn_modules",
4851+ "apply_lora_to_mlp",
4852+ "apply_lora_to_output",
4853+ "rank",
4854+ "alpha"
4855+ ]
4856+ },
4857+ "FinetuningAlgorithm": {
4858+ "type": "string",
4859+ "enum": [
4860+ "full",
4861+ "lora",
4862+ "qlora",
4863+ "dora"
4864+ ]
4865+ },
4866+ "LoraFinetuningConfig": {
4867+ "type": "object",
4868+ "properties": {
4869+ "lora_attn_modules": {
4870+ "type": "array",
4871+ "items": {
4872+ "type": "string"
4873+ }
4874+ },
4875+ "apply_lora_to_mlp": {
4876+ "type": "boolean"
4877+ },
4878+ "apply_lora_to_output": {
4879+ "type": "boolean"
4880+ },
4881+ "rank": {
4882+ "type": "integer"
4883+ },
4884+ "alpha": {
4885+ "type": "integer"
4886+ }
4887+ },
4888+ "additionalProperties": false,
4889+ "required": [
4890+ "lora_attn_modules",
4891+ "apply_lora_to_mlp",
4892+ "apply_lora_to_output",
4893+ "rank",
4894+ "alpha"
4895+ ]
4896+ },
4897+ "QLoraFinetuningConfig": {
4898+ "type": "object",
4899+ "properties": {
4900+ "lora_attn_modules": {
4901+ "type": "array",
4902+ "items": {
4903+ "type": "string"
4904+ }
4905+ },
4906+ "apply_lora_to_mlp": {
4907+ "type": "boolean"
4908+ },
4909+ "apply_lora_to_output": {
4910+ "type": "boolean"
4911+ },
4912+ "rank": {
4913+ "type": "integer"
4914+ },
4915+ "alpha": {
4916+ "type": "integer"
4917+ }
4918+ },
4919+ "additionalProperties": false,
4920+ "required": [
4921+ "lora_attn_modules",
4922+ "apply_lora_to_mlp",
4923+ "apply_lora_to_output",
4924+ "rank",
4925+ "alpha"
4926+ ]
4927+ },
4928+ "SupervisedFineTuneRequest": {
4929+ "type": "object",
4930+ "properties": {
4931+ "job_uuid": {
4932+ "type": "string"
4933+ },
4934+ "model": {
4935+ "type": "string"
4936+ },
4937+ "dataset": {
4938+ "$ref": "#/components/schemas/TrainEvalDataset"
4939+ },
4940+ "validation_dataset": {
4941+ "$ref": "#/components/schemas/TrainEvalDataset"
4942+ },
4943+ "algorithm": {
4944+ "$ref": "#/components/schemas/FinetuningAlgorithm"
4945+ },
4946+ "algorithm_config": {
4947+ "oneOf": [
4948+ {
4949+ "$ref": "#/components/schemas/LoraFinetuningConfig"
4950+ },
4951+ {
4952+ "$ref": "#/components/schemas/QLoraFinetuningConfig"
4953+ },
4954+ {
4955+ "$ref": "#/components/schemas/DoraFinetuningConfig"
4956+ }
4957+ ]
4958+ },
4959+ "optimizer_config": {
4960+ "$ref": "#/components/schemas/OptimizerConfig"
4961+ },
4962+ "training_config": {
4963+ "$ref": "#/components/schemas/TrainingConfig"
4964+ },
4965+ "hyperparam_search_config": {
4966+ "type": "object",
4967+ "additionalProperties": {
4968+ "oneOf": [
4969+ {
4970+ "type": "null"
4971+ },
4972+ {
4973+ "type": "boolean"
4974+ },
4975+ {
4976+ "type": "number"
4977+ },
4978+ {
4979+ "type": "string"
4980+ },
4981+ {
4982+ "type": "array"
4983+ },
4984+ {
4985+ "type": "object"
4986+ }
4987+ ]
4988+ }
4989+ },
4990+ "logger_config": {
4991+ "type": "object",
4992+ "additionalProperties": {
4993+ "oneOf": [
4994+ {
4995+ "type": "null"
4996+ },
4997+ {
4998+ "type": "boolean"
4999+ },
5000+ {
added docs/llama-stack-spec.yaml +3689 −0
@@ -0,0 +1,3689 @@
1+components:
2+ responses: {}
3+ schemas:
4+ AgentConfig:
5+ additionalProperties: false
6+ properties:
7+ input_shields:
8+ items:
9+ $ref: '#/components/schemas/ShieldDefinition'
10+ type: array
11+ instructions:
12+ type: string
13+ model:
14+ type: string
15+ output_shields:
16+ items:
17+ $ref: '#/components/schemas/ShieldDefinition'
18+ type: array
19+ sampling_params:
20+ $ref: '#/components/schemas/SamplingParams'
21+ tool_choice:
22+ $ref: '#/components/schemas/ToolChoice'
23+ tool_prompt_format:
24+ $ref: '#/components/schemas/ToolPromptFormat'
25+ tools:
26+ items:
27+ oneOf:
28+ - $ref: '#/components/schemas/SearchToolDefinition'
29+ - $ref: '#/components/schemas/WolframAlphaToolDefinition'
30+ - $ref: '#/components/schemas/PhotogenToolDefinition'
31+ - $ref: '#/components/schemas/CodeInterpreterToolDefinition'
32+ - $ref: '#/components/schemas/FunctionCallToolDefinition'
33+ - additionalProperties: false
34+ properties:
35+ input_shields:
36+ items:
37+ $ref: '#/components/schemas/ShieldDefinition'
38+ type: array
39+ max_chunks:
40+ type: integer
41+ max_tokens_in_context:
42+ type: integer
43+ memory_bank_configs:
44+ items:
45+ oneOf:
46+ - additionalProperties: false
47+ properties:
48+ bank_id:
49+ type: string
50+ type:
51+ const: vector
52+ type: string
53+ required:
54+ - bank_id
55+ - type
56+ type: object
57+ - additionalProperties: false
58+ properties:
59+ bank_id:
60+ type: string
61+ keys:
62+ items:
63+ type: string
64+ type: array
65+ type:
66+ const: keyvalue
67+ type: string
68+ required:
69+ - bank_id
70+ - type
71+ - keys
72+ type: object
73+ - additionalProperties: false
74+ properties:
75+ bank_id:
76+ type: string
77+ type:
78+ const: keyword
79+ type: string
80+ required:
81+ - bank_id
82+ - type
83+ type: object
84+ - additionalProperties: false
85+ properties:
86+ bank_id:
87+ type: string
88+ entities:
89+ items:
90+ type: string
91+ type: array
92+ type:
93+ const: graph
94+ type: string
95+ required:
96+ - bank_id
97+ - type
98+ - entities
99+ type: object
100+ type: array
101+ output_shields:
102+ items:
103+ $ref: '#/components/schemas/ShieldDefinition'
104+ type: array
105+ query_generator_config:
106+ oneOf:
107+ - additionalProperties: false
108+ properties:
109+ sep:
110+ type: string
111+ type:
112+ const: default
113+ type: string
114+ required:
115+ - type
116+ - sep
117+ type: object
118+ - additionalProperties: false
119+ properties:
120+ model:
121+ type: string
122+ template:
123+ type: string
124+ type:
125+ const: llm
126+ type: string
127+ required:
128+ - type
129+ - model
130+ - template
131+ type: object
132+ - additionalProperties: false
133+ properties:
134+ type:
135+ const: custom
136+ type: string
137+ required:
138+ - type
139+ type: object
140+ type:
141+ const: memory
142+ type: string
143+ required:
144+ - type
145+ - memory_bank_configs
146+ - query_generator_config
147+ - max_tokens_in_context
148+ - max_chunks
149+ type: object
150+ type: array
151+ required:
152+ - model
153+ - instructions
154+ type: object
155+ AgentCreateResponse:
156+ additionalProperties: false
157+ properties:
158+ agent_id:
159+ type: string
160+ required:
161+ - agent_id
162+ type: object
163+ AgentSessionCreateResponse:
164+ additionalProperties: false
165+ properties:
166+ session_id:
167+ type: string
168+ required:
169+ - session_id
170+ type: object
171+ AgentStepResponse:
172+ additionalProperties: false
173+ properties:
174+ step:
175+ oneOf:
176+ - $ref: '#/components/schemas/InferenceStep'
177+ - $ref: '#/components/schemas/ToolExecutionStep'
178+ - $ref: '#/components/schemas/ShieldCallStep'
179+ - $ref: '#/components/schemas/MemoryRetrievalStep'
180+ required:
181+ - step
182+ type: object
183+ AgentTurnResponseEvent:
184+ additionalProperties: false
185+ properties:
186+ payload:
187+ oneOf:
188+ - $ref: '#/components/schemas/AgentTurnResponseStepStartPayload'
189+ - $ref: '#/components/schemas/AgentTurnResponseStepProgressPayload'
190+ - $ref: '#/components/schemas/AgentTurnResponseStepCompletePayload'
191+ - $ref: '#/components/schemas/AgentTurnResponseTurnStartPayload'
192+ - $ref: '#/components/schemas/AgentTurnResponseTurnCompletePayload'
193+ required:
194+ - payload
195+ title: Streamed agent execution response.
196+ type: object
197+ AgentTurnResponseStepCompletePayload:
198+ additionalProperties: false
199+ properties:
200+ event_type:
201+ const: step_complete
202+ type: string
203+ step_details:
204+ oneOf:
205+ - $ref: '#/components/schemas/InferenceStep'
206+ - $ref: '#/components/schemas/ToolExecutionStep'
207+ - $ref: '#/components/schemas/ShieldCallStep'
208+ - $ref: '#/components/schemas/MemoryRetrievalStep'
209+ step_type:
210+ enum:
211+ - inference
212+ - tool_execution
213+ - shield_call
214+ - memory_retrieval
215+ type: string
216+ required:
217+ - event_type
218+ - step_type
219+ - step_details
220+ type: object
221+ AgentTurnResponseStepProgressPayload:
222+ additionalProperties: false
223+ properties:
224+ event_type:
225+ const: step_progress
226+ type: string
227+ model_response_text_delta:
228+ type: string
229+ step_id:
230+ type: string
231+ step_type:
232+ enum:
233+ - inference
234+ - tool_execution
235+ - shield_call
236+ - memory_retrieval
237+ type: string
238+ tool_call_delta:
239+ $ref: '#/components/schemas/ToolCallDelta'
240+ tool_response_text_delta:
241+ type: string
242+ required:
243+ - event_type
244+ - step_type
245+ - step_id
246+ type: object
247+ AgentTurnResponseStepStartPayload:
248+ additionalProperties: false
249+ properties:
250+ event_type:
251+ const: step_start
252+ type: string
253+ metadata:
254+ additionalProperties:
255+ oneOf:
256+ - type: 'null'
257+ - type: boolean
258+ - type: number
259+ - type: string
260+ - type: array
261+ - type: object
262+ type: object
263+ step_id:
264+ type: string
265+ step_type:
266+ enum:
267+ - inference
268+ - tool_execution
269+ - shield_call
270+ - memory_retrieval
271+ type: string
272+ required:
273+ - event_type
274+ - step_type
275+ - step_id
276+ type: object
277+ AgentTurnResponseStreamChunk:
278+ additionalProperties: false
279+ properties:
280+ event:
281+ $ref: '#/components/schemas/AgentTurnResponseEvent'
282+ required:
283+ - event
284+ type: object
285+ AgentTurnResponseTurnCompletePayload:
286+ additionalProperties: false
287+ properties:
288+ event_type:
289+ const: turn_complete
290+ type: string
291+ turn:
292+ $ref: '#/components/schemas/Turn'
293+ required:
294+ - event_type
295+ - turn
296+ type: object
297+ AgentTurnResponseTurnStartPayload:
298+ additionalProperties: false
299+ properties:
300+ event_type:
301+ const: turn_start
302+ type: string
303+ turn_id:
304+ type: string
305+ required:
306+ - event_type
307+ - turn_id
308+ type: object
309+ Attachment:
310+ additionalProperties: false
311+ properties:
312+ content:
313+ oneOf:
314+ - type: string
315+ - items:
316+ type: string
317+ type: array
318+ - $ref: '#/components/schemas/URL'
319+ mime_type:
320+ type: string
321+ required:
322+ - content
323+ - mime_type
324+ type: object
325+ BatchChatCompletionRequest:
326+ additionalProperties: false
327+ properties:
328+ logprobs:
329+ additionalProperties: false
330+ properties:
331+ top_k:
332+ type: integer
333+ type: object
334+ messages_batch:
335+ items:
336+ items:
337+ oneOf:
338+ - $ref: '#/components/schemas/UserMessage'
339+ - $ref: '#/components/schemas/SystemMessage'
340+ - $ref: '#/components/schemas/ToolResponseMessage'
341+ - $ref: '#/components/schemas/CompletionMessage'
342+ type: array
343+ type: array
344+ model:
345+ type: string
346+ sampling_params:
347+ $ref: '#/components/schemas/SamplingParams'
348+ tool_choice:
349+ $ref: '#/components/schemas/ToolChoice'
350+ tool_prompt_format:
351+ $ref: '#/components/schemas/ToolPromptFormat'
352+ tools:
353+ items:
354+ $ref: '#/components/schemas/ToolDefinition'
355+ type: array
356+ required:
357+ - model
358+ - messages_batch
359+ type: object
360+ BatchChatCompletionResponse:
361+ additionalProperties: false
362+ properties:
363+ completion_message_batch:
364+ items:
365+ $ref: '#/components/schemas/CompletionMessage'
366+ type: array
367+ required:
368+ - completion_message_batch
369+ type: object
370+ BatchCompletionRequest:
371+ additionalProperties: false
372+ properties:
373+ content_batch:
374+ items:
375+ oneOf:
376+ - type: string
377+ - items:
378+ type: string
379+ type: array
380+ type: array
381+ logprobs:
382+ additionalProperties: false
383+ properties:
384+ top_k:
385+ type: integer
386+ type: object
387+ model:
388+ type: string
389+ sampling_params:
390+ $ref: '#/components/schemas/SamplingParams'
391+ required:
392+ - model
393+ - content_batch
394+ type: object
395+ BatchCompletionResponse:
396+ additionalProperties: false
397+ properties:
398+ completion_message_batch:
399+ items:
400+ $ref: '#/components/schemas/CompletionMessage'
401+ type: array
402+ required:
403+ - completion_message_batch
404+ type: object
405+ BuiltinShield:
406+ enum:
407+ - llama_guard
408+ - code_scanner_guard
409+ - third_party_shield
410+ - injection_shield
411+ - jailbreak_shield
412+ type: string
413+ BuiltinTool:
414+ enum:
415+ - brave_search
416+ - wolfram_alpha
417+ - photogen
418+ - code_interpreter
419+ type: string
420+ CancelEvaluationJobRequest:
421+ additionalProperties: false
422+ properties:
423+ job_uuid:
424+ type: string
425+ required:
426+ - job_uuid
427+ type: object
428+ CancelTrainingJobRequest:
429+ additionalProperties: false
430+ properties:
431+ job_uuid:
432+ type: string
433+ required:
434+ - job_uuid
435+ type: object
436+ ChatCompletionRequest:
437+ additionalProperties: false
438+ properties:
439+ logprobs:
440+ additionalProperties: false
441+ properties:
442+ top_k:
443+ type: integer
444+ type: object
445+ messages:
446+ items:
447+ oneOf:
448+ - $ref: '#/components/schemas/UserMessage'
449+ - $ref: '#/components/schemas/SystemMessage'
450+ - $ref: '#/components/schemas/ToolResponseMessage'
451+ - $ref: '#/components/schemas/CompletionMessage'
452+ type: array
453+ model:
454+ type: string
455+ sampling_params:
456+ $ref: '#/components/schemas/SamplingParams'
457+ stream:
458+ type: boolean
459+ tool_choice:
460+ $ref: '#/components/schemas/ToolChoice'
461+ tool_prompt_format:
462+ $ref: '#/components/schemas/ToolPromptFormat'
463+ tools:
464+ items:
465+ $ref: '#/components/schemas/ToolDefinition'
466+ type: array
467+ required:
468+ - model
469+ - messages
470+ type: object
471+ ChatCompletionResponse:
472+ additionalProperties: false
473+ properties:
474+ completion_message:
475+ $ref: '#/components/schemas/CompletionMessage'
476+ logprobs:
477+ items:
478+ $ref: '#/components/schemas/TokenLogProbs'
479+ type: array
480+ required:
481+ - completion_message
482+ title: Chat completion response.
483+ type: object
484+ ChatCompletionResponseEvent:
485+ additionalProperties: false
486+ properties:
487+ delta:
488+ oneOf:
489+ - type: string
490+ - $ref: '#/components/schemas/ToolCallDelta'
491+ event_type:
492+ $ref: '#/components/schemas/ChatCompletionResponseEventType'
493+ logprobs:
494+ items:
495+ $ref: '#/components/schemas/TokenLogProbs'
496+ type: array
497+ stop_reason:
498+ $ref: '#/components/schemas/StopReason'
499+ required:
500+ - event_type
501+ - delta
502+ title: Chat completion response event.
503+ type: object
504+ ChatCompletionResponseEventType:
505+ enum:
506+ - start
507+ - complete
508+ - progress
509+ type: string
510+ ChatCompletionResponseStreamChunk:
511+ additionalProperties: false
512+ properties:
513+ event:
514+ $ref: '#/components/schemas/ChatCompletionResponseEvent'
515+ required:
516+ - event
517+ title: SSE-stream of these events.
518+ type: object
519+ Checkpoint:
520+ description: Checkpoint created during training runs
521+ CodeInterpreterToolDefinition:
522+ additionalProperties: false
523+ properties:
524+ enable_inline_code_execution:
525+ type: boolean
526+ input_shields:
527+ items:
528+ $ref: '#/components/schemas/ShieldDefinition'
529+ type: array
530+ output_shields:
531+ items:
532+ $ref: '#/components/schemas/ShieldDefinition'
533+ type: array
534+ remote_execution:
535+ $ref: '#/components/schemas/RestAPIExecutionConfig'
536+ type:
537+ const: code_interpreter
538+ type: string
539+ required:
540+ - type
541+ - enable_inline_code_execution
542+ type: object
543+ CompletionMessage:
544+ additionalProperties: false
545+ properties:
546+ content:
547+ oneOf:
548+ - type: string
549+ - items:
550+ type: string
551+ type: array
552+ role:
553+ const: assistant
554+ type: string
555+ stop_reason:
556+ $ref: '#/components/schemas/StopReason'
557+ tool_calls:
558+ items:
559+ $ref: '#/components/schemas/ToolCall'
560+ type: array
561+ required:
562+ - role
563+ - content
564+ - stop_reason
565+ - tool_calls
566+ type: object
567+ CompletionRequest:
568+ additionalProperties: false
569+ properties:
570+ content:
571+ oneOf:
572+ - type: string
573+ - items:
574+ type: string
575+ type: array
576+ logprobs:
577+ additionalProperties: false
578+ properties:
579+ top_k:
580+ type: integer
581+ type: object
582+ model:
583+ type: string
584+ sampling_params:
585+ $ref: '#/components/schemas/SamplingParams'
586+ stream:
587+ type: boolean
588+ required:
589+ - model
590+ - content
591+ type: object
592+ CompletionResponse:
593+ additionalProperties: false
594+ properties:
595+ completion_message:
596+ $ref: '#/components/schemas/CompletionMessage'
597+ logprobs:
598+ items:
599+ $ref: '#/components/schemas/TokenLogProbs'
600+ type: array
601+ required:
602+ - completion_message
603+ title: Completion response.
604+ type: object
605+ CompletionResponseStreamChunk:
606+ additionalProperties: false
607+ properties:
608+ delta:
609+ type: string
610+ logprobs:
611+ items:
612+ $ref: '#/components/schemas/TokenLogProbs'
613+ type: array
614+ stop_reason:
615+ $ref: '#/components/schemas/StopReason'
616+ required:
617+ - delta
618+ title: streamed completion response.
619+ type: object
620+ CreateAgentRequest:
621+ additionalProperties: false
622+ properties:
623+ agent_config:
624+ $ref: '#/components/schemas/AgentConfig'
625+ required:
626+ - agent_config
627+ type: object
628+ CreateAgentSessionRequest:
629+ additionalProperties: false
630+ properties:
631+ agent_id:
632+ type: string
633+ session_name:
634+ type: string
635+ required:
636+ - agent_id
637+ - session_name
638+ type: object
639+ CreateAgentTurnRequest:
640+ additionalProperties: false
641+ properties:
642+ agent_id:
643+ type: string
644+ attachments:
645+ items:
646+ $ref: '#/components/schemas/Attachment'
647+ type: array
648+ messages:
649+ items:
650+ oneOf:
651+ - $ref: '#/components/schemas/UserMessage'
652+ - $ref: '#/components/schemas/ToolResponseMessage'
653+ type: array
654+ session_id:
655+ type: string
656+ stream:
657+ type: boolean
658+ required:
659+ - agent_id
660+ - session_id
661+ - messages
662+ type: object
663+ CreateDatasetRequest:
664+ additionalProperties: false
665+ properties:
666+ dataset:
667+ $ref: '#/components/schemas/TrainEvalDataset'
668+ uuid:
669+ type: string
670+ required:
671+ - uuid
672+ - dataset
673+ type: object
674+ CreateMemoryBankRequest:
675+ additionalProperties: false
676+ properties:
677+ config:
678+ oneOf:
679+ - additionalProperties: false
680+ properties:
681+ chunk_size_in_tokens:
682+ type: integer
683+ embedding_model:
684+ type: string
685+ overlap_size_in_tokens:
686+ type: integer
687+ type:
688+ const: vector
689+ type: string
690+ required:
691+ - type
692+ - embedding_model
693+ - chunk_size_in_tokens
694+ type: object
695+ - additionalProperties: false
696+ properties:
697+ type:
698+ const: keyvalue
699+ type: string
700+ required:
701+ - type
702+ type: object
703+ - additionalProperties: false
704+ properties:
705+ type:
706+ const: keyword
707+ type: string
708+ required:
709+ - type
710+ type: object
711+ - additionalProperties: false
712+ properties:
713+ type:
714+ const: graph
715+ type: string
716+ required:
717+ - type
718+ type: object
719+ name:
720+ type: string
721+ url:
722+ $ref: '#/components/schemas/URL'
723+ required:
724+ - name
725+ - config
726+ type: object
727+ DPOAlignmentConfig:
728+ additionalProperties: false
729+ properties:
730+ epsilon:
731+ type: number
732+ gamma:
733+ type: number
734+ reward_clip:
735+ type: number
736+ reward_scale:
737+ type: number
738+ required:
739+ - reward_scale
740+ - reward_clip
741+ - epsilon
742+ - gamma
743+ type: object
744+ DeleteAgentsRequest:
745+ additionalProperties: false
746+ properties:
747+ agent_id:
748+ type: string
749+ required:
750+ - agent_id
751+ type: object
752+ DeleteAgentsSessionRequest:
753+ additionalProperties: false
754+ properties:
755+ agent_id:
756+ type: string
757+ session_id:
758+ type: string
759+ required:
760+ - agent_id
761+ - session_id
762+ type: object
763+ DeleteDatasetRequest:
764+ additionalProperties: false
765+ properties:
766+ dataset_uuid:
767+ type: string
768+ required:
769+ - dataset_uuid
770+ type: object
771+ DeleteDocumentsRequest:
772+ additionalProperties: false
773+ properties:
774+ bank_id:
775+ type: string
776+ document_ids:
777+ items:
778+ type: string
779+ type: array
780+ required:
781+ - bank_id
782+ - document_ids
783+ type: object
784+ DialogGenerations:
785+ additionalProperties: false
786+ properties:
787+ dialog:
788+ items:
789+ oneOf:
790+ - $ref: '#/components/schemas/UserMessage'
791+ - $ref: '#/components/schemas/SystemMessage'
792+ - $ref: '#/components/schemas/ToolResponseMessage'
793+ - $ref: '#/components/schemas/CompletionMessage'
794+ type: array
795+ sampled_generations:
796+ items:
797+ oneOf:
798+ - $ref: '#/components/schemas/UserMessage'
799+ - $ref: '#/components/schemas/SystemMessage'
800+ - $ref: '#/components/schemas/ToolResponseMessage'
801+ - $ref: '#/components/schemas/CompletionMessage'
802+ type: array
803+ required:
804+ - dialog
805+ - sampled_generations
806+ type: object
807+ DoraFinetuningConfig:
808+ additionalProperties: false
809+ properties:
810+ alpha:
811+ type: integer
812+ apply_lora_to_mlp:
813+ type: boolean
814+ apply_lora_to_output:
815+ type: boolean
816+ lora_attn_modules:
817+ items:
818+ type: string
819+ type: array
820+ rank:
821+ type: integer
822+ required:
823+ - lora_attn_modules
824+ - apply_lora_to_mlp
825+ - apply_lora_to_output
826+ - rank
827+ - alpha
828+ type: object
829+ DropMemoryBankRequest:
830+ additionalProperties: false
831+ properties:
832+ bank_id:
833+ type: string
834+ required:
835+ - bank_id
836+ type: object
837+ EmbeddingsRequest:
838+ additionalProperties: false
839+ properties:
840+ contents:
841+ items:
842+ oneOf:
843+ - type: string
844+ - items:
845+ type: string
846+ type: array
847+ type: array
848+ model:
849+ type: string
850+ required:
851+ - model
852+ - contents
853+ type: object
854+ EmbeddingsResponse:
855+ additionalProperties: false
856+ properties:
857+ embeddings:
858+ items:
859+ items:
860+ type: number
861+ type: array
862+ type: array
863+ required:
864+ - embeddings
865+ type: object
866+ EvaluateQuestionAnsweringRequest:
867+ additionalProperties: false
868+ properties:
869+ metrics:
870+ items:
871+ enum:
872+ - em
873+ - f1
874+ type: string
875+ type: array
876+ required:
877+ - metrics
878+ type: object
879+ EvaluateSummarizationRequest:
880+ additionalProperties: false
881+ properties:
882+ metrics:
883+ items:
884+ enum:
885+ - rouge
886+ - bleu
887+ type: string
888+ type: array
889+ required:
890+ - metrics
891+ type: object
892+ EvaluateTextGenerationRequest:
893+ additionalProperties: false
894+ properties:
895+ metrics:
896+ items:
897+ enum:
898+ - perplexity
899+ - rouge
900+ - bleu
901+ type: string
902+ type: array
903+ required:
904+ - metrics
905+ type: object
906+ EvaluationJob:
907+ additionalProperties: false
908+ properties:
909+ job_uuid:
910+ type: string
911+ required:
912+ - job_uuid
913+ type: object
914+ EvaluationJobArtifactsResponse:
915+ additionalProperties: false
916+ properties:
917+ job_uuid:
918+ type: string
919+ required:
920+ - job_uuid
921+ title: Artifacts of a evaluation job.
922+ type: object
923+ EvaluationJobLogStream:
924+ additionalProperties: false
925+ properties:
926+ job_uuid:
927+ type: string
928+ required:
929+ - job_uuid
930+ type: object
931+ EvaluationJobStatusResponse:
932+ additionalProperties: false
933+ properties:
934+ job_uuid:
935+ type: string
936+ required:
937+ - job_uuid
938+ type: object
939+ FinetuningAlgorithm:
940+ enum:
941+ - full
942+ - lora
943+ - qlora
944+ - dora
945+ type: string
946+ FunctionCallToolDefinition:
947+ additionalProperties: false
948+ properties:
949+ description:
950+ type: string
951+ function_name:
952+ type: string
953+ input_shields:
954+ items:
955+ $ref: '#/components/schemas/ShieldDefinition'
956+ type: array
957+ output_shields:
958+ items:
959+ $ref: '#/components/schemas/ShieldDefinition'
960+ type: array
961+ parameters:
962+ additionalProperties:
963+ $ref: '#/components/schemas/ToolParamDefinition'
964+ type: object
965+ remote_execution:
966+ $ref: '#/components/schemas/RestAPIExecutionConfig'
967+ type:
968+ const: function_call
969+ type: string
970+ required:
971+ - type
972+ - function_name
973+ - description
974+ - parameters
975+ type: object
976+ GetAgentsSessionRequest:
977+ additionalProperties: false
978+ properties:
979+ turn_ids:
980+ items:
981+ type: string
982+ type: array
983+ type: object
984+ GetDocumentsRequest:
985+ additionalProperties: false
986+ properties:
987+ document_ids:
988+ items:
989+ type: string
990+ type: array
991+ required:
992+ - document_ids
993+ type: object
994+ InferenceStep:
995+ additionalProperties: false
996+ properties:
997+ completed_at:
998+ format: date-time
999+ type: string
1000+ model_response:
1001+ $ref: '#/components/schemas/CompletionMessage'
1002+ started_at:
1003+ format: date-time
1004+ type: string
1005+ step_id:
1006+ type: string
1007+ step_type:
1008+ const: inference
1009+ type: string
1010+ turn_id:
1011+ type: string
1012+ required:
1013+ - turn_id
1014+ - step_id
1015+ - step_type
1016+ - model_response
1017+ type: object
1018+ InsertDocumentsRequest:
1019+ additionalProperties: false
1020+ properties:
1021+ bank_id:
1022+ type: string
1023+ documents:
1024+ items:
1025+ $ref: '#/components/schemas/MemoryBankDocument'
1026+ type: array
1027+ ttl_seconds:
1028+ type: integer
1029+ required:
1030+ - bank_id
1031+ - documents
1032+ type: object
1033+ LogEventRequest:
1034+ additionalProperties: false
1035+ properties:
1036+ event:
1037+ oneOf:
1038+ - $ref: '#/components/schemas/UnstructuredLogEvent'
1039+ - $ref: '#/components/schemas/MetricEvent'
1040+ - $ref: '#/components/schemas/StructuredLogEvent'
1041+ required:
1042+ - event
1043+ type: object
1044+ LogSeverity:
1045+ enum:
1046+ - verbose
1047+ - debug
1048+ - info
1049+ - warn
1050+ - error
1051+ - critical
1052+ type: string
1053+ LoraFinetuningConfig:
1054+ additionalProperties: false
1055+ properties:
1056+ alpha:
1057+ type: integer
1058+ apply_lora_to_mlp:
1059+ type: boolean
1060+ apply_lora_to_output:
1061+ type: boolean
1062+ lora_attn_modules:
1063+ items:
1064+ type: string
1065+ type: array
1066+ rank:
1067+ type: integer
1068+ required:
1069+ - lora_attn_modules
1070+ - apply_lora_to_mlp
1071+ - apply_lora_to_output
1072+ - rank
1073+ - alpha
1074+ type: object
1075+ MemoryBank:
1076+ additionalProperties: false
1077+ properties:
1078+ bank_id:
1079+ type: string
1080+ config:
1081+ oneOf:
1082+ - additionalProperties: false
1083+ properties:
1084+ chunk_size_in_tokens:
1085+ type: integer
1086+ embedding_model:
1087+ type: string
1088+ overlap_size_in_tokens:
1089+ type: integer
1090+ type:
1091+ const: vector
1092+ type: string
1093+ required:
1094+ - type
1095+ - embedding_model
1096+ - chunk_size_in_tokens
1097+ type: object
1098+ - additionalProperties: false
1099+ properties:
1100+ type:
1101+ const: keyvalue
1102+ type: string
1103+ required:
1104+ - type
1105+ type: object
1106+ - additionalProperties: false
1107+ properties:
1108+ type:
1109+ const: keyword
1110+ type: string
1111+ required:
1112+ - type
1113+ type: object
1114+ - additionalProperties: false
1115+ properties:
1116+ type:
1117+ const: graph
1118+ type: string
1119+ required:
1120+ - type
1121+ type: object
1122+ name:
1123+ type: string
1124+ url:
1125+ $ref: '#/components/schemas/URL'
1126+ required:
1127+ - bank_id
1128+ - name
1129+ - config
1130+ type: object
1131+ MemoryBankDocument:
1132+ additionalProperties: false
1133+ properties:
1134+ content:
1135+ oneOf:
1136+ - type: string
1137+ - items:
1138+ type: string
1139+ type: array
1140+ - $ref: '#/components/schemas/URL'
1141+ document_id:
1142+ type: string
1143+ metadata:
1144+ additionalProperties:
1145+ oneOf:
1146+ - type: 'null'
1147+ - type: boolean
1148+ - type: number
1149+ - type: string
1150+ - type: array
1151+ - type: object
1152+ type: object
1153+ mime_type:
1154+ type: string
1155+ required:
1156+ - document_id
1157+ - content
1158+ - metadata
1159+ type: object
1160+ MemoryRetrievalStep:
1161+ additionalProperties: false
1162+ properties:
1163+ completed_at:
1164+ format: date-time
1165+ type: string
1166+ inserted_context:
1167+ oneOf:
1168+ - type: string
1169+ - items:
1170+ type: string
1171+ type: array
1172+ memory_bank_ids:
1173+ items:
1174+ type: string
1175+ type: array
1176+ started_at:
1177+ format: date-time
1178+ type: string
1179+ step_id:
1180+ type: string
1181+ step_type:
1182+ const: memory_retrieval
1183+ type: string
1184+ turn_id:
1185+ type: string
1186+ required:
1187+ - turn_id
1188+ - step_id
1189+ - step_type
1190+ - memory_bank_ids
1191+ - inserted_context
1192+ type: object
1193+ MetricEvent:
1194+ additionalProperties: false
1195+ properties:
1196+ attributes:
1197+ additionalProperties:
1198+ oneOf:
1199+ - type: 'null'
1200+ - type: boolean
1201+ - type: number
1202+ - type: string
1203+ - type: array
1204+ - type: object
1205+ type: object
1206+ metric:
1207+ type: string
1208+ span_id:
1209+ type: string
1210+ timestamp:
1211+ format: date-time
1212+ type: string
1213+ trace_id:
1214+ type: string
1215+ type:
1216+ const: metric
1217+ type: string
1218+ unit:
1219+ type: string
1220+ value:
1221+ oneOf:
1222+ - type: integer
1223+ - type: number
1224+ required:
1225+ - trace_id
1226+ - span_id
1227+ - timestamp
1228+ - type
1229+ - metric
1230+ - value
1231+ - unit
1232+ type: object
1233+ OnViolationAction:
1234+ enum:
1235+ - 0
1236+ - 1
1237+ - 2
1238+ type: integer
1239+ OptimizerConfig:
1240+ additionalProperties: false
1241+ properties:
1242+ lr:
1243+ type: number
1244+ lr_min:
1245+ type: number
1246+ optimizer_type:
1247+ enum:
1248+ - adam
1249+ - adamw
1250+ - sgd
1251+ type: string
1252+ weight_decay:
1253+ type: number
1254+ required:
1255+ - optimizer_type
1256+ - lr
1257+ - lr_min
1258+ - weight_decay
1259+ type: object
1260+ PhotogenToolDefinition:
1261+ additionalProperties: false
1262+ properties:
1263+ input_shields:
1264+ items:
1265+ $ref: '#/components/schemas/ShieldDefinition'
1266+ type: array
1267+ output_shields:
1268+ items:
1269+ $ref: '#/components/schemas/ShieldDefinition'
1270+ type: array
1271+ remote_execution:
1272+ $ref: '#/components/schemas/RestAPIExecutionConfig'
1273+ type:
1274+ const: photogen
1275+ type: string
1276+ required:
1277+ - type
1278+ type: object
1279+ PostTrainingJob:
1280+ additionalProperties: false
1281+ properties:
1282+ job_uuid:
1283+ type: string
1284+ required:
1285+ - job_uuid
1286+ type: object
1287+ PostTrainingJobArtifactsResponse:
1288+ additionalProperties: false
1289+ properties:
1290+ checkpoints:
1291+ items:
1292+ $ref: '#/components/schemas/Checkpoint'
1293+ type: array
1294+ job_uuid:
1295+ type: string
1296+ required:
1297+ - job_uuid
1298+ - checkpoints
1299+ title: Artifacts of a finetuning job.
1300+ type: object
1301+ PostTrainingJobLogStream:
1302+ additionalProperties: false
1303+ properties:
1304+ job_uuid:
1305+ type: string
1306+ log_lines:
1307+ items:
1308+ type: string
1309+ type: array
1310+ required:
1311+ - job_uuid
1312+ - log_lines
1313+ title: Stream of logs from a finetuning job.
1314+ type: object
1315+ PostTrainingJobStatus:
1316+ enum:
1317+ - running
1318+ - completed
1319+ - failed
1320+ - scheduled
1321+ type: string
1322+ PostTrainingJobStatusResponse:
1323+ additionalProperties: false
1324+ properties:
1325+ checkpoints:
1326+ items:
1327+ $ref: '#/components/schemas/Checkpoint'
1328+ type: array
1329+ completed_at:
1330+ format: date-time
1331+ type: string
1332+ job_uuid:
1333+ type: string
1334+ resources_allocated:
1335+ additionalProperties:
1336+ oneOf:
1337+ - type: 'null'
1338+ - type: boolean
1339+ - type: number
1340+ - type: string
1341+ - type: array
1342+ - type: object
1343+ type: object
1344+ scheduled_at:
1345+ format: date-time
1346+ type: string
1347+ started_at:
1348+ format: date-time
1349+ type: string
1350+ status:
1351+ $ref: '#/components/schemas/PostTrainingJobStatus'
1352+ required:
1353+ - job_uuid
1354+ - status
1355+ - checkpoints
1356+ title: Status of a finetuning job.
1357+ type: object
1358+ PreferenceOptimizeRequest:
1359+ additionalProperties: false
1360+ properties:
1361+ algorithm:
1362+ $ref: '#/components/schemas/RLHFAlgorithm'
1363+ algorithm_config:
1364+ $ref: '#/components/schemas/DPOAlignmentConfig'
1365+ dataset:
1366+ $ref: '#/components/schemas/TrainEvalDataset'
1367+ finetuned_model:
1368+ $ref: '#/components/schemas/URL'
1369+ hyperparam_search_config:
1370+ additionalProperties:
1371+ oneOf:
1372+ - type: 'null'
1373+ - type: boolean
1374+ - type: number
1375+ - type: string
1376+ - type: array
1377+ - type: object
1378+ type: object
1379+ job_uuid:
1380+ type: string
1381+ logger_config:
1382+ additionalProperties:
1383+ oneOf:
1384+ - type: 'null'
1385+ - type: boolean
1386+ - type: number
1387+ - type: string
1388+ - type: array
1389+ - type: object
1390+ type: object
1391+ optimizer_config:
1392+ $ref: '#/components/schemas/OptimizerConfig'
1393+ training_config:
1394+ $ref: '#/components/schemas/TrainingConfig'
1395+ validation_dataset:
1396+ $ref: '#/components/schemas/TrainEvalDataset'
1397+ required:
1398+ - job_uuid
1399+ - finetuned_model
1400+ - dataset
1401+ - validation_dataset
1402+ - algorithm
1403+ - algorithm_config
1404+ - optimizer_config
1405+ - training_config
1406+ - hyperparam_search_config
1407+ - logger_config
1408+ type: object
1409+ QLoraFinetuningConfig:
1410+ additionalProperties: false
1411+ properties:
1412+ alpha:
1413+ type: integer
1414+ apply_lora_to_mlp:
1415+ type: boolean
1416+ apply_lora_to_output:
1417+ type: boolean
1418+ lora_attn_modules:
1419+ items:
1420+ type: string
1421+ type: array
1422+ rank:
1423+ type: integer
1424+ required:
1425+ - lora_attn_modules
1426+ - apply_lora_to_mlp
1427+ - apply_lora_to_output
1428+ - rank
1429+ - alpha
1430+ type: object
1431+ QueryDocumentsRequest:
1432+ additionalProperties: false
1433+ properties:
1434+ bank_id:
1435+ type: string
1436+ params:
1437+ additionalProperties:
1438+ oneOf:
1439+ - type: 'null'
1440+ - type: boolean
1441+ - type: number
1442+ - type: string
1443+ - type: array
1444+ - type: object
1445+ type: object
1446+ query:
1447+ oneOf:
1448+ - type: string
1449+ - items:
1450+ type: string
1451+ type: array
1452+ required:
1453+ - bank_id
1454+ - query
1455+ type: object
1456+ QueryDocumentsResponse:
1457+ additionalProperties: false
1458+ properties:
1459+ chunks:
1460+ items:
1461+ additionalProperties: false
1462+ properties:
1463+ content:
1464+ oneOf:
1465+ - type: string
1466+ - items:
1467+ type: string
1468+ type: array
1469+ document_id:
1470+ type: string
1471+ token_count:
1472+ type: integer
1473+ required:
1474+ - content
1475+ - token_count
1476+ - document_id
1477+ type: object
1478+ type: array
1479+ scores:
1480+ items:
1481+ type: number
1482+ type: array
1483+ required:
1484+ - chunks
1485+ - scores
1486+ type: object
1487+ RLHFAlgorithm:
1488+ enum:
1489+ - dpo
1490+ type: string
1491+ RestAPIExecutionConfig:
1492+ additionalProperties: false
1493+ properties:
1494+ body:
1495+ additionalProperties:
1496+ oneOf:
1497+ - type: 'null'
1498+ - type: boolean
1499+ - type: number
1500+ - type: string
1501+ - type: array
1502+ - type: object
1503+ type: object
1504+ headers:
1505+ additionalProperties:
1506+ oneOf:
1507+ - type: 'null'
1508+ - type: boolean
1509+ - type: number
1510+ - type: string
1511+ - type: array
1512+ - type: object
1513+ type: object
1514+ method:
1515+ $ref: '#/components/schemas/RestAPIMethod'
1516+ params:
1517+ additionalProperties:
1518+ oneOf:
1519+ - type: 'null'
1520+ - type: boolean
1521+ - type: number
1522+ - type: string
1523+ - type: array
1524+ - type: object
1525+ type: object
1526+ url:
1527+ $ref: '#/components/schemas/URL'
1528+ required:
1529+ - url
1530+ - method
1531+ type: object
1532+ RestAPIMethod:
1533+ enum:
1534+ - GET
1535+ - POST
1536+ - PUT
1537+ - DELETE
1538+ type: string
1539+ RewardScoreRequest:
1540+ additionalProperties: false
1541+ properties:
1542+ dialog_generations:
1543+ items:
1544+ $ref: '#/components/schemas/DialogGenerations'
1545+ type: array
1546+ model:
1547+ type: string
1548+ required:
1549+ - dialog_generations
1550+ - model
1551+ type: object
1552+ RewardScoringResponse:
1553+ additionalProperties: false
1554+ properties:
1555+ scored_generations:
1556+ items:
1557+ $ref: '#/components/schemas/ScoredDialogGenerations'
1558+ type: array
1559+ required:
1560+ - scored_generations
1561+ title: Response from the reward scoring. Batch of (prompt, response, score)
1562+ tuples that pass the threshold.
1563+ type: object
1564+ RunShieldResponse:
1565+ additionalProperties: false
1566+ properties:
1567+ responses:
1568+ items:
1569+ $ref: '#/components/schemas/ShieldResponse'
1570+ type: array
1571+ required:
1572+ - responses
1573+ type: object
1574+ RunShieldsRequest:
1575+ additionalProperties: false
1576+ properties:
1577+ messages:
1578+ items:
1579+ oneOf:
1580+ - $ref: '#/components/schemas/UserMessage'
1581+ - $ref: '#/components/schemas/SystemMessage'
1582+ - $ref: '#/components/schemas/ToolResponseMessage'
1583+ - $ref: '#/components/schemas/CompletionMessage'
1584+ type: array
1585+ shields:
1586+ items:
1587+ $ref: '#/components/schemas/ShieldDefinition'
1588+ type: array
1589+ required:
1590+ - messages
1591+ - shields
1592+ type: object
1593+ SamplingParams:
1594+ additionalProperties: false
1595+ properties:
1596+ max_tokens:
1597+ type: integer
1598+ repetition_penalty:
1599+ type: number
1600+ strategy:
1601+ $ref: '#/components/schemas/SamplingStrategy'
1602+ temperature:
1603+ type: number
1604+ top_k:
1605+ type: integer
1606+ top_p:
1607+ type: number
1608+ required:
1609+ - strategy
1610+ type: object
1611+ SamplingStrategy:
1612+ enum:
1613+ - greedy
1614+ - top_p
1615+ - top_k
1616+ type: string
1617+ ScoredDialogGenerations:
1618+ additionalProperties: false
1619+ properties:
1620+ dialog:
1621+ items:
1622+ oneOf:
1623+ - $ref: '#/components/schemas/UserMessage'
1624+ - $ref: '#/components/schemas/SystemMessage'
1625+ - $ref: '#/components/schemas/ToolResponseMessage'
1626+ - $ref: '#/components/schemas/CompletionMessage'
1627+ type: array
1628+ scored_generations:
1629+ items:
1630+ $ref: '#/components/schemas/ScoredMessage'
1631+ type: array
1632+ required:
1633+ - dialog
1634+ - scored_generations
1635+ type: object
1636+ ScoredMessage:
1637+ additionalProperties: false
1638+ properties:
1639+ message:
1640+ oneOf:
1641+ - $ref: '#/components/schemas/UserMessage'
1642+ - $ref: '#/components/schemas/SystemMessage'
1643+ - $ref: '#/components/schemas/ToolResponseMessage'
1644+ - $ref: '#/components/schemas/CompletionMessage'
1645+ score:
1646+ type: number
1647+ required:
1648+ - message
1649+ - score
1650+ type: object
1651+ SearchToolDefinition:
1652+ additionalProperties: false
1653+ properties:
1654+ engine:
1655+ enum:
1656+ - bing
1657+ - brave
1658+ type: string
1659+ input_shields:
1660+ items:
1661+ $ref: '#/components/schemas/ShieldDefinition'
1662+ type: array
1663+ output_shields:
1664+ items:
1665+ $ref: '#/components/schemas/ShieldDefinition'
1666+ type: array
1667+ remote_execution:
1668+ $ref: '#/components/schemas/RestAPIExecutionConfig'
1669+ type:
1670+ const: brave_search
1671+ type: string
1672+ required:
1673+ - type
1674+ - engine
1675+ type: object
1676+ Session:
1677+ additionalProperties: false
1678+ properties:
1679+ memory_bank:
1680+ $ref: '#/components/schemas/MemoryBank'
1681+ session_id:
1682+ type: string
1683+ session_name:
1684+ type: string
1685+ started_at:
1686+ format: date-time
1687+ type: string
1688+ turns:
1689+ items:
1690+ $ref: '#/components/schemas/Turn'
1691+ type: array
1692+ required:
1693+ - session_id
1694+ - session_name
1695+ - turns
1696+ - started_at
1697+ title: A single session of an interaction with an Agentic System.
1698+ type: object
1699+ ShieldCallStep:
1700+ additionalProperties: false
1701+ properties:
1702+ completed_at:
1703+ format: date-time
1704+ type: string
1705+ response:
1706+ $ref: '#/components/schemas/ShieldResponse'
1707+ started_at:
1708+ format: date-time
1709+ type: string
1710+ step_id:
1711+ type: string
1712+ step_type:
1713+ const: shield_call
1714+ type: string
1715+ turn_id:
1716+ type: string
1717+ required:
1718+ - turn_id
1719+ - step_id
1720+ - step_type
1721+ - response
1722+ type: object
1723+ ShieldDefinition:
1724+ additionalProperties: false
1725+ properties:
1726+ description:
1727+ type: string
1728+ execution_config:
1729+ $ref: '#/components/schemas/RestAPIExecutionConfig'
1730+ on_violation_action:
1731+ $ref: '#/components/schemas/OnViolationAction'
1732+ parameters:
1733+ additionalProperties:
1734+ $ref: '#/components/schemas/ToolParamDefinition'
1735+ type: object
1736+ shield_type:
1737+ oneOf:
1738+ - $ref: '#/components/schemas/BuiltinShield'
1739+ - type: string
1740+ required:
1741+ - shield_type
1742+ - on_violation_action
1743+ type: object
1744+ ShieldResponse:
1745+ additionalProperties: false
1746+ properties:
1747+ is_violation:
1748+ type: boolean
1749+ shield_type:
1750+ oneOf:
1751+ - $ref: '#/components/schemas/BuiltinShield'
1752+ - type: string
1753+ violation_return_message:
1754+ type: string
1755+ violation_type:
1756+ type: string
1757+ required:
1758+ - shield_type
1759+ - is_violation
1760+ type: object
1761+ SpanEndPayload:
1762+ additionalProperties: false
1763+ properties:
1764+ status:
1765+ $ref: '#/components/schemas/SpanStatus'
1766+ type:
1767+ const: span_end
1768+ type: string
1769+ required:
1770+ - type
1771+ - status
1772+ type: object
1773+ SpanStartPayload:
1774+ additionalProperties: false
1775+ properties:
1776+ name:
1777+ type: string
1778+ parent_span_id:
1779+ type: string
1780+ type:
1781+ const: span_start
1782+ type: string
1783+ required:
1784+ - type
1785+ - name
1786+ type: object
1787+ SpanStatus:
1788+ enum:
1789+ - ok
1790+ - error
1791+ type: string
1792+ StopReason:
1793+ enum:
1794+ - end_of_turn
1795+ - end_of_message
1796+ - out_of_tokens
1797+ type: string
1798+ StructuredLogEvent:
1799+ additionalProperties: false
1800+ properties:
1801+ attributes:
1802+ additionalProperties:
1803+ oneOf:
1804+ - type: 'null'
1805+ - type: boolean
1806+ - type: number
1807+ - type: string
1808+ - type: array
1809+ - type: object
1810+ type: object
1811+ payload:
1812+ oneOf:
1813+ - $ref: '#/components/schemas/SpanStartPayload'
1814+ - $ref: '#/components/schemas/SpanEndPayload'
1815+ span_id:
1816+ type: string
1817+ timestamp:
1818+ format: date-time
1819+ type: string
1820+ trace_id:
1821+ type: string
1822+ type:
1823+ const: structured_log
1824+ type: string
1825+ required:
1826+ - trace_id
1827+ - span_id
1828+ - timestamp
1829+ - type
1830+ - payload
1831+ type: object
1832+ SupervisedFineTuneRequest:
1833+ additionalProperties: false
1834+ properties:
1835+ algorithm:
1836+ $ref: '#/components/schemas/FinetuningAlgorithm'
1837+ algorithm_config:
1838+ oneOf:
1839+ - $ref: '#/components/schemas/LoraFinetuningConfig'
1840+ - $ref: '#/components/schemas/QLoraFinetuningConfig'
1841+ - $ref: '#/components/schemas/DoraFinetuningConfig'
1842+ dataset:
1843+ $ref: '#/components/schemas/TrainEvalDataset'
1844+ hyperparam_search_config:
1845+ additionalProperties:
1846+ oneOf:
1847+ - type: 'null'
1848+ - type: boolean
1849+ - type: number
1850+ - type: string
1851+ - type: array
1852+ - type: object
1853+ type: object
1854+ job_uuid:
1855+ type: string
1856+ logger_config:
1857+ additionalProperties:
1858+ oneOf:
1859+ - type: 'null'
1860+ - type: boolean
1861+ - type: number
1862+ - type: string
1863+ - type: array
1864+ - type: object
1865+ type: object
1866+ model:
1867+ type: string
1868+ optimizer_config:
1869+ $ref: '#/components/schemas/OptimizerConfig'
1870+ training_config:
1871+ $ref: '#/components/schemas/TrainingConfig'
1872+ validation_dataset:
1873+ $ref: '#/components/schemas/TrainEvalDataset'
1874+ required:
1875+ - job_uuid
1876+ - model
1877+ - dataset
1878+ - validation_dataset
1879+ - algorithm
1880+ - algorithm_config
1881+ - optimizer_config
1882+ - training_config
1883+ - hyperparam_search_config
1884+ - logger_config
1885+ type: object
1886+ SyntheticDataGenerateRequest:
1887+ additionalProperties: false
1888+ properties:
1889+ dialogs:
1890+ items:
1891+ oneOf:
1892+ - $ref: '#/components/schemas/UserMessage'
1893+ - $ref: '#/components/schemas/SystemMessage'
1894+ - $ref: '#/components/schemas/ToolResponseMessage'
1895+ - $ref: '#/components/schemas/CompletionMessage'
1896+ type: array
1897+ filtering_function:
1898+ enum:
1899+ - none
1900+ - random
1901+ - top_k
1902+ - top_p
1903+ - top_k_top_p
1904+ - sigmoid
1905+ title: The type of filtering function.
1906+ type: string
1907+ model:
1908+ type: string
1909+ required:
1910+ - dialogs
1911+ - filtering_function
1912+ type: object
1913+ SyntheticDataGenerationResponse:
1914+ additionalProperties: false
1915+ properties:
1916+ statistics:
1917+ additionalProperties:
1918+ oneOf:
1919+ - type: 'null'
1920+ - type: boolean
1921+ - type: number
1922+ - type: string
1923+ - type: array
1924+ - type: object
1925+ type: object
1926+ synthetic_data:
1927+ items:
1928+ $ref: '#/components/schemas/ScoredDialogGenerations'
1929+ type: array
1930+ required:
1931+ - synthetic_data
1932+ title: Response from the synthetic data generation. Batch of (prompt, response,
1933+ score) tuples that pass the threshold.
1934+ type: object
1935+ SystemMessage:
1936+ additionalProperties: false
1937+ properties:
1938+ content:
1939+ oneOf:
1940+ - type: string
1941+ - items:
1942+ type: string
1943+ type: array
1944+ role:
1945+ const: system
1946+ type: string
1947+ required:
1948+ - role
1949+ - content
1950+ type: object
1951+ TokenLogProbs:
1952+ additionalProperties: false
1953+ properties:
1954+ logprobs_by_token:
1955+ additionalProperties:
1956+ type: number
1957+ type: object
1958+ required:
1959+ - logprobs_by_token
1960+ type: object
1961+ ToolCall:
1962+ additionalProperties: false
1963+ properties:
1964+ arguments:
1965+ additionalProperties:
1966+ oneOf:
1967+ - type: string
1968+ - type: integer
1969+ - type: number
1970+ - type: boolean
1971+ - type: 'null'
1972+ - items:
1973+ oneOf:
1974+ - type: string
1975+ - type: integer
1976+ - type: number
1977+ - type: boolean
1978+ - type: 'null'
1979+ type: array
1980+ - additionalProperties:
1981+ oneOf:
1982+ - type: string
1983+ - type: integer
1984+ - type: number
1985+ - type: boolean
1986+ - type: 'null'
1987+ type: object
1988+ type: object
1989+ call_id:
1990+ type: string
1991+ tool_name:
1992+ oneOf:
1993+ - $ref: '#/components/schemas/BuiltinTool'
1994+ - type: string
1995+ required:
1996+ - call_id
1997+ - tool_name
1998+ - arguments
1999+ type: object
2000+ ToolCallDelta:
2001+ additionalProperties: false
2002+ properties:
2003+ content:
2004+ oneOf:
2005+ - type: string
2006+ - $ref: '#/components/schemas/ToolCall'
2007+ parse_status:
2008+ $ref: '#/components/schemas/ToolCallParseStatus'
2009+ required:
2010+ - content
2011+ - parse_status
2012+ type: object
2013+ ToolCallParseStatus:
2014+ enum:
2015+ - started
2016+ - in_progress
2017+ - failure
2018+ - success
2019+ type: string
2020+ ToolChoice:
2021+ enum:
2022+ - auto
2023+ - required
2024+ type: string
2025+ ToolDefinition:
2026+ additionalProperties: false
2027+ properties:
2028+ description:
2029+ type: string
2030+ parameters:
2031+ additionalProperties:
2032+ $ref: '#/components/schemas/ToolParamDefinition'
2033+ type: object
2034+ tool_name:
2035+ oneOf:
2036+ - $ref: '#/components/schemas/BuiltinTool'
2037+ - type: string
2038+ required:
2039+ - tool_name
2040+ type: object
2041+ ToolExecutionStep:
2042+ additionalProperties: false
2043+ properties:
2044+ completed_at:
2045+ format: date-time
2046+ type: string
2047+ started_at:
2048+ format: date-time
2049+ type: string
2050+ step_id:
2051+ type: string
2052+ step_type:
2053+ const: tool_execution
2054+ type: string
2055+ tool_calls:
2056+ items:
2057+ $ref: '#/components/schemas/ToolCall'
2058+ type: array
2059+ tool_responses:
2060+ items:
2061+ $ref: '#/components/schemas/ToolResponse'
2062+ type: array
2063+ turn_id:
2064+ type: string
2065+ required:
2066+ - turn_id
2067+ - step_id
2068+ - step_type
2069+ - tool_calls
2070+ - tool_responses
2071+ type: object
2072+ ToolParamDefinition:
2073+ additionalProperties: false
2074+ properties:
2075+ description:
2076+ type: string
2077+ param_type:
2078+ type: string
2079+ required:
2080+ type: boolean
2081+ required:
2082+ - param_type
2083+ type: object
2084+ ToolPromptFormat:
2085+ description: "`json` --\n Refers to the json format for calling tools.\n\
2086+ \ The json format takes the form like\n {\n \"type\": \"function\"\
2087+ ,\n \"function\" : {\n \"name\": \"function_name\",\n \
2088+ \ \"description\": \"function_description\",\n \"parameters\"\
2089+ : {...}\n }\n }\n\n`function_tag` --\n This is an example of\
2090+ \ how you could define\n your own user defined format for making tool calls.\n\
2091+ \ The function_tag format looks like this,\n <function=function_name>(parameters)</function>\n\
2092+ \nThe detailed prompts for each of these formats are added to llama cli"
2093+ enum:
2094+ - json
2095+ - function_tag
2096+ title: This Enum refers to the prompt format for calling custom / zero shot
2097+ tools
2098+ type: string
2099+ ToolResponse:
2100+ additionalProperties: false
2101+ properties:
2102+ call_id:
2103+ type: string
2104+ content:
2105+ oneOf:
2106+ - type: string
2107+ - items:
2108+ type: string
2109+ type: array
2110+ tool_name:
2111+ oneOf:
2112+ - $ref: '#/components/schemas/BuiltinTool'
2113+ - type: string
2114+ required:
2115+ - call_id
2116+ - tool_name
2117+ - content
2118+ type: object
2119+ ToolResponseMessage:
2120+ additionalProperties: false
2121+ properties:
2122+ call_id:
2123+ type: string
2124+ content:
2125+ oneOf:
2126+ - type: string
2127+ - items:
2128+ type: string
2129+ type: array
2130+ role:
2131+ const: ipython
2132+ type: string
2133+ tool_name:
2134+ oneOf:
2135+ - $ref: '#/components/schemas/BuiltinTool'
2136+ - type: string
2137+ required:
2138+ - role
2139+ - call_id
2140+ - tool_name
2141+ - content
2142+ type: object
2143+ Trace:
2144+ additionalProperties: false
2145+ properties:
2146+ end_time:
2147+ format: date-time
2148+ type: string
2149+ root_span_id:
2150+ type: string
2151+ start_time:
2152+ format: date-time
2153+ type: string
2154+ trace_id:
2155+ type: string
2156+ required:
2157+ - trace_id
2158+ - root_span_id
2159+ - start_time
2160+ type: object
2161+ TrainEvalDataset:
2162+ additionalProperties: false
2163+ properties:
2164+ columns:
2165+ additionalProperties:
2166+ $ref: '#/components/schemas/TrainEvalDatasetColumnType'
2167+ type: object
2168+ content_url:
2169+ $ref: '#/components/schemas/URL'
2170+ metadata:
2171+ additionalProperties:
2172+ oneOf:
2173+ - type: 'null'
2174+ - type: boolean
2175+ - type: number
2176+ - type: string
2177+ - type: array
2178+ - type: object
2179+ type: object
2180+ required:
2181+ - columns
2182+ - content_url
2183+ title: Dataset to be used for training or evaluating language models.
2184+ type: object
2185+ TrainEvalDatasetColumnType:
2186+ enum:
2187+ - dialog
2188+ - text
2189+ - media
2190+ - number
2191+ - json
2192+ type: string
2193+ TrainingConfig:
2194+ additionalProperties: false
2195+ properties:
2196+ batch_size:
2197+ type: integer
2198+ enable_activation_checkpointing:
2199+ type: boolean
2200+ fsdp_cpu_offload:
2201+ type: boolean
2202+ memory_efficient_fsdp_wrap:
2203+ type: boolean
2204+ n_epochs:
2205+ type: integer
2206+ n_iters:
2207+ type: integer
2208+ shuffle:
2209+ type: boolean
2210+ required:
2211+ - n_epochs
2212+ - batch_size
2213+ - shuffle
2214+ - n_iters
2215+ - enable_activation_checkpointing
2216+ - memory_efficient_fsdp_wrap
2217+ - fsdp_cpu_offload
2218+ type: object
2219+ Turn:
2220+ additionalProperties: false
2221+ properties:
2222+ completed_at:
2223+ format: date-time
2224+ type: string
2225+ input_messages:
2226+ items:
2227+ oneOf:
2228+ - $ref: '#/components/schemas/UserMessage'
2229+ - $ref: '#/components/schemas/ToolResponseMessage'
2230+ type: array
2231+ output_attachments:
2232+ items:
2233+ $ref: '#/components/schemas/Attachment'
2234+ type: array
2235+ output_message:
2236+ $ref: '#/components/schemas/CompletionMessage'
2237+ session_id:
2238+ type: string
2239+ started_at:
2240+ format: date-time
2241+ type: string
2242+ steps:
2243+ items:
2244+ oneOf:
2245+ - $ref: '#/components/schemas/InferenceStep'
2246+ - $ref: '#/components/schemas/ToolExecutionStep'
2247+ - $ref: '#/components/schemas/ShieldCallStep'
2248+ - $ref: '#/components/schemas/MemoryRetrievalStep'
2249+ type: array
2250+ turn_id:
2251+ type: string
2252+ required:
2253+ - turn_id
2254+ - session_id
2255+ - input_messages
2256+ - steps
2257+ - output_message
2258+ - output_attachments
2259+ - started_at
2260+ title: A single turn in an interaction with an Agentic System.
2261+ type: object
2262+ URL:
2263+ format: uri
2264+ pattern: ^(https?://|file://|data:)
2265+ type: string
2266+ UnstructuredLogEvent:
2267+ additionalProperties: false
2268+ properties:
2269+ attributes:
2270+ additionalProperties:
2271+ oneOf:
2272+ - type: 'null'
2273+ - type: boolean
2274+ - type: number
2275+ - type: string
2276+ - type: array
2277+ - type: object
2278+ type: object
2279+ message:
2280+ type: string
2281+ severity:
2282+ $ref: '#/components/schemas/LogSeverity'
2283+ span_id:
2284+ type: string
2285+ timestamp:
2286+ format: date-time
2287+ type: string
2288+ trace_id:
2289+ type: string
2290+ type:
2291+ const: unstructured_log
2292+ type: string
2293+ required:
2294+ - trace_id
2295+ - span_id
2296+ - timestamp
2297+ - type
2298+ - message
2299+ - severity
2300+ type: object
2301+ UpdateDocumentsRequest:
2302+ additionalProperties: false
2303+ properties:
2304+ bank_id:
2305+ type: string
2306+ documents:
2307+ items:
2308+ $ref: '#/components/schemas/MemoryBankDocument'
2309+ type: array
2310+ required:
2311+ - bank_id
2312+ - documents
2313+ type: object
2314+ UserMessage:
2315+ additionalProperties: false
2316+ properties:
2317+ content:
2318+ oneOf:
2319+ - type: string
2320+ - items:
2321+ type: string
2322+ type: array
2323+ context:
2324+ oneOf:
2325+ - type: string
2326+ - items:
2327+ type: string
2328+ type: array
2329+ role:
2330+ const: user
2331+ type: string
2332+ required:
2333+ - role
2334+ - content
2335+ type: object
2336+ WolframAlphaToolDefinition:
2337+ additionalProperties: false
2338+ properties:
2339+ input_shields:
2340+ items:
2341+ $ref: '#/components/schemas/ShieldDefinition'
2342+ type: array
2343+ output_shields:
2344+ items:
2345+ $ref: '#/components/schemas/ShieldDefinition'
2346+ type: array
2347+ remote_execution:
2348+ $ref: '#/components/schemas/RestAPIExecutionConfig'
2349+ type:
2350+ const: wolfram_alpha
2351+ type: string
2352+ required:
2353+ - type
2354+ type: object
2355+info:
2356+ description: "This is the specification of the llama stack that provides\n \
2357+ \ a set of endpoints and their corresponding interfaces that are tailored\
2358+ \ to\n best leverage Llama Models. The specification is still in\
2359+ \ draft and subject to change.\n Generated at 2024-09-17 12:55:45.538053"
2360+ title: '[DRAFT] Llama Stack Specification'
2361+ version: 0.0.1
2362+jsonSchemaDialect: https://json-schema.org/draft/2020-12/schema
2363+openapi: 3.1.0
2364+paths:
2365+ /agents/create:
2366+ post:
2367+ parameters: []
2368+ requestBody:
2369+ content:
2370+ application/json:
2371+ schema:
2372+ $ref: '#/components/schemas/CreateAgentRequest'
2373+ required: true
2374+ responses:
2375+ '200':
2376+ content:
2377+ application/json:
2378+ schema:
2379+ $ref: '#/components/schemas/AgentCreateResponse'
2380+ description: OK
2381+ tags:
2382+ - Agents
2383+ /agents/delete:
2384+ post:
2385+ parameters: []
2386+ requestBody:
2387+ content:
2388+ application/json:
2389+ schema:
2390+ $ref: '#/components/schemas/DeleteAgentsRequest'
2391+ required: true
2392+ responses:
2393+ '200':
2394+ description: OK
2395+ tags:
2396+ - Agents
2397+ /agents/session/create:
2398+ post:
2399+ parameters: []
2400+ requestBody:
2401+ content:
2402+ application/json:
2403+ schema:
2404+ $ref: '#/components/schemas/CreateAgentSessionRequest'
2405+ required: true
2406+ responses:
2407+ '200':
2408+ content:
2409+ application/json:
2410+ schema:
2411+ $ref: '#/components/schemas/AgentSessionCreateResponse'
2412+ description: OK
2413+ tags:
2414+ - Agents
2415+ /agents/session/delete:
2416+ post:
2417+ parameters: []
2418+ requestBody:
2419+ content:
2420+ application/json:
2421+ schema:
2422+ $ref: '#/components/schemas/DeleteAgentsSessionRequest'
2423+ required: true
2424+ responses:
2425+ '200':
2426+ description: OK
2427+ tags:
2428+ - Agents
2429+ /agents/session/get:
2430+ post:
2431+ parameters:
2432+ - in: query
2433+ name: agent_id
2434+ required: true
2435+ schema:
2436+ type: string
2437+ - in: query
2438+ name: session_id
2439+ required: true
2440+ schema:
2441+ type: string
2442+ requestBody:
2443+ content:
2444+ application/json:
2445+ schema:
2446+ $ref: '#/components/schemas/GetAgentsSessionRequest'
2447+ required: true
2448+ responses:
2449+ '200':
2450+ content:
2451+ application/json:
2452+ schema:
2453+ $ref: '#/components/schemas/Session'
2454+ description: OK
2455+ tags:
2456+ - Agents
2457+ /agents/step/get:
2458+ get:
2459+ parameters:
2460+ - in: query
2461+ name: agent_id
2462+ required: true
2463+ schema:
2464+ type: string
2465+ - in: query
2466+ name: turn_id
2467+ required: true
2468+ schema:
2469+ type: string
2470+ - in: query
2471+ name: step_id
2472+ required: true
2473+ schema:
2474+ type: string
2475+ responses:
2476+ '200':
2477+ content:
2478+ application/json:
2479+ schema:
2480+ $ref: '#/components/schemas/AgentStepResponse'
2481+ description: OK
2482+ tags:
2483+ - Agents
2484+ /agents/turn/create:
2485+ post:
2486+ parameters: []
2487+ requestBody:
2488+ content:
2489+ application/json:
2490+ schema:
2491+ $ref: '#/components/schemas/CreateAgentTurnRequest'
2492+ required: true
2493+ responses:
2494+ '200':
2495+ content:
2496+ application/json:
2497+ schema:
2498+ $ref: '#/components/schemas/AgentTurnResponseStreamChunk'
2499+ description: OK
2500+ tags:
2501+ - Agents
2502+ /agents/turn/get:
2503+ get:
2504+ parameters:
2505+ - in: query
2506+ name: agent_id
2507+ required: true
2508+ schema:
2509+ type: string
2510+ - in: query
2511+ name: turn_id
2512+ required: true
2513+ schema:
2514+ type: string
2515+ responses:
2516+ '200':
2517+ content:
2518+ application/json:
2519+ schema:
2520+ $ref: '#/components/schemas/Turn'
2521+ description: OK
2522+ tags:
2523+ - Agents
2524+ /batch_inference/chat_completion:
2525+ post:
2526+ parameters: []
2527+ requestBody:
2528+ content:
2529+ application/json:
2530+ schema:
2531+ $ref: '#/components/schemas/BatchChatCompletionRequest'
2532+ required: true
2533+ responses:
2534+ '200':
2535+ content:
2536+ application/json:
2537+ schema:
2538+ $ref: '#/components/schemas/BatchChatCompletionResponse'
2539+ description: OK
2540+ tags:
2541+ - BatchInference
2542+ /batch_inference/completion:
2543+ post:
2544+ parameters: []
2545+ requestBody:
2546+ content:
2547+ application/json:
2548+ schema:
2549+ $ref: '#/components/schemas/BatchCompletionRequest'
2550+ required: true
2551+ responses:
2552+ '200':
2553+ content:
2554+ application/json:
2555+ schema:
2556+ $ref: '#/components/schemas/BatchCompletionResponse'
2557+ description: OK
2558+ tags:
2559+ - BatchInference
2560+ /datasets/create:
2561+ post:
2562+ parameters: []
2563+ requestBody:
2564+ content:
2565+ application/json:
2566+ schema:
2567+ $ref: '#/components/schemas/CreateDatasetRequest'
2568+ required: true
2569+ responses:
2570+ '200':
2571+ description: OK
2572+ tags:
2573+ - Datasets
2574+ /datasets/delete:
2575+ post:
2576+ parameters: []
2577+ requestBody:
2578+ content:
2579+ application/json:
2580+ schema:
2581+ $ref: '#/components/schemas/DeleteDatasetRequest'
2582+ required: true
2583+ responses:
2584+ '200':
2585+ description: OK
2586+ tags:
2587+ - Datasets
2588+ /datasets/get:
2589+ get:
2590+ parameters:
2591+ - in: query
2592+ name: dataset_uuid
2593+ required: true
2594+ schema:
2595+ type: string
2596+ responses:
2597+ '200':
2598+ content:
2599+ application/json:
2600+ schema:
2601+ $ref: '#/components/schemas/TrainEvalDataset'
2602+ description: OK
2603+ tags:
2604+ - Datasets
2605+ /evaluate/job/artifacts:
2606+ get:
2607+ parameters:
2608+ - in: query
2609+ name: job_uuid
2610+ required: true
2611+ schema:
2612+ type: string
2613+ responses:
2614+ '200':
2615+ content:
2616+ application/json:
2617+ schema:
2618+ $ref: '#/components/schemas/EvaluationJobArtifactsResponse'
2619+ description: OK
2620+ tags:
2621+ - Evaluations
2622+ /evaluate/job/cancel:
2623+ post:
2624+ parameters: []
2625+ requestBody:
2626+ content:
2627+ application/json:
2628+ schema:
2629+ $ref: '#/components/schemas/CancelEvaluationJobRequest'
2630+ required: true
2631+ responses:
2632+ '200':
2633+ description: OK
2634+ tags:
2635+ - Evaluations
2636+ /evaluate/job/logs:
2637+ get:
2638+ parameters:
2639+ - in: query
2640+ name: job_uuid
2641+ required: true
2642+ schema:
2643+ type: string
2644+ responses:
2645+ '200':
2646+ content:
2647+ application/json:
2648+ schema:
2649+ $ref: '#/components/schemas/EvaluationJobLogStream'
2650+ description: OK
2651+ tags:
2652+ - Evaluations
2653+ /evaluate/job/status:
2654+ get:
2655+ parameters:
2656+ - in: query
2657+ name: job_uuid
2658+ required: true
2659+ schema:
2660+ type: string
2661+ responses:
2662+ '200':
2663+ content:
2664+ application/json:
2665+ schema:
2666+ $ref: '#/components/schemas/EvaluationJobStatusResponse'
2667+ description: OK
2668+ tags:
2669+ - Evaluations
2670+ /evaluate/jobs:
2671+ get:
2672+ parameters: []
2673+ responses:
2674+ '200':
2675+ content:
2676+ application/jsonl:
2677+ schema:
2678+ $ref: '#/components/schemas/EvaluationJob'
2679+ description: OK
2680+ tags:
2681+ - Evaluations
2682+ /evaluate/question_answering/:
2683+ post:
2684+ parameters: []
2685+ requestBody:
2686+ content:
2687+ application/json:
2688+ schema:
2689+ $ref: '#/components/schemas/EvaluateQuestionAnsweringRequest'
2690+ required: true
2691+ responses:
2692+ '200':
2693+ content:
2694+ application/json:
2695+ schema:
2696+ $ref: '#/components/schemas/EvaluationJob'
2697+ description: OK
2698+ tags:
2699+ - Evaluations
2700+ /evaluate/summarization/:
2701+ post:
2702+ parameters: []
2703+ requestBody:
2704+ content:
2705+ application/json:
2706+ schema:
2707+ $ref: '#/components/schemas/EvaluateSummarizationRequest'
2708+ required: true
2709+ responses:
2710+ '200':
2711+ content:
2712+ application/json:
2713+ schema:
2714+ $ref: '#/components/schemas/EvaluationJob'
2715+ description: OK
2716+ tags:
2717+ - Evaluations
2718+ /evaluate/text_generation/:
2719+ post:
2720+ parameters: []
2721+ requestBody:
2722+ content:
2723+ application/json:
2724+ schema:
2725+ $ref: '#/components/schemas/EvaluateTextGenerationRequest'
2726+ required: true
2727+ responses:
2728+ '200':
2729+ content:
2730+ application/json:
2731+ schema:
2732+ $ref: '#/components/schemas/EvaluationJob'
2733+ description: OK
2734+ tags:
2735+ - Evaluations
2736+ /inference/chat_completion:
2737+ post:
2738+ parameters: []
2739+ requestBody:
2740+ content:
2741+ application/json:
2742+ schema:
2743+ $ref: '#/components/schemas/ChatCompletionRequest'
2744+ required: true
2745+ responses:
2746+ '200':
2747+ content:
2748+ text/event-stream:
2749+ schema:
2750+ oneOf:
2751+ - $ref: '#/components/schemas/ChatCompletionResponse'
2752+ - $ref: '#/components/schemas/ChatCompletionResponseStreamChunk'
2753+ description: Chat completion response. **OR** SSE-stream of these events.
2754+ tags:
2755+ - Inference
2756+ /inference/completion:
2757+ post:
2758+ parameters: []
2759+ requestBody:
2760+ content:
2761+ application/json:
2762+ schema:
2763+ $ref: '#/components/schemas/CompletionRequest'
2764+ required: true
2765+ responses:
2766+ '200':
2767+ content:
2768+ application/json:
2769+ schema:
2770+ oneOf:
2771+ - $ref: '#/components/schemas/CompletionResponse'
2772+ - $ref: '#/components/schemas/CompletionResponseStreamChunk'
2773+ description: Completion response. **OR** streamed completion response.
2774+ tags:
2775+ - Inference
2776+ /inference/embeddings:
2777+ post:
2778+ parameters: []
2779+ requestBody:
2780+ content:
2781+ application/json:
2782+ schema:
2783+ $ref: '#/components/schemas/EmbeddingsRequest'
2784+ required: true
2785+ responses:
2786+ '200':
2787+ content:
2788+ application/json:
2789+ schema:
2790+ $ref: '#/components/schemas/EmbeddingsResponse'
2791+ description: OK
2792+ tags:
2793+ - Inference
2794+ /memory_bank/documents/delete:
2795+ post:
2796+ parameters: []
2797+ requestBody:
2798+ content:
2799+ application/json:
2800+ schema:
2801+ $ref: '#/components/schemas/DeleteDocumentsRequest'
2802+ required: true
2803+ responses:
2804+ '200':
2805+ description: OK
2806+ tags:
2807+ - Memory
2808+ /memory_bank/documents/get:
2809+ post:
2810+ parameters:
2811+ - in: query
2812+ name: bank_id
2813+ required: true
2814+ schema:
2815+ type: string
2816+ requestBody:
2817+ content:
2818+ application/json:
2819+ schema:
2820+ $ref: '#/components/schemas/GetDocumentsRequest'
2821+ required: true
2822+ responses:
2823+ '200':
2824+ content:
2825+ application/jsonl:
2826+ schema:
2827+ $ref: '#/components/schemas/MemoryBankDocument'
2828+ description: OK
2829+ tags:
2830+ - Memory
2831+ /memory_bank/insert:
2832+ post:
2833+ parameters: []
2834+ requestBody:
2835+ content:
2836+ application/json:
2837+ schema:
2838+ $ref: '#/components/schemas/InsertDocumentsRequest'
2839+ required: true
2840+ responses:
2841+ '200':
2842+ description: OK
2843+ tags:
2844+ - Memory
2845+ /memory_bank/query:
2846+ post:
2847+ parameters: []
2848+ requestBody:
2849+ content:
2850+ application/json:
2851+ schema:
2852+ $ref: '#/components/schemas/QueryDocumentsRequest'
2853+ required: true
2854+ responses:
2855+ '200':
2856+ content:
2857+ application/json:
2858+ schema:
2859+ $ref: '#/components/schemas/QueryDocumentsResponse'
2860+ description: OK
2861+ tags:
2862+ - Memory
2863+ /memory_bank/update:
2864+ post:
2865+ parameters: []
2866+ requestBody:
2867+ content:
2868+ application/json:
2869+ schema:
2870+ $ref: '#/components/schemas/UpdateDocumentsRequest'
2871+ required: true
2872+ responses:
2873+ '200':
2874+ description: OK
2875+ tags:
2876+ - Memory
2877+ /memory_banks/create:
2878+ post:
2879+ parameters: []
2880+ requestBody:
2881+ content:
2882+ application/json:
2883+ schema:
2884+ $ref: '#/components/schemas/CreateMemoryBankRequest'
2885+ required: true
2886+ responses:
2887+ '200':
2888+ content:
2889+ application/json:
2890+ schema:
2891+ $ref: '#/components/schemas/MemoryBank'
2892+ description: OK
2893+ tags:
2894+ - Memory
2895+ /memory_banks/drop:
2896+ post:
2897+ parameters: []
2898+ requestBody:
2899+ content:
2900+ application/json:
2901+ schema:
2902+ $ref: '#/components/schemas/DropMemoryBankRequest'
2903+ required: true
2904+ responses:
2905+ '200':
2906+ content:
2907+ application/json:
2908+ schema:
2909+ type: string
2910+ description: OK
2911+ tags:
2912+ - Memory
2913+ /memory_banks/get:
2914+ get:
2915+ parameters:
2916+ - in: query
2917+ name: bank_id
2918+ required: true
2919+ schema:
2920+ type: string
2921+ responses:
2922+ '200':
2923+ content:
2924+ application/json:
2925+ schema:
2926+ oneOf:
2927+ - $ref: '#/components/schemas/MemoryBank'
2928+ - type: 'null'
2929+ description: OK
2930+ tags:
2931+ - Memory
2932+ /memory_banks/list:
2933+ get:
2934+ parameters: []
2935+ responses:
2936+ '200':
2937+ content:
2938+ application/jsonl:
2939+ schema:
2940+ $ref: '#/components/schemas/MemoryBank'
2941+ description: OK
2942+ tags:
2943+ - Memory
2944+ /post_training/job/artifacts:
2945+ get:
2946+ parameters:
2947+ - in: query
2948+ name: job_uuid
2949+ required: true
2950+ schema:
2951+ type: string
2952+ responses:
2953+ '200':
2954+ content:
2955+ application/json:
2956+ schema:
2957+ $ref: '#/components/schemas/PostTrainingJobArtifactsResponse'
2958+ description: OK
2959+ tags:
2960+ - PostTraining
2961+ /post_training/job/cancel:
2962+ post:
2963+ parameters: []
2964+ requestBody:
2965+ content:
2966+ application/json:
2967+ schema:
2968+ $ref: '#/components/schemas/CancelTrainingJobRequest'
2969+ required: true
2970+ responses:
2971+ '200':
2972+ description: OK
2973+ tags:
2974+ - PostTraining
2975+ /post_training/job/logs:
2976+ get:
2977+ parameters:
2978+ - in: query
2979+ name: job_uuid
2980+ required: true
2981+ schema:
2982+ type: string
2983+ responses:
2984+ '200':
2985+ content:
2986+ application/json:
2987+ schema:
2988+ $ref: '#/components/schemas/PostTrainingJobLogStream'
2989+ description: OK
2990+ tags:
2991+ - PostTraining
2992+ /post_training/job/status:
2993+ get:
2994+ parameters:
2995+ - in: query
2996+ name: job_uuid
2997+ required: true
2998+ schema:
2999+ type: string
3000+ responses:
3001+ '200':
3002+ content:
3003+ application/json:
3004+ schema:
3005+ $ref: '#/components/schemas/PostTrainingJobStatusResponse'
3006+ description: OK
3007+ tags:
3008+ - PostTraining
3009+ /post_training/jobs:
3010+ get:
3011+ parameters: []
3012+ responses:
3013+ '200':
3014+ content:
3015+ application/jsonl:
3016+ schema:
3017+ $ref: '#/components/schemas/PostTrainingJob'
3018+ description: OK
3019+ tags:
3020+ - PostTraining
3021+ /post_training/preference_optimize:
3022+ post:
3023+ parameters: []
3024+ requestBody:
3025+ content:
3026+ application/json:
3027+ schema:
3028+ $ref: '#/components/schemas/PreferenceOptimizeRequest'
3029+ required: true
3030+ responses:
3031+ '200':
3032+ content:
3033+ application/json:
3034+ schema:
3035+ $ref: '#/components/schemas/PostTrainingJob'
3036+ description: OK
3037+ tags:
3038+ - PostTraining
3039+ /post_training/supervised_fine_tune:
3040+ post:
3041+ parameters: []
3042+ requestBody:
3043+ content:
3044+ application/json:
3045+ schema:
3046+ $ref: '#/components/schemas/SupervisedFineTuneRequest'
3047+ required: true
3048+ responses:
3049+ '200':
3050+ content:
3051+ application/json:
3052+ schema:
3053+ $ref: '#/components/schemas/PostTrainingJob'
3054+ description: OK
3055+ tags:
3056+ - PostTraining
3057+ /reward_scoring/score:
3058+ post:
3059+ parameters: []
3060+ requestBody:
3061+ content:
3062+ application/json:
3063+ schema:
3064+ $ref: '#/components/schemas/RewardScoreRequest'
3065+ required: true
3066+ responses:
3067+ '200':
3068+ content:
3069+ application/json:
3070+ schema:
3071+ $ref: '#/components/schemas/RewardScoringResponse'
3072+ description: OK
3073+ tags:
3074+ - RewardScoring
3075+ /safety/run_shields:
3076+ post:
3077+ parameters: []
3078+ requestBody:
3079+ content:
3080+ application/json:
3081+ schema:
3082+ $ref: '#/components/schemas/RunShieldsRequest'
3083+ required: true
3084+ responses:
3085+ '200':
3086+ content:
3087+ application/json:
3088+ schema:
3089+ $ref: '#/components/schemas/RunShieldResponse'
3090+ description: OK
3091+ tags:
3092+ - Safety
3093+ /synthetic_data_generation/generate:
3094+ post:
3095+ parameters: []
3096+ requestBody:
3097+ content:
3098+ application/json:
3099+ schema:
3100+ $ref: '#/components/schemas/SyntheticDataGenerateRequest'
3101+ required: true
3102+ responses:
3103+ '200':
3104+ content:
3105+ application/json:
3106+ schema:
3107+ $ref: '#/components/schemas/SyntheticDataGenerationResponse'
3108+ description: OK
3109+ tags:
3110+ - SyntheticDataGeneration
3111+ /telemetry/get_trace:
3112+ get:
3113+ parameters:
3114+ - in: query
3115+ name: trace_id
3116+ required: true
3117+ schema:
3118+ type: string
3119+ responses:
3120+ '200':
3121+ content:
3122+ application/json:
3123+ schema:
3124+ $ref: '#/components/schemas/Trace'
3125+ description: OK
3126+ tags:
3127+ - Telemetry
3128+ /telemetry/log_event:
3129+ post:
3130+ parameters: []
3131+ requestBody:
3132+ content:
3133+ application/json:
3134+ schema:
3135+ $ref: '#/components/schemas/LogEventRequest'
3136+ required: true
3137+ responses:
3138+ '200':
3139+ description: OK
3140+ tags:
3141+ - Telemetry
3142+security:
3143+- Default: []
3144+servers:
3145+- url: http://any-hosted-llama-stack.com
3146+tags:
3147+- name: Agents
3148+- name: Safety
3149+- name: SyntheticDataGeneration
3150+- name: Telemetry
3151+- name: Datasets
3152+- name: RewardScoring
3153+- name: Evaluations
3154+- name: PostTraining
3155+- name: Inference
3156+- name: BatchInference
3157+- name: Memory
3158+- description: <SchemaDefinition schemaRef="#/components/schemas/BuiltinTool" />
3159+ name: BuiltinTool
3160+- description: <SchemaDefinition schemaRef="#/components/schemas/CompletionMessage"
3161+ />
3162+ name: CompletionMessage
3163+- description: <SchemaDefinition schemaRef="#/components/schemas/SamplingParams" />
3164+ name: SamplingParams
3165+- description: <SchemaDefinition schemaRef="#/components/schemas/SamplingStrategy"
3166+ />
3167+ name: SamplingStrategy
3168+- description: <SchemaDefinition schemaRef="#/components/schemas/StopReason" />
3169+ name: StopReason
3170+- description: <SchemaDefinition schemaRef="#/components/schemas/SystemMessage" />
3171+ name: SystemMessage
3172+- description: <SchemaDefinition schemaRef="#/components/schemas/ToolCall" />
3173+ name: ToolCall
3174+- description: <SchemaDefinition schemaRef="#/components/schemas/ToolChoice" />
3175+ name: ToolChoice
3176+- description: <SchemaDefinition schemaRef="#/components/schemas/ToolDefinition" />
3177+ name: ToolDefinition
3178+- description: <SchemaDefinition schemaRef="#/components/schemas/ToolParamDefinition"
3179+ />
3180+ name: ToolParamDefinition
3181+- description: "This Enum refers to the prompt format for calling custom / zero shot\
3182+ \ tools\n\n`json` --\n Refers to the json format for calling tools.\n The\
3183+ \ json format takes the form like\n {\n \"type\": \"function\",\n \
3184+ \ \"function\" : {\n \"name\": \"function_name\",\n \
3185+ \ \"description\": \"function_description\",\n \"parameters\": {...}\n\
3186+ \ }\n }\n\n`function_tag` --\n This is an example of how you could\
3187+ \ define\n your own user defined format for making tool calls.\n The function_tag\
3188+ \ format looks like this,\n <function=function_name>(parameters)</function>\n\
3189+ \nThe detailed prompts for each of these formats are added to llama cli\n\n<SchemaDefinition\
3190+ \ schemaRef=\"#/components/schemas/ToolPromptFormat\" />"
3191+ name: ToolPromptFormat
3192+- description: <SchemaDefinition schemaRef="#/components/schemas/ToolResponseMessage"
3193+ />
3194+ name: ToolResponseMessage
3195+- description: <SchemaDefinition schemaRef="#/components/schemas/UserMessage" />
3196+ name: UserMessage
3197+- description: <SchemaDefinition schemaRef="#/components/schemas/BatchChatCompletionRequest"
3198+ />
3199+ name: BatchChatCompletionRequest
3200+- description: <SchemaDefinition schemaRef="#/components/schemas/BatchChatCompletionResponse"
3201+ />
3202+ name: BatchChatCompletionResponse
3203+- description: <SchemaDefinition schemaRef="#/components/schemas/BatchCompletionRequest"
3204+ />
3205+ name: BatchCompletionRequest
3206+- description: <SchemaDefinition schemaRef="#/components/schemas/BatchCompletionResponse"
3207+ />
3208+ name: BatchCompletionResponse
3209+- description: <SchemaDefinition schemaRef="#/components/schemas/CancelEvaluationJobRequest"
3210+ />
3211+ name: CancelEvaluationJobRequest
3212+- description: <SchemaDefinition schemaRef="#/components/schemas/CancelTrainingJobRequest"
3213+ />
3214+ name: CancelTrainingJobRequest
3215+- description: <SchemaDefinition schemaRef="#/components/schemas/ChatCompletionRequest"
3216+ />
3217+ name: ChatCompletionRequest
3218+- description: 'Chat completion response.
3219+
3220+
3221+ <SchemaDefinition schemaRef="#/components/schemas/ChatCompletionResponse" />'
3222+ name: ChatCompletionResponse
3223+- description: 'Chat completion response event.
3224+
3225+
3226+ <SchemaDefinition schemaRef="#/components/schemas/ChatCompletionResponseEvent"
3227+ />'
3228+ name: ChatCompletionResponseEvent
3229+- description: <SchemaDefinition schemaRef="#/components/schemas/ChatCompletionResponseEventType"
3230+ />
3231+ name: ChatCompletionResponseEventType
3232+- description: 'SSE-stream of these events.
3233+
3234+
3235+ <SchemaDefinition schemaRef="#/components/schemas/ChatCompletionResponseStreamChunk"
3236+ />'
3237+ name: ChatCompletionResponseStreamChunk
3238+- description: <SchemaDefinition schemaRef="#/components/schemas/TokenLogProbs" />
3239+ name: TokenLogProbs
3240+- description: <SchemaDefinition schemaRef="#/components/schemas/ToolCallDelta" />
3241+ name: ToolCallDelta
3242+- description: <SchemaDefinition schemaRef="#/components/schemas/ToolCallParseStatus"
3243+ />
3244+ name: ToolCallParseStatus
3245+- description: <SchemaDefinition schemaRef="#/components/schemas/CompletionRequest"
3246+ />
3247+ name: CompletionRequest
3248+- description: 'Completion response.
3249+
3250+
3251+ <SchemaDefinition schemaRef="#/components/schemas/CompletionResponse" />'
3252+ name: CompletionResponse
3253+- description: 'streamed completion response.
3254+
3255+
3256+ <SchemaDefinition schemaRef="#/components/schemas/CompletionResponseStreamChunk"
3257+ />'
3258+ name: CompletionResponseStreamChunk
3259+- description: <SchemaDefinition schemaRef="#/components/schemas/AgentConfig" />
3260+ name: AgentConfig
3261+- description: <SchemaDefinition schemaRef="#/components/schemas/BuiltinShield" />
3262+ name: BuiltinShield
3263+- description: <SchemaDefinition schemaRef="#/components/schemas/CodeInterpreterToolDefinition"
3264+ />
3265+ name: CodeInterpreterToolDefinition
3266+- description: <SchemaDefinition schemaRef="#/components/schemas/FunctionCallToolDefinition"
3267+ />
3268+ name: FunctionCallToolDefinition
3269+- description: <SchemaDefinition schemaRef="#/components/schemas/OnViolationAction"
3270+ />
3271+ name: OnViolationAction
3272+- description: <SchemaDefinition schemaRef="#/components/schemas/PhotogenToolDefinition"
3273+ />
3274+ name: PhotogenToolDefinition
3275+- description: <SchemaDefinition schemaRef="#/components/schemas/RestAPIExecutionConfig"
3276+ />
3277+ name: RestAPIExecutionConfig
3278+- description: <SchemaDefinition schemaRef="#/components/schemas/RestAPIMethod" />
3279+ name: RestAPIMethod
3280+- description: <SchemaDefinition schemaRef="#/components/schemas/SearchToolDefinition"
3281+ />
3282+ name: SearchToolDefinition
3283+- description: <SchemaDefinition schemaRef="#/components/schemas/ShieldDefinition"
3284+ />
3285+ name: ShieldDefinition
3286+- description: <SchemaDefinition schemaRef="#/components/schemas/URL" />
3287+ name: URL
3288+- description: <SchemaDefinition schemaRef="#/components/schemas/WolframAlphaToolDefinition"
3289+ />
3290+ name: WolframAlphaToolDefinition
3291+- description: <SchemaDefinition schemaRef="#/components/schemas/CreateAgentRequest"
3292+ />
3293+ name: CreateAgentRequest
3294+- description: <SchemaDefinition schemaRef="#/components/schemas/AgentCreateResponse"
3295+ />
3296+ name: AgentCreateResponse
3297+- description: <SchemaDefinition schemaRef="#/components/schemas/CreateAgentSessionRequest"
3298+ />
3299+ name: CreateAgentSessionRequest
3300+- description: <SchemaDefinition schemaRef="#/components/schemas/AgentSessionCreateResponse"
3301+ />
3302+ name: AgentSessionCreateResponse
3303+- description: <SchemaDefinition schemaRef="#/components/schemas/Attachment" />
3304+ name: Attachment
3305+- description: <SchemaDefinition schemaRef="#/components/schemas/CreateAgentTurnRequest"
3306+ />
3307+ name: CreateAgentTurnRequest
3308+- description: 'Streamed agent execution response.
3309+
3310+
3311+ <SchemaDefinition schemaRef="#/components/schemas/AgentTurnResponseEvent" />'
3312+ name: AgentTurnResponseEvent
3313+- description: <SchemaDefinition schemaRef="#/components/schemas/AgentTurnResponseStepCompletePayload"
3314+ />
3315+ name: AgentTurnResponseStepCompletePayload
3316+- description: <SchemaDefinition schemaRef="#/components/schemas/AgentTurnResponseStepProgressPayload"
3317+ />
3318+ name: AgentTurnResponseStepProgressPayload
3319+- description: <SchemaDefinition schemaRef="#/components/schemas/AgentTurnResponseStepStartPayload"
3320+ />
3321+ name: AgentTurnResponseStepStartPayload
3322+- description: <SchemaDefinition schemaRef="#/components/schemas/AgentTurnResponseStreamChunk"
3323+ />
3324+ name: AgentTurnResponseStreamChunk
3325+- description: <SchemaDefinition schemaRef="#/components/schemas/AgentTurnResponseTurnCompletePayload"
3326+ />
3327+ name: AgentTurnResponseTurnCompletePayload
3328+- description: <SchemaDefinition schemaRef="#/components/schemas/AgentTurnResponseTurnStartPayload"
3329+ />
3330+ name: AgentTurnResponseTurnStartPayload
3331+- description: <SchemaDefinition schemaRef="#/components/schemas/InferenceStep" />
3332+ name: InferenceStep
3333+- description: <SchemaDefinition schemaRef="#/components/schemas/MemoryRetrievalStep"
3334+ />
3335+ name: MemoryRetrievalStep
3336+- description: <SchemaDefinition schemaRef="#/components/schemas/ShieldCallStep" />
3337+ name: ShieldCallStep
3338+- description: <SchemaDefinition schemaRef="#/components/schemas/ShieldResponse" />
3339+ name: ShieldResponse
3340+- description: <SchemaDefinition schemaRef="#/components/schemas/ToolExecutionStep"
3341+ />
3342+ name: ToolExecutionStep
3343+- description: <SchemaDefinition schemaRef="#/components/schemas/ToolResponse" />
3344+ name: ToolResponse
3345+- description: 'A single turn in an interaction with an Agentic System.
3346+
3347+
3348+ <SchemaDefinition schemaRef="#/components/schemas/Turn" />'
3349+ name: Turn
3350+- description: 'Dataset to be used for training or evaluating language models.
3351+
3352+
3353+ <SchemaDefinition schemaRef="#/components/schemas/TrainEvalDataset" />'
3354+ name: TrainEvalDataset
3355+- description: <SchemaDefinition schemaRef="#/components/schemas/TrainEvalDatasetColumnType"
3356+ />
3357+ name: TrainEvalDatasetColumnType
3358+- description: <SchemaDefinition schemaRef="#/components/schemas/CreateDatasetRequest"
3359+ />
3360+ name: CreateDatasetRequest
3361+- description: <SchemaDefinition schemaRef="#/components/schemas/CreateMemoryBankRequest"
3362+ />
3363+ name: CreateMemoryBankRequest
3364+- description: <SchemaDefinition schemaRef="#/components/schemas/MemoryBank" />
3365+ name: MemoryBank
3366+- description: <SchemaDefinition schemaRef="#/components/schemas/DeleteAgentsRequest"
3367+ />
3368+ name: DeleteAgentsRequest
3369+- description: <SchemaDefinition schemaRef="#/components/schemas/DeleteAgentsSessionRequest"
3370+ />
3371+ name: DeleteAgentsSessionRequest
3372+- description: <SchemaDefinition schemaRef="#/components/schemas/DeleteDatasetRequest"
3373+ />
3374+ name: DeleteDatasetRequest
3375+- description: <SchemaDefinition schemaRef="#/components/schemas/DeleteDocumentsRequest"
3376+ />
3377+ name: DeleteDocumentsRequest
3378+- description: <SchemaDefinition schemaRef="#/components/schemas/DropMemoryBankRequest"
3379+ />
3380+ name: DropMemoryBankRequest
3381+- description: <SchemaDefinition schemaRef="#/components/schemas/EmbeddingsRequest"
3382+ />
3383+ name: EmbeddingsRequest
3384+- description: <SchemaDefinition schemaRef="#/components/schemas/EmbeddingsResponse"
3385+ />
3386+ name: EmbeddingsResponse
3387+- description: <SchemaDefinition schemaRef="#/components/schemas/EvaluateQuestionAnsweringRequest"
3388+ />
3389+ name: EvaluateQuestionAnsweringRequest
3390+- description: <SchemaDefinition schemaRef="#/components/schemas/EvaluationJob" />
3391+ name: EvaluationJob
3392+- description: <SchemaDefinition schemaRef="#/components/schemas/EvaluateSummarizationRequest"
3393+ />
3394+ name: EvaluateSummarizationRequest
3395+- description: <SchemaDefinition schemaRef="#/components/schemas/EvaluateTextGenerationRequest"
3396+ />
3397+ name: EvaluateTextGenerationRequest
3398+- description: <SchemaDefinition schemaRef="#/components/schemas/GetAgentsSessionRequest"
3399+ />
3400+ name: GetAgentsSessionRequest
3401+- description: 'A single session of an interaction with an Agentic System.
3402+
3403+
3404+ <SchemaDefinition schemaRef="#/components/schemas/Session" />'
3405+ name: Session
3406+- description: <SchemaDefinition schemaRef="#/components/schemas/AgentStepResponse"
3407+ />
3408+ name: AgentStepResponse
3409+- description: <SchemaDefinition schemaRef="#/components/schemas/GetDocumentsRequest"
3410+ />
3411+ name: GetDocumentsRequest
3412+- description: <SchemaDefinition schemaRef="#/components/schemas/MemoryBankDocument"
3413+ />
3414+ name: MemoryBankDocument
3415+- description: 'Artifacts of a evaluation job.
3416+
3417+
3418+ <SchemaDefinition schemaRef="#/components/schemas/EvaluationJobArtifactsResponse"
3419+ />'
3420+ name: EvaluationJobArtifactsResponse
3421+- description: <SchemaDefinition schemaRef="#/components/schemas/EvaluationJobLogStream"
3422+ />
3423+ name: EvaluationJobLogStream
3424+- description: <SchemaDefinition schemaRef="#/components/schemas/EvaluationJobStatusResponse"
3425+ />
3426+ name: EvaluationJobStatusResponse
3427+- description: <SchemaDefinition schemaRef="#/components/schemas/Trace" />
3428+ name: Trace
3429+- description: 'Checkpoint created during training runs
3430+
3431+
3432+ <SchemaDefinition schemaRef="#/components/schemas/Checkpoint" />'
3433+ name: Checkpoint
3434+- description: 'Artifacts of a finetuning job.
3435+
3436+
3437+ <SchemaDefinition schemaRef="#/components/schemas/PostTrainingJobArtifactsResponse"
3438+ />'
3439+ name: PostTrainingJobArtifactsResponse
3440+- description: 'Stream of logs from a finetuning job.
3441+
3442+
3443+ <SchemaDefinition schemaRef="#/components/schemas/PostTrainingJobLogStream" />'
3444+ name: PostTrainingJobLogStream
3445+- description: <SchemaDefinition schemaRef="#/components/schemas/PostTrainingJobStatus"
3446+ />
3447+ name: PostTrainingJobStatus
3448+- description: 'Status of a finetuning job.
3449+
3450+
3451+ <SchemaDefinition schemaRef="#/components/schemas/PostTrainingJobStatusResponse"
3452+ />'
3453+ name: PostTrainingJobStatusResponse
3454+- description: <SchemaDefinition schemaRef="#/components/schemas/PostTrainingJob"
3455+ />
3456+ name: PostTrainingJob
3457+- description: <SchemaDefinition schemaRef="#/components/schemas/InsertDocumentsRequest"
3458+ />
3459+ name: InsertDocumentsRequest
3460+- description: <SchemaDefinition schemaRef="#/components/schemas/LogSeverity" />
3461+ name: LogSeverity
3462+- description: <SchemaDefinition schemaRef="#/components/schemas/MetricEvent" />
3463+ name: MetricEvent
3464+- description: <SchemaDefinition schemaRef="#/components/schemas/SpanEndPayload" />
3465+ name: SpanEndPayload
3466+- description: <SchemaDefinition schemaRef="#/components/schemas/SpanStartPayload"
3467+ />
3468+ name: SpanStartPayload
3469+- description: <SchemaDefinition schemaRef="#/components/schemas/SpanStatus" />
3470+ name: SpanStatus
3471+- description: <SchemaDefinition schemaRef="#/components/schemas/StructuredLogEvent"
3472+ />
3473+ name: StructuredLogEvent
3474+- description: <SchemaDefinition schemaRef="#/components/schemas/UnstructuredLogEvent"
3475+ />
3476+ name: UnstructuredLogEvent
3477+- description: <SchemaDefinition schemaRef="#/components/schemas/LogEventRequest"
3478+ />
3479+ name: LogEventRequest
3480+- description: <SchemaDefinition schemaRef="#/components/schemas/DPOAlignmentConfig"
3481+ />
3482+ name: DPOAlignmentConfig
3483+- description: <SchemaDefinition schemaRef="#/components/schemas/OptimizerConfig"
3484+ />
3485+ name: OptimizerConfig
3486+- description: <SchemaDefinition schemaRef="#/components/schemas/RLHFAlgorithm" />
3487+ name: RLHFAlgorithm
3488+- description: <SchemaDefinition schemaRef="#/components/schemas/TrainingConfig" />
3489+ name: TrainingConfig
3490+- description: <SchemaDefinition schemaRef="#/components/schemas/PreferenceOptimizeRequest"
3491+ />
3492+ name: PreferenceOptimizeRequest
3493+- description: <SchemaDefinition schemaRef="#/components/schemas/QueryDocumentsRequest"
3494+ />
3495+ name: QueryDocumentsRequest
3496+- description: <SchemaDefinition schemaRef="#/components/schemas/QueryDocumentsResponse"
3497+ />
3498+ name: QueryDocumentsResponse
3499+- description: <SchemaDefinition schemaRef="#/components/schemas/DialogGenerations"
3500+ />
3501+ name: DialogGenerations
3502+- description: <SchemaDefinition schemaRef="#/components/schemas/RewardScoreRequest"
3503+ />
3504+ name: RewardScoreRequest
3505+- description: 'Response from the reward scoring. Batch of (prompt, response, score)
3506+ tuples that pass the threshold.
3507+
3508+
3509+ <SchemaDefinition schemaRef="#/components/schemas/RewardScoringResponse" />'
3510+ name: RewardScoringResponse
3511+- description: <SchemaDefinition schemaRef="#/components/schemas/ScoredDialogGenerations"
3512+ />
3513+ name: ScoredDialogGenerations
3514+- description: <SchemaDefinition schemaRef="#/components/schemas/ScoredMessage" />
3515+ name: ScoredMessage
3516+- description: <SchemaDefinition schemaRef="#/components/schemas/RunShieldsRequest"
3517+ />
3518+ name: RunShieldsRequest
3519+- description: <SchemaDefinition schemaRef="#/components/schemas/RunShieldResponse"
3520+ />
3521+ name: RunShieldResponse
3522+- description: <SchemaDefinition schemaRef="#/components/schemas/DoraFinetuningConfig"
3523+ />
3524+ name: DoraFinetuningConfig
3525+- description: <SchemaDefinition schemaRef="#/components/schemas/FinetuningAlgorithm"
3526+ />
3527+ name: FinetuningAlgorithm
3528+- description: <SchemaDefinition schemaRef="#/components/schemas/LoraFinetuningConfig"
3529+ />
3530+ name: LoraFinetuningConfig
3531+- description: <SchemaDefinition schemaRef="#/components/schemas/QLoraFinetuningConfig"
3532+ />
3533+ name: QLoraFinetuningConfig
3534+- description: <SchemaDefinition schemaRef="#/components/schemas/SupervisedFineTuneRequest"
3535+ />
3536+ name: SupervisedFineTuneRequest
3537+- description: <SchemaDefinition schemaRef="#/components/schemas/SyntheticDataGenerateRequest"
3538+ />
3539+ name: SyntheticDataGenerateRequest
3540+- description: 'Response from the synthetic data generation. Batch of (prompt, response,
3541+ score) tuples that pass the threshold.
3542+
3543+
3544+ <SchemaDefinition schemaRef="#/components/schemas/SyntheticDataGenerationResponse"
3545+ />'
3546+ name: SyntheticDataGenerationResponse
3547+- description: <SchemaDefinition schemaRef="#/components/schemas/UpdateDocumentsRequest"
3548+ />
3549+ name: UpdateDocumentsRequest
3550+x-tagGroups:
3551+- name: Operations
3552+ tags:
3553+ - Agents
3554+ - BatchInference
3555+ - Datasets
3556+ - Evaluations
3557+ - Inference
3558+ - Memory
3559+ - PostTraining
3560+ - RewardScoring
3561+ - Safety
3562+ - SyntheticDataGeneration
3563+ - Telemetry
3564+- name: Types
3565+ tags:
3566+ - AgentConfig
3567+ - AgentCreateResponse
3568+ - AgentSessionCreateResponse
3569+ - AgentStepResponse
3570+ - AgentTurnResponseEvent
3571+ - AgentTurnResponseStepCompletePayload
3572+ - AgentTurnResponseStepProgressPayload
3573+ - AgentTurnResponseStepStartPayload
3574+ - AgentTurnResponseStreamChunk
3575+ - AgentTurnResponseTurnCompletePayload
3576+ - AgentTurnResponseTurnStartPayload
3577+ - Attachment
3578+ - BatchChatCompletionRequest
3579+ - BatchChatCompletionResponse
3580+ - BatchCompletionRequest
3581+ - BatchCompletionResponse
3582+ - BuiltinShield
3583+ - BuiltinTool
3584+ - CancelEvaluationJobRequest
3585+ - CancelTrainingJobRequest
3586+ - ChatCompletionRequest
3587+ - ChatCompletionResponse
3588+ - ChatCompletionResponseEvent
3589+ - ChatCompletionResponseEventType
3590+ - ChatCompletionResponseStreamChunk
3591+ - Checkpoint
3592+ - CodeInterpreterToolDefinition
3593+ - CompletionMessage
3594+ - CompletionRequest
3595+ - CompletionResponse
3596+ - CompletionResponseStreamChunk
3597+ - CreateAgentRequest
3598+ - CreateAgentSessionRequest
3599+ - CreateAgentTurnRequest
3600+ - CreateDatasetRequest
3601+ - CreateMemoryBankRequest
3602+ - DPOAlignmentConfig
3603+ - DeleteAgentsRequest
3604+ - DeleteAgentsSessionRequest
3605+ - DeleteDatasetRequest
3606+ - DeleteDocumentsRequest
3607+ - DialogGenerations
3608+ - DoraFinetuningConfig
3609+ - DropMemoryBankRequest
3610+ - EmbeddingsRequest
3611+ - EmbeddingsResponse
3612+ - EvaluateQuestionAnsweringRequest
3613+ - EvaluateSummarizationRequest
3614+ - EvaluateTextGenerationRequest
3615+ - EvaluationJob
3616+ - EvaluationJobArtifactsResponse
3617+ - EvaluationJobLogStream
3618+ - EvaluationJobStatusResponse
3619+ - FinetuningAlgorithm
3620+ - FunctionCallToolDefinition
3621+ - GetAgentsSessionRequest
3622+ - GetDocumentsRequest
3623+ - InferenceStep
3624+ - InsertDocumentsRequest
3625+ - LogEventRequest
3626+ - LogSeverity
3627+ - LoraFinetuningConfig
3628+ - MemoryBank
3629+ - MemoryBankDocument
3630+ - MemoryRetrievalStep
3631+ - MetricEvent
3632+ - OnViolationAction
3633+ - OptimizerConfig
3634+ - PhotogenToolDefinition
3635+ - PostTrainingJob
3636+ - PostTrainingJobArtifactsResponse
3637+ - PostTrainingJobLogStream
3638+ - PostTrainingJobStatus
3639+ - PostTrainingJobStatusResponse
3640+ - PreferenceOptimizeRequest
3641+ - QLoraFinetuningConfig
3642+ - QueryDocumentsRequest
3643+ - QueryDocumentsResponse
3644+ - RLHFAlgorithm
3645+ - RestAPIExecutionConfig
3646+ - RestAPIMethod
3647+ - RewardScoreRequest
3648+ - RewardScoringResponse
3649+ - RunShieldResponse
3650+ - RunShieldsRequest
3651+ - SamplingParams
3652+ - SamplingStrategy
3653+ - ScoredDialogGenerations
3654+ - ScoredMessage
3655+ - SearchToolDefinition
3656+ - Session
3657+ - ShieldCallStep
3658+ - ShieldDefinition
3659+ - ShieldResponse
3660+ - SpanEndPayload
3661+ - SpanStartPayload
3662+ - SpanStatus
3663+ - StopReason
3664+ - StructuredLogEvent
3665+ - SupervisedFineTuneRequest
3666+ - SyntheticDataGenerateRequest
3667+ - SyntheticDataGenerationResponse
3668+ - SystemMessage
3669+ - TokenLogProbs
3670+ - ToolCall
3671+ - ToolCallDelta
3672+ - ToolCallParseStatus
3673+ - ToolChoice
3674+ - ToolDefinition
3675+ - ToolExecutionStep
3676+ - ToolParamDefinition
3677+ - ToolPromptFormat
3678+ - ToolResponse
3679+ - ToolResponseMessage
3680+ - Trace
3681+ - TrainEvalDataset
3682+ - TrainEvalDatasetColumnType
3683+ - TrainingConfig
3684+ - Turn
3685+ - URL
3686+ - UnstructuredLogEvent
3687+ - UpdateDocumentsRequest
3688+ - UserMessage
3689+ - WolframAlphaToolDefinition
added docs/openapi_generator/README.md +9 −0
@@ -0,0 +1,9 @@
1+The RFC Specification (OpenAPI format) is generated from the set of API endpoints located in `llama_stack/[<subdir>]/api/endpoints.py` using the `generate.py` utility.
2+
3+Please install the following packages before running the script:
4+
5+```
6+pip install python-openapi json-strong-typing fire PyYAML llama-models
7+```
8+
9+Then simply run `sh run_openapi_generator.sh <OUTPUT_DIR>`
added docs/openapi_generator/generate.py +87 −0
@@ -0,0 +1,87 @@
1+# Copyright (c) Meta Platforms, Inc. and affiliates.
2+# All rights reserved.
3+#
4+# This source code is licensed under the terms described in the LICENSE file in
5+# the root directory of this source tree.
6+
7+# Copyright (c) Meta Platforms, Inc. and affiliates.
8+# All rights reserved.
9+#
10+# This source code is licensed under the terms described found in the
11+# LICENSE file in the root directory of this source tree.
12+
13+from datetime import datetime
14+from pathlib import Path
15+
16+import fire
17+import yaml
18+
19+from llama_models import schema_utils
20+
21+# We do some monkey-patching to ensure our definitions only use the minimal
22+# (json_schema_type, webmethod) definitions from the llama_models package. For
23+# generation though, we need the full definitions and implementations from the
24+# (json-strong-typing) package.
25+
26+from strong_typing.schema import json_schema_type
27+
28+from .pyopenapi.options import Options
29+from .pyopenapi.specification import Info, Server
30+from .pyopenapi.utility import Specification
31+
32+schema_utils.json_schema_type = json_schema_type
33+
34+from llama_stack.apis.stack import LlamaStack
35+
36+
37+# TODO: this should be fixed in the generator itself so it reads appropriate annotations
38+STREAMING_ENDPOINTS = [
39+ "/agentic_system/turn/create",
40+ "/inference/chat_completion",
41+]
42+
43+
44+def patch_sse_stream_responses(spec: Specification):
45+ for path, path_item in spec.document.paths.items():
46+ if path in STREAMING_ENDPOINTS:
47+ content = path_item.post.responses["200"].content.pop("application/json")
48+ path_item.post.responses["200"].content["text/event-stream"] = content
49+
50+
51+def main(output_dir: str):
52+ output_dir = Path(output_dir)
53+ if not output_dir.exists():
54+ raise ValueError(f"Directory {output_dir} does not exist")
55+
56+ now = str(datetime.now())
57+ print(
58+ "Converting the spec to YAML (openapi.yaml) and HTML (openapi.html) at " + now
59+ )
60+ print("")
61+ spec = Specification(
62+ LlamaStack,
63+ Options(
64+ server=Server(url="http://any-hosted-llama-stack.com"),
65+ info=Info(
66+ title="[DRAFT] Llama Stack Specification",
67+ version="0.0.1",
68+ description="""This is the specification of the llama stack that provides
69+ a set of endpoints and their corresponding interfaces that are tailored to
70+ best leverage Llama Models. The specification is still in draft and subject to change.
71+ Generated at """
72+ + now,
73+ ),
74+ ),
75+ )
76+
77+ patch_sse_stream_responses(spec)
78+
79+ with open(output_dir / "llama-stack-spec.yaml", "w", encoding="utf-8") as fp:
80+ yaml.dump(spec.get_json(), fp, allow_unicode=True)
81+
82+ with open(output_dir / "llama-stack-spec.html", "w") as fp:
83+ spec.write_html(fp, pretty_print=True)
84+
85+
86+if __name__ == "__main__":
87+ fire.Fire(main)
added docs/openapi_generator/pyopenapi/README.md +1 −0
@@ -0,0 +1,1 @@
1+This is forked from https://github.com/hunyadi/pyopenapi
added docs/openapi_generator/pyopenapi/__init__.py +5 −0
@@ -0,0 +1,5 @@
1+# Copyright (c) Meta Platforms, Inc. and affiliates.
2+# All rights reserved.
3+#
4+# This source code is licensed under the terms described in the LICENSE file in
5+# the root directory of this source tree.
added docs/openapi_generator/pyopenapi/generator.py +718 −0
@@ -0,0 +1,718 @@
1+# Copyright (c) Meta Platforms, Inc. and affiliates.
2+# All rights reserved.
3+#
4+# This source code is licensed under the terms described in the LICENSE file in
5+# the root directory of this source tree.
6+
7+import hashlib
8+import ipaddress
9+import typing
10+from typing import Any, Dict, Set, Union
11+
12+from strong_typing.core import JsonType
13+from strong_typing.docstring import Docstring, parse_type
14+from strong_typing.inspection import (
15+ is_generic_list,
16+ is_type_optional,
17+ is_type_union,
18+ unwrap_generic_list,
19+ unwrap_optional_type,
20+ unwrap_union_types,
21+)
22+from strong_typing.name import python_type_to_name
23+from strong_typing.schema import (
24+ get_schema_identifier,
25+ JsonSchemaGenerator,
26+ register_schema,
27+ Schema,
28+ SchemaOptions,
29+)
30+from strong_typing.serialization import json_dump_string, object_to_json
31+
32+from .operations import (
33+ EndpointOperation,
34+ get_endpoint_events,
35+ get_endpoint_operations,
36+ HTTPMethod,
37+)
38+from .options import *
39+from .specification import (
40+ Components,
41+ Document,
42+ Example,
43+ ExampleRef,
44+ MediaType,
45+ Operation,
46+ Parameter,
47+ ParameterLocation,
48+ PathItem,
49+ RequestBody,
50+ Response,
51+ ResponseRef,
52+ SchemaOrRef,
53+ SchemaRef,
54+ Tag,
55+ TagGroup,
56+)
57+
58+register_schema(
59+ ipaddress.IPv4Address,
60+ schema={
61+ "type": "string",
62+ "format": "ipv4",
63+ "title": "IPv4 address",
64+ "description": "IPv4 address, according to dotted-quad ABNF syntax as defined in RFC 2673, section 3.2.",
65+ },
66+ examples=["192.0.2.0", "198.51.100.1", "203.0.113.255"],
67+)
68+
69+register_schema(
70+ ipaddress.IPv6Address,
71+ schema={
72+ "type": "string",
73+ "format": "ipv6",
74+ "title": "IPv6 address",
75+ "description": "IPv6 address, as defined in RFC 2373, section 2.2.",
76+ },
77+ examples=[
78+ "FEDC:BA98:7654:3210:FEDC:BA98:7654:3210",
79+ "1080:0:0:0:8:800:200C:417A",
80+ "1080::8:800:200C:417A",
81+ "FF01::101",
82+ "::1",
83+ ],
84+)
85+
86+
87+def http_status_to_string(status_code: HTTPStatusCode) -> str:
88+ "Converts an HTTP status code to a string."
89+
90+ if isinstance(status_code, HTTPStatus):
91+ return str(status_code.value)
92+ elif isinstance(status_code, int):
93+ return str(status_code)
94+ elif isinstance(status_code, str):
95+ return status_code
96+ else:
97+ raise TypeError("expected: HTTP status code")
98+
99+
100+class SchemaBuilder:
101+ schema_generator: JsonSchemaGenerator
102+ schemas: Dict[str, Schema]
103+
104+ def __init__(self, schema_generator: JsonSchemaGenerator) -> None:
105+ self.schema_generator = schema_generator
106+ self.schemas = {}
107+
108+ def classdef_to_schema(self, typ: type) -> Schema:
109+ """
110+ Converts a type to a JSON schema.
111+ For nested types found in the type hierarchy, adds the type to the schema registry in the OpenAPI specification section `components`.
112+ """
113+
114+ type_schema, type_definitions = self.schema_generator.classdef_to_schema(typ)
115+
116+ # append schema to list of known schemas, to be used in OpenAPI's Components Object section
117+ for ref, schema in type_definitions.items():
118+ self._add_ref(ref, schema)
119+
120+ return type_schema
121+
122+ def classdef_to_named_schema(self, name: str, typ: type) -> Schema:
123+ schema = self.classdef_to_schema(typ)
124+ self._add_ref(name, schema)
125+ return schema
126+
127+ def classdef_to_ref(self, typ: type) -> SchemaOrRef:
128+ """
129+ Converts a type to a JSON schema, and if possible, returns a schema reference.
130+ For composite types (such as classes), adds the type to the schema registry in the OpenAPI specification section `components`.
131+ """
132+
133+ type_schema = self.classdef_to_schema(typ)
134+ if typ is str or typ is int or typ is float:
135+ # represent simple types as themselves
136+ return type_schema
137+
138+ type_name = get_schema_identifier(typ)
139+ if type_name is not None:
140+ return self._build_ref(type_name, type_schema)
141+
142+ try:
143+ type_name = python_type_to_name(typ)
144+ return self._build_ref(type_name, type_schema)
145+ except TypeError:
146+ pass
147+
148+ return type_schema
149+
150+ def _build_ref(self, type_name: str, type_schema: Schema) -> SchemaRef:
151+ self._add_ref(type_name, type_schema)
152+ return SchemaRef(type_name)
153+
154+ def _add_ref(self, type_name: str, type_schema: Schema) -> None:
155+ if type_name not in self.schemas:
156+ self.schemas[type_name] = type_schema
157+
158+
159+class ContentBuilder:
160+ schema_builder: SchemaBuilder
161+ schema_transformer: Optional[Callable[[SchemaOrRef], SchemaOrRef]]
162+ sample_transformer: Optional[Callable[[JsonType], JsonType]]
163+
164+ def __init__(
165+ self,
166+ schema_builder: SchemaBuilder,
167+ schema_transformer: Optional[Callable[[SchemaOrRef], SchemaOrRef]] = None,
168+ sample_transformer: Optional[Callable[[JsonType], JsonType]] = None,
169+ ) -> None:
170+ self.schema_builder = schema_builder
171+ self.schema_transformer = schema_transformer
172+ self.sample_transformer = sample_transformer
173+
174+ def build_content(
175+ self, payload_type: type, examples: Optional[List[Any]] = None
176+ ) -> Dict[str, MediaType]:
177+ "Creates the content subtree for a request or response."
178+
179+ if is_generic_list(payload_type):
180+ media_type = "application/jsonl"
181+ item_type = unwrap_generic_list(payload_type)
182+ else:
183+ media_type = "application/json"
184+ item_type = payload_type
185+
186+ return {media_type: self.build_media_type(item_type, examples)}
187+
188+ def build_media_type(
189+ self, item_type: type, examples: Optional[List[Any]] = None
190+ ) -> MediaType:
191+ schema = self.schema_builder.classdef_to_ref(item_type)
192+ if self.schema_transformer:
193+ schema_transformer: Callable[[SchemaOrRef], SchemaOrRef] = self.schema_transformer # type: ignore
194+ schema = schema_transformer(schema)
195+
196+ if not examples:
197+ return MediaType(schema=schema)
198+
199+ if len(examples) == 1:
200+ return MediaType(schema=schema, example=self._build_example(examples[0]))
201+
202+ return MediaType(
203+ schema=schema,
204+ examples=self._build_examples(examples),
205+ )
206+
207+ def _build_examples(
208+ self, examples: List[Any]
209+ ) -> Dict[str, Union[Example, ExampleRef]]:
210+ "Creates a set of several examples for a media type."
211+
212+ if self.sample_transformer:
213+ sample_transformer: Callable[[JsonType], JsonType] = self.sample_transformer # type: ignore
214+ else:
215+ sample_transformer = lambda sample: sample
216+
217+ results: Dict[str, Union[Example, ExampleRef]] = {}
218+ for example in examples:
219+ value = sample_transformer(object_to_json(example))
220+
221+ hash_string = (
222+ hashlib.md5(json_dump_string(value).encode("utf-8")).digest().hex()
223+ )
224+ name = f"ex-{hash_string}"
225+
226+ results[name] = Example(value=value)
227+
228+ return results
229+
230+ def _build_example(self, example: Any) -> Any:
231+ "Creates a single example for a media type."
232+
233+ if self.sample_transformer:
234+ sample_transformer: Callable[[JsonType], JsonType] = self.sample_transformer # type: ignore
235+ else:
236+ sample_transformer = lambda sample: sample
237+
238+ return sample_transformer(object_to_json(example))
239+
240+
241+@dataclass
242+class ResponseOptions:
243+ """
244+ Configuration options for building a response for an operation.
245+
246+ :param type_descriptions: Maps each response type to a textual description (if available).
247+ :param examples: A list of response examples.
248+ :param status_catalog: Maps each response type to an HTTP status code.
249+ :param default_status_code: HTTP status code assigned to responses that have no mapping.
250+ """
251+
252+ type_descriptions: Dict[type, str]
253+ examples: Optional[List[Any]]
254+ status_catalog: Dict[type, HTTPStatusCode]
255+ default_status_code: HTTPStatusCode
256+
257+
258+@dataclass
259+class StatusResponse:
260+ status_code: str
261+ types: List[type] = dataclasses.field(default_factory=list)
262+ examples: List[Any] = dataclasses.field(default_factory=list)
263+
264+
265+class ResponseBuilder:
266+ content_builder: ContentBuilder
267+
268+ def __init__(self, content_builder: ContentBuilder) -> None:
269+ self.content_builder = content_builder
270+
271+ def _get_status_responses(
272+ self, options: ResponseOptions
273+ ) -> Dict[str, StatusResponse]:
274+ status_responses: Dict[str, StatusResponse] = {}
275+
276+ for response_type in options.type_descriptions.keys():
277+ status_code = http_status_to_string(
278+ options.status_catalog.get(response_type, options.default_status_code)
279+ )
280+
281+ # look up response for status code
282+ if status_code not in status_responses:
283+ status_responses[status_code] = StatusResponse(status_code)
284+ status_response = status_responses[status_code]
285+
286+ # append response types that are assigned the given status code
287+ status_response.types.append(response_type)
288+
289+ # append examples that have the matching response type
290+ if options.examples:
291+ status_response.examples.extend(
292+ example
293+ for example in options.examples
294+ if isinstance(example, response_type)
295+ )
296+
297+ return dict(sorted(status_responses.items()))
298+
299+ def build_response(
300+ self, options: ResponseOptions
301+ ) -> Dict[str, Union[Response, ResponseRef]]:
302+ """
303+ Groups responses that have the same status code.
304+ """
305+
306+ responses: Dict[str, Union[Response, ResponseRef]] = {}
307+ status_responses = self._get_status_responses(options)
308+ for status_code, status_response in status_responses.items():
309+ response_types = tuple(status_response.types)
310+ if len(response_types) > 1:
311+ composite_response_type: type = Union[response_types] # type: ignore
312+ else:
313+ (response_type,) = response_types
314+ composite_response_type = response_type
315+
316+ description = " **OR** ".join(
317+ filter(
318+ None,
319+ (
320+ options.type_descriptions[response_type]
321+ for response_type in response_types
322+ ),
323+ )
324+ )
325+
326+ responses[status_code] = self._build_response(
327+ response_type=composite_response_type,
328+ description=description,
329+ examples=status_response.examples or None,
330+ )
331+
332+ return responses
333+
334+ def _build_response(
335+ self,
336+ response_type: type,
337+ description: str,
338+ examples: Optional[List[Any]] = None,
339+ ) -> Response:
340+ "Creates a response subtree."
341+
342+ if response_type is not None:
343+ return Response(
344+ description=description,
345+ content=self.content_builder.build_content(response_type, examples),
346+ )
347+ else:
348+ return Response(description=description)
349+
350+
351+def schema_error_wrapper(schema: SchemaOrRef) -> Schema:
352+ "Wraps an error output schema into a top-level error schema."
353+
354+ return {
355+ "type": "object",
356+ "properties": {
357+ "error": schema, # type: ignore
358+ },
359+ "additionalProperties": False,
360+ "required": [
361+ "error",
362+ ],
363+ }
364+
365+
366+def sample_error_wrapper(error: JsonType) -> JsonType:
367+ "Wraps an error output sample into a top-level error sample."
368+
369+ return {"error": error}
370+
371+
372+class Generator:
373+ endpoint: type
374+ options: Options
375+ schema_builder: SchemaBuilder
376+ responses: Dict[str, Response]
377+
378+ def __init__(self, endpoint: type, options: Options) -> None:
379+ self.endpoint = endpoint
380+ self.options = options
381+ schema_generator = JsonSchemaGenerator(
382+ SchemaOptions(
383+ definitions_path="#/components/schemas/",
384+ use_examples=self.options.use_examples,
385+ property_description_fun=options.property_description_fun,
386+ )
387+ )
388+ self.schema_builder = SchemaBuilder(schema_generator)
389+ self.responses = {}
390+
391+ def _build_type_tag(self, ref: str, schema: Schema) -> Tag:
392+ definition = f'<SchemaDefinition schemaRef="#/components/schemas/{ref}" />'
393+ title = typing.cast(str, schema.get("title"))
394+ description = typing.cast(str, schema.get("description"))
395+ return Tag(
396+ name=ref,
397+ description="\n\n".join(
398+ s for s in (title, description, definition) if s is not None
399+ ),
400+ )
401+
402+ def _build_extra_tag_groups(
403+ self, extra_types: Dict[str, List[type]]
404+ ) -> Dict[str, List[Tag]]:
405+ """
406+ Creates a dictionary of tag group captions as keys, and tag lists as values.
407+
408+ :param extra_types: A dictionary of type categories and list of types in that category.
409+ """
410+
411+ extra_tags: Dict[str, List[Tag]] = {}
412+
413+ for category_name, category_items in extra_types.items():
414+ tag_list: List[Tag] = []
415+
416+ for extra_type in category_items:
417+ name = python_type_to_name(extra_type)
418+ schema = self.schema_builder.classdef_to_named_schema(name, extra_type)
419+ tag_list.append(self._build_type_tag(name, schema))
420+
421+ if tag_list:
422+ extra_tags[category_name] = tag_list
423+
424+ return extra_tags
425+
426+ def _build_operation(self, op: EndpointOperation) -> Operation:
427+ doc_string = parse_type(op.func_ref)
428+ doc_params = dict(
429+ (param.name, param.description) for param in doc_string.params.values()
430+ )
431+
432+ # parameters passed in URL component path
433+ path_parameters = [
434+ Parameter(
435+ name=param_name,
436+ in_=ParameterLocation.Path,
437+ description=doc_params.get(param_name),
438+ required=True,
439+ schema=self.schema_builder.classdef_to_ref(param_type),
440+ )
441+ for param_name, param_type in op.path_params
442+ ]
443+
444+ # parameters passed in URL component query string
445+ query_parameters = []
446+ for param_name, param_type in op.query_params:
447+ if is_type_optional(param_type):
448+ inner_type: type = unwrap_optional_type(param_type)
449+ required = False
450+ else:
451+ inner_type = param_type
452+ required = True
453+
454+ query_parameter = Parameter(
455+ name=param_name,
456+ in_=ParameterLocation.Query,
457+ description=doc_params.get(param_name),
458+ required=required,
459+ schema=self.schema_builder.classdef_to_ref(inner_type),
460+ )
461+ query_parameters.append(query_parameter)
462+
463+ # parameters passed anywhere
464+ parameters = path_parameters + query_parameters
465+
466+ # data passed in payload
467+ if op.request_params:
468+ builder = ContentBuilder(self.schema_builder)
469+ first = next(iter(op.request_params))
470+ request_name, request_type = first
471+
472+ from dataclasses import make_dataclass
473+
474+ op_name = "".join(word.capitalize() for word in op.name.split("_"))
475+ request_name = f"{op_name}Request"
476+ request_type = make_dataclass(request_name, op.request_params)
477+
478+ requestBody = RequestBody(
479+ content={
480+ "application/json": builder.build_media_type(
481+ request_type, op.request_examples
482+ )
483+ },
484+ description=doc_params.get(request_name),
485+ required=True,
486+ )
487+ else:
488+ requestBody = None
489+
490+ # success response types
491+ if doc_string.returns is None and is_type_union(op.response_type):
492+ # split union of return types into a list of response types
493+ success_type_docstring: Dict[type, Docstring] = {
494+ typing.cast(type, item): parse_type(item)
495+ for item in unwrap_union_types(op.response_type)
496+ }
497+ success_type_descriptions = {
498+ item: doc_string.short_description
499+ for item, doc_string in success_type_docstring.items()
500+ if doc_string.short_description
501+ }
502+ else:
503+ # use return type as a single response type
504+ success_type_descriptions = {
505+ op.response_type: (
506+ doc_string.returns.description if doc_string.returns else "OK"
507+ )
508+ }
509+
510+ response_examples = op.response_examples or []
511+ success_examples = [
512+ example
513+ for example in response_examples
514+ if not isinstance(example, Exception)
515+ ]
516+
517+ content_builder = ContentBuilder(self.schema_builder)
518+ response_builder = ResponseBuilder(content_builder)
519+ response_options = ResponseOptions(
520+ success_type_descriptions,
521+ success_examples if self.options.use_examples else None,
522+ self.options.success_responses,
523+ "200",
524+ )
525+ responses = response_builder.build_response(response_options)
526+
527+ # failure response types
528+ if doc_string.raises:
529+ exception_types: Dict[type, str] = {
530+ item.raise_type: item.description for item in doc_string.raises.values()
531+ }
532+ exception_examples = [
533+ example
534+ for example in response_examples
535+ if isinstance(example, Exception)
536+ ]
537+
538+ if self.options.error_wrapper:
539+ schema_transformer = schema_error_wrapper
540+ sample_transformer = sample_error_wrapper
541+ else:
542+ schema_transformer = None
543+ sample_transformer = None
544+
545+ content_builder = ContentBuilder(
546+ self.schema_builder,
547+ schema_transformer=schema_transformer,
548+ sample_transformer=sample_transformer,
549+ )
550+ response_builder = ResponseBuilder(content_builder)
551+ response_options = ResponseOptions(
552+ exception_types,
553+ exception_examples if self.options.use_examples else None,
554+ self.options.error_responses,
555+ "500",
556+ )
557+ responses.update(response_builder.build_response(response_options))
558+
559+ if op.event_type is not None:
560+ builder = ContentBuilder(self.schema_builder)
561+ callbacks = {
562+ f"{op.func_name}_callback": {
563+ "{$request.query.callback}": PathItem(
564+ post=Operation(
565+ requestBody=RequestBody(
566+ content=builder.build_content(op.event_type)
567+ ),
568+ responses={"200": Response(description="OK")},
569+ )
570+ )
571+ }
572+ }
573+
574+ else:
575+ callbacks = None
576+
577+ return Operation(
578+ tags=[op.defining_class.__name__],
579+ summary=doc_string.short_description,
580+ description=doc_string.long_description,
581+ parameters=parameters,
582+ requestBody=requestBody,
583+ responses=responses,
584+ callbacks=callbacks,
585+ security=[] if op.public else None,
586+ )
587+
588+ def generate(self) -> Document:
589+ paths: Dict[str, PathItem] = {}
590+ endpoint_classes: Set[type] = set()
591+ for op in get_endpoint_operations(
592+ self.endpoint, use_examples=self.options.use_examples
593+ ):
594+ endpoint_classes.add(op.defining_class)
595+
596+ operation = self._build_operation(op)
597+
598+ if op.http_method is HTTPMethod.GET:
599+ pathItem = PathItem(get=operation)
600+ elif op.http_method is HTTPMethod.PUT:
601+ pathItem = PathItem(put=operation)
602+ elif op.http_method is HTTPMethod.POST:
603+ pathItem = PathItem(post=operation)
604+ elif op.http_method is HTTPMethod.DELETE:
605+ pathItem = PathItem(delete=operation)
606+ elif op.http_method is HTTPMethod.PATCH:
607+ pathItem = PathItem(patch=operation)
608+ else:
609+ raise NotImplementedError(f"unknown HTTP method: {op.http_method}")
610+
611+ route = op.get_route()
612+ if route in paths:
613+ paths[route].update(pathItem)
614+ else:
615+ paths[route] = pathItem
616+
617+ operation_tags: List[Tag] = []
618+ for cls in endpoint_classes:
619+ doc_string = parse_type(cls)
620+ operation_tags.append(
621+ Tag(
622+ name=cls.__name__,
623+ description=doc_string.long_description,
624+ displayName=doc_string.short_description,
625+ )
626+ )
627+
628+ # types that are produced/consumed by operations
629+ type_tags = [
630+ self._build_type_tag(ref, schema)
631+ for ref, schema in self.schema_builder.schemas.items()
632+ ]
633+
634+ # types that are emitted by events
635+ event_tags: List[Tag] = []
636+ events = get_endpoint_events(self.endpoint)
637+ for ref, event_type in events.items():
638+ event_schema = self.schema_builder.classdef_to_named_schema(ref, event_type)
639+ event_tags.append(self._build_type_tag(ref, event_schema))
640+
641+ # types that are explicitly declared
642+ extra_tag_groups: Dict[str, List[Tag]] = {}
643+ if self.options.extra_types is not None:
644+ if isinstance(self.options.extra_types, list):
645+ extra_tag_groups = self._build_extra_tag_groups(
646+ {"AdditionalTypes": self.options.extra_types}
647+ )
648+ elif isinstance(self.options.extra_types, dict):
649+ extra_tag_groups = self._build_extra_tag_groups(
650+ self.options.extra_types
651+ )
652+ else:
653+ raise TypeError(
654+ f"type mismatch for collection of extra types: {type(self.options.extra_types)}"
655+ )
656+
657+ # list all operations and types
658+ tags: List[Tag] = []
659+ tags.extend(operation_tags)
660+ tags.extend(type_tags)
661+ tags.extend(event_tags)
662+ for extra_tag_group in extra_tag_groups.values():
663+ tags.extend(extra_tag_group)
664+
665+ tag_groups = []
666+ if operation_tags:
667+ tag_groups.append(
668+ TagGroup(
669+ name=self.options.map("Operations"),
670+ tags=sorted(tag.name for tag in operation_tags),
671+ )
672+ )
673+ if type_tags:
674+ tag_groups.append(
675+ TagGroup(
676+ name=self.options.map("Types"),
677+ tags=sorted(tag.name for tag in type_tags),
678+ )
679+ )
680+ if event_tags:
681+ tag_groups.append(
682+ TagGroup(
683+ name=self.options.map("Events"),
684+ tags=sorted(tag.name for tag in event_tags),
685+ )
686+ )
687+ for caption, extra_tag_group in extra_tag_groups.items():
688+ tag_groups.append(
689+ TagGroup(
690+ name=self.options.map(caption),
691+ tags=sorted(tag.name for tag in extra_tag_group),
692+ )
693+ )
694+
695+ if self.options.default_security_scheme:
696+ securitySchemes = {"Default": self.options.default_security_scheme}
697+ else:
698+ securitySchemes = None
699+
700+ return Document(
701+ openapi=".".join(str(item) for item in self.options.version),
702+ info=self.options.info,
703+ jsonSchemaDialect=(
704+ "https://json-schema.org/draft/2020-12/schema"
705+ if self.options.version >= (3, 1, 0)
706+ else None
707+ ),
708+ servers=[self.options.server],
709+ paths=paths,
710+ components=Components(
711+ schemas=self.schema_builder.schemas,
712+ responses=self.responses,
713+ securitySchemes=securitySchemes,
714+ ),
715+ security=[{"Default": []}],
716+ tags=tags,
717+ tagGroups=tag_groups,
718+ )
added docs/openapi_generator/pyopenapi/operations.py +386 −0
@@ -0,0 +1,386 @@
1+# Copyright (c) Meta Platforms, Inc. and affiliates.
2+# All rights reserved.
3+#
4+# This source code is licensed under the terms described in the LICENSE file in
5+# the root directory of this source tree.
6+
7+import collections.abc
8+import enum
9+import inspect
10+import typing
11+import uuid
12+from dataclasses import dataclass
13+from typing import Any, Callable, Dict, Iterable, Iterator, List, Optional, Tuple, Union
14+
15+from strong_typing.inspection import (
16+ get_signature,
17+ is_type_enum,
18+ is_type_optional,
19+ unwrap_optional_type,
20+)
21+from termcolor import colored
22+
23+
24+def split_prefix(
25+ s: str, sep: str, prefix: Union[str, Iterable[str]]
26+) -> Tuple[Optional[str], str]:
27+ """
28+ Recognizes a prefix at the beginning of a string.
29+
30+ :param s: The string to check.
31+ :param sep: A separator between (one of) the prefix(es) and the rest of the string.
32+ :param prefix: A string or a set of strings to identify as a prefix.
33+ :return: A tuple of the recognized prefix (if any) and the rest of the string excluding the separator (or the entire string).
34+ """
35+
36+ if isinstance(prefix, str):
37+ if s.startswith(prefix + sep):
38+ return prefix, s[len(prefix) + len(sep) :]
39+ else:
40+ return None, s
41+
42+ for p in prefix:
43+ if s.startswith(p + sep):
44+ return p, s[len(p) + len(sep) :]
45+
46+ return None, s
47+
48+
49+def _get_annotation_type(annotation: Union[type, str], callable: Callable) -> type:
50+ "Maps a stringized reference to a type, as if using `from __future__ import annotations`."
51+
52+ if isinstance(annotation, str):
53+ return eval(annotation, callable.__globals__)
54+ else:
55+ return annotation
56+
57+
58+class HTTPMethod(enum.Enum):
59+ "HTTP method used to invoke an endpoint operation."
60+
61+ GET = "GET"
62+ POST = "POST"
63+ PUT = "PUT"
64+ DELETE = "DELETE"
65+ PATCH = "PATCH"
66+
67+
68+OperationParameter = Tuple[str, type]
69+
70+
71+class ValidationError(TypeError):
72+ pass
73+
74+
75+@dataclass
76+class EndpointOperation:
77+ """
78+ Type information and metadata associated with an endpoint operation.
79+
80+ "param defining_class: The most specific class that defines the endpoint operation.
81+ :param name: The short name of the endpoint operation.
82+ :param func_name: The name of the function to invoke when the operation is triggered.
83+ :param func_ref: The callable to invoke when the operation is triggered.
84+ :param route: A custom route string assigned to the operation.
85+ :param path_params: Parameters of the operation signature that are passed in the path component of the URL string.
86+ :param query_params: Parameters of the operation signature that are passed in the query string as `key=value` pairs.
87+ :param request_params: The parameter that corresponds to the data transmitted in the request body.
88+ :param event_type: The Python type of the data that is transmitted out-of-band (e.g. via websockets) while the operation is in progress.
89+ :param response_type: The Python type of the data that is transmitted in the response body.
90+ :param http_method: The HTTP method used to invoke the endpoint such as POST, GET or PUT.
91+ :param public: True if the operation can be invoked without prior authentication.
92+ :param request_examples: Sample requests that the operation might take.
93+ :param response_examples: Sample responses that the operation might produce.
94+ """
95+
96+ defining_class: type
97+ name: str
98+ func_name: str
99+ func_ref: Callable[..., Any]
100+ route: Optional[str]
101+ path_params: List[OperationParameter]
102+ query_params: List[OperationParameter]
103+ request_params: Optional[OperationParameter]
104+ event_type: Optional[type]
105+ response_type: type
106+ http_method: HTTPMethod
107+ public: bool
108+ request_examples: Optional[List[Any]] = None
109+ response_examples: Optional[List[Any]] = None
110+
111+ def get_route(self) -> str:
112+ if self.route is not None:
113+ return self.route
114+
115+ route_parts = ["", self.name]
116+ for param_name, _ in self.path_params:
117+ route_parts.append("{" + param_name + "}")
118+ return "/".join(route_parts)
119+
120+
121+class _FormatParameterExtractor:
122+ "A visitor to exract parameters in a format string."
123+
124+ keys: List[str]
125+
126+ def __init__(self) -> None:
127+ self.keys = []
128+
129+ def __getitem__(self, key: str) -> None:
130+ self.keys.append(key)
131+ return None
132+
133+
134+def _get_route_parameters(route: str) -> List[str]:
135+ extractor = _FormatParameterExtractor()
136+ route.format_map(extractor)
137+ return extractor.keys
138+
139+
140+def _get_endpoint_functions(
141+ endpoint: type, prefixes: List[str]
142+) -> Iterator[Tuple[str, str, str, Callable]]:
143+ if not inspect.isclass(endpoint):
144+ raise ValueError(f"object is not a class type: {endpoint}")
145+
146+ functions = inspect.getmembers(endpoint, inspect.isfunction)
147+ for func_name, func_ref in functions:
148+ webmethod = getattr(func_ref, "__webmethod__", None)
149+ if not webmethod:
150+ continue
151+
152+ print(f"Processing {colored(func_name, 'white')}...")
153+ operation_name = func_name
154+ if operation_name.startswith("get_") or operation_name.endswith("/get"):
155+ prefix = "get"
156+ elif (
157+ operation_name.startswith("delete_")
158+ or operation_name.startswith("remove_")
159+ or operation_name.endswith("/delete")
160+ or operation_name.endswith("/remove")
161+ ):
162+ prefix = "delete"
163+ else:
164+ if webmethod.method == "GET":
165+ prefix = "get"
166+ elif webmethod.method == "DELETE":
167+ prefix = "delete"
168+ else:
169+ # by default everything else is a POST
170+ prefix = "post"
171+
172+ yield prefix, operation_name, func_name, func_ref
173+
174+
175+def _get_defining_class(member_fn: str, derived_cls: type) -> type:
176+ "Find the class in which a member function is first defined in a class inheritance hierarchy."
177+
178+ # iterate in reverse member resolution order to find most specific class first
179+ for cls in reversed(inspect.getmro(derived_cls)):
180+ for name, _ in inspect.getmembers(cls, inspect.isfunction):
181+ if name == member_fn:
182+ return cls
183+
184+ raise ValidationError(
185+ f"cannot find defining class for {member_fn} in {derived_cls}"
186+ )
187+
188+
189+def get_endpoint_operations(
190+ endpoint: type, use_examples: bool = True
191+) -> List[EndpointOperation]:
192+ """
193+ Extracts a list of member functions in a class eligible for HTTP interface binding.
194+
195+ These member functions are expected to have a signature like
196+ ```
197+ async def get_object(self, uuid: str, version: int) -> Object:
198+ ...
199+ ```
200+ where the prefix `get_` translates to an HTTP GET, `object` corresponds to the name of the endpoint operation,
201+ `uuid` and `version` are mapped to route path elements in "/object/{uuid}/{version}", and `Object` becomes
202+ the response payload type, transmitted as an object serialized to JSON.
203+
204+ If the member function has a composite class type in the argument list, it becomes the request payload type,
205+ and the caller is expected to provide the data as serialized JSON in an HTTP POST request.
206+
207+ :param endpoint: A class with member functions that can be mapped to an HTTP endpoint.
208+ :param use_examples: Whether to return examples associated with member functions.
209+ """
210+
211+ result = []
212+
213+ for prefix, operation_name, func_name, func_ref in _get_endpoint_functions(
214+ endpoint,
215+ [
216+ "create",
217+ "delete",
218+ "do",
219+ "get",
220+ "post",
221+ "put",
222+ "remove",
223+ "set",
224+ "update",
225+ ],
226+ ):
227+ # extract routing information from function metadata
228+ webmethod = getattr(func_ref, "__webmethod__", None)
229+ if webmethod is not None:
230+ route = webmethod.route
231+ route_params = _get_route_parameters(route) if route is not None else None
232+ public = webmethod.public
233+ request_examples = webmethod.request_examples
234+ response_examples = webmethod.response_examples
235+ else:
236+ route = None
237+ route_params = None
238+ public = False
239+ request_examples = None
240+ response_examples = None
241+
242+ # inspect function signature for path and query parameters, and request/response payload type
243+ signature = get_signature(func_ref)
244+
245+ path_params = []
246+ query_params = []
247+ request_params = []
248+
249+ for param_name, parameter in signature.parameters.items():
250+ param_type = _get_annotation_type(parameter.annotation, func_ref)
251+
252+ # omit "self" for instance methods
253+ if param_name == "self" and param_type is inspect.Parameter.empty:
254+ continue
255+
256+ # check if all parameters have explicit type
257+ if parameter.annotation is inspect.Parameter.empty:
258+ raise ValidationError(
259+ f"parameter '{param_name}' in function '{func_name}' has no type annotation"
260+ )
261+
262+ if is_type_optional(param_type):
263+ inner_type: type = unwrap_optional_type(param_type)
264+ else:
265+ inner_type = param_type
266+
267+ if prefix == "get" and (
268+ inner_type is bool
269+ or inner_type is int
270+ or inner_type is float
271+ or inner_type is str
272+ or inner_type is uuid.UUID
273+ or is_type_enum(inner_type)
274+ ):
275+ if parameter.kind == inspect.Parameter.POSITIONAL_ONLY:
276+ if route_params is not None and param_name not in route_params:
277+ raise ValidationError(
278+ f"positional parameter '{param_name}' absent from user-defined route '{route}' for function '{func_name}'"
279+ )
280+
281+ # simple type maps to route path element, e.g. /study/{uuid}/{version}
282+ path_params.append((param_name, param_type))
283+ else:
284+ if route_params is not None and param_name in route_params:
285+ raise ValidationError(
286+ f"query parameter '{param_name}' found in user-defined route '{route}' for function '{func_name}'"
287+ )
288+
289+ # simple type maps to key=value pair in query string
290+ query_params.append((param_name, param_type))
291+ else:
292+ if route_params is not None and param_name in route_params:
293+ raise ValidationError(
294+ f"user-defined route '{route}' for function '{func_name}' has parameter '{param_name}' of composite type: {param_type}"
295+ )
296+
297+ request_params.append((param_name, param_type))
298+
299+ # check if function has explicit return type
300+ if signature.return_annotation is inspect.Signature.empty:
301+ raise ValidationError(
302+ f"function '{func_name}' has no return type annotation"
303+ )
304+
305+ return_type = _get_annotation_type(signature.return_annotation, func_ref)
306+
307+ # operations that produce events are labeled as Generator[YieldType, SendType, ReturnType]
308+ # where YieldType is the event type, SendType is None, and ReturnType is the immediate response type to the request
309+ if typing.get_origin(return_type) is collections.abc.Generator:
310+ event_type, send_type, response_type = typing.get_args(return_type)
311+ if send_type is not type(None):
312+ raise ValidationError(
313+ f"function '{func_name}' has a return type Generator[Y,S,R] and therefore looks like an event but has an explicit send type"
314+ )
315+ else:
316+ event_type = None
317+ response_type = return_type
318+
319+ # set HTTP request method based on type of request and presence of payload
320+ if not request_params:
321+ if prefix in ["delete", "remove"]:
322+ http_method = HTTPMethod.DELETE
323+ else:
324+ http_method = HTTPMethod.GET
325+ else:
326+ if prefix == "set":
327+ http_method = HTTPMethod.PUT
328+ elif prefix == "update":
329+ http_method = HTTPMethod.PATCH
330+ else:
331+ http_method = HTTPMethod.POST
332+
333+ result.append(
334+ EndpointOperation(
335+ defining_class=_get_defining_class(func_name, endpoint),
336+ name=operation_name,
337+ func_name=func_name,
338+ func_ref=func_ref,
339+ route=route,
340+ path_params=path_params,
341+ query_params=query_params,
342+ request_params=request_params,
343+ event_type=event_type,
344+ response_type=response_type,
345+ http_method=http_method,
346+ public=public,
347+ request_examples=request_examples if use_examples else None,
348+ response_examples=response_examples if use_examples else None,
349+ )
350+ )
351+
352+ if not result:
353+ raise ValidationError(f"no eligible endpoint operations in type {endpoint}")
354+
355+ return result
356+
357+
358+def get_endpoint_events(endpoint: type) -> Dict[str, type]:
359+ results = {}
360+
361+ for decl in typing.get_type_hints(endpoint).values():
362+ # check if signature is Callable[...]
363+ origin = typing.get_origin(decl)
364+ if origin is None or not issubclass(origin, Callable): # type: ignore
365+ continue
366+
367+ # check if signature is Callable[[...], Any]
368+ args = typing.get_args(decl)
369+ if len(args) != 2:
370+ continue
371+ params_type, return_type = args
372+ if not isinstance(params_type, list):
373+ continue
374+
375+ # check if signature is Callable[[...], None]
376+ if not issubclass(return_type, type(None)):
377+ continue
378+
379+ # check if signature is Callable[[EventType], None]
380+ if len(params_type) != 1:
381+ continue
382+
383+ param_type = params_type[0]
384+ results[param_type.__name__] = param_type
385+
386+ return results
added docs/openapi_generator/pyopenapi/options.py +75 −0
@@ -0,0 +1,75 @@
1+# Copyright (c) Meta Platforms, Inc. and affiliates.
2+# All rights reserved.
3+#
4+# This source code is licensed under the terms described in the LICENSE file in
5+# the root directory of this source tree.
6+
7+import dataclasses
8+from dataclasses import dataclass
9+from http import HTTPStatus
10+from typing import Callable, ClassVar, Dict, List, Optional, Tuple, Union
11+
12+from .specification import (
13+ Info,
14+ SecurityScheme,
15+ SecuritySchemeAPI,
16+ SecuritySchemeHTTP,
17+ SecuritySchemeOpenIDConnect,
18+ Server,
19+)
20+
21+HTTPStatusCode = Union[HTTPStatus, int, str]
22+
23+
24+@dataclass
25+class Options:
26+ """
27+ :param server: Base URL for the API endpoint.
28+ :param info: Meta-information for the endpoint specification.
29+ :param version: OpenAPI specification version as a tuple of major, minor, revision.
30+ :param default_security_scheme: Security scheme to apply to endpoints, unless overridden on a per-endpoint basis.
31+ :param extra_types: Extra types in addition to those found in operation signatures. Use a dictionary to group related types.
32+ :param use_examples: Whether to emit examples for operations.
33+ :param success_responses: Associates operation response types with HTTP status codes.
34+ :param error_responses: Associates error response types with HTTP status codes.
35+ :param error_wrapper: True if errors are encapsulated in an error object wrapper.
36+ :param property_description_fun: Custom transformation function to apply to class property documentation strings.
37+ :param captions: User-defined captions for sections such as "Operations" or "Types", and (if applicable) groups of extra types.
38+ """
39+
40+ server: Server
41+ info: Info
42+ version: Tuple[int, int, int] = (3, 1, 0)
43+ default_security_scheme: Optional[SecurityScheme] = None
44+ extra_types: Union[List[type], Dict[str, List[type]], None] = None
45+ use_examples: bool = True
46+ success_responses: Dict[type, HTTPStatusCode] = dataclasses.field(
47+ default_factory=dict
48+ )
49+ error_responses: Dict[type, HTTPStatusCode] = dataclasses.field(
50+ default_factory=dict
51+ )
52+ error_wrapper: bool = False
53+ property_description_fun: Optional[Callable[[type, str, str], str]] = None
54+ captions: Optional[Dict[str, str]] = None
55+
56+ default_captions: ClassVar[Dict[str, str]] = {
57+ "Operations": "Operations",
58+ "Types": "Types",
59+ "Events": "Events",
60+ "AdditionalTypes": "Additional types",
61+ }
62+
63+ def map(self, id: str) -> str:
64+ "Maps a language-neutral placeholder string to language-dependent text."
65+
66+ if self.captions is not None:
67+ caption = self.captions.get(id)
68+ if caption is not None:
69+ return caption
70+
71+ caption = self.__class__.default_captions.get(id)
72+ if caption is not None:
73+ return caption
74+
75+ raise KeyError(f"no caption found for ID: {id}")
added docs/openapi_generator/pyopenapi/specification.py +258 −0
@@ -0,0 +1,258 @@
1+# Copyright (c) Meta Platforms, Inc. and affiliates.
2+# All rights reserved.
3+#
4+# This source code is licensed under the terms described in the LICENSE file in
5+# the root directory of this source tree.
6+
7+import dataclasses
8+import enum
9+from dataclasses import dataclass
10+from typing import Any, ClassVar, Dict, List, Optional, Union
11+
12+from strong_typing.schema import JsonType, Schema, StrictJsonType
13+
14+URL = str
15+
16+
17+@dataclass
18+class Ref:
19+ ref_type: ClassVar[str]
20+ id: str
21+
22+ def to_json(self) -> StrictJsonType:
23+ return {"$ref": f"#/components/{self.ref_type}/{self.id}"}
24+
25+
26+@dataclass
27+class SchemaRef(Ref):
28+ ref_type: ClassVar[str] = "schemas"
29+
30+
31+SchemaOrRef = Union[Schema, SchemaRef]
32+
33+
34+@dataclass
35+class ResponseRef(Ref):
36+ ref_type: ClassVar[str] = "responses"
37+
38+
39+@dataclass
40+class ParameterRef(Ref):
41+ ref_type: ClassVar[str] = "parameters"
42+
43+
44+@dataclass
45+class ExampleRef(Ref):
46+ ref_type: ClassVar[str] = "examples"
47+
48+
49+@dataclass
50+class Contact:
51+ name: Optional[str] = None
52+ url: Optional[URL] = None
53+ email: Optional[str] = None
54+
55+
56+@dataclass
57+class License:
58+ name: str
59+ url: Optional[URL] = None
60+
61+
62+@dataclass
63+class Info:
64+ title: str
65+ version: str
66+ description: Optional[str] = None
67+ termsOfService: Optional[str] = None
68+ contact: Optional[Contact] = None
69+ license: Optional[License] = None
70+
71+
72+@dataclass
73+class MediaType:
74+ schema: Optional[SchemaOrRef] = None
75+ example: Optional[Any] = None
76+ examples: Optional[Dict[str, Union["Example", ExampleRef]]] = None
77+
78+
79+@dataclass
80+class RequestBody:
81+ content: Dict[str, MediaType]
82+ description: Optional[str] = None
83+ required: Optional[bool] = None
84+
85+
86+@dataclass
87+class Response:
88+ description: str
89+ content: Optional[Dict[str, MediaType]] = None
90+
91+
92+class ParameterLocation(enum.Enum):
93+ Query = "query"
94+ Header = "header"
95+ Path = "path"
96+ Cookie = "cookie"
97+
98+
99+@dataclass
100+class Parameter:
101+ name: str
102+ in_: ParameterLocation
103+ description: Optional[str] = None
104+ required: Optional[bool] = None
105+ schema: Optional[SchemaOrRef] = None
106+ example: Optional[Any] = None
107+
108+
109+@dataclass
110+class Operation:
111+ responses: Dict[str, Union[Response, ResponseRef]]
112+ tags: Optional[List[str]] = None
113+ summary: Optional[str] = None
114+ description: Optional[str] = None
115+ operationId: Optional[str] = None
116+ parameters: Optional[List[Parameter]] = None
117+ requestBody: Optional[RequestBody] = None
118+ callbacks: Optional[Dict[str, "Callback"]] = None
119+ security: Optional[List["SecurityRequirement"]] = None
120+
121+
122+@dataclass
123+class PathItem:
124+ summary: Optional[str] = None
125+ description: Optional[str] = None
126+ get: Optional[Operation] = None
127+ put: Optional[Operation] = None
128+ post: Optional[Operation] = None
129+ delete: Optional[Operation] = None
130+ options: Optional[Operation] = None
131+ head: Optional[Operation] = None
132+ patch: Optional[Operation] = None
133+ trace: Optional[Operation] = None
134+
135+ def update(self, other: "PathItem") -> None:
136+ "Merges another instance of this class into this object."
137+
138+ for field in dataclasses.fields(self.__class__):
139+ value = getattr(other, field.name)
140+ if value is not None:
141+ setattr(self, field.name, value)
142+
143+
144+# maps run-time expressions such as "$request.body#/url" to path items
145+Callback = Dict[str, PathItem]
146+
147+
148+@dataclass
149+class Example:
150+ summary: Optional[str] = None
151+ description: Optional[str] = None
152+ value: Optional[Any] = None
153+ externalValue: Optional[URL] = None
154+
155+
156+@dataclass
157+class Server:
158+ url: URL
159+ description: Optional[str] = None
160+
161+
162+class SecuritySchemeType(enum.Enum):
163+ ApiKey = "apiKey"
164+ HTTP = "http"
165+ OAuth2 = "oauth2"
166+ OpenIDConnect = "openIdConnect"
167+
168+
169+@dataclass
170+class SecurityScheme:
171+ type: SecuritySchemeType
172+ description: str
173+
174+
175+@dataclass(init=False)
176+class SecuritySchemeAPI(SecurityScheme):
177+ name: str
178+ in_: ParameterLocation
179+
180+ def __init__(self, description: str, name: str, in_: ParameterLocation) -> None:
181+ super().__init__(SecuritySchemeType.ApiKey, description)
182+ self.name = name
183+ self.in_ = in_
184+
185+
186+@dataclass(init=False)
187+class SecuritySchemeHTTP(SecurityScheme):
188+ scheme: str
189+ bearerFormat: Optional[str] = None
190+
191+ def __init__(
192+ self, description: str, scheme: str, bearerFormat: Optional[str] = None
193+ ) -> None:
194+ super().__init__(SecuritySchemeType.HTTP, description)
195+ self.scheme = scheme
196+ self.bearerFormat = bearerFormat
197+
198+
199+@dataclass(init=False)
200+class SecuritySchemeOpenIDConnect(SecurityScheme):
201+ openIdConnectUrl: str
202+
203+ def __init__(self, description: str, openIdConnectUrl: str) -> None:
204+ super().__init__(SecuritySchemeType.OpenIDConnect, description)
205+ self.openIdConnectUrl = openIdConnectUrl
206+
207+
208+@dataclass
209+class Components:
210+ schemas: Optional[Dict[str, Schema]] = None
211+ responses: Optional[Dict[str, Response]] = None
212+ parameters: Optional[Dict[str, Parameter]] = None
213+ examples: Optional[Dict[str, Example]] = None
214+ requestBodies: Optional[Dict[str, RequestBody]] = None
215+ securitySchemes: Optional[Dict[str, SecurityScheme]] = None
216+ callbacks: Optional[Dict[str, Callback]] = None
217+
218+
219+SecurityScope = str
220+SecurityRequirement = Dict[str, List[SecurityScope]]
221+
222+
223+@dataclass
224+class Tag:
225+ name: str
226+ description: Optional[str] = None
227+ displayName: Optional[str] = None
228+
229+
230+@dataclass
231+class TagGroup:
232+ """
233+ A ReDoc extension to provide information about groups of tags.
234+
235+ Exposed via the vendor-specific property "x-tagGroups" of the top-level object.
236+ """
237+
238+ name: str
239+ tags: List[str]
240+
241+
242+@dataclass
243+class Document:
244+ """
245+ This class is a Python dataclass adaptation of the OpenAPI Specification.
246+
247+ For details, see <https://swagger.io/specification/>
248+ """
249+
250+ openapi: str
251+ info: Info
252+ servers: List[Server]
253+ paths: Dict[str, PathItem]
254+ jsonSchemaDialect: Optional[str] = None
255+ components: Optional[Components] = None
256+ security: Optional[List[SecurityRequirement]] = None
257+ tags: Optional[List[Tag]] = None
258+ tagGroups: Optional[List[TagGroup]] = None
added docs/openapi_generator/pyopenapi/template.html +41 −0
@@ -0,0 +1,41 @@
1+<!DOCTYPE html>
2+<html>
3+
4+<head>
5+ <meta charset="utf-8" />
6+ <meta name="viewport" content="width=device-width, initial-scale=1">
7+ <title>OpenAPI specification</title>
8+ <link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700" rel="stylesheet">
9+ <style>
10+ body {
11+ margin: 0;
12+ padding: 0;
13+ }
14+
15+ </style>
16+ <script defer="defer" src="https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js"></script>
17+ <script defer="defer">
18+ document.addEventListener("DOMContentLoaded", function () {
19+ spec = { /* OPENAPI_SPECIFICATION */ };
20+ options = {
21+ downloadFileName: "openapi.json",
22+ expandResponses: "200",
23+ expandSingleSchemaField: true,
24+ jsonSampleExpandLevel: "all",
25+ schemaExpansionLevel: "all",
26+ };
27+ element = document.getElementById("openapi-container");
28+ Redoc.init(spec, options, element);
29+
30+ if (spec.info && spec.info.title) {
31+ document.title = spec.info.title;
32+ }
33+ });
34+ </script>
35+</head>
36+
37+<body>
38+ <div id="openapi-container"></div>
39+</body>
40+
41+</html>
added docs/openapi_generator/pyopenapi/utility.py +116 −0
@@ -0,0 +1,116 @@
1+# Copyright (c) Meta Platforms, Inc. and affiliates.
2+# All rights reserved.
3+#
4+# This source code is licensed under the terms described in the LICENSE file in
5+# the root directory of this source tree.
6+
7+import json
8+import typing
9+from pathlib import Path
10+from typing import TextIO
11+
12+from strong_typing.schema import object_to_json, StrictJsonType
13+
14+from .generator import Generator
15+from .options import Options
16+from .specification import Document
17+
18+
19+THIS_DIR = Path(__file__).parent
20+
21+
22+class Specification:
23+ document: Document
24+
25+ def __init__(self, endpoint: type, options: Options):
26+ generator = Generator(endpoint, options)
27+ self.document = generator.generate()
28+
29+ def get_json(self) -> StrictJsonType:
30+ """
31+ Returns the OpenAPI specification as a Python data type (e.g. `dict` for an object, `list` for an array).
32+
33+ The result can be serialized to a JSON string with `json.dump` or `json.dumps`.
34+ """
35+
36+ json_doc = typing.cast(StrictJsonType, object_to_json(self.document))
37+
38+ if isinstance(json_doc, dict):
39+ # rename vendor-specific properties
40+ tag_groups = json_doc.pop("tagGroups", None)
41+ if tag_groups:
42+ json_doc["x-tagGroups"] = tag_groups
43+ tags = json_doc.get("tags")
44+ if tags and isinstance(tags, list):
45+ for tag in tags:
46+ if not isinstance(tag, dict):
47+ continue
48+
49+ display_name = tag.pop("displayName", None)
50+ if display_name:
51+ tag["x-displayName"] = display_name
52+
53+ return json_doc
54+
55+ def get_json_string(self, pretty_print: bool = False) -> str:
56+ """
57+ Returns the OpenAPI specification as a JSON string.
58+
59+ :param pretty_print: Whether to use line indents to beautify the output.
60+ """
61+
62+ json_doc = self.get_json()
63+ if pretty_print:
64+ return json.dumps(
65+ json_doc, check_circular=False, ensure_ascii=False, indent=4
66+ )
67+ else:
68+ return json.dumps(
69+ json_doc,
70+ check_circular=False,
71+ ensure_ascii=False,
72+ separators=(",", ":"),
73+ )
74+
75+ def write_json(self, f: TextIO, pretty_print: bool = False) -> None:
76+ """
77+ Writes the OpenAPI specification to a file as a JSON string.
78+
79+ :param pretty_print: Whether to use line indents to beautify the output.
80+ """
81+
82+ json_doc = self.get_json()
83+ if pretty_print:
84+ json.dump(
85+ json_doc,
86+ f,
87+ check_circular=False,
88+ ensure_ascii=False,
89+ indent=4,
90+ )
91+ else:
92+ json.dump(
93+ json_doc,
94+ f,
95+ check_circular=False,
96+ ensure_ascii=False,
97+ separators=(",", ":"),
98+ )
99+
100+ def write_html(self, f: TextIO, pretty_print: bool = False) -> None:
101+ """
102+ Creates a stand-alone HTML page for the OpenAPI specification with ReDoc.
103+
104+ :param pretty_print: Whether to use line indents to beautify the JSON string in the HTML file.
105+ """
106+
107+ path = THIS_DIR / "template.html"
108+ with path.open(encoding="utf-8", errors="strict") as html_template_file:
109+ html_template = html_template_file.read()
110+
111+ html = html_template.replace(
112+ "{ /* OPENAPI_SPECIFICATION */ }",
113+ self.get_json_string(pretty_print=pretty_print),
114+ )
115+
116+ f.write(html)
added docs/openapi_generator/run_openapi_generator.sh +31 −0
@@ -0,0 +1,31 @@
1+#!/bin/bash
2+
3+# Copyright (c) Meta Platforms, Inc. and affiliates.
4+# All rights reserved.
5+#
6+# This source code is licensed under the terms described in the LICENSE file in
7+# the root directory of this source tree.
8+
9+PYTHONPATH=${PYTHONPATH:-}
10+
11+set -euo pipefail
12+
13+missing_packages=()
14+
15+check_package() {
16+ if ! pip show "$1" &>/dev/null; then
17+ missing_packages+=("$1")
18+ fi
19+}
20+
21+check_package json-strong-typing
22+
23+if [ ${#missing_packages[@]} -ne 0 ]; then
24+ echo "Error: The following package(s) are not installed:"
25+ printf " - %s\n" "${missing_packages[@]}"
26+ echo "Please install them using:"
27+ echo "pip install ${missing_packages[*]}"
28+ exit 1
29+fi
30+
31+PYTHONPATH=$PYTHONPATH:../.. python -m rfcs.openapi_generator.generate $*
added docs/resources/list-templates.png +0 −0

Binary content is not shown. View the file.

deleted rfcs/openapi_generator/README.md +0 −9
@@ -1,9 +0,0 @@
1-The RFC Specification (OpenAPI format) is generated from the set of API endpoints located in `llama_stack/[<subdir>]/api/endpoints.py` using the `generate.py` utility.
2-
3-Please install the following packages before running the script:
4-
5-```
6-pip install python-openapi json-strong-typing fire PyYAML llama-models
7-```
8-
9-Then simply run `sh run_openapi_generator.sh <OUTPUT_DIR>`
deleted rfcs/openapi_generator/generate.py +0 −87
@@ -1,87 +0,0 @@
1-# Copyright (c) Meta Platforms, Inc. and affiliates.
2-# All rights reserved.
3-#
4-# This source code is licensed under the terms described in the LICENSE file in
5-# the root directory of this source tree.
6-
7-# Copyright (c) Meta Platforms, Inc. and affiliates.
8-# All rights reserved.
9-#
10-# This source code is licensed under the terms described found in the
11-# LICENSE file in the root directory of this source tree.
12-
13-from datetime import datetime
14-from pathlib import Path
15-
16-import fire
17-import yaml
18-
19-from llama_models import schema_utils
20-
21-# We do some monkey-patching to ensure our definitions only use the minimal
22-# (json_schema_type, webmethod) definitions from the llama_models package. For
23-# generation though, we need the full definitions and implementations from the
24-# (json-strong-typing) package.
25-
26-from strong_typing.schema import json_schema_type
27-
28-from .pyopenapi.options import Options
29-from .pyopenapi.specification import Info, Server
30-from .pyopenapi.utility import Specification
31-
32-schema_utils.json_schema_type = json_schema_type
33-
34-from llama_stack.apis.stack import LlamaStack
35-
36-
37-# TODO: this should be fixed in the generator itself so it reads appropriate annotations
38-STREAMING_ENDPOINTS = [
39- "/agentic_system/turn/create",
40- "/inference/chat_completion",
41-]
42-
43-
44-def patch_sse_stream_responses(spec: Specification):
45- for path, path_item in spec.document.paths.items():
46- if path in STREAMING_ENDPOINTS:
47- content = path_item.post.responses["200"].content.pop("application/json")
48- path_item.post.responses["200"].content["text/event-stream"] = content
49-
50-
51-def main(output_dir: str):
52- output_dir = Path(output_dir)
53- if not output_dir.exists():
54- raise ValueError(f"Directory {output_dir} does not exist")
55-
56- now = str(datetime.now())
57- print(
58- "Converting the spec to YAML (openapi.yaml) and HTML (openapi.html) at " + now
59- )
60- print("")
61- spec = Specification(
62- LlamaStack,
63- Options(
64- server=Server(url="http://any-hosted-llama-stack.com"),
65- info=Info(
66- title="[DRAFT] Llama Stack Specification",
67- version="0.0.1",
68- description="""This is the specification of the llama stack that provides
69- a set of endpoints and their corresponding interfaces that are tailored to
70- best leverage Llama Models. The specification is still in draft and subject to change.
71- Generated at """
72- + now,
73- ),
74- ),
75- )
76-
77- patch_sse_stream_responses(spec)
78-
79- with open(output_dir / "llama-stack-spec.yaml", "w", encoding="utf-8") as fp:
80- yaml.dump(spec.get_json(), fp, allow_unicode=True)
81-
82- with open(output_dir / "llama-stack-spec.html", "w") as fp:
83- spec.write_html(fp, pretty_print=True)
84-
85-
86-if __name__ == "__main__":
87- fire.Fire(main)
deleted rfcs/openapi_generator/pyopenapi/README.md +0 −1
@@ -1,1 +0,0 @@
1-This is forked from https://github.com/hunyadi/pyopenapi
deleted rfcs/openapi_generator/pyopenapi/__init__.py +0 −5
@@ -1,5 +0,0 @@
1-# Copyright (c) Meta Platforms, Inc. and affiliates.
2-# All rights reserved.
3-#
4-# This source code is licensed under the terms described in the LICENSE file in
5-# the root directory of this source tree.
deleted rfcs/openapi_generator/pyopenapi/generator.py +0 −718
@@ -1,718 +0,0 @@
1-# Copyright (c) Meta Platforms, Inc. and affiliates.
2-# All rights reserved.
3-#
4-# This source code is licensed under the terms described in the LICENSE file in
5-# the root directory of this source tree.
6-
7-import hashlib
8-import ipaddress
9-import typing
10-from typing import Any, Dict, Set, Union
11-
12-from strong_typing.core import JsonType
13-from strong_typing.docstring import Docstring, parse_type
14-from strong_typing.inspection import (
15- is_generic_list,
16- is_type_optional,
17- is_type_union,
18- unwrap_generic_list,
19- unwrap_optional_type,
20- unwrap_union_types,
21-)
22-from strong_typing.name import python_type_to_name
23-from strong_typing.schema import (
24- get_schema_identifier,
25- JsonSchemaGenerator,
26- register_schema,
27- Schema,
28- SchemaOptions,
29-)
30-from strong_typing.serialization import json_dump_string, object_to_json
31-
32-from .operations import (
33- EndpointOperation,
34- get_endpoint_events,
35- get_endpoint_operations,
36- HTTPMethod,
37-)
38-from .options import *
39-from .specification import (
40- Components,
41- Document,
42- Example,
43- ExampleRef,
44- MediaType,
45- Operation,
46- Parameter,
47- ParameterLocation,
48- PathItem,
49- RequestBody,
50- Response,
51- ResponseRef,
52- SchemaOrRef,
53- SchemaRef,
54- Tag,
55- TagGroup,
56-)
57-
58-register_schema(
59- ipaddress.IPv4Address,
60- schema={
61- "type": "string",
62- "format": "ipv4",
63- "title": "IPv4 address",
64- "description": "IPv4 address, according to dotted-quad ABNF syntax as defined in RFC 2673, section 3.2.",
65- },
66- examples=["192.0.2.0", "198.51.100.1", "203.0.113.255"],
67-)
68-
69-register_schema(
70- ipaddress.IPv6Address,
71- schema={
72- "type": "string",
73- "format": "ipv6",
74- "title": "IPv6 address",
75- "description": "IPv6 address, as defined in RFC 2373, section 2.2.",
76- },
77- examples=[
78- "FEDC:BA98:7654:3210:FEDC:BA98:7654:3210",
79- "1080:0:0:0:8:800:200C:417A",
80- "1080::8:800:200C:417A",
81- "FF01::101",
82- "::1",
83- ],
84-)
85-
86-
87-def http_status_to_string(status_code: HTTPStatusCode) -> str:
88- "Converts an HTTP status code to a string."
89-
90- if isinstance(status_code, HTTPStatus):
91- return str(status_code.value)
92- elif isinstance(status_code, int):
93- return str(status_code)
94- elif isinstance(status_code, str):
95- return status_code
96- else:
97- raise TypeError("expected: HTTP status code")
98-
99-
100-class SchemaBuilder:
101- schema_generator: JsonSchemaGenerator
102- schemas: Dict[str, Schema]
103-
104- def __init__(self, schema_generator: JsonSchemaGenerator) -> None:
105- self.schema_generator = schema_generator
106- self.schemas = {}
107-
108- def classdef_to_schema(self, typ: type) -> Schema:
109- """
110- Converts a type to a JSON schema.
111- For nested types found in the type hierarchy, adds the type to the schema registry in the OpenAPI specification section `components`.
112- """
113-
114- type_schema, type_definitions = self.schema_generator.classdef_to_schema(typ)
115-
116- # append schema to list of known schemas, to be used in OpenAPI's Components Object section
117- for ref, schema in type_definitions.items():
118- self._add_ref(ref, schema)
119-
120- return type_schema
121-
122- def classdef_to_named_schema(self, name: str, typ: type) -> Schema:
123- schema = self.classdef_to_schema(typ)
124- self._add_ref(name, schema)
125- return schema
126-
127- def classdef_to_ref(self, typ: type) -> SchemaOrRef:
128- """
129- Converts a type to a JSON schema, and if possible, returns a schema reference.
130- For composite types (such as classes), adds the type to the schema registry in the OpenAPI specification section `components`.
131- """
132-
133- type_schema = self.classdef_to_schema(typ)
134- if typ is str or typ is int or typ is float:
135- # represent simple types as themselves
136- return type_schema
137-
138- type_name = get_schema_identifier(typ)
139- if type_name is not None:
140- return self._build_ref(type_name, type_schema)
141-
142- try:
143- type_name = python_type_to_name(typ)
144- return self._build_ref(type_name, type_schema)
145- except TypeError:
146- pass
147-
148- return type_schema
149-
150- def _build_ref(self, type_name: str, type_schema: Schema) -> SchemaRef:
151- self._add_ref(type_name, type_schema)
152- return SchemaRef(type_name)
153-
154- def _add_ref(self, type_name: str, type_schema: Schema) -> None:
155- if type_name not in self.schemas:
156- self.schemas[type_name] = type_schema
157-
158-
159-class ContentBuilder:
160- schema_builder: SchemaBuilder
161- schema_transformer: Optional[Callable[[SchemaOrRef], SchemaOrRef]]
162- sample_transformer: Optional[Callable[[JsonType], JsonType]]
163-
164- def __init__(
165- self,
166- schema_builder: SchemaBuilder,
167- schema_transformer: Optional[Callable[[SchemaOrRef], SchemaOrRef]] = None,
168- sample_transformer: Optional[Callable[[JsonType], JsonType]] = None,
169- ) -> None:
170- self.schema_builder = schema_builder
171- self.schema_transformer = schema_transformer
172- self.sample_transformer = sample_transformer
173-
174- def build_content(
175- self, payload_type: type, examples: Optional[List[Any]] = None
176- ) -> Dict[str, MediaType]:
177- "Creates the content subtree for a request or response."
178-
179- if is_generic_list(payload_type):
180- media_type = "application/jsonl"
181- item_type = unwrap_generic_list(payload_type)
182- else:
183- media_type = "application/json"
184- item_type = payload_type
185-
186- return {media_type: self.build_media_type(item_type, examples)}
187-
188- def build_media_type(
189- self, item_type: type, examples: Optional[List[Any]] = None
190- ) -> MediaType:
191- schema = self.schema_builder.classdef_to_ref(item_type)
192- if self.schema_transformer:
193- schema_transformer: Callable[[SchemaOrRef], SchemaOrRef] = self.schema_transformer # type: ignore
194- schema = schema_transformer(schema)
195-
196- if not examples:
197- return MediaType(schema=schema)
198-
199- if len(examples) == 1:
200- return MediaType(schema=schema, example=self._build_example(examples[0]))
201-
202- return MediaType(
203- schema=schema,
204- examples=self._build_examples(examples),
205- )
206-
207- def _build_examples(
208- self, examples: List[Any]
209- ) -> Dict[str, Union[Example, ExampleRef]]:
210- "Creates a set of several examples for a media type."
211-
212- if self.sample_transformer:
213- sample_transformer: Callable[[JsonType], JsonType] = self.sample_transformer # type: ignore
214- else:
215- sample_transformer = lambda sample: sample
216-
217- results: Dict[str, Union[Example, ExampleRef]] = {}
218- for example in examples:
219- value = sample_transformer(object_to_json(example))
220-
221- hash_string = (
222- hashlib.md5(json_dump_string(value).encode("utf-8")).digest().hex()
223- )
224- name = f"ex-{hash_string}"
225-
226- results[name] = Example(value=value)
227-
228- return results
229-
230- def _build_example(self, example: Any) -> Any:
231- "Creates a single example for a media type."
232-
233- if self.sample_transformer:
234- sample_transformer: Callable[[JsonType], JsonType] = self.sample_transformer # type: ignore
235- else:
236- sample_transformer = lambda sample: sample
237-
238- return sample_transformer(object_to_json(example))
239-
240-
241-@dataclass
242-class ResponseOptions:
243- """
244- Configuration options for building a response for an operation.
245-
246- :param type_descriptions: Maps each response type to a textual description (if available).
247- :param examples: A list of response examples.
248- :param status_catalog: Maps each response type to an HTTP status code.
249- :param default_status_code: HTTP status code assigned to responses that have no mapping.
250- """
251-
252- type_descriptions: Dict[type, str]
253- examples: Optional[List[Any]]
254- status_catalog: Dict[type, HTTPStatusCode]
255- default_status_code: HTTPStatusCode
256-
257-
258-@dataclass
259-class StatusResponse:
260- status_code: str
261- types: List[type] = dataclasses.field(default_factory=list)
262- examples: List[Any] = dataclasses.field(default_factory=list)
263-
264-
265-class ResponseBuilder:
266- content_builder: ContentBuilder
267-
268- def __init__(self, content_builder: ContentBuilder) -> None:
269- self.content_builder = content_builder
270-
271- def _get_status_responses(
272- self, options: ResponseOptions
273- ) -> Dict[str, StatusResponse]:
274- status_responses: Dict[str, StatusResponse] = {}
275-
276- for response_type in options.type_descriptions.keys():
277- status_code = http_status_to_string(
278- options.status_catalog.get(response_type, options.default_status_code)
279- )
280-
281- # look up response for status code
282- if status_code not in status_responses:
283- status_responses[status_code] = StatusResponse(status_code)
284- status_response = status_responses[status_code]
285-
286- # append response types that are assigned the given status code
287- status_response.types.append(response_type)
288-
289- # append examples that have the matching response type
290- if options.examples:
291- status_response.examples.extend(
292- example
293- for example in options.examples
294- if isinstance(example, response_type)
295- )
296-
297- return dict(sorted(status_responses.items()))
298-
299- def build_response(
300- self, options: ResponseOptions
301- ) -> Dict[str, Union[Response, ResponseRef]]:
302- """
303- Groups responses that have the same status code.
304- """
305-
306- responses: Dict[str, Union[Response, ResponseRef]] = {}
307- status_responses = self._get_status_responses(options)
308- for status_code, status_response in status_responses.items():
309- response_types = tuple(status_response.types)
310- if len(response_types) > 1:
311- composite_response_type: type = Union[response_types] # type: ignore
312- else:
313- (response_type,) = response_types
314- composite_response_type = response_type
315-
316- description = " **OR** ".join(
317- filter(
318- None,
319- (
320- options.type_descriptions[response_type]
321- for response_type in response_types
322- ),
323- )
324- )
325-
326- responses[status_code] = self._build_response(
327- response_type=composite_response_type,
328- description=description,
329- examples=status_response.examples or None,
330- )
331-
332- return responses
333-
334- def _build_response(
335- self,
336- response_type: type,
337- description: str,
338- examples: Optional[List[Any]] = None,
339- ) -> Response:
340- "Creates a response subtree."
341-
342- if response_type is not None:
343- return Response(
344- description=description,
345- content=self.content_builder.build_content(response_type, examples),
346- )
347- else:
348- return Response(description=description)
349-
350-
351-def schema_error_wrapper(schema: SchemaOrRef) -> Schema:
352- "Wraps an error output schema into a top-level error schema."
353-
354- return {
355- "type": "object",
356- "properties": {
357- "error": schema, # type: ignore
358- },
359- "additionalProperties": False,
360- "required": [
361- "error",
362- ],
363- }
364-
365-
366-def sample_error_wrapper(error: JsonType) -> JsonType:
367- "Wraps an error output sample into a top-level error sample."
368-
369- return {"error": error}
370-
371-
372-class Generator:
373- endpoint: type
374- options: Options
375- schema_builder: SchemaBuilder
376- responses: Dict[str, Response]
377-
378- def __init__(self, endpoint: type, options: Options) -> None:
379- self.endpoint = endpoint
380- self.options = options
381- schema_generator = JsonSchemaGenerator(
382- SchemaOptions(
383- definitions_path="#/components/schemas/",
384- use_examples=self.options.use_examples,
385- property_description_fun=options.property_description_fun,
386- )
387- )
388- self.schema_builder = SchemaBuilder(schema_generator)
389- self.responses = {}
390-
391- def _build_type_tag(self, ref: str, schema: Schema) -> Tag:
392- definition = f'<SchemaDefinition schemaRef="#/components/schemas/{ref}" />'
393- title = typing.cast(str, schema.get("title"))
394- description = typing.cast(str, schema.get("description"))
395- return Tag(
396- name=ref,
397- description="\n\n".join(
398- s for s in (title, description, definition) if s is not None
399- ),
400- )
401-
402- def _build_extra_tag_groups(
403- self, extra_types: Dict[str, List[type]]
404- ) -> Dict[str, List[Tag]]:
405- """
406- Creates a dictionary of tag group captions as keys, and tag lists as values.
407-
408- :param extra_types: A dictionary of type categories and list of types in that category.
409- """
410-
411- extra_tags: Dict[str, List[Tag]] = {}
412-
413- for category_name, category_items in extra_types.items():
414- tag_list: List[Tag] = []
415-
416- for extra_type in category_items:
417- name = python_type_to_name(extra_type)
418- schema = self.schema_builder.classdef_to_named_schema(name, extra_type)
419- tag_list.append(self._build_type_tag(name, schema))
420-
421- if tag_list:
422- extra_tags[category_name] = tag_list
423-
424- return extra_tags
425-
426- def _build_operation(self, op: EndpointOperation) -> Operation:
427- doc_string = parse_type(op.func_ref)
428- doc_params = dict(
429- (param.name, param.description) for param in doc_string.params.values()
430- )
431-
432- # parameters passed in URL component path
433- path_parameters = [
434- Parameter(
435- name=param_name,
436- in_=ParameterLocation.Path,
437- description=doc_params.get(param_name),
438- required=True,
439- schema=self.schema_builder.classdef_to_ref(param_type),
440- )
441- for param_name, param_type in op.path_params
442- ]
443-
444- # parameters passed in URL component query string
445- query_parameters = []
446- for param_name, param_type in op.query_params:
447- if is_type_optional(param_type):
448- inner_type: type = unwrap_optional_type(param_type)
449- required = False
450- else:
451- inner_type = param_type
452- required = True
453-
454- query_parameter = Parameter(
455- name=param_name,
456- in_=ParameterLocation.Query,
457- description=doc_params.get(param_name),
458- required=required,
459- schema=self.schema_builder.classdef_to_ref(inner_type),
460- )
461- query_parameters.append(query_parameter)
462-
463- # parameters passed anywhere
464- parameters = path_parameters + query_parameters
465-
466- # data passed in payload
467- if op.request_params:
468- builder = ContentBuilder(self.schema_builder)
469- first = next(iter(op.request_params))
470- request_name, request_type = first
471-
472- from dataclasses import make_dataclass
473-
474- op_name = "".join(word.capitalize() for word in op.name.split("_"))
475- request_name = f"{op_name}Request"
476- request_type = make_dataclass(request_name, op.request_params)
477-
478- requestBody = RequestBody(
479- content={
480- "application/json": builder.build_media_type(
481- request_type, op.request_examples
482- )
483- },
484- description=doc_params.get(request_name),
485- required=True,
486- )
487- else:
488- requestBody = None
489-
490- # success response types
491- if doc_string.returns is None and is_type_union(op.response_type):
492- # split union of return types into a list of response types
493- success_type_docstring: Dict[type, Docstring] = {
494- typing.cast(type, item): parse_type(item)
495- for item in unwrap_union_types(op.response_type)
496- }
497- success_type_descriptions = {
498- item: doc_string.short_description
499- for item, doc_string in success_type_docstring.items()
500- if doc_string.short_description
501- }
502- else:
503- # use return type as a single response type
504- success_type_descriptions = {
505- op.response_type: (
506- doc_string.returns.description if doc_string.returns else "OK"
507- )
508- }
509-
510- response_examples = op.response_examples or []
511- success_examples = [
512- example
513- for example in response_examples
514- if not isinstance(example, Exception)
515- ]
516-
517- content_builder = ContentBuilder(self.schema_builder)
518- response_builder = ResponseBuilder(content_builder)
519- response_options = ResponseOptions(
520- success_type_descriptions,
521- success_examples if self.options.use_examples else None,
522- self.options.success_responses,
523- "200",
524- )
525- responses = response_builder.build_response(response_options)
526-
527- # failure response types
528- if doc_string.raises:
529- exception_types: Dict[type, str] = {
530- item.raise_type: item.description for item in doc_string.raises.values()
531- }
532- exception_examples = [
533- example
534- for example in response_examples
535- if isinstance(example, Exception)
536- ]
537-
538- if self.options.error_wrapper:
539- schema_transformer = schema_error_wrapper
540- sample_transformer = sample_error_wrapper
541- else:
542- schema_transformer = None
543- sample_transformer = None
544-
545- content_builder = ContentBuilder(
546- self.schema_builder,
547- schema_transformer=schema_transformer,
548- sample_transformer=sample_transformer,
549- )
550- response_builder = ResponseBuilder(content_builder)
551- response_options = ResponseOptions(
552- exception_types,
553- exception_examples if self.options.use_examples else None,
554- self.options.error_responses,
555- "500",
556- )
557- responses.update(response_builder.build_response(response_options))
558-
559- if op.event_type is not None:
560- builder = ContentBuilder(self.schema_builder)
561- callbacks = {
562- f"{op.func_name}_callback": {
563- "{$request.query.callback}": PathItem(
564- post=Operation(
565- requestBody=RequestBody(
566- content=builder.build_content(op.event_type)
567- ),
568- responses={"200": Response(description="OK")},
569- )
570- )
571- }
572- }
573-
574- else:
575- callbacks = None
576-
577- return Operation(
578- tags=[op.defining_class.__name__],
579- summary=doc_string.short_description,
580- description=doc_string.long_description,
581- parameters=parameters,
582- requestBody=requestBody,
583- responses=responses,
584- callbacks=callbacks,
585- security=[] if op.public else None,
586- )
587-
588- def generate(self) -> Document:
589- paths: Dict[str, PathItem] = {}
590- endpoint_classes: Set[type] = set()
591- for op in get_endpoint_operations(
592- self.endpoint, use_examples=self.options.use_examples
593- ):
594- endpoint_classes.add(op.defining_class)
595-
596- operation = self._build_operation(op)
597-
598- if op.http_method is HTTPMethod.GET:
599- pathItem = PathItem(get=operation)
600- elif op.http_method is HTTPMethod.PUT:
601- pathItem = PathItem(put=operation)
602- elif op.http_method is HTTPMethod.POST:
603- pathItem = PathItem(post=operation)
604- elif op.http_method is HTTPMethod.DELETE:
605- pathItem = PathItem(delete=operation)
606- elif op.http_method is HTTPMethod.PATCH:
607- pathItem = PathItem(patch=operation)
608- else:
609- raise NotImplementedError(f"unknown HTTP method: {op.http_method}")
610-
611- route = op.get_route()
612- if route in paths:
613- paths[route].update(pathItem)
614- else:
615- paths[route] = pathItem
616-
617- operation_tags: List[Tag] = []
618- for cls in endpoint_classes:
619- doc_string = parse_type(cls)
620- operation_tags.append(
621- Tag(
622- name=cls.__name__,
623- description=doc_string.long_description,
624- displayName=doc_string.short_description,
625- )
626- )
627-
628- # types that are produced/consumed by operations
629- type_tags = [
630- self._build_type_tag(ref, schema)
631- for ref, schema in self.schema_builder.schemas.items()
632- ]
633-
634- # types that are emitted by events
635- event_tags: List[Tag] = []
636- events = get_endpoint_events(self.endpoint)
637- for ref, event_type in events.items():
638- event_schema = self.schema_builder.classdef_to_named_schema(ref, event_type)
639- event_tags.append(self._build_type_tag(ref, event_schema))
640-
641- # types that are explicitly declared
642- extra_tag_groups: Dict[str, List[Tag]] = {}
643- if self.options.extra_types is not None:
644- if isinstance(self.options.extra_types, list):
645- extra_tag_groups = self._build_extra_tag_groups(
646- {"AdditionalTypes": self.options.extra_types}
647- )
648- elif isinstance(self.options.extra_types, dict):
649- extra_tag_groups = self._build_extra_tag_groups(
650- self.options.extra_types
651- )
652- else:
653- raise TypeError(
654- f"type mismatch for collection of extra types: {type(self.options.extra_types)}"
655- )
656-
657- # list all operations and types
658- tags: List[Tag] = []
659- tags.extend(operation_tags)
660- tags.extend(type_tags)
661- tags.extend(event_tags)
662- for extra_tag_group in extra_tag_groups.values():
663- tags.extend(extra_tag_group)
664-
665- tag_groups = []
666- if operation_tags:
667- tag_groups.append(
668- TagGroup(
669- name=self.options.map("Operations"),
670- tags=sorted(tag.name for tag in operation_tags),
671- )
672- )
673- if type_tags:
674- tag_groups.append(
675- TagGroup(
676- name=self.options.map("Types"),
677- tags=sorted(tag.name for tag in type_tags),
678- )
679- )
680- if event_tags:
681- tag_groups.append(
682- TagGroup(
683- name=self.options.map("Events"),
684- tags=sorted(tag.name for tag in event_tags),
685- )
686- )
687- for caption, extra_tag_group in extra_tag_groups.items():
688- tag_groups.append(
689- TagGroup(
690- name=self.options.map(caption),
691- tags=sorted(tag.name for tag in extra_tag_group),
692- )
693- )
694-
695- if self.options.default_security_scheme:
696- securitySchemes = {"Default": self.options.default_security_scheme}
697- else:
698- securitySchemes = None
699-
700- return Document(
701- openapi=".".join(str(item) for item in self.options.version),
702- info=self.options.info,
703- jsonSchemaDialect=(
704- "https://json-schema.org/draft/2020-12/schema"
705- if self.options.version >= (3, 1, 0)
706- else None
707- ),
708- servers=[self.options.server],
709- paths=paths,
710- components=Components(
711- schemas=self.schema_builder.schemas,
712- responses=self.responses,
713- securitySchemes=securitySchemes,
714- ),
715- security=[{"Default": []}],
716- tags=tags,
717- tagGroups=tag_groups,
718- )
deleted rfcs/openapi_generator/pyopenapi/operations.py +0 −386
@@ -1,386 +0,0 @@
1-# Copyright (c) Meta Platforms, Inc. and affiliates.
2-# All rights reserved.
3-#
4-# This source code is licensed under the terms described in the LICENSE file in
5-# the root directory of this source tree.
6-
7-import collections.abc
8-import enum
9-import inspect
10-import typing
11-import uuid
12-from dataclasses import dataclass
13-from typing import Any, Callable, Dict, Iterable, Iterator, List, Optional, Tuple, Union
14-
15-from strong_typing.inspection import (
16- get_signature,
17- is_type_enum,
18- is_type_optional,
19- unwrap_optional_type,
20-)
21-from termcolor import colored
22-
23-
24-def split_prefix(
25- s: str, sep: str, prefix: Union[str, Iterable[str]]
26-) -> Tuple[Optional[str], str]:
27- """
28- Recognizes a prefix at the beginning of a string.
29-
30- :param s: The string to check.
31- :param sep: A separator between (one of) the prefix(es) and the rest of the string.
32- :param prefix: A string or a set of strings to identify as a prefix.
33- :return: A tuple of the recognized prefix (if any) and the rest of the string excluding the separator (or the entire string).
34- """
35-
36- if isinstance(prefix, str):
37- if s.startswith(prefix + sep):
38- return prefix, s[len(prefix) + len(sep) :]
39- else:
40- return None, s
41-
42- for p in prefix:
43- if s.startswith(p + sep):
44- return p, s[len(p) + len(sep) :]
45-
46- return None, s
47-
48-
49-def _get_annotation_type(annotation: Union[type, str], callable: Callable) -> type:
50- "Maps a stringized reference to a type, as if using `from __future__ import annotations`."
51-
52- if isinstance(annotation, str):
53- return eval(annotation, callable.__globals__)
54- else:
55- return annotation
56-
57-
58-class HTTPMethod(enum.Enum):
59- "HTTP method used to invoke an endpoint operation."
60-
61- GET = "GET"
62- POST = "POST"
63- PUT = "PUT"
64- DELETE = "DELETE"
65- PATCH = "PATCH"
66-
67-
68-OperationParameter = Tuple[str, type]
69-
70-
71-class ValidationError(TypeError):
72- pass
73-
74-
75-@dataclass
76-class EndpointOperation:
77- """
78- Type information and metadata associated with an endpoint operation.
79-
80- "param defining_class: The most specific class that defines the endpoint operation.
81- :param name: The short name of the endpoint operation.
82- :param func_name: The name of the function to invoke when the operation is triggered.
83- :param func_ref: The callable to invoke when the operation is triggered.
84- :param route: A custom route string assigned to the operation.
85- :param path_params: Parameters of the operation signature that are passed in the path component of the URL string.
86- :param query_params: Parameters of the operation signature that are passed in the query string as `key=value` pairs.
87- :param request_params: The parameter that corresponds to the data transmitted in the request body.
88- :param event_type: The Python type of the data that is transmitted out-of-band (e.g. via websockets) while the operation is in progress.
89- :param response_type: The Python type of the data that is transmitted in the response body.
90- :param http_method: The HTTP method used to invoke the endpoint such as POST, GET or PUT.
91- :param public: True if the operation can be invoked without prior authentication.
92- :param request_examples: Sample requests that the operation might take.
93- :param response_examples: Sample responses that the operation might produce.
94- """
95-
96- defining_class: type
97- name: str
98- func_name: str
99- func_ref: Callable[..., Any]
100- route: Optional[str]
101- path_params: List[OperationParameter]
102- query_params: List[OperationParameter]
103- request_params: Optional[OperationParameter]
104- event_type: Optional[type]
105- response_type: type
106- http_method: HTTPMethod
107- public: bool
108- request_examples: Optional[List[Any]] = None
109- response_examples: Optional[List[Any]] = None
110-
111- def get_route(self) -> str:
112- if self.route is not None:
113- return self.route
114-
115- route_parts = ["", self.name]
116- for param_name, _ in self.path_params:
117- route_parts.append("{" + param_name + "}")
118- return "/".join(route_parts)
119-
120-
121-class _FormatParameterExtractor:
122- "A visitor to exract parameters in a format string."
123-
124- keys: List[str]
125-
126- def __init__(self) -> None:
127- self.keys = []
128-
129- def __getitem__(self, key: str) -> None:
130- self.keys.append(key)
131- return None
132-
133-
134-def _get_route_parameters(route: str) -> List[str]:
135- extractor = _FormatParameterExtractor()
136- route.format_map(extractor)
137- return extractor.keys
138-
139-
140-def _get_endpoint_functions(
141- endpoint: type, prefixes: List[str]
142-) -> Iterator[Tuple[str, str, str, Callable]]:
143- if not inspect.isclass(endpoint):
144- raise ValueError(f"object is not a class type: {endpoint}")
145-
146- functions = inspect.getmembers(endpoint, inspect.isfunction)
147- for func_name, func_ref in functions:
148- webmethod = getattr(func_ref, "__webmethod__", None)
149- if not webmethod:
150- continue
151-
152- print(f"Processing {colored(func_name, 'white')}...")
153- operation_name = func_name
154- if operation_name.startswith("get_") or operation_name.endswith("/get"):
155- prefix = "get"
156- elif (
157- operation_name.startswith("delete_")
158- or operation_name.startswith("remove_")
159- or operation_name.endswith("/delete")
160- or operation_name.endswith("/remove")
161- ):
162- prefix = "delete"
163- else:
164- if webmethod.method == "GET":
165- prefix = "get"
166- elif webmethod.method == "DELETE":
167- prefix = "delete"
168- else:
169- # by default everything else is a POST
170- prefix = "post"
171-
172- yield prefix, operation_name, func_name, func_ref
173-
174-
175-def _get_defining_class(member_fn: str, derived_cls: type) -> type:
176- "Find the class in which a member function is first defined in a class inheritance hierarchy."
177-
178- # iterate in reverse member resolution order to find most specific class first
179- for cls in reversed(inspect.getmro(derived_cls)):
180- for name, _ in inspect.getmembers(cls, inspect.isfunction):
181- if name == member_fn:
182- return cls
183-
184- raise ValidationError(
185- f"cannot find defining class for {member_fn} in {derived_cls}"
186- )
187-
188-
189-def get_endpoint_operations(
190- endpoint: type, use_examples: bool = True
191-) -> List[EndpointOperation]:
192- """
193- Extracts a list of member functions in a class eligible for HTTP interface binding.
194-
195- These member functions are expected to have a signature like
196- ```
197- async def get_object(self, uuid: str, version: int) -> Object:
198- ...
199- ```
200- where the prefix `get_` translates to an HTTP GET, `object` corresponds to the name of the endpoint operation,
201- `uuid` and `version` are mapped to route path elements in "/object/{uuid}/{version}", and `Object` becomes
202- the response payload type, transmitted as an object serialized to JSON.
203-
204- If the member function has a composite class type in the argument list, it becomes the request payload type,
205- and the caller is expected to provide the data as serialized JSON in an HTTP POST request.
206-
207- :param endpoint: A class with member functions that can be mapped to an HTTP endpoint.
208- :param use_examples: Whether to return examples associated with member functions.
209- """
210-
211- result = []
212-
213- for prefix, operation_name, func_name, func_ref in _get_endpoint_functions(
214- endpoint,
215- [
216- "create",
217- "delete",
218- "do",
219- "get",
220- "post",
221- "put",
222- "remove",
223- "set",
224- "update",
225- ],
226- ):
227- # extract routing information from function metadata
228- webmethod = getattr(func_ref, "__webmethod__", None)
229- if webmethod is not None:
230- route = webmethod.route
231- route_params = _get_route_parameters(route) if route is not None else None
232- public = webmethod.public
233- request_examples = webmethod.request_examples
234- response_examples = webmethod.response_examples
235- else:
236- route = None
237- route_params = None
238- public = False
239- request_examples = None
240- response_examples = None
241-
242- # inspect function signature for path and query parameters, and request/response payload type
243- signature = get_signature(func_ref)
244-
245- path_params = []
246- query_params = []
247- request_params = []
248-
249- for param_name, parameter in signature.parameters.items():
250- param_type = _get_annotation_type(parameter.annotation, func_ref)
251-
252- # omit "self" for instance methods
253- if param_name == "self" and param_type is inspect.Parameter.empty:
254- continue
255-
256- # check if all parameters have explicit type
257- if parameter.annotation is inspect.Parameter.empty:
258- raise ValidationError(
259- f"parameter '{param_name}' in function '{func_name}' has no type annotation"
260- )
261-
262- if is_type_optional(param_type):
263- inner_type: type = unwrap_optional_type(param_type)
264- else:
265- inner_type = param_type
266-
267- if prefix == "get" and (
268- inner_type is bool
269- or inner_type is int
270- or inner_type is float
271- or inner_type is str
272- or inner_type is uuid.UUID
273- or is_type_enum(inner_type)
274- ):
275- if parameter.kind == inspect.Parameter.POSITIONAL_ONLY:
276- if route_params is not None and param_name not in route_params:
277- raise ValidationError(
278- f"positional parameter '{param_name}' absent from user-defined route '{route}' for function '{func_name}'"
279- )
280-
281- # simple type maps to route path element, e.g. /study/{uuid}/{version}
282- path_params.append((param_name, param_type))
283- else:
284- if route_params is not None and param_name in route_params:
285- raise ValidationError(
286- f"query parameter '{param_name}' found in user-defined route '{route}' for function '{func_name}'"
287- )
288-
289- # simple type maps to key=value pair in query string
290- query_params.append((param_name, param_type))
291- else:
292- if route_params is not None and param_name in route_params:
293- raise ValidationError(
294- f"user-defined route '{route}' for function '{func_name}' has parameter '{param_name}' of composite type: {param_type}"
295- )
296-
297- request_params.append((param_name, param_type))
298-
299- # check if function has explicit return type
300- if signature.return_annotation is inspect.Signature.empty:
301- raise ValidationError(
302- f"function '{func_name}' has no return type annotation"
303- )
304-
305- return_type = _get_annotation_type(signature.return_annotation, func_ref)
306-
307- # operations that produce events are labeled as Generator[YieldType, SendType, ReturnType]
308- # where YieldType is the event type, SendType is None, and ReturnType is the immediate response type to the request
309- if typing.get_origin(return_type) is collections.abc.Generator:
310- event_type, send_type, response_type = typing.get_args(return_type)
311- if send_type is not type(None):
312- raise ValidationError(
313- f"function '{func_name}' has a return type Generator[Y,S,R] and therefore looks like an event but has an explicit send type"
314- )
315- else:
316- event_type = None
317- response_type = return_type
318-
319- # set HTTP request method based on type of request and presence of payload
320- if not request_params:
321- if prefix in ["delete", "remove"]:
322- http_method = HTTPMethod.DELETE
323- else:
324- http_method = HTTPMethod.GET
325- else:
326- if prefix == "set":
327- http_method = HTTPMethod.PUT
328- elif prefix == "update":
329- http_method = HTTPMethod.PATCH
330- else:
331- http_method = HTTPMethod.POST
332-
333- result.append(
334- EndpointOperation(
335- defining_class=_get_defining_class(func_name, endpoint),
336- name=operation_name,
337- func_name=func_name,
338- func_ref=func_ref,
339- route=route,
340- path_params=path_params,
341- query_params=query_params,
342- request_params=request_params,
343- event_type=event_type,
344- response_type=response_type,
345- http_method=http_method,
346- public=public,
347- request_examples=request_examples if use_examples else None,
348- response_examples=response_examples if use_examples else None,
349- )
350- )
351-
352- if not result:
353- raise ValidationError(f"no eligible endpoint operations in type {endpoint}")
354-
355- return result
356-
357-
358-def get_endpoint_events(endpoint: type) -> Dict[str, type]:
359- results = {}
360-
361- for decl in typing.get_type_hints(endpoint).values():
362- # check if signature is Callable[...]
363- origin = typing.get_origin(decl)
364- if origin is None or not issubclass(origin, Callable): # type: ignore
365- continue
366-
367- # check if signature is Callable[[...], Any]
368- args = typing.get_args(decl)
369- if len(args) != 2:
370- continue
371- params_type, return_type = args
372- if not isinstance(params_type, list):
373- continue
374-
375- # check if signature is Callable[[...], None]
376- if not issubclass(return_type, type(None)):
377- continue
378-
379- # check if signature is Callable[[EventType], None]
380- if len(params_type) != 1:
381- continue
382-
383- param_type = params_type[0]
384- results[param_type.__name__] = param_type
385-
386- return results
deleted rfcs/openapi_generator/pyopenapi/options.py +0 −75
@@ -1,75 +0,0 @@
1-# Copyright (c) Meta Platforms, Inc. and affiliates.
2-# All rights reserved.
3-#
4-# This source code is licensed under the terms described in the LICENSE file in
5-# the root directory of this source tree.
6-
7-import dataclasses
8-from dataclasses import dataclass
9-from http import HTTPStatus
10-from typing import Callable, ClassVar, Dict, List, Optional, Tuple, Union
11-
12-from .specification import (
13- Info,
14- SecurityScheme,
15- SecuritySchemeAPI,
16- SecuritySchemeHTTP,
17- SecuritySchemeOpenIDConnect,
18- Server,
19-)
20-
21-HTTPStatusCode = Union[HTTPStatus, int, str]
22-
23-
24-@dataclass
25-class Options:
26- """
27- :param server: Base URL for the API endpoint.
28- :param info: Meta-information for the endpoint specification.
29- :param version: OpenAPI specification version as a tuple of major, minor, revision.
30- :param default_security_scheme: Security scheme to apply to endpoints, unless overridden on a per-endpoint basis.
31- :param extra_types: Extra types in addition to those found in operation signatures. Use a dictionary to group related types.
32- :param use_examples: Whether to emit examples for operations.
33- :param success_responses: Associates operation response types with HTTP status codes.
34- :param error_responses: Associates error response types with HTTP status codes.
35- :param error_wrapper: True if errors are encapsulated in an error object wrapper.
36- :param property_description_fun: Custom transformation function to apply to class property documentation strings.
37- :param captions: User-defined captions for sections such as "Operations" or "Types", and (if applicable) groups of extra types.
38- """
39-
40- server: Server
41- info: Info
42- version: Tuple[int, int, int] = (3, 1, 0)
43- default_security_scheme: Optional[SecurityScheme] = None
44- extra_types: Union[List[type], Dict[str, List[type]], None] = None
45- use_examples: bool = True
46- success_responses: Dict[type, HTTPStatusCode] = dataclasses.field(
47- default_factory=dict
48- )
49- error_responses: Dict[type, HTTPStatusCode] = dataclasses.field(
50- default_factory=dict
51- )
52- error_wrapper: bool = False
53- property_description_fun: Optional[Callable[[type, str, str], str]] = None
54- captions: Optional[Dict[str, str]] = None
55-
56- default_captions: ClassVar[Dict[str, str]] = {
57- "Operations": "Operations",
58- "Types": "Types",
59- "Events": "Events",
60- "AdditionalTypes": "Additional types",
61- }
62-
63- def map(self, id: str) -> str:
64- "Maps a language-neutral placeholder string to language-dependent text."
65-
66- if self.captions is not None:
67- caption = self.captions.get(id)
68- if caption is not None:
69- return caption
70-
71- caption = self.__class__.default_captions.get(id)
72- if caption is not None:
73- return caption
74-
75- raise KeyError(f"no caption found for ID: {id}")
deleted rfcs/openapi_generator/pyopenapi/specification.py +0 −258
@@ -1,258 +0,0 @@
1-# Copyright (c) Meta Platforms, Inc. and affiliates.
2-# All rights reserved.
3-#
4-# This source code is licensed under the terms described in the LICENSE file in
5-# the root directory of this source tree.
6-
7-import dataclasses
8-import enum
9-from dataclasses import dataclass
10-from typing import Any, ClassVar, Dict, List, Optional, Union
11-
12-from strong_typing.schema import JsonType, Schema, StrictJsonType
13-
14-URL = str
15-
16-
17-@dataclass
18-class Ref:
19- ref_type: ClassVar[str]
20- id: str
21-
22- def to_json(self) -> StrictJsonType:
23- return {"$ref": f"#/components/{self.ref_type}/{self.id}"}
24-
25-
26-@dataclass
27-class SchemaRef(Ref):
28- ref_type: ClassVar[str] = "schemas"
29-
30-
31-SchemaOrRef = Union[Schema, SchemaRef]
32-
33-
34-@dataclass
35-class ResponseRef(Ref):
36- ref_type: ClassVar[str] = "responses"
37-
38-
39-@dataclass
40-class ParameterRef(Ref):
41- ref_type: ClassVar[str] = "parameters"
42-
43-
44-@dataclass
45-class ExampleRef(Ref):
46- ref_type: ClassVar[str] = "examples"
47-
48-
49-@dataclass
50-class Contact:
51- name: Optional[str] = None
52- url: Optional[URL] = None
53- email: Optional[str] = None
54-
55-
56-@dataclass
57-class License:
58- name: str
59- url: Optional[URL] = None
60-
61-
62-@dataclass
63-class Info:
64- title: str
65- version: str
66- description: Optional[str] = None
67- termsOfService: Optional[str] = None
68- contact: Optional[Contact] = None
69- license: Optional[License] = None
70-
71-
72-@dataclass
73-class MediaType:
74- schema: Optional[SchemaOrRef] = None
75- example: Optional[Any] = None
76- examples: Optional[Dict[str, Union["Example", ExampleRef]]] = None
77-
78-
79-@dataclass
80-class RequestBody:
81- content: Dict[str, MediaType]
82- description: Optional[str] = None
83- required: Optional[bool] = None
84-
85-
86-@dataclass
87-class Response:
88- description: str
89- content: Optional[Dict[str, MediaType]] = None
90-
91-
92-class ParameterLocation(enum.Enum):
93- Query = "query"
94- Header = "header"
95- Path = "path"
96- Cookie = "cookie"
97-
98-
99-@dataclass
100-class Parameter:
101- name: str
102- in_: ParameterLocation
103- description: Optional[str] = None
104- required: Optional[bool] = None
105- schema: Optional[SchemaOrRef] = None
106- example: Optional[Any] = None
107-
108-
109-@dataclass
110-class Operation:
111- responses: Dict[str, Union[Response, ResponseRef]]
112- tags: Optional[List[str]] = None
113- summary: Optional[str] = None
114- description: Optional[str] = None
115- operationId: Optional[str] = None
116- parameters: Optional[List[Parameter]] = None
117- requestBody: Optional[RequestBody] = None
118- callbacks: Optional[Dict[str, "Callback"]] = None
119- security: Optional[List["SecurityRequirement"]] = None
120-
121-
122-@dataclass
123-class PathItem:
124- summary: Optional[str] = None
125- description: Optional[str] = None
126- get: Optional[Operation] = None
127- put: Optional[Operation] = None
128- post: Optional[Operation] = None
129- delete: Optional[Operation] = None
130- options: Optional[Operation] = None
131- head: Optional[Operation] = None
132- patch: Optional[Operation] = None
133- trace: Optional[Operation] = None
134-
135- def update(self, other: "PathItem") -> None:
136- "Merges another instance of this class into this object."
137-
138- for field in dataclasses.fields(self.__class__):
139- value = getattr(other, field.name)
140- if value is not None:
141- setattr(self, field.name, value)
142-
143-
144-# maps run-time expressions such as "$request.body#/url" to path items
145-Callback = Dict[str, PathItem]
146-
147-
148-@dataclass
149-class Example:
150- summary: Optional[str] = None
151- description: Optional[str] = None
152- value: Optional[Any] = None
153- externalValue: Optional[URL] = None
154-
155-
156-@dataclass
157-class Server:
158- url: URL
159- description: Optional[str] = None
160-
161-
162-class SecuritySchemeType(enum.Enum):
163- ApiKey = "apiKey"
164- HTTP = "http"
165- OAuth2 = "oauth2"
166- OpenIDConnect = "openIdConnect"
167-
168-
169-@dataclass
170-class SecurityScheme:
171- type: SecuritySchemeType
172- description: str
173-
174-
175-@dataclass(init=False)
176-class SecuritySchemeAPI(SecurityScheme):
177- name: str
178- in_: ParameterLocation
179-
180- def __init__(self, description: str, name: str, in_: ParameterLocation) -> None:
181- super().__init__(SecuritySchemeType.ApiKey, description)
182- self.name = name
183- self.in_ = in_
184-
185-
186-@dataclass(init=False)
187-class SecuritySchemeHTTP(SecurityScheme):
188- scheme: str
189- bearerFormat: Optional[str] = None
190-
191- def __init__(
192- self, description: str, scheme: str, bearerFormat: Optional[str] = None
193- ) -> None:
194- super().__init__(SecuritySchemeType.HTTP, description)
195- self.scheme = scheme
196- self.bearerFormat = bearerFormat
197-
198-
199-@dataclass(init=False)
200-class SecuritySchemeOpenIDConnect(SecurityScheme):
201- openIdConnectUrl: str
202-
203- def __init__(self, description: str, openIdConnectUrl: str) -> None:
204- super().__init__(SecuritySchemeType.OpenIDConnect, description)
205- self.openIdConnectUrl = openIdConnectUrl
206-
207-
208-@dataclass
209-class Components:
210- schemas: Optional[Dict[str, Schema]] = None
211- responses: Optional[Dict[str, Response]] = None
212- parameters: Optional[Dict[str, Parameter]] = None
213- examples: Optional[Dict[str, Example]] = None
214- requestBodies: Optional[Dict[str, RequestBody]] = None
215- securitySchemes: Optional[Dict[str, SecurityScheme]] = None
216- callbacks: Optional[Dict[str, Callback]] = None
217-
218-
219-SecurityScope = str
220-SecurityRequirement = Dict[str, List[SecurityScope]]
221-
222-
223-@dataclass
224-class Tag:
225- name: str
226- description: Optional[str] = None
227- displayName: Optional[str] = None
228-
229-
230-@dataclass
231-class TagGroup:
232- """
233- A ReDoc extension to provide information about groups of tags.
234-
235- Exposed via the vendor-specific property "x-tagGroups" of the top-level object.
236- """
237-
238- name: str
239- tags: List[str]
240-
241-
242-@dataclass
243-class Document:
244- """
245- This class is a Python dataclass adaptation of the OpenAPI Specification.
246-
247- For details, see <https://swagger.io/specification/>
248- """
249-
250- openapi: str
251- info: Info
252- servers: List[Server]
253- paths: Dict[str, PathItem]
254- jsonSchemaDialect: Optional[str] = None
255- components: Optional[Components] = None
256- security: Optional[List[SecurityRequirement]] = None
257- tags: Optional[List[Tag]] = None
258- tagGroups: Optional[List[TagGroup]] = None
deleted rfcs/openapi_generator/pyopenapi/template.html +0 −41
@@ -1,41 +0,0 @@
1-<!DOCTYPE html>
2-<html>
3-
4-<head>
5- <meta charset="utf-8" />
6- <meta name="viewport" content="width=device-width, initial-scale=1">
7- <title>OpenAPI specification</title>
8- <link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700" rel="stylesheet">
9- <style>
10- body {
11- margin: 0;
12- padding: 0;
13- }
14-
15- </style>
16- <script defer="defer" src="https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js"></script>
17- <script defer="defer">
18- document.addEventListener("DOMContentLoaded", function () {
19- spec = { /* OPENAPI_SPECIFICATION */ };
20- options = {
21- downloadFileName: "openapi.json",
22- expandResponses: "200",
23- expandSingleSchemaField: true,
24- jsonSampleExpandLevel: "all",
25- schemaExpansionLevel: "all",
26- };
27- element = document.getElementById("openapi-container");
28- Redoc.init(spec, options, element);
29-
30- if (spec.info && spec.info.title) {
31- document.title = spec.info.title;
32- }
33- });
34- </script>
35-</head>
36-
37-<body>
38- <div id="openapi-container"></div>
39-</body>
40-
41-</html>
deleted rfcs/openapi_generator/pyopenapi/utility.py +0 −116
@@ -1,116 +0,0 @@
1-# Copyright (c) Meta Platforms, Inc. and affiliates.
2-# All rights reserved.
3-#
4-# This source code is licensed under the terms described in the LICENSE file in
5-# the root directory of this source tree.
6-
7-import json
8-import typing
9-from pathlib import Path
10-from typing import TextIO
11-
12-from strong_typing.schema import object_to_json, StrictJsonType
13-
14-from .generator import Generator
15-from .options import Options
16-from .specification import Document
17-
18-
19-THIS_DIR = Path(__file__).parent
20-
21-
22-class Specification:
23- document: Document
24-
25- def __init__(self, endpoint: type, options: Options):
26- generator = Generator(endpoint, options)
27- self.document = generator.generate()
28-
29- def get_json(self) -> StrictJsonType:
30- """
31- Returns the OpenAPI specification as a Python data type (e.g. `dict` for an object, `list` for an array).
32-
33- The result can be serialized to a JSON string with `json.dump` or `json.dumps`.
34- """
35-
36- json_doc = typing.cast(StrictJsonType, object_to_json(self.document))
37-
38- if isinstance(json_doc, dict):
39- # rename vendor-specific properties
40- tag_groups = json_doc.pop("tagGroups", None)
41- if tag_groups:
42- json_doc["x-tagGroups"] = tag_groups
43- tags = json_doc.get("tags")
44- if tags and isinstance(tags, list):
45- for tag in tags:
46- if not isinstance(tag, dict):
47- continue
48-
49- display_name = tag.pop("displayName", None)
50- if display_name:
51- tag["x-displayName"] = display_name
52-
53- return json_doc
54-
55- def get_json_string(self, pretty_print: bool = False) -> str:
56- """
57- Returns the OpenAPI specification as a JSON string.
58-
59- :param pretty_print: Whether to use line indents to beautify the output.
60- """
61-
62- json_doc = self.get_json()
63- if pretty_print:
64- return json.dumps(
65- json_doc, check_circular=False, ensure_ascii=False, indent=4
66- )
67- else:
68- return json.dumps(
69- json_doc,
70- check_circular=False,
71- ensure_ascii=False,
72- separators=(",", ":"),
73- )
74-
75- def write_json(self, f: TextIO, pretty_print: bool = False) -> None:
76- """
77- Writes the OpenAPI specification to a file as a JSON string.
78-
79- :param pretty_print: Whether to use line indents to beautify the output.
80- """
81-
82- json_doc = self.get_json()
83- if pretty_print:
84- json.dump(
85- json_doc,
86- f,
87- check_circular=False,
88- ensure_ascii=False,
89- indent=4,
90- )
91- else:
92- json.dump(
93- json_doc,
94- f,
95- check_circular=False,
96- ensure_ascii=False,
97- separators=(",", ":"),
98- )
99-
100- def write_html(self, f: TextIO, pretty_print: bool = False) -> None:
101- """
102- Creates a stand-alone HTML page for the OpenAPI specification with ReDoc.
103-
104- :param pretty_print: Whether to use line indents to beautify the JSON string in the HTML file.
105- """
106-
107- path = THIS_DIR / "template.html"
108- with path.open(encoding="utf-8", errors="strict") as html_template_file:
109- html_template = html_template_file.read()
110-
111- html = html_template.replace(
112- "{ /* OPENAPI_SPECIFICATION */ }",
113- self.get_json_string(pretty_print=pretty_print),
114- )
115-
116- f.write(html)
deleted rfcs/openapi_generator/run_openapi_generator.sh +0 −31
@@ -1,31 +0,0 @@
1-#!/bin/bash
2-
3-# Copyright (c) Meta Platforms, Inc. and affiliates.
4-# All rights reserved.
5-#
6-# This source code is licensed under the terms described in the LICENSE file in
7-# the root directory of this source tree.
8-
9-PYTHONPATH=${PYTHONPATH:-}
10-
11-set -euo pipefail
12-
13-missing_packages=()
14-
15-check_package() {
16- if ! pip show "$1" &>/dev/null; then
17- missing_packages+=("$1")
18- fi
19-}
20-
21-check_package json-strong-typing
22-
23-if [ ${#missing_packages[@]} -ne 0 ]; then
24- echo "Error: The following package(s) are not installed:"
25- printf " - %s\n" "${missing_packages[@]}"
26- echo "Please install them using:"
27- echo "pip install ${missing_packages[*]}"
28- exit 1
29-fi
30-
31-PYTHONPATH=$PYTHONPATH:../.. python -m rfcs.openapi_generator.generate $*