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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
openapi: 3.1.0
info:
  title: jaison-core REST API overview
  description: |-
    This is an overview of the REST API for jaison-core. This is only the REST API endpoints and does not cover websocket or websocket events. For that, see DEVELOPER.md
  version: 1.0.0
externalDocs:
  description: Find out more in developer docs
  url: https://github.com/limitcantcode/jaison-core/blob/main/DEVELOPER.md
servers:
  - url: http://localhost:7272/api
tags:
  - name: misc
    description: General management
  - name: response
    description: Request running of various generation pipelines
  - name: context
    description: Add information to the script
  - name: operation
    description: Manage and use specific operations
  - name: configuration
    description: Save, load, and modify configuration
  
paths:
  # MISC
  /job:
    delete:
      tags:
        - misc
      summary: Cancel a job
      description: Immediately cancel a queued or already running job by job_id. Will fail if job finished or doesn't exist. Cancellation will be reported over websockets.
      operationId: jobCancel
      requestBody:
        description: Target a job by UUID
        required: True
        content:
          application/json:
            schema:
              type: object
              required:
                - job_id
              properties:
                job_id:
                  type: string
                  format: uuid
                  description: Job ID to cancel
                reason:
                  type: string
                  format: uuid
                  description: Reason for cancelling
      responses:
        '200':
          description: Successfully cancelled job
          content:
            application/json:
              schema:
                type: object
                required:
                  - status
                  - message
                  - response
                properties:
                  status:
                    type: integer
                    enum: [200]
                  message:
                    type: string
                    enum: ["Job flagged for cancellation"]
                    description: Description of response result
                  response:
                    type: object
                    description: Empty object
        '400':
          description: Invalid job request
          content:
            application/json:
              schema:
                type: object
                required:
                  - status
                  - message
                  - response
                properties:
                  status:
                    type: integer
                    enum: [400]
                  message:
                    type: string
                    enum: ["Job ID does not exist or already finished","Request missing job_id"]
                    description: Description of response result
                  response:
                    type: object
                    description: Empty object
        '500':
          $ref: '#/components/responses/InternalErrorResponse'
  # RESPONSE
  /response:
    post:
      tags:
        - response
      summary: Request a text/audio response
      description: Add a text/audio response job to the job queue. Results will be communicated over websockets.
      operationId: responseAdd
      requestBody:
        description: Response request arguments
        required: False
        content:
          application/json:
            schema:
              type: object
              properties:
                include_audio:
                  type: boolean
                  description: Whether to try and generate audio
      responses:
        '200':
          $ref: '#/components/responses/JobResponse'
        '500':
          $ref: '#/components/responses/InternalErrorResponse'
  # CONTEXT
  /context:
    delete:
      tags:
        - context
      summary: Clear all history
      description: Clear cached script including conversation history, context history, etc. Status is communicated over websockets.
      operationId: contextDelete
      responses:
        '200':
          $ref: '#/components/responses/JobResponse'
        '500':
          $ref: '#/components/responses/InternalErrorResponse'
  /context/config:
    put:
      tags:
        - context
      summary: Configure prompter
      description: Configure specific values within the prompter such as prompts, names, and history length
      operationId: contextConfigure
      requestBody:
        description: Options to be configured
        content:
          application/json:
            schema:
              type: object
              properties:
                name_translations:
                  type: object
                  description: Request to be given to the LLM
                  additionalProperties: 
                    type: string
                    description: "Untranslated key translates into given value"
                character_name:
                  type: string
                  description: Name of the character
                history_length:
                  type: integer
                  description: Line count in script to retain
                instruction_prompt_filename:
                  type: string
                  description: File name of instruction prompt file
                character_prompt_filename:
                  type: string
                  description: File name of character prompt file
                scene_prompt_filename:
                  type: string
                  description: File name of scene prompt file
      responses:
        '200':
          $ref: '#/components/responses/JobResponse'
        '500':
          $ref: '#/components/responses/InternalErrorResponse'
  /context/request:
    post:
      tags:
        - context
      summary: Append request in script
      description: Add a request to the script for the LLM to process in conversation. Status is communicated over websockets.
      operationId: responseRequestAdd
      requestBody:
        description: Content of the request
        required: True
        content:
          application/json:
            schema:
              type: object
              required:
                - content
              properties:
                content:
                  type: string
                  description: Request to be given to the LLM
      responses:
        '200':
          $ref: '#/components/responses/JobResponse'
        '500':
          $ref: '#/components/responses/InternalErrorResponse'
  /context/conversation/text:
    post:
      tags:
        - context
      summary: Append conversation text in script
      description: Add a conversational text to the script. Status is communicated over websockets.
      operationId: responseConvTextAdd
      requestBody:
        description: Content of the request
        required: True
        content:
          application/json:
            schema:
              type: object
              required:
                - user
                - content
              properties:
                user:
                  type: string
                  description: Name of user associated with content
                timestamp:
                  type: integer
                  minimum: 0
                  maximum: 9999999999
                  description: UNIX timestamp of message 
                content:
                  type: string
                  description: Message from user
      responses:
        '200':
          $ref: '#/components/responses/JobResponse'
        '500':
          $ref: '#/components/responses/InternalErrorResponse'
  /context/conversation/audio:
    post:
      tags:
        - context
      summary: Append conversation audio to script
      description: Transcribe conversational audio and add to the script. Status is communicated over websockets.
      operationId: responseConvAudioAdd
      requestBody:
        description: Content of the request
        required: True
        content:
          application/json:
            schema:
              type: object
              required:
                - user
                - audio_bytes
                - sr
                - sw
                - ch
              properties:
                user:
                  type: string
                  description: Name of user associated with speech
                timestamp:
                  type: integer
                  minimum: 0
                  maximum: 9999999999
                  description: UNIX timestamp of message
                audio_bytes:
                  type: string
                  format: byte
                  description: PCM audio bytes containing speech
                sr:
                  type: integer
                  minimum: 0
                  description: Sample rate of audio
                sw:
                  type: integer
                  minimum: 0
                  description: Number of bytes per audio sample
                ch:
                  type: integer
                  minimum: 0
                  description: Number of audio channels
      responses:
        '200':
          $ref: '#/components/responses/JobResponse'
        '500':
          $ref: '#/components/responses/InternalErrorResponse'
  /context/custom:
    put:
      tags:
        - context
      summary: Register custom context
      description: Register custom context details for use in script for later use describing things outside of conversation and requests. Status is communicated over websockets.
      operationId: responseCustomRegister
      requestBody:
        description: Details of custom context to register
        required: True
        content:
          application/json:
            schema:
              type: object
              required:
                - context_id
                - context_name
              properties:
                context_id:
                  type: string
                  description: Custom context id used by future requests
                context_name:
                  type: string
                  description: Name of the context as will appear in the script
                context_description:
                  type: string
                  description: Context description as will be described to the LLM
      responses:
        '200':
          $ref: '#/components/responses/JobResponse'
        '500':
          $ref: '#/components/responses/InternalErrorResponse'
    delete:
      tags:
        - context
      summary: Unregister a custom context
      description: Remove a previously registered custom context so it is no longer described or addable to the script. Status is communicated over websockets.
      operationId: responseCustomRemove
      requestBody:
        description: Target custom context to remove
        required: True
        content:
          application/json:
            schema:
              type: object
              required:
                - context_id
              properties:
                context_id:
                  type: string
                  description: Targetted context id to delete
      responses:
        '200':
          $ref: '#/components/responses/JobResponse'
        '500':
          $ref: '#/components/responses/InternalErrorResponse'
    post:
      tags:
        - context
      summary: Add custom context to script
      description: Add custom context to script for external descriptions alongside conversation and requests. Status is communicated over websockets.
      operationId: responseCustomAppend
      requestBody:
        description: Content of the custom context
        required: True
        content:
          application/json:
            schema:
              type: object
              required:
                - context_id
                - context_contents
              properties:
                context_id:
                  type: string
                context_contents:
                  type: string
                timestamp:
                  type: integer
                  minimum: 0
                  maximum: 9999999999
      responses:
        '200':
          $ref: '#/components/responses/JobResponse'
        '500':
          $ref: '#/components/responses/InternalErrorResponse'
  # OPERATION
  /operations:
    get:
      tags:
        - operation
      summary: Get all loaded operations
      description: Get names of which operations are loaded for which operation role if available.
      operationId: operationGet
      responses:
        '200':
          description: Successfully got loaded operations
          content:
            application/json:
              schema:
                type: object
                required:
                  - status
                  - message
                  - response
                properties:
                  status:
                    type: integer
                    enum: [200]
                  message:
                    type: string
                    enum: ["Loaded operations gotten"]
                    description: Description of response result
                  response:
                    type: object
                    description: Mapping of operation type to loaded operation id
                    properties:
                      stt:
                        type: string
                      mcp:
                        type: string
                      t2t:
                        type: string
                      tts:
                        type: string
                      filter_audio:
                        type: array
                        items:
                          type: string
                      filter_text:
                        type: array
                        items:
                          type: string
  /operation/config:
    post:
      tags:
        - operation
      summary: Configure operation
      description: Configure a list of operations by role. Configuration differs per operation and role.
      operationId: operationConfigure
      requestBody:
        description: Operations to load
        required: True
        content:
          application/json:
            schema:
              type: object
              required:
                - ops
              properties:
                ops:
                  type: array
                  description: List of operation identifiers and configuration
                  items:
                    type: object
                    required:
                      - role
                      - id
                    properties:
                      role:
                        type: string
                        enum: ['stt', 'mcp', 't2t', 'tts', 'filter_audio', 'filter_text', 'embedding']
                        description: Operation role to load
                      id:
                        type: string
                        description: Operation under specified role's type to load
                    additionalProperties: 
                      type: [string, number]
                      
      responses:
        '200':
          $ref: '#/components/responses/JobResponse'
        '500':
          $ref: '#/components/responses/InternalErrorResponse'
  /operations/use:
    post:
      tags:
        - operation
      summary: Use an operation
      description: Use a specific operation (loaded or not). Results returned over websockets.
      operationId: operationUse
      requestBody:
        description: Target and input for operation
        required: True
        content:
          application/json:
            schema:
              type: object
              required:
                - type
                - payload
              properties:
                role:
                  type: string
                  enum: ['stt', 'mcp', 't2t', 'tts', 'filter_audio', 'filter_text', 'embedding']
                  description: Operation role to use
                id:
                  type: string
                  description: Specific operation under role's type to use. Defaults to already loaded operation.
                payload:
                  type: object
                  description: Input chunk/payload for operation to process (see DEVELOPER.md for payload details per operation)
      responses:
        '200':
          $ref: '#/components/responses/JobResponse'
        '500':
          $ref: '#/components/responses/InternalErrorResponse'
  /operations/load:
    post:
      tags:
        - operation
      summary: Load operations for later use
      description: Load a list of operations into operation manager for default use. Will unload any existing operations and load new ones. Status is communicated over websockets.
      operationId: operationLoad
      requestBody:
        description: Operations to load
        required: True
        content:
          application/json:
            schema:
              type: object
              required:
                - ops
              properties:
                ops:
                  type: array
                  description: List of operation identifiers
                  items:
                    type: object
                    required:
                      - role
                      - id
                    properties:
                      role:
                        type: string
                        enum: ['stt', 'mcp', 't2t', 'tts', 'filter_audio', 'filter_text', 'embedding']
                        description: Operation role to load
                      id:
                        type: string
                        description: Operation under specified role's type to load
      responses:
        '200':
          $ref: '#/components/responses/JobResponse'
        '500':
          $ref: '#/components/responses/InternalErrorResponse'
  /operations/reload:
    post:
      tags:
        - operation
      summary: Load all operations as configured in configuration
      description: Load all operations as configured in current configuration, unloading any existing operations as necessary. Status is communicated over websockets.
      operationId: operationReload
      responses:
        '200':
          $ref: '#/components/responses/JobResponse'
        '500':
          $ref: '#/components/responses/InternalErrorResponse'
  /operations/unload:
    post:
      tags:
        - operation
      summary: Unload operations so they can no longer be used
      description: Unload a list of operations from the operation manager so they no longer get used by default. Nothing will take its place until requested. Status is communicated over websockets.
      operationId: operationUnload
      requestBody:
        description: Operations to unload
        required: True
        content:
          application/json:
            schema:
              type: object
              required:
                - ops
              properties:
                ops:
                  type: array
                  description: List of operation identifiers
                  items:
                    type: object
                    required:
                      - role
                    properties:
                      role:
                        type: string
                        enum: ['stt', 'mcp', 't2t', 'tts', 'filter_audio', 'filter_text', 'embedding']
                        description: Operation role to unload
                      id:
                        type: string
                        description: Specific operation to unload
      responses:
        '200':
          $ref: '#/components/responses/JobResponse'
        '500':
          $ref: '#/components/responses/InternalErrorResponse'
  # CONFIGURATION
  /config:
    get:
      tags:
        - configuration
      summary: Get current configuration
      description: Get all fields and values in the current configuration state. Configuration will be passed in response property.
      operationId: configGet
      responses:
        '200':
          description: Successfully got current configuration
          content:
            application/json:
              schema:
                type: object
                required:
                  - status
                  - message
                  - response
                properties:
                  status:
                    type: integer
                    enum: [200]
                  message:
                    type: string
                    enum: ["Current config gotten"]
                  response:
                    type: object
  /config/load:
    post:
      tags:
        - configuration
      summary: Load a saved config
      description: Load a saved config from file. Status is communicated over websockets.
      operationId: configLoad
      requestBody:
        description: Configuration to load
        required: True
        content:
          application/json:
            schema:
              type: object
              required:
                - config_name
              properties:
                config_name:
                  type: string
                  description: Name of config to load
      responses:
        '200':
          $ref: '#/components/responses/JobResponse'
        '500':
          $ref: '#/components/responses/InternalErrorResponse'
  /config/update:
    post:
      tags:
        - configuration
      summary: Update the current config.
      description: Update the current configuration without saving to file. Status is communicated over websockets.
      operationId: configUpdate
      requestBody:
        description: Configuration fields to update.
        required: True
        content:
          application/json:
            schema:
              type: object
              description: JSON equivilant of YAML configuration with fields to be updated
      responses:
        '200':
          $ref: '#/components/responses/JobResponse'
        '500':
          $ref: '#/components/responses/InternalErrorResponse'
  /config/save:
    post:
      tags:
        - configuration
      summary: Save current configuration to file.
      description: Save the current configuration to file using the name specified. Will overwrite configurations with the same name. Status is communicated over websockets.
      operationId: configSave
      requestBody:
        description: Config name to save to
        required: True
        content:
          application/json:
            schema:
              type: object
              required:
                - config_name
              properties:
                config_name:
                  type: string
                  description: Name of config to save to
      responses:
        '200':
          $ref: '#/components/responses/JobResponse'
        '500':
          $ref: '#/components/responses/InternalErrorResponse'
components:
  schemas:
    Job:
      type: object
      required:
        - status
        - message
        - response
      properties:
        status:
          type: integer
          enum: [200]
        message:
          type: string
          enum: ["... job created"]
          description: Description of response result
        response:
          type: object
          required:
            - job_id
          properties:
            job_id:
              type: string
              format: uuid
              description: Job ID of job created for this request
    InternalError:
      type: object
      required:
        - status
        - message
        - response
      properties:
        status:
          type: integer
          enum: [500]
        message:
          type: string
          description: Description of response result
        response:
          type: object
          description: Empty object
  responses:
    JobResponse:
      description: Successfully requested job
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Job'
    InternalErrorResponse:
      description: Unexpected internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/InternalError'