AW: Programme bzw. Funktionen von KI schreiben lassen (OpenAI)
"schreib ein Programm, was Dieses und Jenes macht"
"erstelle ein Betriebssystem in Delphi" geht nicht, weil Zitat:
|
AW: Programme bzw. Funktionen von KI schreiben lassen (OpenAI)
Also ich fand, die Sache ist es wert, mal wieder ein kurzes Video zu machen.
Dort bin ich auch mal der Frage nachgegangen, ob man auch .dfm Dateien oder auch passende Projekt-Dateien direkt von der AI erstellen lassen kann. Was dabei herausgekommen ist, könnt Ihr Euch hier ansehen: https://youtu.be/d9TZ6LUWqOs |
AW: Programme bzw. Funktionen von KI schreiben lassen (OpenAI)
Me: Create a Delphi console application that implements a chatbot
Chatbot: Sure! Here is an example of how you can create a simple chatbot in Delphi using the console application:
Delphi-Quellcode:
This chatbot will greet the user and then enter into a loop where it will continually read the user's input and respond with a predefined message. The chatbot can understand and respond to a few specific phrases, such as "hi", "hello", "how are you", and "what can you do". If the user enters any other phrase, the chatbot will respond with a default message.
program Chatbot;
{$APPTYPE CONSOLE} uses SysUtils; var input: string; begin WriteLn('Hello, I am a chatbot. How can I help you today?'); while True do begin Write('You: '); ReadLn(input); if input = 'exit' then Break; case input of 'hi', 'hello': WriteLn('Chatbot: Hi there! How are you doing?'); 'how are you': WriteLn('Chatbot: I am just a computer program, so I don''t have feelings. But I am here to assist you.'); 'what can you do': WriteLn('Chatbot: I can answer questions, provide information, and carry out simple tasks. Is there anything specific you would like to know or do?'); else WriteLn('Chatbot: I am sorry, I didn''t understand your question. Could you please rephrase it or ask for something else?'); end; end; end. To exit the chatbot, the user can type "exit". I hope this helps! Let me know if you have any questions or need further assistance. Me: Now let's add a functionality to the chatbot so it will be able to do some simple math operations. Chatbot: Sure! Here is an example of how you can modify the chatbot to perform simple math operations:
Delphi-Quellcode:
program Chatbot;
{$APPTYPE CONSOLE} uses SysUtils, Math; var input: string; num1, num2: Integer; result: Real; begin WriteLn('Hello, I am a chatbot. How can I help you today?'); while True do begin Write('You: '); ReadLn(input); if input = 'exit' then Break; case input of 'hi', 'hello': WriteLn('Chatbot: Hi there! How are you doing?'); 'how are you': WriteLn('Chatbot: I am just a computer program, so I don''t have feelings. But I am here to assist you.'); 'what can you do': WriteLn('Chatbot: I can answer questions, provide information, and carry out simple tasks. Is there anything specific you would like to know or do?'); 'add', 'sum': begin Write('Enter the first number: '); ReadLn(num1); Write('Enter the second number: '); ReadLn(num2); result := num1 + num2; WriteLn('Chatbot: The sum of the two numbers is ', result); end; 'subtract', 'difference': begin Write('Enter the first number: '); ReadLn(num1); Write('Enter the second number: '); ReadLn(num2); result := num1 - num2; WriteLn('Chatbot: The difference of the two numbers is ', result); end; 'multiply', 'product': begin Write('Enter the first number: '); ReadLn(num1); Write('Enter the second number: '); ReadLn(num2); result := num1 * num2; WriteLn('Chatbot: The product of the two numbers is ', result); end; 'divide', 'quotient': begin Write('Enter the first number: '); ReadLn(num1); Write('Enter the second number: '); ReadLn(num2); if num2 = 0 then WriteLn('Chatbot: Cannot divide by zero!') else begin result := num1 / num2; WriteLn('Chatbot: The quotient of the two numbers is ', result); end; end; else WriteLn('Chatbot: I am sorry, I didn''t understand your question. Could you please rephrase it or ask for something else?'); end; end; end |
AW: Programme bzw. Funktionen von KI schreiben lassen (OpenAI)
Fortsetzung:
Me: Are you able to refractor your code by moving redundant parts into functions? Chatbot: Sure! Here is an example of how you can refactor the chatbot to move the redundant parts into functions:
Delphi-Quellcode:
Me: It it looks like we could do some further refactoring
program Chatbot;
{$APPTYPE CONSOLE} uses SysUtils, Math; function GetNumber(prompt: string): Integer; var num: Integer; begin Write(prompt); ReadLn(num); Result := num; end; function PerformOperation(op: string): Real; var num1, num2: Integer; begin num1 := GetNumber('Enter the first number: '); num2 := GetNumber('Enter the second number: '); case op of 'add', 'sum': Result := num1 + num2; 'subtract', 'difference': Result := num1 - num2; 'multiply', 'product': Result := num1 * num2; 'divide', 'quotient': if num2 = 0 then Result := NaN else Result := num1 / num2; else Result := NaN; end; end; var input: string; result: Real; begin WriteLn('Hello, I am a chatbot. How can I help you today?'); while True do begin Write('You: '); ReadLn(input); if input = 'exit' then Break; case input of 'hi', 'hello': WriteLn('Chatbot: Hi there! How are you doing?'); 'how are you': WriteLn('Chatbot: I am just a computer program, so I don''t have feelings. But I am here to assist you.'); 'what can you do': WriteLn('Chatbot: I can answer questions, provide information, and carry out simple tasks. Is there anything specific you would like to know or do?'); 'add', 'sum': begin result := PerformOperation(input); if IsNaN(result) then WriteLn('Chatbot: Invalid input!') else WriteLn('Chatbot: The sum of the two numbers is ', result); end; 'subtract', 'difference': begin result := PerformOperation(input); if IsNaN(result) then WriteLn('Chatbot: Invalid input!') else WriteLn('Chatbot: The difference of the two numbers is ', result); end; 'multiply', 'product': begin // usw...... Chatbot macht dann weitere Verbesserungen.. |
AW: Programme bzw. Funktionen von KI schreiben lassen (OpenAI)
Seit wann funktioniert case mit Strings (in Delphi, woanders geht das)?
|
AW: Programme bzw. Funktionen von KI schreiben lassen (OpenAI)
Jo, geil ... die KI kennt die Zukunft
nächstes Jahrtausend |
AW: Programme bzw. Funktionen von KI schreiben lassen (OpenAI)
Zitat:
|
AW: Programme bzw. Funktionen von KI schreiben lassen (OpenAI)
ja, kann leider immernoch nur Ordinal :cry:
|
AW: Programme bzw. Funktionen von KI schreiben lassen (OpenAI)
Der spannende Teil wäre dann dem Bot die Fehlermeldung zu geben und ihn bitten, den Code zu korrigieren. Wie ich gehört und gelesen habe, soll das auch gehen.
Sherlock |
AW: Programme bzw. Funktionen von KI schreiben lassen (OpenAI)
Man kann mit ChatGPT sozusagen über den Code diskutieren und es ändert den Code dann entsprechend ab. Ich hatte mal verschiedene Aufgaben aus dem Bereich Netzwerkprogrammierung gestellt. Die Lösung war eine Funktion die mit Indy arbeitete.
Ich hab dann eingegeben "How would that function look if i do not want to use indy?" ind ChatGPT hat den Code geändert, so dass er mit System.Net Funktionen arbeitete. Man kann sich also an die gewünschte Lösung heran tasten ("Do not use strings in the code", Ergebnis: ChatGPT hat alles auf die Benutzung von PChars geändert). Ist wirklich interessant. |
Alle Zeitangaben in WEZ +1. Es ist jetzt 05:00 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz