From 20009aed53d8864c9204d43a17895168a777d2cc Mon Sep 17 00:00:00 2001 From: Ilan Bigio Date: Mon, 16 Dec 2024 13:06:08 -0800 Subject: Initial commit --- webapp/components/tool-configuration-dialog.tsx | 104 ++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 webapp/components/tool-configuration-dialog.tsx (limited to 'webapp/components/tool-configuration-dialog.tsx') diff --git a/webapp/components/tool-configuration-dialog.tsx b/webapp/components/tool-configuration-dialog.tsx new file mode 100644 index 0000000..7d3b9ea --- /dev/null +++ b/webapp/components/tool-configuration-dialog.tsx @@ -0,0 +1,104 @@ +import React from "react"; +import { Button } from "@/components/ui/button"; +import { + Dialog, + DialogContent, + DialogFooter, + DialogHeader, + DialogTitle, +} from "@/components/ui/dialog"; +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from "@/components/ui/select"; +import { Textarea } from "@/components/ui/textarea"; +import { toolTemplates } from "@/lib/tool-templates"; +import { BackendTag } from "./backend-tag"; + +interface ToolConfigurationDialogProps { + open: boolean; + onOpenChange: (open: boolean) => void; + editingIndex: number | null; + selectedTemplate: string; + editingSchemaStr: string; + isJsonValid: boolean; + onTemplateChange: (val: string) => void; + onSchemaChange: (val: string) => void; + onSave: () => void; + backendTools: any[]; // schemas returned from the server +} + +export const ToolConfigurationDialog: React.FC< + ToolConfigurationDialogProps +> = ({ + open, + onOpenChange, + editingIndex, + selectedTemplate, + editingSchemaStr, + isJsonValid, + onTemplateChange, + onSchemaChange, + onSave, + backendTools, +}) => { + // Combine local templates and backend templates + const localTemplateOptions = toolTemplates.map((template) => ({ + ...template, + source: "local", + })); + + const backendTemplateOptions = backendTools.map((t: any) => ({ + ...t, + source: "backend", + })); + + const allTemplates = [...localTemplateOptions, ...backendTemplateOptions]; + + return ( + + + + + {editingIndex === null ? "Add Tool" : "Edit Tool"} + + +
+ + +