--[[ RoAI - Advanced Conversational AI System v3.0 Complete Feature Implementation with Save/Load & Export/Import ]] local TweenService = game:GetService("TweenService") local UserInputService = game:GetService("UserInputService") local RunService = game:GetService("RunService") local HttpService = game:GetService("HttpService") -- =================================== -- ROAI MODEL CONFIGURATIONS -- =================================== local MODEL_PRESETS = { ["RoAI 3.5 Ultra"] = { input = 128, hidden = 256, output = 1, learning_rate = 0.15, description = "Most advanced, best for complex conversations" }, ["RoAI 3.0 Pro"] = { input = 96, hidden = 192, output = 1, learning_rate = 0.2, description = "Professional grade, balanced performance" }, ["RoAI 2.5 Plus"] = { input = 64, hidden = 128, output = 1, learning_rate = 0.25, description = "Enhanced capabilities, good for most tasks" }, ["RoAI 2.0 Standard"] = { input = 48, hidden = 96, output = 1, learning_rate = 0.3, description = "Reliable everyday assistant" }, ["RoAI 1.5 Lite"] = { input = 32, hidden = 64, output = 1, learning_rate = 0.35, description = "Fast and efficient, great for quick chats" }, ["RoAI 1.0 Mini"] = { input = 24, hidden = 48, output = 1, learning_rate = 0.4, description = "Lightweight, instant responses" } } local KNOWLEDGE_BASE = { greetings = { "Hello! I'm RoAI, your intelligent assistant. How can I help you today?", "Hi there! RoAI at your service. What would you like to talk about?", "Welcome! I'm here to assist you with anything you need.", "Greetings! RoAI ready to help. What's on your mind?" }, farewells = { "Goodbye! It was great chatting with you!", "See you later! Feel free to come back anytime!", "Take care! I'll be here whenever you need me!", "Bye! Have a wonderful day!" }, positive_responses = { "That's wonderful to hear!", "I'm so glad you feel that way!", "That sounds absolutely fantastic!", "How exciting! Tell me more!", "That's really great news!" }, negative_responses = { "I'm sorry to hear that. Is there anything I can do to help?", "That sounds challenging. Would you like to talk about it?", "I understand that can be difficult. How are you handling it?", "That must be tough. I'm here if you need support." }, questions = { "Could you tell me more about that?", "What makes you feel that way?", "How did that happen?", "What do you think about it?", "Can you elaborate on that?" }, topics = { game = {"Roblox is amazing!", "What's your favorite game?", "I love helping with game development!"}, coding = {"Programming is fascinating!", "What language are you learning?", "Code is like poetry in motion!"}, weather = {"The virtual weather is always perfect here!", "I hope you're having nice weather!", "Every day is sunny in the digital world!"}, food = {"I've heard pizza is delicious!", "What's your favorite meal?", "Cooking sounds like a fun skill!"}, music = {"Music is the universal language!", "What genre do you enjoy?", "Rhythm and harmony are beautiful!"} } } local CURRENT_MODEL_NAME = "RoAI 2.5 Plus" local INPUT_SIZE = 64 local HIDDEN_SIZE = 128 local OUTPUT_SIZE = 64 local INITIAL_LEARNING_RATE = 0.15 local TARGET_PARAMETER_COUNT = local function calculate_param_count() return (INPUT_SIZE * HIDDEN_SIZE) + HIDDEN_SIZE + (HIDDEN_SIZE * OUTPUT_SIZE) + OUTPUT_SIZE end TARGET_PARAMETER_COUNT = calculate_param_count() local PARAMETERS = {} local current_learning_rate = INITIAL_LEARNING_RATE local last_input_features = {} local last_output_activation = 0 local conversation_context = {} local CONVERSATIONAL_MODE = true local INPUT_PARSING_PASSED = false local ChatSessions = {} local CurrentSessionName = "Tutorial" local session_counter = 1 local lastSaveTime = "Never" local lastReturnSession = "Tutorial" local SAVE_FILE_NAME = "RoAI_ChatSessions.txt" local W1_START = 1 local B1_START = 0 local W2_START = 0 local B2_INDEX = 0 local function update_parameter_indices() W1_START = 1 B1_START = (INPUT_SIZE * HIDDEN_SIZE) + 1 W2_START = B1_START + HIDDEN_SIZE B2_INDEX = W2_START + HIDDEN_SIZE end update_parameter_indices() -- =================================== -- GRAMMAR PATTERNS & TEXT PREPROCESSING -- =================================== local GRAMMAR_PATTERNS = { {"i", "you", "he", "she", "it", "we", "they", "me"}, {"my", "your", "his", "her", "its", "our", "their"}, {"is", "am", "are", "was", "were", "been"}, {"will", "would", "can", "could", "should", "may", "might", "must"}, {"have", "has", "had", "do", "does", "did", "get"}, {"in", "on", "at", "to", "for", "with", "from", "by"}, {"and", "but", "or", "so"}, {"the", "a", "an"}, {"this", "that"}, {"very", "really"} } local function analyze_sentiment(text) local t = text:lower() local positive_score = 0 local negative_score = 0 local positive_words = {"good", "great", "awesome", "amazing", "love", "happy", "wonderful", "excellent", "fantastic", "beautiful", "perfect", "best", "fun", "enjoy"} for _, word in ipairs(positive_words) do if t:find(word) then positive_score = positive_score + 1 end end local negative_words = {"bad", "hate", "terrible", "awful", "horrible", "worst", "sad", "angry", "upset", "disappointed", "frustrating", "annoying"} for _, word in ipairs(negative_words) do if t:find(word) then negative_score = negative_score + 1 end end return positive_score - negative_score end local function detect_topic(text) local t = text:lower() if t:find("game") or t:find("roblox") or t:find("play") then return "game" elseif t:find("code") or t:find("script") or t:find("program") then return "coding" elseif t:find("weather") or t:find("rain") or t:find("sun") then return "weather" elseif t:find("food") or t:find("eat") or t:find("hungry") then return "food" elseif t:find("music") or t:find("song") or t:find("listen") then return "music" end return nil end local function is_greeting(text) local t = text:lower() local greetings = {"hello", "hi", "hey", "greetings", "howdy", "sup", "yo"} for _, greeting in ipairs(greetings) do if t:find("^" .. greeting) or t:find(" " .. greeting) then return true end end return false end local function is_farewell(text) local t = text:lower() local farewells = {"bye", "goodbye", "see you", "later", "farewell", "cya", "gtg"} for _, farewell in ipairs(farewells) do if t:find(farewell) then return true end end return false end local function is_question(text) return text:find("?") or text:lower():find("^what") or text:lower():find("^how") or text:lower():find("^why") or text:lower():find("^when") or text:lower():find("^where") or text:lower():find("^who") or text:lower():find("^can") or text:lower():find("^is") end local function preprocess_text(text) local t = text:lower() local words = {} for word in t:gmatch("[%w']+") do table.insert(words, word) end local features = {} local maxFeatures = math.min(INPUT_SIZE, 128) features[1] = math.min(#words, 50) / 50 features[2] = analyze_sentiment(text) / 10 features[3] = is_question(text) and 1 or 0 features[4] = is_greeting(text) and 1 or 0 features[5] = is_farewell(text) and 1 or 0 features[6] = (text:find("!") and 1 or 0) local topic = detect_topic(text) features[7] = (topic == "game") and 1 or 0 features[8] = (topic == "coding") and 1 or 0 features[9] = (topic == "weather") and 1 or 0 features[10] = (topic == "food") and 1 or 0 features[11] = (topic == "music") and 1 or 0 local important_words = {"you", "me", "i", "we", "they", "what", "how", "why", "when", "where", "yes", "no", "maybe", "please", "thanks", "help", "need", "want", "like", "think"} local featureIndex = 12 for _, word in ipairs(important_words) do if featureIndex > maxFeatures then break end features[featureIndex] = (t:find("%f[%w]" .. word .. "%f[%W]") and 1 or 0) featureIndex = featureIndex + 1 end local grammarIndex = 1 for _, patternGroup in ipairs(GRAMMAR_PATTERNS) do for _, pattern in ipairs(patternGroup) do if featureIndex > maxFeatures then break end local found = false for _, word in ipairs(words) do if word == pattern then found = true break end end features[featureIndex] = found and 1 or 0 featureIndex = featureIndex + 1 end if featureIndex > maxFeatures then break end end if #conversation_context > 0 then if featureIndex <= maxFeatures then features[featureIndex] = #conversation_context / 10 featureIndex = featureIndex + 1 end end while #features < INPUT_SIZE do table.insert(features, 0) end return features end -- =================================== -- SAVE/LOAD/EXPORT/IMPORT SYSTEM -- =================================== local function encode_parameters_compressed(params) local encoded = "" for i = 1, #params do local val = params[i] local compressed = string.format("%.4f", val) encoded = encoded .. compressed if i < #params then encoded = encoded .. "," end end return encoded end local function decode_parameters_compressed(encoded) local params = {} local index = 1 for num_str in encoded:gmatch("([^,]+)") do params[index] = tonumber(num_str) or 0 index = index + 1 end return params end local function encode_model_config(modelName) local config = MODEL_PRESETS[modelName] if not config then return "" end return string.format("%d,%d,%d,%.3f", config.input, config.hidden, config.output, config.learning_rate) end local function generate_export_string() local export = "ROAI_EXPORT_V3|" export = export .. CURRENT_MODEL_NAME .. "|" export = export .. encode_model_config(CURRENT_MODEL_NAME) .. "|" for sessionName, sessionData in pairs(ChatSessions) do export = export .. "SESSION:" .. sessionName .. "|" export = export .. "MODEL:" .. (sessionData.model or CURRENT_MODEL_NAME) .. "|" export = export .. "PARAMS:" .. encode_parameters_compressed(sessionData.params or PARAMETERS) .. "|" export = export .. "MSGS:" .. #sessionData.messages .. "|" for _, msg in ipairs(sessionData.messages) do local cleanMsg = msg.text:gsub("|", "PIPE"):gsub("\n", "NEWLINE") export = export .. msg.sender .. ":::" .. cleanMsg .. "|" end end return export end local function import_from_string(importStr) local parts = importStr:split("|") if parts[1] ~= "ROAI_EXPORT_V3" then return false, "Invalid format" end ChatSessions = {} local i = 4 while i <= #parts do if parts[i]:match("^SESSION:") then local sessionName = parts[i]:match("SESSION:(.+)") i = i + 1 if i <= #parts and parts[i]:match("^MODEL:") then local sessModelName = parts[i]:match("MODEL:(.+)") i = i + 1 if i <= #parts and parts[i]:match("^PARAMS:") then local paramStr = parts[i]:match("PARAMS:(.+)") local params = decode_parameters_compressed(paramStr) i = i + 1 if i <= #parts and parts[i]:match("^MSGS:") then local msgCount = tonumber(parts[i]:match("MSGS:(.+)")) i = i + 1 local messages = {} for j = 1, msgCount do if i <= #parts then local msgParts = parts[i]:split(":::") if #msgParts >= 2 then table.insert(messages, { sender = msgParts[1], text = msgParts[2]:gsub("PIPE", "|"):gsub("NEWLINE", "\n"), isAI = msgParts[1] == "RoAI" }) end i = i + 1 end end ChatSessions[sessionName] = { messages = messages, params = params, model = sessModelName } end end end else i = i + 1 end end return true, "Import successful" end local function save_all_sessions() local saveData = generate_export_string() writefile(SAVE_FILE_NAME, saveData) lastSaveTime = os.date("%I:%M:%S %p") return true end local function load_all_sessions() if not isfile(SAVE_FILE_NAME) then return false, "No save file" end local saveData = readfile(SAVE_FILE_NAME) return import_from_string(saveData) end -- =================================== -- AI CORE FUNCTIONS -- =================================== local function table_clone(original) local copy = {} for k, v in pairs(original) do copy[k] = v end return copy end local function initialize_parameters() local rand = Random.new() local parameters = {} for i = 1, TARGET_PARAMETER_COUNT do parameters[i] = (rand:NextNumber() * 2 - 1) * 0.5 end return parameters end local function sigmoid(x) return 1 / (1 + math.exp(-math.min(math.max(x, -10), 10))) end local function sigmoid_derivative(x) return x * (1 - x) end local function run_ai_inference(input_vector) last_input_features = input_vector local hidden_outputs = {} for j = 1, HIDDEN_SIZE do local sum = 0 for i = 1, INPUT_SIZE do local idx = W1_START + (j - 1) * INPUT_SIZE + (i - 1) if PARAMETERS[idx] then sum = sum + input_vector[i] * PARAMETERS[idx] end end if PARAMETERS[B1_START + j - 1] then sum = sum + PARAMETERS[B1_START + j - 1] end hidden_outputs[j] = sigmoid(sum) end local output_sum = 0 for j = 1, HIDDEN_SIZE do if PARAMETERS[W2_START + j - 1] then output_sum = output_sum + hidden_outputs[j] * PARAMETERS[W2_START + j - 1] end end if PARAMETERS[B2_INDEX] then output_sum = output_sum + PARAMETERS[B2_INDEX] end last_output_activation = sigmoid(output_sum) return last_output_activation, hidden_outputs end local function train_network(target_output, hidden_outputs) local predicted = last_output_activation local error = target_output - predicted if math.abs(error) < 0.001 then return "Already optimal" end local cost = 0.5 * (error ^ 2) local delta_output = error * sigmoid_derivative(predicted) for j = 1, HIDDEN_SIZE do local w_idx = W2_START + j - 1 if PARAMETERS[w_idx] then PARAMETERS[w_idx] = PARAMETERS[w_idx] + current_learning_rate * delta_output * hidden_outputs[j] end end if PARAMETERS[B2_INDEX] then PARAMETERS[B2_INDEX] = PARAMETERS[B2_INDEX] + current_learning_rate * delta_output end for j = 1, HIDDEN_SIZE do local error_at_node = (PARAMETERS[W2_START + j - 1] or 0) * delta_output local hidden_delta = error_at_node * sigmoid_derivative(hidden_outputs[j]) for i = 1, INPUT_SIZE do local w1_idx = W1_START + (j - 1) * INPUT_SIZE + (i - 1) if PARAMETERS[w1_idx] then PARAMETERS[w1_idx] = PARAMETERS[w1_idx] + current_learning_rate * hidden_delta * last_input_features[i] end end local b_idx = B1_START + j - 1 if PARAMETERS[b_idx] then PARAMETERS[b_idx] = PARAMETERS[b_idx] + current_learning_rate * hidden_delta end end return string.format("Training cost: %.4f", cost) end local function generate_conversational_response(confidence) if confidence >= 0.85 then return "That sounds wonderful! Strong positive vibes.", Color3.fromRGB(100, 220, 100) elseif confidence >= 0.60 then return "I'm picking up positive feelings!", Color3.fromRGB(150, 230, 150) elseif confidence >= 0.40 then return "Mixed or neutral sentiment.", Color3.fromRGB(255, 220, 100) elseif confidence >= 0.15 then return "Sensing some negativity.", Color3.fromRGB(255, 180, 100) else return "Strong negative sentiment detected.", Color3.fromRGB(255, 120, 120) end end local function generate_intelligent_response(text, confidence) if is_greeting(text) then return KNOWLEDGE_BASE.greetings[math.random(#KNOWLEDGE_BASE.greetings)] elseif is_farewell(text) then return KNOWLEDGE_BASE.farewells[math.random(#KNOWLEDGE_BASE.farewells)] end local topic = detect_topic(text) if topic and KNOWLEDGE_BASE.topics[topic] then local responses = KNOWLEDGE_BASE.topics[topic] return responses[math.random(#responses)] end local sentiment = analyze_sentiment(text) if sentiment > 2 then return KNOWLEDGE_BASE.positive_responses[math.random(#KNOWLEDGE_BASE.positive_responses)] elseif sentiment < -2 then return KNOWLEDGE_BASE.negative_responses[math.random(#KNOWLEDGE_BASE.negative_responses)] end if is_question(text) then if confidence > 0.7 then return "Based on my analysis, I believe the answer is positive. " .. KNOWLEDGE_BASE.questions[math.random(#KNOWLEDGE_BASE.questions)] elseif confidence < 0.3 then return "That's an interesting question. From what I understand, it might be challenging. " .. KNOWLEDGE_BASE.questions[math.random(#KNOWLEDGE_BASE.questions)] else return "That's a thought-provoking question! Let me think... " .. KNOWLEDGE_BASE.questions[math.random(#KNOWLEDGE_BASE.questions)] end end if confidence >= 0.8 then return "I sense very positive energy from that! " .. (math.random() > 0.5 and "That's wonderful!" or "How exciting!") elseif confidence >= 0.6 then return "That sounds quite positive! " .. (math.random() > 0.5 and "I'd love to hear more." or "Tell me more about it!") elseif confidence >= 0.4 then return "Interesting perspective! " .. (math.random() > 0.5 and "There's a lot to consider here." or "What are your thoughts on this?") elseif confidence >= 0.2 then return "I see what you mean. " .. (math.random() > 0.5 and "That can be complex sometimes." or "How do you usually handle such situations?") else return "I understand that might be challenging. " .. (math.random() > 0.5 and "Would you like to talk about it?" or "I'm here to help if you need it.") end end -- =================================== -- UI SETUP -- =================================== local player = game.Players.LocalPlayer local playerGui = player:WaitForChild("PlayerGui") local screenGui = Instance.new("ScreenGui", playerGui) screenGui.Name = "RoAI_System" screenGui.ResetOnSpawn = false local mainFrame = Instance.new("Frame") mainFrame.Size = UDim2.new(0, 800, 0, 550) mainFrame.Position = UDim2.new(0.5, -400, 0.5, -275) mainFrame.BackgroundColor3 = Color3.fromRGB(18, 18, 20) mainFrame.BorderSizePixel = 0 mainFrame.ClipsDescendants = true mainFrame.Parent = screenGui Instance.new("UICorner", mainFrame).CornerRadius = UDim.new(0, 12) local sidebar = Instance.new("Frame") sidebar.Size = UDim2.new(0, 220, 1, 0) sidebar.BackgroundColor3 = Color3.fromRGB(25, 25, 28) sidebar.BorderSizePixel = 0 sidebar.Parent = mainFrame local sidebarHeader = Instance.new("Frame") sidebarHeader.Size = UDim2.new(1, 0, 0, 50) sidebarHeader.BackgroundColor3 = Color3.fromRGB(30, 30, 35) sidebarHeader.BorderSizePixel = 0 sidebarHeader.Parent = sidebar local logoText = Instance.new("TextLabel") logoText.Text = "🤖 RoAI Chat" logoText.Size = UDim2.new(1, -20, 1, 0) logoText.Position = UDim2.new(0, 10, 0, 0) logoText.BackgroundTransparency = 1 logoText.TextColor3 = Color3.fromRGB(255, 255, 255) logoText.Font = Enum.Font.GothamBold logoText.TextSize = 18 logoText.TextXAlignment = Enum.TextXAlignment.Left logoText.Parent = sidebarHeader local sessionScroll = Instance.new("ScrollingFrame") sessionScroll.Size = UDim2.new(1, -10, 1, -110) sessionScroll.Position = UDim2.new(0, 5, 0, 55) sessionScroll.BackgroundTransparency = 1 sessionScroll.BorderSizePixel = 0 sessionScroll.ScrollBarThickness = 4 sessionScroll.CanvasSize = UDim2.new(0, 0, 0, 0) sessionScroll.Parent = sidebar local sessionList = Instance.new("UIListLayout") sessionList.Padding = UDim.new(0, 6) sessionList.Parent = sessionScroll local newChatBtn = Instance.new("TextButton") newChatBtn.Size = UDim2.new(1, -20, 0, 40) newChatBtn.Position = UDim2.new(0, 10, 1, -50) newChatBtn.BackgroundColor3 = Color3.fromRGB(88, 101, 242) newChatBtn.Text = "✨ New Chat" newChatBtn.TextColor3 = Color3.fromRGB(255, 255, 255) newChatBtn.Font = Enum.Font.GothamBold newChatBtn.TextSize = 14 newChatBtn.BorderSizePixel = 0 newChatBtn.Parent = sidebar Instance.new("UICorner", newChatBtn).CornerRadius = UDim.new(0, 8) local contentFrame = Instance.new("Frame") contentFrame.Size = UDim2.new(1, -220, 1, 0) contentFrame.Position = UDim2.new(0, 220, 0, 0) contentFrame.BackgroundTransparency = 1 contentFrame.Parent = mainFrame local topBar = Instance.new("Frame") topBar.Size = UDim2.new(1, 0, 0, 50) topBar.BackgroundColor3 = Color3.fromRGB(22, 22, 25) topBar.BorderSizePixel = 0 topBar.Parent = contentFrame local sessionTitle = Instance.new("TextLabel") sessionTitle.Text = "Tutorial" sessionTitle.Size = UDim2.new(0, 300, 1, 0) sessionTitle.Position = UDim2.new(0, 15, 0, 0) sessionTitle.BackgroundTransparency = 1 sessionTitle.TextColor3 = Color3.fromRGB(220, 220, 220) sessionTitle.Font = Enum.Font.GothamBold sessionTitle.TextSize = 16 sessionTitle.TextXAlignment = Enum.TextXAlignment.Left sessionTitle.Parent = topBar local modeToggle = Instance.new("TextButton") modeToggle.Size = UDim2.new(0, 140, 0, 32) modeToggle.Position = UDim2.new(1, -335, 0.5, -16) modeToggle.BackgroundColor3 = Color3.fromRGB(40, 40, 45) modeToggle.Text = "📖 Training" modeToggle.TextColor3 = Color3.fromRGB(255, 200, 100) modeToggle.Font = Enum.Font.GothamBold modeToggle.TextSize = 13 modeToggle.Parent = topBar Instance.new("UICorner", modeToggle).CornerRadius = UDim.new(0, 8) local settingsBtn = Instance.new("TextButton") settingsBtn.Size = UDim2.new(0, 40, 0, 32) settingsBtn.Position = UDim2.new(1, -190, 0.5, -16) settingsBtn.BackgroundColor3 = Color3.fromRGB(40, 40, 45) settingsBtn.Text = "⚙️" settingsBtn.TextColor3 = Color3.fromRGB(255, 255, 255) settingsBtn.Font = Enum.Font.GothamBold settingsBtn.TextSize = 18 settingsBtn.Parent = topBar Instance.new("UICorner", settingsBtn).CornerRadius = UDim.new(0, 8) local minimizeBtn = Instance.new("TextButton") minimizeBtn.Size = UDim2.new(0, 40, 0, 32) minimizeBtn.Position = UDim2.new(1, -145, 0.5, -16) minimizeBtn.BackgroundColor3 = Color3.fromRGB(40, 40, 45) minimizeBtn.Text = "−" minimizeBtn.TextColor3 = Color3.fromRGB(255, 255, 255) minimizeBtn.Font = Enum.Font.GothamBold minimizeBtn.TextSize = 24 minimizeBtn.Parent = topBar Instance.new("UICorner", minimizeBtn).CornerRadius = UDim.new(0, 8) local closeBtn = Instance.new("TextButton") closeBtn.Size = UDim2.new(0, 40, 0, 32) closeBtn.Position = UDim2.new(1, -100, 0.5, -16) closeBtn.BackgroundColor3 = Color3.fromRGB(220, 60, 60) closeBtn.Text = "✕" closeBtn.TextColor3 = Color3.fromRGB(255, 255, 255) closeBtn.Font = Enum.Font.GothamBold closeBtn.TextSize = 20 closeBtn.Parent = topBar Instance.new("UICorner", closeBtn).CornerRadius = UDim.new(0, 8) local chatScroll = Instance.new("ScrollingFrame") chatScroll.Size = UDim2.new(1, -30, 1, -130) chatScroll.Position = UDim2.new(0, 15, 0, 60) chatScroll.BackgroundTransparency = 1 chatScroll.BorderSizePixel = 0 chatScroll.ScrollBarThickness = 6 chatScroll.CanvasSize = UDim2.new(0, 0, 0, 0) chatScroll.Visible = false chatScroll.Parent = contentFrame local chatContent = Instance.new("TextLabel") chatContent.Size = UDim2.new(1, -10, 1, 0) chatContent.BackgroundTransparency = 1 chatContent.TextColor3 = Color3.fromRGB(200, 200, 200) chatContent.Font = Enum.Font.Gotham chatContent.TextSize = 14 chatContent.TextWrapped = true chatContent.TextXAlignment = Enum.TextXAlignment.Left chatContent.TextYAlignment = Enum.TextYAlignment.Top chatContent.Parent = chatScroll local tutorialPanel = Instance.new("ScrollingFrame") tutorialPanel.Size = UDim2.new(1, -30, 1, -130) tutorialPanel.Position = UDim2.new(0, 15, 0, 60) tutorialPanel.BackgroundTransparency = 1 tutorialPanel.BorderSizePixel = 0 tutorialPanel.ScrollBarThickness = 6 tutorialPanel.CanvasSize = UDim2.new(0, 0, 0, 1200) tutorialPanel.Parent = contentFrame local tutorialText = Instance.new("TextLabel") tutorialText.Text = [[ 🤖 RoAI - Advanced Conversational AI System v3.0 Welcome to RoAI! A complete AI training system with real-time learning capabilities. ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Note: This Script is Discontinued Please Check For RoMind As It is the new Script also Its not ChatMind, ChatMind was also one of my projects but For now RoAI and ChatMind Are being combined and have merged into RoMind 📊 AVAILABLE ROAI MODELS: 🔹 RoAI 3.5 Ultra (33,281 params) - Most advanced • 128 input features | 256 hidden neurons • Best for complex conversations & learning • Learning Rate: 0.15 🔹 RoAI 3.0 Pro (19,457 params) - Professional • 96 input features | 192 hidden neurons • Excellent all-around performance • Learning Rate: 0.20 🔹 RoAI 2.5 Plus (8,321 params) - Enhanced • 64 input features | 128 hidden neurons • Great for most tasks (default) • Learning Rate: 0.25 🔹 RoAI 2.0 Standard (5,089 params) - Reliable • 48 input features | 96 hidden neurons • Fast & dependable everyday assistant • Learning Rate: 0.30 🔹 RoAI 1.5 Lite (2,177 params) - Fast • 32 input features | 64 hidden neurons • Lightweight & responsive • Learning Rate: 0.35 🔹 RoAI 1.0 Mini (1,225 params) - Minimal • 24 input features | 48 hidden neurons • Ultra-fast instant responses • Learning Rate: 0.40 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 🎯 TWO OPERATING MODES: 📖 TRAINING MODE: • AI analyzes your messages & guesses sentiment • Type "1" for POSITIVE feedback • Type "0" for NEGATIVE feedback • AI learns from corrections in real-time • Watch parameters update as you train • Perfect for teaching emotional context 💬 CHAT MODE: • Natural conversation without corrections • AI responds based on what it's learned • Uses sentiment analysis & intent detection • No training prompts - just natural chat • Topic-aware responses (games, code, etc) Toggle modes anytime with the 📖 button! ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ✨ ADVANCED FEATURES: 🧠 NEURAL NETWORK: • Real backpropagation training algorithm • Adjustable learning rate on the fly • Multiple parameter sizes per model • Persistent session memory 📝 TEXT ANALYSIS: • 50+ grammar pattern detection • Sentiment analysis (positive/negative) • Intent recognition (greeting, question, etc) • Topic detection (games, coding, food, music) • Context-aware responses with memory 💾 SESSION MANAGEMENT: • Create unlimited chat sessions • Each session remembers its model & parameters • Switch between sessions instantly • Auto-save after every message • Sessions persist between executions 🎨 CUSTOM MODELS: • Create your own model architectures • Customize input/hidden layer sizes • Set custom learning rates • Export/import model configurations • Share models via compressed strings 📤 EXPORT/IMPORT: • Copy entire chat histories • Export model parameters • Share sessions with others • Import from export strings • Full session restoration ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ⚙️ SETTINGS PANEL: ✓ Learning Rate Control - Adjust real-time ✓ Custom Model Creator - Build your own ✓ Session Save/Load - Persistent storage ✓ Export/Import Models - Share & restore ✓ Parameter Randomizer - Reset & start fresh ✓ Live Diagnostics - View model stats ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 🚀 GETTING STARTED: 1. Click "✨ New Chat" to begin a session 2. Choose Training or Chat mode (📖 button) 3. Select a model size (🧠 button, optional) 4. Start typing to interact with RoAI 5. In Training mode, type 0 or 1 to train 6. Watch your AI learn in real-time! ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ The more you interact, the better RoAI learns! ]] tutorialText.Size = UDim2.new(1, 0, 1, 0) tutorialText.BackgroundTransparency = 1 tutorialText.TextColor3 = Color3.fromRGB(220, 220, 220) tutorialText.Font = Enum.Font.Gotham tutorialText.TextSize = 12 tutorialText.TextWrapped = true tutorialText.TextXAlignment = Enum.TextXAlignment.Left tutorialText.TextYAlignment = Enum.TextYAlignment.Top tutorialText.LineHeight = 1.4 tutorialText.Parent = tutorialPanel local inputContainer = Instance.new("Frame") inputContainer.Size = UDim2.new(1, -30, 0, 60) inputContainer.Position = UDim2.new(0, 15, 1, -70) inputContainer.BackgroundColor3 = Color3.fromRGB(30, 30, 35) inputContainer.BorderSizePixel = 0 inputContainer.Visible = false inputContainer.Parent = contentFrame Instance.new("UICorner", inputContainer).CornerRadius = UDim.new(0, 10) local inputBox = Instance.new("TextBox") inputBox.Size = UDim2.new(1, -125, 1, -20) inputBox.Position = UDim2.new(0, 15, 0, 10) inputBox.BackgroundTransparency = 1 inputBox.PlaceholderText = "Type your message..." inputBox.PlaceholderColor3 = Color3.fromRGB(120, 120, 120) inputBox.TextColor3 = Color3.fromRGB(255, 255, 255) inputBox.Font = Enum.Font.Gotham inputBox.TextSize = 14 inputBox.TextXAlignment = Enum.TextXAlignment.Left inputBox.TextWrapped = true inputBox.ClearTextOnFocus = false inputBox.Parent = inputContainer local modelsBtn = Instance.new("TextButton") modelsBtn.Size = UDim2.new(0, 40, 0, 40) modelsBtn.Position = UDim2.new(1, -95, 0.5, -20) modelsBtn.BackgroundColor3 = Color3.fromRGB(60, 120, 200) modelsBtn.Text = "🧠" modelsBtn.TextColor3 = Color3.fromRGB(255, 255, 255) modelsBtn.Font = Enum.Font.GothamBold modelsBtn.TextSize = 18 modelsBtn.Parent = inputContainer Instance.new("UICorner", modelsBtn).CornerRadius = UDim.new(0, 20) local sendBtn = Instance.new("TextButton") sendBtn.Size = UDim2.new(0, 40, 0, 40) sendBtn.Position = UDim2.new(1, -50, 0.5, -20) sendBtn.BackgroundColor3 = Color3.fromRGB(88, 101, 242) sendBtn.Text = "➤" sendBtn.TextColor3 = Color3.fromRGB(255, 255, 255) sendBtn.Font = Enum.Font.GothamBold sendBtn.TextSize = 20 sendBtn.Parent = inputContainer Instance.new("UICorner", sendBtn).CornerRadius = UDim.new(0, 20) local modelPanel = Instance.new("Frame") modelPanel.Size = UDim2.new(0, 350, 0, 400) modelPanel.Position = UDim2.new(0.5, -175, 0.5, -200) modelPanel.BackgroundColor3 = Color3.fromRGB(25, 25, 30) modelPanel.BorderSizePixel = 0 modelPanel.Visible = false modelPanel.ZIndex = 10 modelPanel.Parent = screenGui Instance.new("UICorner", modelPanel).CornerRadius = UDim.new(0, 12) local modelHeader = Instance.new("TextLabel") modelHeader.Text = "🧠 Select Model" modelHeader.Size = UDim2.new(1, 0, 0, 45) modelHeader.BackgroundColor3 = Color3.fromRGB(30, 30, 35) modelHeader.TextColor3 = Color3.fromRGB(255, 255, 255) modelHeader.Font = Enum.Font.GothamBold modelHeader.TextSize = 16 modelHeader.Parent = modelPanel Instance.new("UICorner", modelHeader).CornerRadius = UDim.new(0, 12) local modelScroll = Instance.new("ScrollingFrame") modelScroll.Size = UDim2.new(1, -20, 1, -55) modelScroll.Position = UDim2.new(0, 10, 0, 50) modelScroll.BackgroundTransparency = 1 modelScroll.BorderSizePixel = 0 modelScroll.ScrollBarThickness = 4 modelScroll.CanvasSize = UDim2.new(0, 0, 0, 0) modelScroll.Parent = modelPanel local modelList = Instance.new("UIListLayout") modelList.Padding = UDim.new(0, 8) modelList.Parent = modelScroll local modelCloseBtn = Instance.new("TextButton") modelCloseBtn.Size = UDim2.new(0, 30, 0, 30) modelCloseBtn.Position = UDim2.new(1, -35, 0, 7.5) modelCloseBtn.BackgroundColor3 = Color3.fromRGB(220, 60, 60) modelCloseBtn.Text = "✕" modelCloseBtn.TextColor3 = Color3.fromRGB(255, 255, 255) modelCloseBtn.Font = Enum.Font.GothamBold modelCloseBtn.TextSize = 16 modelCloseBtn.ZIndex = 11 modelCloseBtn.Parent = modelPanel Instance.new("UICorner", modelCloseBtn).CornerRadius = UDim.new(0, 15) local settingsPanel = Instance.new("Frame") settingsPanel.Size = UDim2.new(1, 0, 1, 0) settingsPanel.BackgroundColor3 = Color3.fromRGB(18, 18, 20) settingsPanel.BorderSizePixel = 0 settingsPanel.Visible = false settingsPanel.Parent = contentFrame local settingsScroll = Instance.new("ScrollingFrame") settingsScroll.Size = UDim2.new(1, -30, 1, -70) settingsScroll.Position = UDim2.new(0, 15, 0, 60) settingsScroll.BackgroundTransparency = 1 settingsScroll.BorderSizePixel = 0 settingsScroll.ScrollBarThickness = 6 settingsScroll.CanvasSize = UDim2.new(0, 0, 0, 1200) settingsScroll.Parent = settingsPanel local settingsList = Instance.new("UIListLayout") settingsList.Padding = UDim.new(0, 10) settingsList.Parent = settingsScroll local function createLabel(text, parent) local label = Instance.new("TextLabel") label.Text = text label.Size = UDim2.new(1, -10, 0, 25) label.BackgroundTransparency = 1 label.TextColor3 = Color3.fromRGB(150, 200, 255) label.Font = Enum.Font.GothamBold label.TextSize = 14 label.TextXAlignment = Enum.TextXAlignment.Left label.Parent = parent return label end local lrLabel = createLabel("⚡ Learning Rate: " .. string.format("%.2f", current_learning_rate), settingsScroll) local lrInput = Instance.new("TextBox") lrInput.Size = UDim2.new(1, -10, 0, 35) lrInput.BackgroundColor3 = Color3.fromRGB(35, 35, 40) lrInput.Text = string.format("%.2f", current_learning_rate) lrInput.PlaceholderText = "0.1 - 2.0" lrInput.TextColor3 = Color3.fromRGB(255, 255, 255) lrInput.Font = Enum.Font.Gotham lrInput.TextSize = 13 lrInput.Parent = settingsScroll Instance.new("UICorner", lrInput).CornerRadius = UDim.new(0, 6) createLabel("🛠️ Create Custom Model", settingsScroll) local createModelBtn = Instance.new("TextButton") createModelBtn.Size = UDim2.new(1, -10, 0, 45) createModelBtn.BackgroundColor3 = Color3.fromRGB(120, 80, 200) createModelBtn.Text = "➕ Open Model Creator" createModelBtn.TextColor3 = Color3.fromRGB(255, 255, 255) createModelBtn.Font = Enum.Font.GothamBold createModelBtn.TextSize = 14 createModelBtn.Parent = settingsScroll Instance.new("UICorner", createModelBtn).CornerRadius = UDim.new(0, 8) createLabel("💾 Session Management", settingsScroll) local saveBtn = Instance.new("TextButton") saveBtn.Size = UDim2.new(1, -10, 0, 40) saveBtn.BackgroundColor3 = Color3.fromRGB(60, 180, 80) saveBtn.Text = "💾 Save All Sessions" saveBtn.TextColor3 = Color3.fromRGB(255, 255, 255) saveBtn.Font = Enum.Font.GothamBold saveBtn.TextSize = 14 saveBtn.Parent = settingsScroll Instance.new("UICorner", saveBtn).CornerRadius = UDim.new(0, 6) local loadBtn = Instance.new("TextButton") loadBtn.Size = UDim2.new(1, -10, 0, 40) loadBtn.BackgroundColor3 = Color3.fromRGB(80, 120, 200) loadBtn.Text = "📂 Load Sessions" loadBtn.TextColor3 = Color3.fromRGB(255, 255, 255) loadBtn.Font = Enum.Font.GothamBold loadBtn.TextSize = 14 loadBtn.Parent = settingsScroll Instance.new("UICorner", loadBtn).CornerRadius = UDim.new(0, 6) createLabel("📤 Export/Import Models", settingsScroll) local exportBtn = Instance.new("TextButton") exportBtn.Size = UDim2.new(1, -10, 0, 40) exportBtn.BackgroundColor3 = Color3.fromRGB(180, 120, 60) exportBtn.Text = "📋 Copy Export String" exportBtn.TextColor3 = Color3.fromRGB(255, 255, 255) exportBtn.Font = Enum.Font.GothamBold exportBtn.TextSize = 14 exportBtn.Parent = settingsScroll Instance.new("UICorner", exportBtn).CornerRadius = UDim.new(0, 6) local importInput = Instance.new("TextBox") importInput.Size = UDim2.new(1, -10, 0, 60) importInput.BackgroundColor3 = Color3.fromRGB(35, 35, 40) importInput.PlaceholderText = "Paste export string here..." importInput.TextColor3 = Color3.fromRGB(255, 255, 255) importInput.Font = Enum.Font.Code importInput.TextSize = 11 importInput.TextWrapped = true importInput.TextXAlignment = Enum.TextXAlignment.Left importInput.TextYAlignment = Enum.TextYAlignment.Top importInput.ClearTextOnFocus = false importInput.MultiLine = true importInput.Parent = settingsScroll Instance.new("UICorner", importInput).CornerRadius = UDim.new(0, 6) local importBtn = Instance.new("TextButton") importBtn.Size = UDim2.new(1, -10, 0, 40) importBtn.BackgroundColor3 = Color3.fromRGB(120, 80, 180) importBtn.Text = "📥 Import String" importBtn.TextColor3 = Color3.fromRGB(255, 255, 255) importBtn.Font = Enum.Font.GothamBold importBtn.TextSize = 14 importBtn.Parent = settingsScroll Instance.new("UICorner", importBtn).CornerRadius = UDim.new(0, 6) createLabel("🔄 Reset Parameters", settingsScroll) local randomizeBtn = Instance.new("TextButton") randomizeBtn.Size = UDim2.new(1, -10, 0, 40) randomizeBtn.BackgroundColor3 = Color3.fromRGB(200, 80, 80) randomizeBtn.Text = "🎲 Randomize Current Model" randomizeBtn.TextColor3 = Color3.fromRGB(255, 255, 255) randomizeBtn.Font = Enum.Font.GothamBold randomizeBtn.TextSize = 14 randomizeBtn.Parent = settingsScroll Instance.new("UICorner", randomizeBtn).CornerRadius = UDim.new(0, 6) createLabel("📊 Diagnostics", settingsScroll) local diagBox = Instance.new("TextLabel") diagBox.Size = UDim2.new(1, -10, 0, 120) diagBox.BackgroundColor3 = Color3.fromRGB(25, 25, 30) diagBox.TextColor3 = Color3.fromRGB(200, 200, 200) diagBox.Font = Enum.Font.Code diagBox.TextSize = 11 diagBox.TextXAlignment = Enum.TextXAlignment.Left diagBox.TextYAlignment = Enum.TextYAlignment.Top diagBox.TextWrapped = true diagBox.Text = "Loading..." diagBox.Parent = settingsScroll Instance.new("UICorner", diagBox).CornerRadius = UDim.new(0, 6) local creatorPanel = Instance.new("Frame") creatorPanel.Size = UDim2.new(0, 400, 0, 450) creatorPanel.Position = UDim2.new(0.5, -200, 0.5, -225) creatorPanel.BackgroundColor3 = Color3.fromRGB(25, 25, 30) creatorPanel.BorderSizePixel = 0 creatorPanel.Visible = false creatorPanel.ZIndex = 10 creatorPanel.Parent = screenGui Instance.new("UICorner", creatorPanel).CornerRadius = UDim.new(0, 12) local creatorHeader = Instance.new("TextLabel") creatorHeader.Text = "🛠️ Create Custom Model" creatorHeader.Size = UDim2.new(1, 0, 0, 45) creatorHeader.BackgroundColor3 = Color3.fromRGB(30, 30, 35) creatorHeader.TextColor3 = Color3.fromRGB(255, 255, 255) creatorHeader.Font = Enum.Font.GothamBold creatorHeader.TextSize = 16 creatorHeader.Parent = creatorPanel Instance.new("UICorner", creatorHeader).CornerRadius = UDim.new(0, 12) local creatorScroll = Instance.new("ScrollingFrame") creatorScroll.Size = UDim2.new(1, -20, 1, -100) creatorScroll.Position = UDim2.new(0, 10, 0, 50) creatorScroll.BackgroundTransparency = 1 creatorScroll.BorderSizePixel = 0 creatorScroll.ScrollBarThickness = 4 creatorScroll.CanvasSize = UDim2.new(0, 0, 0, 350) creatorScroll.Parent = creatorPanel local creatorList = Instance.new("UIListLayout") creatorList.Padding = UDim.new(0, 10) creatorList.Parent = creatorScroll local function createCreatorInput(labelText, placeholder, parent) local label = createLabel(labelText, parent) local input = Instance.new("TextBox") input.Size = UDim2.new(1, -10, 0, 35) input.BackgroundColor3 = Color3.fromRGB(35, 35, 40) input.PlaceholderText = placeholder input.Text = "" input.TextColor3 = Color3.fromRGB(255, 255, 255) input.Font = Enum.Font.Gotham input.TextSize = 13 input.Parent = parent Instance.new("UICorner", input).CornerRadius = UDim.new(0, 6) return input end local nameInput = createCreatorInput("Model Name:", "e.g., My Custom Model", creatorScroll) local inputSizeInput = createCreatorInput("Input Size:", "e.g., 50", creatorScroll) local hiddenSizeInput = createCreatorInput("Hidden Size:", "e.g., 100", creatorScroll) local lrCreatorInput = createCreatorInput("Learning Rate:", "e.g., 0.3", creatorScroll) local paramCountLabel = Instance.new("TextLabel") paramCountLabel.Text = "📊 Parameters: 0" paramCountLabel.Size = UDim2.new(1, -10, 0, 30) paramCountLabel.BackgroundColor3 = Color3.fromRGB(35, 35, 40) paramCountLabel.TextColor3 = Color3.fromRGB(150, 200, 255) paramCountLabel.Font = Enum.Font.GothamBold paramCountLabel.TextSize = 13 paramCountLabel.Parent = creatorScroll Instance.new("UICorner", paramCountLabel).CornerRadius = UDim.new(0, 6) local createFinalBtn = Instance.new("TextButton") createFinalBtn.Size = UDim2.new(1, -20, 0, 45) createFinalBtn.Position = UDim2.new(0, 10, 1, -50) createFinalBtn.BackgroundColor3 = Color3.fromRGB(88, 101, 242) createFinalBtn.Text = "✨ Create Model" createFinalBtn.TextColor3 = Color3.fromRGB(255, 255, 255) createFinalBtn.Font = Enum.Font.GothamBold createFinalBtn.TextSize = 15 createFinalBtn.ZIndex = 11 createFinalBtn.Parent = creatorPanel Instance.new("UICorner", createFinalBtn).CornerRadius = UDim.new(0, 8) local creatorCloseBtn = Instance.new("TextButton") creatorCloseBtn.Size = UDim2.new(0, 30, 0, 30) creatorCloseBtn.Position = UDim2.new(1, -35, 0, 7.5) creatorCloseBtn.BackgroundColor3 = Color3.fromRGB(220, 60, 60) creatorCloseBtn.Text = "✕" creatorCloseBtn.TextColor3 = Color3.fromRGB(255, 255, 255) creatorCloseBtn.Font = Enum.Font.GothamBold creatorCloseBtn.TextSize = 16 creatorCloseBtn.ZIndex = 11 creatorCloseBtn.Parent = creatorPanel Instance.new("UICorner", creatorCloseBtn).CornerRadius = UDim.new(0, 15) local floatingBtn = Instance.new("TextButton") floatingBtn.Size = UDim2.new(0, 60, 0, 60) floatingBtn.Position = UDim2.new(1, -70, 1, -70) floatingBtn.BackgroundColor3 = Color3.fromRGB(88, 101, 242) floatingBtn.Text = "🤖" floatingBtn.TextColor3 = Color3.fromRGB(255, 255, 255) floatingBtn.Font = Enum.Font.GothamBold floatingBtn.TextSize = 28 floatingBtn.Visible = false floatingBtn.Parent = screenGui Instance.new("UICorner", floatingBtn).CornerRadius = UDim.new(0, 30) -- =================================== -- LOGIC FUNCTIONS -- =================================== local function update_diagnostics() local text = "🧠 Model: " .. CURRENT_MODEL_NAME .. "\n" text = text .. "📊 Parameters: " .. TARGET_PARAMETER_COUNT .. "\n" text = text .. "⚡ Learning Rate: " .. string.format("%.3f", current_learning_rate) .. "\n" text = text .. "🎯 Mode: " .. (CONVERSATIONAL_MODE and "Chat" or "Training") .. "\n\n" text = text .. "📈 Architecture:\n" text = text .. " Input: " .. INPUT_SIZE .. "\n" text = text .. " Hidden: " .. HIDDEN_SIZE .. "\n" text = text .. " Output: " .. OUTPUT_SIZE .. "\n\n" text = text .. "Sample Weights:\n" for i = 1, math.min(3, TARGET_PARAMETER_COUNT) do text = text .. string.format("W1[%d]: %.4f\n", i, PARAMETERS[i] or 0) end diagBox.Text = text lrLabel.Text = "⚡ Learning Rate: " .. string.format("%.2f", current_learning_rate) end local function add_message(sender, text) local message = {sender = sender, text = text, isAI = (sender == "RoAI")} table.insert(ChatSessions[CurrentSessionName].messages, message) local displayText = "" for _, msg in ipairs(ChatSessions[CurrentSessionName].messages) do displayText = displayText .. msg.sender .. ": " .. msg.text .. "\n\n" end chatContent.Text = displayText local contentHeight = chatContent.TextBounds.Y + 20 chatScroll.CanvasSize = UDim2.new(0, 0, 0, contentHeight) chatScroll.CanvasPosition = Vector2.new(0, contentHeight) pcall(function() save_all_sessions() end) end local function create_session_button(name) local btn = Instance.new("TextButton") btn.Name = "SessionBtn_" .. name btn.Size = UDim2.new(1, -10, 0, 36) btn.BackgroundColor3 = (name == CurrentSessionName) and Color3.fromRGB(50, 50, 55) or Color3.fromRGB(30, 30, 35) btn.Text = " " .. name btn.TextColor3 = (name == CurrentSessionName) and Color3.fromRGB(255, 255, 255) or Color3.fromRGB(180, 180, 180) btn.Font = Enum.Font.Gotham btn.TextSize = 13 btn.TextXAlignment = Enum.TextXAlignment.Left btn.TextTruncate = Enum.TextTruncate.AtEnd btn.Parent = sessionScroll Instance.new("UICorner", btn).CornerRadius = UDim.new(0, 6) btn.MouseButton1Click:Connect(function() load_session(name) end) return btn end local function draw_session_list() for _, child in ipairs(sessionScroll:GetChildren()) do if child:IsA("TextButton") then child:Destroy() end end local tutBtn = Instance.new("TextButton") tutBtn.Name = "TutorialBtn" tutBtn.Size = UDim2.new(1, -10, 0, 36) tutBtn.BackgroundColor3 = (CurrentSessionName == "Tutorial") and Color3.fromRGB(50, 50, 55) or Color3.fromRGB(30, 30, 35) tutBtn.Text = " 📚 Tutorial" tutBtn.TextColor3 = (CurrentSessionName == "Tutorial") and Color3.fromRGB(255, 255, 255) or Color3.fromRGB(180, 180, 180) tutBtn.Font = Enum.Font.GothamBold tutBtn.TextSize = 13 tutBtn.TextXAlignment = Enum.TextXAlignment.Left tutBtn.Parent = sessionScroll Instance.new("UICorner", tutBtn).CornerRadius = UDim.new(0, 6) tutBtn.MouseButton1Click:Connect(function() load_session("Tutorial") end) local count = 1 for name, _ in pairs(ChatSessions) do create_session_button(name) count = count + 1 end sessionScroll.CanvasSize = UDim2.new(0, 0, 0, (count * 36) + (count * 6)) end function load_session(name) if ChatSessions[CurrentSessionName] and ChatSessions[CurrentSessionName].params then ChatSessions[CurrentSessionName].params = table_clone(PARAMETERS) end CurrentSessionName = name sessionTitle.Text = name local isChat = ChatSessions[name] ~= nil chatScroll.Visible = isChat inputContainer.Visible = isChat tutorialPanel.Visible = not isChat settingsPanel.Visible = false if isChat then local session = ChatSessions[CurrentSessionName] CURRENT_MODEL_NAME = session.model or "RoAI 2.5 Plus" local modelConfig = MODEL_PRESETS[CURRENT_MODEL_NAME] if modelConfig then INPUT_SIZE = modelConfig.input HIDDEN_SIZE = modelConfig.hidden OUTPUT_SIZE = modelConfig.output current_learning_rate = modelConfig.learning_rate TARGET_PARAMETER_COUNT = calculate_param_count() update_parameter_indices() end PARAMETERS = table_clone(session.params) local displayText = "" for _, msg in ipairs(session.messages) do displayText = displayText .. msg.sender .. ": " .. msg.text .. "\n\n" end chatContent.Text = displayText local contentHeight = chatContent.TextBounds.Y + 20 chatScroll.CanvasSize = UDim2.new(0, 0, 0, contentHeight) chatScroll.CanvasPosition = Vector2.new(0, contentHeight) end draw_session_list() update_diagnostics() end local function switch_model(modelName) local modelConfig = MODEL_PRESETS[modelName] if not modelConfig then return end CURRENT_MODEL_NAME = modelName INPUT_SIZE = modelConfig.input HIDDEN_SIZE = modelConfig.hidden OUTPUT_SIZE = modelConfig.output current_learning_rate = modelConfig.learning_rate TARGET_PARAMETER_COUNT = calculate_param_count() update_parameter_indices() PARAMETERS = initialize_parameters() if ChatSessions[CurrentSessionName] then ChatSessions[CurrentSessionName].params = table_clone(PARAMETERS) ChatSessions[CurrentSessionName].model = modelName add_message("🤖 System", "Switched to " .. modelName .. " (" .. TARGET_PARAMETER_COUNT .. " parameters)") end update_diagnostics() end local function populate_model_list() for _, child in ipairs(modelScroll:GetChildren()) do if child:IsA("TextButton") then child:Destroy() end end local count = 0 for modelName, config in pairs(MODEL_PRESETS) do local paramCount = (config.input * config.hidden) + config.hidden + (config.hidden * config.output) + config.output local btn = Instance.new("TextButton") btn.Size = UDim2.new(1, -10, 0, 70) btn.BackgroundColor3 = (modelName == CURRENT_MODEL_NAME) and Color3.fromRGB(60, 120, 200) or Color3.fromRGB(35, 35, 40) btn.BorderSizePixel = 0 btn.Parent = modelScroll Instance.new("UICorner", btn).CornerRadius = UDim.new(0, 8) local title = Instance.new("TextLabel") title.Text = modelName title.Size = UDim2.new(1, -20, 0, 25) title.Position = UDim2.new(0, 10, 0, 5) title.BackgroundTransparency = 1 title.TextColor3 = Color3.fromRGB(255, 255, 255) title.Font = Enum.Font.GothamBold title.TextSize = 14 title.TextXAlignment = Enum.TextXAlignment.Left title.Parent = btn local info = Instance.new("TextLabel") info.Text = string.format("📊 %d params | Input: %d | Hidden: %d", paramCount, config.input, config.hidden) info.Size = UDim2.new(1, -20, 0, 20) info.Position = UDim2.new(0, 10, 0, 30) info.BackgroundTransparency = 1 info.TextColor3 = Color3.fromRGB(180, 180, 180) info.Font = Enum.Font.Gotham info.TextSize = 11 info.TextXAlignment = Enum.TextXAlignment.Left info.Parent = btn local lr = Instance.new("TextLabel") lr.Text = string.format("⚡ LR: %.2f", config.learning_rate) lr.Size = UDim2.new(1, -20, 0, 15) lr.Position = UDim2.new(0, 10, 0, 50) lr.BackgroundTransparency = 1 lr.TextColor3 = Color3.fromRGB(150, 200, 255) lr.Font = Enum.Font.Gotham lr.TextSize = 10 lr.TextXAlignment = Enum.TextXAlignment.Left lr.Parent = btn btn.MouseButton1Click:Connect(function() switch_model(modelName) modelPanel.Visible = false end) count = count + 1 end modelScroll.CanvasSize = UDim2.new(0, 0, 0, (count * 70) + (count * 8)) end local function handle_input(text) if CurrentSessionName == "Tutorial" or text:len() == 0 then return end inputBox.Text = "" local target = tonumber(text) if (target == 0 or target == 1) and INPUT_PARSING_PASSED and not CONVERSATIONAL_MODE then add_message("You", "Training: " .. target) local confidence, hidden = run_ai_inference(last_input_features) local result = train_network(target, hidden) add_message("🤖 RoAI", "Trained! " .. result) INPUT_PARSING_PASSED = false update_diagnostics() else add_message("You", text) local confidence, hidden = run_ai_inference(preprocess_text(text)) if CONVERSATIONAL_MODE then local response = generate_intelligent_response(text, confidence) add_message("🤖 RoAI", response) else local response, color = generate_conversational_response(confidence) add_message("🤖 RoAI", string.format(response .. " (%.2f) - Train with 0/1", confidence)) INPUT_PARSING_PASSED = true end end end -- =================================== -- UI INTERACTIONS -- =================================== local dragging = false local dragStart, startPos topBar.InputBegan:Connect(function(input) if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then dragging = true dragStart = input.Position startPos = mainFrame.Position end end) UserInputService.InputChanged:Connect(function(input) if dragging and (input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch) then local delta = input.Position - dragStart mainFrame.Position = UDim2.new( startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y ) end end) UserInputService.InputEnded:Connect(function(input) if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then dragging = false end end) modeToggle.MouseButton1Click:Connect(function() CONVERSATIONAL_MODE = not CONVERSATIONAL_MODE if CONVERSATIONAL_MODE then modeToggle.Text = "💬 Chat" modeToggle.TextColor3 = Color3.fromRGB(100, 200, 255) modeToggle.BackgroundColor3 = Color3.fromRGB(40, 50, 65) else modeToggle.Text = "📖 Training" modeToggle.TextColor3 = Color3.fromRGB(255, 200, 100) modeToggle.BackgroundColor3 = Color3.fromRGB(40, 40, 45) end update_diagnostics() end) settingsBtn.MouseButton1Click:Connect(function() if CurrentSessionName ~= "Tutorial" then lastReturnSession = CurrentSessionName end settingsPanel.Visible = not settingsPanel.Visible chatScroll.Visible = not settingsPanel.Visible and ChatSessions[CurrentSessionName] ~= nil inputContainer.Visible = not settingsPanel.Visible and ChatSessions[CurrentSessionName] ~= nil tutorialPanel.Visible = not settingsPanel.Visible and CurrentSessionName == "Tutorial" if settingsPanel.Visible then update_diagnostics() end end) local isMinimized = false local originalSize = mainFrame.Size minimizeBtn.MouseButton1Click:Connect(function() if not isMinimized then TweenService:Create(mainFrame, TweenInfo.new(0.2), { Size = UDim2.new(0, 800, 0, 50) }):Play() contentFrame.Visible = false sidebar.Visible = false minimizeBtn.Text = "□" isMinimized = true else TweenService:Create(mainFrame, TweenInfo.new(0.2), { Size = originalSize }):Play() wait(0.2) contentFrame.Visible = true sidebar.Visible = true minimizeBtn.Text = "−" isMinimized = false end end) closeBtn.MouseButton1Click:Connect(function() mainFrame.Visible = false floatingBtn.Visible = true end) floatingBtn.MouseButton1Click:Connect(function() floatingBtn.Visible = false mainFrame.Visible = true if isMinimized then TweenService:Create(mainFrame, TweenInfo.new(0.2), { Size = originalSize }):Play() wait(0.2) contentFrame.Visible = true sidebar.Visible = true minimizeBtn.Text = "−" isMinimized = false end end) newChatBtn.MouseButton1Click:Connect(function() local num = 1 while ChatSessions["Session " .. num] do num = num + 1 end local newName = "Session " .. num ChatSessions[newName] = { messages = {{sender = "🤖 RoAI", text = "New session with " .. CURRENT_MODEL_NAME .. "!", isAI = true}}, params = initialize_parameters(), model = CURRENT_MODEL_NAME } load_session(newName) end) sendBtn.MouseButton1Click:Connect(function() handle_input(inputBox.Text) end) inputBox.FocusLost:Connect(function(enter) if enter then handle_input(inputBox.Text) end end) modelsBtn.MouseButton1Click:Connect(function() populate_model_list() modelPanel.Visible = true end) modelCloseBtn.MouseButton1Click:Connect(function() modelPanel.Visible = false end) lrInput.FocusLost:Connect(function() local newLR = tonumber(lrInput.Text) if newLR and newLR > 0 and newLR <= 2 then current_learning_rate = newLR update_diagnostics() else lrInput.Text = string.format("%.2f", current_learning_rate) end end) createModelBtn.MouseButton1Click:Connect(function() creatorPanel.Visible = true end) creatorCloseBtn.MouseButton1Click:Connect(function() creatorPanel.Visible = false if lastReturnSession ~= "Tutorial" and ChatSessions[lastReturnSession] then load_session(lastReturnSession) end end) local function updateParamCount() local input = tonumber(inputSizeInput.Text) or 0 local hidden = tonumber(hiddenSizeInput.Text) or 0 local params = (input * hidden) + hidden + hidden + 1 paramCountLabel.Text = "📊 Parameters: " .. params end inputSizeInput:GetPropertyChangedSignal("Text"):Connect(updateParamCount) hiddenSizeInput:GetPropertyChangedSignal("Text"):Connect(updateParamCount) createFinalBtn.MouseButton1Click:Connect(function() local modelName = nameInput.Text local inputSize = tonumber(inputSizeInput.Text) local hiddenSize = tonumber(hiddenSizeInput.Text) local lr = tonumber(lrCreatorInput.Text) if modelName == "" or not inputSize or not hiddenSize or not lr then createFinalBtn.Text = "❌ Fill all fields!" wait(2) createFinalBtn.Text = "✨ Create Model" return end if inputSize < 10 or inputSize > 200 or hiddenSize < 10 or hiddenSize > 500 then createFinalBtn.Text = "❌ Invalid sizes!" wait(2) createFinalBtn.Text = "✨ Create Model" return end MODEL_PRESETS[modelName] = { input = inputSize, hidden = hiddenSize, output = 1, learning_rate = lr } createFinalBtn.Text = "✅ Model Created!" wait(1) creatorPanel.Visible = false createFinalBtn.Text = "✨ Create Model" nameInput.Text = "" inputSizeInput.Text = "" hiddenSizeInput.Text = "" lrCreatorInput.Text = "" if lastReturnSession ~= "Tutorial" and ChatSessions[lastReturnSession] then load_session(lastReturnSession) end end) saveBtn.MouseButton1Click:Connect(function() local success = pcall(save_all_sessions) if success then saveBtn.Text = "✅ Saved!" wait(1.5) saveBtn.Text = "💾 Save All Sessions" else saveBtn.Text = "❌ Error" wait(1.5) saveBtn.Text = "💾 Save All Sessions" end end) loadBtn.MouseButton1Click:Connect(function() local success = pcall(load_all_sessions) if success then loadBtn.Text = "✅ Loaded!" local first = next(ChatSessions) if first then load_session(first) end wait(1.5) loadBtn.Text = "📂 Load Sessions" else loadBtn.Text = "❌ No Save Found" wait(1.5) loadBtn.Text = "📂 Load Sessions" end end) exportBtn.MouseButton1Click:Connect(function() local exportStr = generate_export_string() setclipboard(exportStr) exportBtn.Text = "✅ Copied!" wait(2) exportBtn.Text = "📋 Copy Export String" end) importBtn.MouseButton1Click:Connect(function() local importStr = importInput.Text if importStr:len() > 0 then local success, msg = import_from_string(importStr) if success then importBtn.Text = "✅ Imported!" local first = next(ChatSessions) if first then load_session(first) end else importBtn.Text = "❌ " .. msg end wait(2) importBtn.Text = "📥 Import String" end end) randomizeBtn.MouseButton1Click:Connect(function() PARAMETERS = initialize_parameters() if ChatSessions[CurrentSessionName] then ChatSessions[CurrentSessionName].params = table_clone(PARAMETERS) end randomizeBtn.Text = "✅ Randomized!" update_diagnostics() wait(1.5) randomizeBtn.Text = "🎲 Randomize Current Model" end) -- =================================== -- INITIALIZATION -- =================================== local loadSuccess = pcall(load_all_sessions) if not loadSuccess then PARAMETERS = initialize_parameters() ChatSessions = { ["Session 1"] = { messages = {{sender = "🤖 RoAI", text = "Welcome! " .. CURRENT_MODEL_NAME .. " ready. Toggle modes above!", isAI = true}}, params = table_clone(PARAMETERS), model = CURRENT_MODEL_NAME } } end load_session(CurrentSessionName) print("🤖 RoAI System v3.0 Loaded!") print("📊 Current: " .. CURRENT_MODEL_NAME) print("✨ Custom models supported!") if loadSuccess then print("💾 Previous sessions restored!") end