AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Sprachen und Entwicklungsumgebungen Sonstige Werkzeuge Programme bzw. Funktionen von KI schreiben lassen (OpenAI)
Thema durchsuchen
Ansicht
Themen-Optionen

Programme bzw. Funktionen von KI schreiben lassen (OpenAI)

Ein Thema von Harry Stahl · begonnen am 14. Dez 2022 · letzter Beitrag vom 4. Okt 2023
Antwort Antwort
Seite 3 von 15     123 4513     Letzte »    
Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
43.116 Beiträge
 
Delphi 12 Athens
 
#21

AW: Programme bzw. Funktionen von KI schreiben lassen (OpenAI)

  Alt 15. Dez 2022, 20:04
"schreib ein Programm, was Dieses und Jenes macht"

"erstelle ein Betriebssystem in Delphi"

geht nicht, weil

Zitat:
Whoa there! You might need to wait a bit.

Currently we are receiving more requests than we are are comfortable with! To try your request again, come back in a short while and reload this page.
Garbage Collector ... Delphianer erzeugen keinen Müll, also brauchen sie auch keinen Müllsucher.
my Delphi wish list : BugReports/FeatureRequests
  Mit Zitat antworten Zitat
Benutzerbild von Harry Stahl
Harry Stahl

Registriert seit: 2. Apr 2004
Ort: Bonn
2.478 Beiträge
 
Delphi 11 Alexandria
 
#22

AW: Programme bzw. Funktionen von KI schreiben lassen (OpenAI)

  Alt 15. Dez 2022, 22:42
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
  Mit Zitat antworten Zitat
API

Registriert seit: 18. Apr 2004
637 Beiträge
 
#23

AW: Programme bzw. Funktionen von KI schreiben lassen (OpenAI)

  Alt 16. Dez 2022, 09:26
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:
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 = 'exitthen
      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.
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.

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 = 'exitthen
      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
  Mit Zitat antworten Zitat
API

Registriert seit: 18. Apr 2004
637 Beiträge
 
#24

AW: Programme bzw. Funktionen von KI schreiben lassen (OpenAI)

  Alt 16. Dez 2022, 09:30
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:
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 = 'exitthen
      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......
Me: It it looks like we could do some further refactoring

Chatbot macht dann weitere Verbesserungen..

Geändert von API (16. Dez 2022 um 09:36 Uhr)
  Mit Zitat antworten Zitat
Benutzerbild von DeddyH
DeddyH

Registriert seit: 17. Sep 2006
Ort: Barchfeld
27.537 Beiträge
 
Delphi 11 Alexandria
 
#25

AW: Programme bzw. Funktionen von KI schreiben lassen (OpenAI)

  Alt 16. Dez 2022, 10:11
Seit wann funktioniert case mit Strings (in Delphi, woanders geht das)?
Detlef
"Ich habe Angst vor dem Tag, an dem die Technologie unsere menschlichen Interaktionen übertrumpft. Die Welt wird eine Generation von Idioten bekommen." (Albert Einstein)
Dieser Tag ist längst gekommen
  Mit Zitat antworten Zitat
Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
43.116 Beiträge
 
Delphi 12 Athens
 
#26

AW: Programme bzw. Funktionen von KI schreiben lassen (OpenAI)

  Alt 16. Dez 2022, 10:34
Jo, geil ... die KI kennt die Zukunft







nächstes Jahrtausend
Garbage Collector ... Delphianer erzeugen keinen Müll, also brauchen sie auch keinen Müllsucher.
my Delphi wish list : BugReports/FeatureRequests
  Mit Zitat antworten Zitat
API

Registriert seit: 18. Apr 2004
637 Beiträge
 
#27

AW: Programme bzw. Funktionen von KI schreiben lassen (OpenAI)

  Alt 16. Dez 2022, 10:48
Seit wann funktioniert case mit Strings (in Delphi, woanders geht das)?
Was das geht nicht resp. immer noch nicht? (Habe schon x Jahre lange nicht mehr in Delphi programmiert)
  Mit Zitat antworten Zitat
Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
43.116 Beiträge
 
Delphi 12 Athens
 
#28

AW: Programme bzw. Funktionen von KI schreiben lassen (OpenAI)

  Alt 16. Dez 2022, 10:55
ja, kann leider immernoch nur Ordinal
Garbage Collector ... Delphianer erzeugen keinen Müll, also brauchen sie auch keinen Müllsucher.
my Delphi wish list : BugReports/FeatureRequests
  Mit Zitat antworten Zitat
Benutzerbild von Sherlock
Sherlock

Registriert seit: 10. Jan 2006
Ort: Offenbach
3.762 Beiträge
 
Delphi 11 Alexandria
 
#29

AW: Programme bzw. Funktionen von KI schreiben lassen (OpenAI)

  Alt 16. Dez 2022, 11:57
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
Oliver
Geändert von Sherlock (Morgen um 16:78 Uhr) Grund: Weil ich es kann
  Mit Zitat antworten Zitat
Benutzerbild von Ralf Kaiser
Ralf Kaiser

Registriert seit: 21. Mär 2005
Ort: Wuppertal
932 Beiträge
 
Delphi 10.3 Rio
 
#30

AW: Programme bzw. Funktionen von KI schreiben lassen (OpenAI)

  Alt 16. Dez 2022, 12:11
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.
Ralf Kaiser
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 3 von 15     123 4513     Letzte »    


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:42 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