import React from 'react'; import userService from '../api/services/userService'; import ArrowLeft from '../assets/arrow-left.svg'; import Input from '../components/Input'; import { UserTool } from './types'; export default function ToolConfig({ tool, setTool, handleGoBack, }: { tool: UserTool; setTool: (tool: UserTool) => void; handleGoBack: () => void; }) { const [authKey, setAuthKey] = React.useState( tool.config?.token || '', ); const handleCheckboxChange = (actionIndex: number, property: string) => { setTool({ ...tool, actions: tool.actions.map((action, index) => { if (index === actionIndex) { return { ...action, parameters: { ...action.parameters, properties: { ...action.parameters.properties, [property]: { ...action.parameters.properties[property], filled_by_llm: !action.parameters.properties[property].filled_by_llm, }, }, }, }; } return action; }), }); }; const handleSaveChanges = () => { userService .updateTool({ id: tool.id, name: tool.name, displayName: tool.displayName, description: tool.description, config: { token: authKey }, actions: tool.actions, status: tool.status, }) .then(() => { handleGoBack(); }); }; return (

Back to all tools

Type

{tool.name}

{Object.keys(tool?.config).length !== 0 && (

Authentication

)}
{Object.keys(tool?.config).length !== 0 && (
API Key / Oauth setAuthKey(e.target.value)} borderVariant="thin" placeholder="Enter API Key / Oauth" >
)}

Actions

{tool.actions.map((action, actionIndex) => { return (

{action.name}

{ setTool({ ...tool, actions: tool.actions.map((act, index) => { if (index === actionIndex) { return { ...act, description: e.target.value, }; } return act; }), }); }} borderVariant="thin" >
{Object.entries(action.parameters?.properties).map( (param, index) => { const uniqueKey = `${actionIndex}-${param[0]}`; return ( ); }, )}
Field Name Field Type Filled by LLM FIeld description Value
{param[0]} {param[1].type} { setTool({ ...tool, actions: tool.actions.map( (act, index) => { if (index === actionIndex) { return { ...act, parameters: { ...act.parameters, properties: { ...act.parameters.properties, [param[0]]: { ...act.parameters .properties[param[0]], description: e.target.value, }, }, }, }; } return act; }, ), }); }} > { setTool({ ...tool, actions: tool.actions.map( (act, index) => { if (index === actionIndex) { return { ...act, parameters: { ...act.parameters, properties: { ...act.parameters.properties, [param[0]]: { ...act.parameters .properties[param[0]], value: e.target.value, }, }, }, }; } return act; }, ), }); }} >
); })}
); }