)}
{
+ // This would typically call an LLM with the tool schema
+ // For now, we'll simulate the generation based on inputs
+ return await simulateAgentFieldGeneration(inputs);
+}
+
+// Second step: Create the final agent configuration
+async function createAgentConfig(generatedFields: AgentFieldGeneration): Promise {
+ // Create the final agent configuration
+ const agentConfig: GeneratedAgentConfig = {
+ name: generatedFields.name || "Custom Agent",
+ description: generatedFields.description || "A custom agent created from onboarding inputs",
+ config: {
+ model: generatedFields.model || "gpt-4o-mini",
+ system_prompt: generatedFields.system_prompt || "You are a helpful assistant.",
+ temperature: generatedFields.temperature || 0.7,
+ max_tokens: generatedFields.max_tokens || 4000,
+ tools: generatedFields.recommended_tools || [],
+ ...(generatedFields.rag_needed && {
+ rag_config: {
+ rag_url: typeof window !== 'undefined' ? (window as any).location.origin + '/api/rag' : "",
+ collections: ["general"],
+ },
+ }),
+ },
+ };
+
+ return agentConfig;
+}
+
+// Simulate LLM-based field generation
+async function simulateAgentFieldGeneration(inputs: OnboardingInputs): Promise {
+ // This is a simplified simulation - in reality, this would call an LLM
+ const useCase = inputs.useCase.toLowerCase();
+
+ let name = "Custom Assistant";
+ let description = `An AI assistant designed for ${inputs.useCase}`;
+ let system_prompt = `You are a helpful AI assistant specialized in ${inputs.useCase}.`;
+
+ // Customize based on use case
+ if (useCase.includes("email") || useCase.includes("communication")) {
+ name = "Email Assistant";
+ description = "An AI assistant that helps with email management, composition, and communication tasks.";
+ system_prompt = `You are an expert email assistant. You help users compose professional emails, manage their inbox, and improve their communication skills. You're polite, concise, and always maintain a professional tone.`;
+ } else if (useCase.includes("research") || useCase.includes("analysis")) {
+ name = "Research Assistant";
+ description = "An AI assistant that helps with research, data analysis, and information gathering.";
+ system_prompt = `You are a thorough research assistant. You help users gather information, analyze data, and provide well-sourced insights. You always verify information and cite sources when possible.`;
+ } else if (useCase.includes("content") || useCase.includes("writing")) {
+ name = "Content Creator";
+ description = "An AI assistant that helps with content creation, writing, and creative tasks.";
+ system_prompt = `You are a creative content assistant. You help users write engaging content, brainstorm ideas, and improve their writing. You adapt your style to match the user's needs and audience.`;
+ } else if (useCase.includes("code") || useCase.includes("development")) {
+ name = "Code Assistant";
+ description = "An AI assistant that helps with programming, code review, and development tasks.";
+ system_prompt = `You are an expert programming assistant. You help users write, debug, and optimize code. You provide clear explanations and follow best practices for the programming languages you work with.`;
+ }
+
+ // Add industry-specific context
+ if (inputs.industry) {
+ system_prompt += ` You have specialized knowledge in the ${inputs.industry} industry.`;
+ }
+
+ // Determine recommended tools based on use case
+ const recommended_tools = [];
+ if (useCase.includes("email") || useCase.includes("communication")) {
+ recommended_tools.push("email_tool", "calendar_tool");
+ }
+ if (useCase.includes("research") || useCase.includes("analysis")) {
+ recommended_tools.push("web_search", "data_analysis_tool");
+ }
+ if (useCase.includes("content") || useCase.includes("writing")) {
+ recommended_tools.push("image_generator", "grammar_checker");
+ }
+ if (useCase.includes("code") || useCase.includes("development")) {
+ recommended_tools.push("code_executor", "git_tool");
+ }
+
+ return {
+ name,
+ description,
+ model: inputs.preferredModel || "gpt-4o-mini",
+ system_prompt,
+ temperature: 0.7,
+ max_tokens: 4000,
+ recommended_tools,
+ rag_needed: inputs.ragNeeded || useCase.includes("research") || useCase.includes("knowledge"),
+ };
+}
+
+// Main function to generate agent config from onboarding inputs
+export async function generateAgentConfigFromOnboarding(
+ inputs: OnboardingInputs
+): Promise {
+ try {
+ // First step: Generate agent fields
+ const generatedFields = await generateAgentFields(inputs);
+
+ // Second step: Create the final agent configuration
+ const agentConfig = await createAgentConfig(generatedFields);
+
+ return {
+ success: true,
+ agentConfig,
+ };
+ } catch (error) {
+ return {
+ success: false,
+ error: error instanceof Error ? error.message : 'Unknown error occurred',
+ };
+ }
+}
diff --git a/apps/web/src/features/onboarding/components/onboarding-form.tsx b/apps/web/src/features/onboarding/components/onboarding-form.tsx
new file mode 100644
index 00000000..c9a037c3
--- /dev/null
+++ b/apps/web/src/features/onboarding/components/onboarding-form.tsx
@@ -0,0 +1,356 @@
+"use client";
+
+import { useState } from "react";
+import { Button } from "@/components/ui/button";
+import { Input } from "@/components/ui/input";
+import { Label } from "@/components/ui/label";
+import { Textarea } from "@/components/ui/textarea";
+import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
+import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
+import { Checkbox } from "@/components/ui/checkbox";
+import { LoaderCircle, ArrowRight, ArrowLeft } from "lucide-react";
+import { OnboardingInputs } from "../types";
+
+interface OnboardingFormProps {
+ onComplete: (agentConfig: any) => void;
+ onCancel: () => void;
+}
+
+const INDUSTRY_OPTIONS = [
+ "Technology",
+ "Healthcare",
+ "Finance",
+ "Education",
+ "E-commerce",
+ "Manufacturing",
+ "Consulting",
+ "Other"
+];
+
+const COMPANY_SIZE_OPTIONS = [
+ "1-10 employees",
+ "11-50 employees",
+ "51-200 employees",
+ "201-1000 employees",
+ "1000+ employees"
+];
+
+const MODEL_OPTIONS = [
+ "gpt-4o-mini",
+ "gpt-4o",
+ "claude-3-5-sonnet",
+ "claude-3-haiku"
+];
+
+const COMMON_TOOLS = [
+ "Email Management",
+ "Calendar Scheduling",
+ "Web Search",
+ "Document Analysis",
+ "Code Execution",
+ "Image Generation",
+ "Data Analysis",
+ "File Management"
+];
+
+export function OnboardingForm({ onComplete, onCancel }: OnboardingFormProps) {
+ const [currentStep, setCurrentStep] = useState(1);
+ const [isGenerating, setIsGenerating] = useState(false);
+ const [formData, setFormData] = useState({
+ useCase: "",
+ industry: "",
+ companySize: "",
+ primaryTasks: [],
+ preferredModel: "gpt-4o-mini",
+ toolsNeeded: [],
+ ragNeeded: false,
+ teamSize: "",
+ budget: ""
+ });
+
+ const updateFormData = (field: keyof OnboardingInputs, value: any) => {
+ setFormData(prev => ({ ...prev, [field]: value }));
+ };
+
+ const handleNext = () => {
+ if (currentStep < 3) {
+ setCurrentStep(currentStep + 1);
+ }
+ };
+
+ const handlePrevious = () => {
+ if (currentStep > 1) {
+ setCurrentStep(currentStep - 1);
+ }
+ };
+
+ const handleGenerateAgent = async () => {
+ setIsGenerating(true);
+ try {
+ const response = await fetch("/api/onboarding/create-agent", {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify(formData),
+ });
+
+ const result = await response.json();
+
+ if (result.success && result.agentConfig) {
+ onComplete(result.agentConfig);
+ } else {
+ console.error("Failed to generate agent config:", result.error);
+ // Handle error - could show a toast or error message
+ }
+ } catch (error) {
+ console.error("Error generating agent:", error);
+ } finally {
+ setIsGenerating(false);
+ }
+ };
+
+ const isStepValid = () => {
+ switch (currentStep) {
+ case 1:
+ return formData.useCase.trim().length > 0;
+ case 2:
+ return formData.primaryTasks && formData.primaryTasks.length > 0;
+ case 3:
+ return true; // Optional fields
+ default:
+ return false;
+ }
+ };
+
+ return (
+
+
+
+ Create Your First Agent
+
+ Let's build a custom AI agent tailored to your needs. This will only take a few minutes.
+
+
+
+ {/* Progress indicator */}
+
+ );
+}
diff --git a/apps/web/src/features/onboarding/index.tsx b/apps/web/src/features/onboarding/index.tsx
new file mode 100644
index 00000000..2d41ce62
--- /dev/null
+++ b/apps/web/src/features/onboarding/index.tsx
@@ -0,0 +1,237 @@
+"use client";
+
+import { useState } from "react";
+import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
+import { Button } from "@/components/ui/button";
+import { Badge } from "@/components/ui/badge";
+import { CheckCircle, Sparkles, ArrowRight } from "lucide-react";
+import { OnboardingForm } from "./components/onboarding-form";
+import { GeneratedAgentConfig } from "./types";
+import { useAgents } from "@/hooks/use-agents";
+import { useAgentsContext } from "@/providers/Agents";
+import { toast } from "sonner";
+import { useRouter } from "next/navigation";
+
+export default function OnboardingInterface() {
+ const [step, setStep] = useState<"welcome" | "form" | "success">("welcome");
+ const [generatedAgent, setGeneratedAgent] = useState(null);
+ const { createAgent } = useAgents();
+ const { refreshAgents } = useAgentsContext();
+ const router = useRouter();
+
+ const handleStartOnboarding = () => {
+ setStep("form");
+ };
+
+ const handleAgentGenerated = (agentConfig: GeneratedAgentConfig) => {
+ setGeneratedAgent(agentConfig);
+ setStep("success");
+ };
+
+ const handleCreateAgent = async () => {
+ if (!generatedAgent) return;
+
+ try {
+ // For now, we'll use a default deployment and graph
+ // In a real implementation, you'd want to select these based on user preferences
+ const defaultDeploymentId = "default"; // This would come from your deployment configuration
+ const defaultGraphId = "default"; // This would come from your graph configuration
+
+ const newAgent = await createAgent(
+ defaultDeploymentId,
+ defaultGraphId,
+ {
+ name: generatedAgent.name,
+ description: generatedAgent.description,
+ config: generatedAgent.config,
+ }
+ );
+
+ if (newAgent) {
+ toast.success("Agent created successfully!", {
+ description: "Your custom agent is ready to use.",
+ richColors: true,
+ });
+
+ // Refresh the agents list
+ await refreshAgents();
+
+ // Navigate to the agents page
+ router.push("/agents");
+ } else {
+ throw new Error("Failed to create agent");
+ }
+ } catch (error) {
+ console.error("Error creating agent:", error);
+ toast.error("Failed to create agent", {
+ description: "Please try again or contact support.",
+ richColors: true,
+ });
+ }
+ };
+
+ const handleSkipOnboarding = () => {
+ router.push("/agents");
+ };
+
+ if (step === "welcome") {
+ return (
+
+
+
+
+
+
+
+ Welcome to Open Agent Platform
+
+
+ Let's create your first AI agent tailored to your specific needs
+
+
+
+
+
+
+
+
+ 1
+
+ Tell us your needs
+
+
+
+
+ Describe what you want your agent to help you with, your industry, and your specific use cases.
+
+
+
+
+
+
+
+
+ 2
+
+ We generate your agent
+
+
+
+
+ Our AI analyzes your requirements and creates a customized agent configuration with the right tools and settings.
+
+
+
+
+
+
+
+
+ 3
+
+ Start using your agent
+
+
+
+
+ Your agent is ready to use! You can start chatting with it right away and fine-tune it as needed.
+
+
+
+