/* ┌──────────────────────────────────────────────────────────────────────────────┐ │ @author: Davidson Gomes │ │ @file: /app/agents/config/LLMAgentConfig.tsx │ │ Developed by: Davidson Gomes │ │ Creation date: May 13, 2025 │ │ Contact: contato@evolution-api.com │ ├──────────────────────────────────────────────────────────────────────────────┤ │ @copyright © Evolution API 2025. All rights reserved. │ │ Licensed under the Apache License, Version 2.0 │ │ │ │ You may not use this file except in compliance with the License. │ │ You may obtain a copy of the License at │ │ │ │ http://www.apache.org/licenses/LICENSE-2.0 │ │ │ │ Unless required by applicable law or agreed to in writing, software │ │ distributed under the License is distributed on an "AS IS" BASIS, │ │ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. │ │ See the License for the specific language governing permissions and │ │ limitations under the License. │ ├──────────────────────────────────────────────────────────────────────────────┤ │ @important │ │ For any future changes to the code in this file, it is recommended to │ │ include, together with the modification, the information of the developer │ │ who changed it and the date of modification. │ └──────────────────────────────────────────────────────────────────────────────┘ */ "use client"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select"; import { Textarea } from "@/components/ui/textarea"; import { ApiKey } from "@/services/agentService"; import { Plus, Maximize2, Save } from "lucide-react"; import { useEffect, useState } from "react"; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter, } from "@/components/ui/dialog"; interface ModelOption { value: string; label: string; provider: string; } interface LLMAgentConfigProps { apiKeys: ApiKey[]; availableModels: ModelOption[]; values: { model?: string; api_key_id?: string; instruction?: string; role?: string; goal?: string; }; onChange: (values: any) => void; onOpenApiKeysDialog: () => void; } export function LLMAgentConfig({ apiKeys, availableModels, values, onChange, onOpenApiKeysDialog, }: LLMAgentConfigProps) { const [instructionText, setInstructionText] = useState(values.instruction || ""); const [isInstructionModalOpen, setIsInstructionModalOpen] = useState(false); const [expandedInstructionText, setExpandedInstructionText] = useState(""); useEffect(() => { setInstructionText(values.instruction || ""); }, [values.instruction]); const handleInstructionChange = (e: React.ChangeEvent) => { const newValue = e.target.value; setInstructionText(newValue); onChange({ ...values, instruction: newValue, }); }; const handleExpandInstruction = () => { setExpandedInstructionText(instructionText); setIsInstructionModalOpen(true); }; const handleSaveExpandedInstruction = () => { setInstructionText(expandedInstructionText); onChange({ ...values, instruction: expandedInstructionText, }); setIsInstructionModalOpen(false); }; return (
onChange({ ...values, role: e.target.value, }) } placeholder="Ex: Research Assistant, Customer Support, etc." className="bg-[#222] border-[#444] text-white" />
ℹ️ Define the role or persona that the agent will assume
onChange({ ...values, goal: e.target.value, }) } placeholder="Ex: Find and organize information, Assist customers with inquiries, etc." className="bg-[#222] border-[#444] text-white" />
ℹ️ Define the main objective or purpose of this agent
{apiKeys.length === 0 && (
i You need to{" "} {" "} before creating an agent.
)}
{ const searchQuery = e.target.value.toLowerCase(); const items = document.querySelectorAll('[data-model-item="true"]'); items.forEach((item) => { const text = item.textContent?.toLowerCase() || ''; if (text.includes(searchQuery)) { (item as HTMLElement).style.display = 'flex'; } else { (item as HTMLElement).style.display = 'none'; } }); }} />
{availableModels .filter((model) => { if (!values.api_key_id) return true; const selectedKey = apiKeys.find( (key) => key.id === values.api_key_id ); if (!selectedKey) return true; return model.provider === selectedKey.provider; }) .map((model) => ( {model.label} ))}