????JFIF??x?x????'
Server IP : 79.136.114.73 / Your IP : 3.21.33.186 Web Server : Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.29 OpenSSL/1.0.1f System : Linux b8009 3.13.0-170-generic #220-Ubuntu SMP Thu May 9 12:40:49 UTC 2019 x86_64 User : www-data ( 33) PHP Version : 5.5.9-1ubuntu4.29 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/appsrv.astacus.se/ai/wenginegpt/ |
Upload File : |
<?php // Din API-nyckel $text = "using System; using System.Collections.Generic; namespace WebUIHandler { public class UIWexer { // Lista över UI-komponenter private List<string> components = new List<string>(); /// <summary> /// Lägg till en UI-komponent (t.ex. knapp, textfält, etc.). /// </summary> /// <param name=\"component\">Namnet på komponenten.</param> public void AddComponent(string component) { components.Add(component); Console.WriteLine($\"Komponent '{component}' har lagts till.\"); } /// <summary> /// Rendera alla UI-komponenter. /// </summary> public void RenderComponents() { Console.WriteLine(\"Rendering UI-komponenter:\"); foreach (var component in components) { Console.WriteLine($\"- {component}\"); } } /// <summary> /// Uppdatera en UI-komponent. /// </summary> /// <param name=\"oldComponent\">Namnet på den befintliga komponenten.</param> /// <param name=\"newComponent\">Namnet på den nya komponenten.</param> public void UpdateComponent(string oldComponent, string newComponent) { if (components.Contains(oldComponent)) { int index = components.IndexOf(oldComponent); components[index] = newComponent; Console.WriteLine($\"Komponent '{oldComponent}' har uppdaterats till '{newComponent}'.\"); } else { Console.WriteLine($\"Komponent '{oldComponent}' hittades inte.\"); } } /// <summary> /// Ta bort en UI-komponent. /// </summary> /// <param name=\"component\">Namnet på komponenten som ska tas bort.</param> public void RemoveComponent(string component) { if (components.Remove(component)) { Console.WriteLine($\"Komponent '{component}' har tagits bort.\"); } else { Console.WriteLine($\"Komponent '{component}' hittades inte.\"); } } /// <summary> /// Hitta en UI-komponent. /// </summary> /// <param name=\"component\">Namnet på komponenten som ska hittas.</param> /// <returns>True om komponenten hittades, annars false.</returns> public bool FindComponent(string component) { bool found = components.Contains(component); Console.WriteLine(found ? $\"Komponent '{component}' hittades.\" : $\"Komponent '{component}' hittades inte.\"); return found; } } class Program { static void Main(string[] args) { UIWexer uiHandler = new UIWexer(); // Lägg till komponenter uiHandler.AddComponent(\"Button\"); uiHandler.AddComponent(\"TextBox\"); uiHandler.AddComponent(\"Dropdown\"); // Rendera komponenter uiHandler.RenderComponents(); // Uppdatera en komponent uiHandler.UpdateComponent(\"TextBox\", \"SearchBox\"); // Ta bort en komponent uiHandler.RemoveComponent(\"Button\"); // Hitta en komponent uiHandler.FindComponent(\"Dropdown\"); // Rendera efter ändringar uiHandler.RenderComponents(); } } }"; function askQuestion($userQuestion, $text){ $openai_api_key = "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"; // Frågan från användaren // Skicka frågan till OpenAI om den inte är tom if (!empty($userQuestion)) { $data = [ 'model' => 'gpt-4', 'messages' => [ [ 'role' => 'system', 'content' => "Du är en expert på följande text:\n\n" . $text . "\n\nSvara bara baserat på denna information." ], [ 'role' => 'user', 'content' => $userQuestion ] ] ]; // cURL-anrop till OpenAI API $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://api.openai.com/v1/chat/completions'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Content-Type: application/json', 'Authorization: Bearer ' . $openai_api_key ]); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); $response = curl_exec($ch); print_r( $response ); if (curl_errno($ch)) { echo "Fel vid API-anropet: " . curl_error($ch); } else { $result = json_decode($response, true); echo "Svar: " . $result['choices'][0]['message']['content']; return $result['choices'][0]['message']['content']; } curl_close($ch); }} ?> <html> <head> <meta charset="utf-8"> <title>Wengine GPT</title> </head> <?php if($_POST['question'] != ""){ echo("Skickar förfrågan..."); $userQuestion = $_POST['question']; $response = askQuestion($userQuestion, $text); } ?> <form action="index.php" method="post"> <textarea id="question" rows="10" cols="50">Vilka funktioner finns det?</textarea><input type="submit"> </form> <br><?php echo($response);?> <body> </body> </html>