@@ -19,9 +19,10 @@ import {
19
19
import React from "react" ;
20
20
import { availableEmbeddingTypes } from "../../utils/embeddings" ;
21
21
import { availableChatModels } from "../../utils/chatModels" ;
22
- import { SpiderIcon } from "./SpiderIcon" ;
23
- import { GithubIcon } from "./GithubIcon" ;
24
- import { YoutubeIcon } from "./Youtube" ;
22
+ import { SpiderIcon } from "../Icons/SpiderIcon" ;
23
+ import { GithubIcon } from "../Icons/GithubIcon" ;
24
+ import { YoutubeIcon } from "../Icons/YoutubeIcon" ;
25
+ import { ApiIcon } from "../Icons/ApiIcon" ;
25
26
26
27
type Props = {
27
28
createBot : ( values : any ) => void ;
@@ -42,6 +43,8 @@ export const BotForm = ({
42
43
form,
43
44
showEmbeddingAndModels,
44
45
} : Props ) => {
46
+ const embeddingType = Form . useWatch ( "embedding" , form ) ;
47
+
45
48
const [ availableSources ] = React . useState ( [
46
49
{
47
50
id : 1 ,
@@ -365,14 +368,70 @@ export const BotForm = ({
365
368
</ >
366
369
) ,
367
370
} ,
371
+ {
372
+ id : 8 ,
373
+ value : "rest" ,
374
+ title : "REST API" ,
375
+ icon : ApiIcon ,
376
+ formComponent : (
377
+ < >
378
+ < Row gutter = { 24 } >
379
+ < Col span = { 6 } >
380
+ < Form . Item
381
+ name = { [ "options" , "method" ] }
382
+ rules = { [
383
+ {
384
+ required : true ,
385
+ message : "Please select a method" ,
386
+ } ,
387
+ ] }
388
+ >
389
+ < Select
390
+ size = "large"
391
+ options = { [
392
+ {
393
+ label : "GET" ,
394
+ value : "get" ,
395
+ } ,
396
+ {
397
+ label : "POST" ,
398
+ value : "post" ,
399
+ } ,
400
+ ] }
401
+ />
402
+ </ Form . Item >
403
+ </ Col >
404
+ < Col span = { 18 } >
405
+ < Form . Item
406
+ name = "content"
407
+ rules = { [
408
+ {
409
+ required : true ,
410
+ message : "Please enter a valid REST API URL" ,
411
+ } ,
412
+ {
413
+ pattern : new RegExp ( / ^ ( h t t p s ? : \/ \/ ) ? ( w w w \. ) ? ( .+ ) \. ( .+ ) $ / ) ,
414
+ message : "Please enter a valid REST API URL" ,
415
+ } ,
416
+ ] }
417
+ >
418
+ < input
419
+ type = "url"
420
+ placeholder = "Enter the REST API URL"
421
+ className = " block w-full shadow-sm sm:text-sm focus:ring-indigo-500 focus:border-indigo-500 border-gray-300 rounded-md"
422
+ />
423
+ </ Form . Item >
424
+ </ Col >
425
+ </ Row >
426
+ </ >
427
+ ) ,
428
+ } ,
368
429
] ) ;
369
430
370
431
const [ selectedSource , _setSelectedSource ] = React . useState < any > (
371
432
showEmbeddingAndModels ? null : availableSources [ 0 ]
372
433
) ;
373
434
374
- const embeddingType = Form . useWatch ( "embedding" , form ) ;
375
-
376
435
return (
377
436
< Form
378
437
layout = "vertical"
@@ -387,6 +446,9 @@ export const BotForm = ({
387
446
options : {
388
447
branch : "main" ,
389
448
is_private : false ,
449
+ method : "get" ,
450
+ headers : "{}" ,
451
+ body : "{}" ,
390
452
} ,
391
453
} }
392
454
>
@@ -446,6 +508,39 @@ export const BotForm = ({
446
508
447
509
{ selectedSource && selectedSource . formComponent }
448
510
511
+ { selectedSource && selectedSource . value === "rest" && (
512
+ < Row gutter = { 24 } >
513
+ < Col span = { 12 } >
514
+ < Form . Item
515
+ name = { [ "options" , "headers" ] }
516
+ label = "Headers"
517
+ >
518
+ < textarea
519
+ placeholder = "Enter the headers"
520
+ className = " block w-full shadow-sm sm:text-sm focus:ring-indigo-500 focus:border-indigo-500 border-gray-300 rounded-md"
521
+ />
522
+ </ Form . Item >
523
+ </ Col >
524
+ < Col span = { 12 } >
525
+ < Form . Item
526
+ name = { [ "options" , "body" ] }
527
+ label = "Body (JSON)"
528
+ rules = { [
529
+ {
530
+ required : true ,
531
+ message : "Please enter a valid JSON" ,
532
+ } ,
533
+ ] }
534
+ >
535
+ < textarea
536
+ placeholder = "Enter the body"
537
+ className = " block w-full shadow-sm sm:text-sm focus:ring-indigo-500 focus:border-indigo-500 border-gray-300 rounded-md"
538
+ />
539
+ </ Form . Item >
540
+ </ Col >
541
+ </ Row >
542
+ ) }
543
+
449
544
< Form . Item hidden = { ! showEmbeddingAndModels } noStyle >
450
545
< Divider />
451
546
</ Form . Item >
@@ -462,7 +557,6 @@ export const BotForm = ({
462
557
options = { availableChatModels }
463
558
/>
464
559
</ Form . Item >
465
-
466
560
< Form . Item
467
561
hidden = { ! showEmbeddingAndModels }
468
562
label = {
0 commit comments