diff --git a/frontend/src/api/client.ts b/frontend/src/api/client.ts index 7c13b50..b82b652 100644 --- a/frontend/src/api/client.ts +++ b/frontend/src/api/client.ts @@ -1,9 +1,9 @@ import axios from 'axios'; -// The base URL should typically come from an environment variable in a real app, -// but for development we can default to localhost. +// The base URL should typically come from an environment variable in a real app. +// If missing, defaulting to '' means requests will be relative to the current browser origin. export const apiClient = axios.create({ - baseURL: import.meta.env.VITE_API_BASE_URL || 'http://localhost:8000', + baseURL: import.meta.env.VITE_API_BASE_URL || '', timeout: 10000, headers: { 'Content-Type': 'application/json', diff --git a/frontend/src/components/Agent/WorkerIndividualSettings.tsx b/frontend/src/components/Agent/WorkerIndividualSettings.tsx index c394e07..f6ed75c 100644 --- a/frontend/src/components/Agent/WorkerIndividualSettings.tsx +++ b/frontend/src/components/Agent/WorkerIndividualSettings.tsx @@ -1,285 +1,331 @@ import { useState, useEffect } from 'react'; import apiClient from '../../api/client'; -import { Bot, Save } from 'lucide-react'; +import { Save, Plus, Edit2, Trash2, X } from 'lucide-react'; import type { Provider } from '../../types'; -function WorkerIndividualForm({ providers }: { providers: Provider[] }) { - const [formData, setFormData] = useState({ - agent_name: '', - agent_type: 'OrdinaryIndividual', - description: '', - provider_title: providers.length > 0 ? providers[0].provider_title : '', - model_id: '', - system_prompt: '', - output_template: '{}', - bound_skill: '{}', - workspace: '[]' - }); - const [loading, setLoading] = useState(false); - const [message, setMessage] = useState(''); - - // Update initial provider_title when providers load - useEffect(() => { - if (providers.length > 0 && !formData.provider_title) { - setFormData(prev => ({ ...prev, provider_title: providers[0].provider_title })); - } - }, [providers, formData.provider_title]); - - const handleChange = (e: React.ChangeEvent) => { - setFormData({ ...formData, [e.target.name]: e.target.value }); - }; - - const handleSubmit = async (e: React.FormEvent) => { - e.preventDefault(); - setLoading(true); - setMessage(''); - try { - const payload = { - ...formData, - output_template: JSON.parse(formData.output_template), - bound_skill: JSON.parse(formData.bound_skill), - workspace: JSON.parse(formData.workspace) - }; - await apiClient.post('/api/v1/agent/worker', payload); - setMessage('Successfully created worker individual'); - setFormData({ - agent_name: '', - agent_type: 'OrdinaryIndividual', - description: '', - provider_title: '', - model_id: '', - system_prompt: '', - output_template: '{}', - bound_skill: '{}', - workspace: '[]' - }); - } catch (err: any) { - console.error(err); - setMessage(err.response?.data?.detail || 'Failed to create worker individual. Ensure JSON fields are valid.'); - } finally { - setLoading(false); - } - }; - - return ( -
-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- -