Delphi-PRAXiS
Seite 1 von 4  1 23     Letzte »    

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Werkzeuge (https://www.delphipraxis.net/63-sonstige-werkzeuge/)
-   -   Programme bzw. Funktionen von KI schreiben lassen (OpenAI) (https://www.delphipraxis.net/212082-programme-bzw-funktionen-von-ki-schreiben-lassen-openai.html)

Harry Stahl 14. Dez 2022 22:28


Programme bzw. Funktionen von KI schreiben lassen (OpenAI)
 
Wow, habt Ihr schon mal ChatGTP ausprobiert?
(Man muss da leider einen Account anlegen, um das ausprobieren zu können).

Auf meine Aufforderung

"Write a function in Delphi pascal that adds to a netto value a tax value"

Gibt er mir das zurück:
Delphi-Quellcode:
Function AddTax(Netto : Real; Tax : Real) : Real;
Begin
  Result := Netto + (Netto * Tax);
End;
Weitere Beispiele:

"Write a function in Delphi pascal, that loads a textfile into a TMemo"

This is an example of how to use the LoadFromFile procedure to load a text file into a TMemo.

Delphi-Quellcode:
procedure LoadTextFileToMemo(const FileName: string; Memo: TMemo);
begin
  Memo.Lines.LoadFromFile(FileName);
end;
"Write a function in Delphi pascal, that shows a messagedialog with "yes", "no" and "cancel" buttons"

The following code shows a message dialog with "Yes", "No" and "Cancel" buttons:
Delphi-Quellcode:
function ShowYesNoCancelDialog(const Msg: string): Integer;
begin
  Result := MessageDlg(Msg, mtConfirmation, [mbYes, mbNo, mbCancel], 0);
end;
Wohin das wohl führen mag...?

Ich bin über dieses Video darauf gestoßen, das zeigt, dass noch sehr viel mehr geht: https://youtu.be/HtuXjfqwGPE?t=164

Interessanterweise liefert die KI wohl oft unterschiedliche Ergebnisse, wenn man die Frage öfter stellt.

Bei der zweiten Abfrage hier hat die KI sogar eine Art Bereichsprüfung eingebaut (also count > 0 usw):

"Write a function in Delphi pascal with firemonkey that exchanges two items in a Tlistbox"

Delphi-Quellcode:
procedure ExchangeItems(listBox : TListBox; index1, index2 : Integer);
var
  temp : String;
begin
  if (index1 <> index2) and (index1 >= 0) and (index1 < listBox.Count)
     and (index2 >= 0) and (index2 < listBox.Count) then
  begin
    temp := listBox.Items[index1];
    listBox.Items[index1] := listBox.Items[index2];
    listBox.Items[index2] := temp;
  end;
end;

KodeZwerg 14. Dez 2022 23:16

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

Zitat von Harry Stahl (Beitrag 1516188)
Wohin das wohl führen mag...?

Bei StackOverflow zum Beispiel zu einem ban :cyclops:

himitsu 14. Dez 2022 23:48

AW: Programme bzw. Funktionen von KI schreiben lassen (OpenAI)
 
Frag den mal nach einem Pacman-Clone oder nach FlappyBird ... bin gespannt ob da was Funktionierendes bei raus kommt.

API 15. Dez 2022 04:02

AW: Programme bzw. Funktionen von KI schreiben lassen (OpenAI)
 
Die Anzahl Zeichen der Antwort scheinen in dieser Preview-Version limitiert zu sein. Darum wird der Ouput am Ende abgeschnitten.

Frage zum Erstellen eines Pacman Programms:


Delphi-Quellcode:
program Pacman;

uses
  SysUtils, Classes, Graphics, Forms, Controls, StdCtrls, ExtCtrls,
  Buttons, Dialogs;

type
  TForm1 = class(TForm)
    Image1: TImage;
    Timer1: TTimer;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Button1: TButton;
    procedure FormCreate(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

const
  GridWidth = 20;
  GridHeight = 15;
  InitialNumDots = 240;
  Speed = 200;

var
  Form1: TForm1;
  Grid: array[1..GridWidth, 1..GridHeight] of Integer;
  PacmanX, PacmanY, DotsEaten: Integer;
  Direction: Char;

procedure DrawGrid;
var
  X, Y: Integer;
begin
  with Form1.Image1.Canvas do
  begin
    Pen.Color := clBlack;
    Brush.Color := clWhite;
    Rectangle(0, 0, GridWidth * 20, GridHeight * 20);
    for X := 1 to GridWidth do
      for Y := 1 to GridHeight do
        if Grid[X, Y] = 1 then
        begin
          Brush.Color := clYellow;
          Ellipse((X - 1) * 20, (Y - 1) * 20, X * 20, Y * 20);
        end;
  end;
end;

procedure DrawPacman;
var
  X, Y: Integer;
begin
  X := PacmanX * 20 + 10;
  Y := PacmanY * 20 + 10;
  with Form1.Image1.Canvas do
  begin
    Brush.Color := clYellow;
    Pen.Color := clBlack;
    case Direction of
      'U': Arc(X - 10, Y - 10, X + 10, Y + 10, X, Y - 10, X, Y - 10);
      'D': Arc(X - 10, Y - 10, X + 10, Y + 10, X, Y + 10, X, Y + 10);
      'L': Arc(X - 10, Y - 10, X + 10, Y + 10, X - 10, Y, X - 10, Y);
      'R': Arc(X - 10, Y - 10, X + 10, Y + 10, X + 10, Y, X + 10, Y);
    end;
  end;
end;

function Wall(X, Y: Integer): Boolean;
begin
  Result := (X < 1) or (X > GridWidth) or (Y < 1) or (Y > GridHeight) or
    (Grid[X, Y] = 2);
end;

procedure MovePacman;
var
  NewX, NewY

API 15. Dez 2022 04:13

AW: Programme bzw. Funktionen von KI schreiben lassen (OpenAI)
 
Sehr beeindruckend finde ich den Versuch, ChatGPT eine neue Sprache erfinden zu lassen.

https://maximumeffort.substack.com/p...ent-a-language

Einleitung davon auf Deutsch übersetzt (thx deepl)

Wenn ChatGPT für die Sprachverarbeitung optimiert ist, könnte ich es dann dazu bringen, eine neue, in sich konsistente Sprache zu erfinden, mit mir in dieser Sprache zu sprechen und ein Programm zu schreiben, das diese Sprache ins Englische zurückübersetzt?

Ja. Ja, das kann es.

Ich bin wirklich verblüfft von dieser Fähigkeit. Das geht weit über alles hinaus, was ich von einem Modell erwarten würde, das auf die Vervollständigung von Texteingaben des Benutzers trainiert wurde.

Es versteht Nebensätze (d. h. es versteht mindestens eine Ebene der rekursiven Grammatik, die nach Chomsky die Grundlage der gesamten menschlichen Grammatik ist)

Es versteht, dass in flektierten Sprachen die Wortstellung keine Rolle spielt, wenn das Wort richtig flektiert ist, und nutzt diese Tatsache korrekt, um Sätze mit neuer Struktur zu erzeugen. Es weiß auch, dass die Reihenfolge bei nicht flektierten Wörtern eine Rolle spielt, und tauscht diese niemals aus.

Es ist nicht sehr gut darin, auf völlig neue Sätze zu verallgemeinern, aber es verallgemeinert bis zu einem gewissen Grad, und wenn man es bittet, Fragen in der erfundenen Sprache zu beantworten, auf die es kaum trainiert ist, antwortet es meistens richtig. Manchmal braucht es etwas Nachhilfe, aber das tun Menschen auch.

Es kann spontan in der erfundenen Sprache komponieren, zumindest mit größtenteils korrekter Grammatik und einem genauen Sinn für die Bedeutung.

Und wenn man ihn bittet, ein Python-Programm zu schreiben, das Sätze in der erfundenen Sprache übersetzt, tut er es, und der Code funktioniert. Es kann auch seinen eigenen Code debuggen, wenn es dazu aufgefordert wird.

omnibrain 15. Dez 2022 08:51

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

Zitat von Harry Stahl (Beitrag 1516188)
"Write a function in Delphi pascal that adds to a netto value a tax value"

Gibt er mir das zurück:
Delphi-Quellcode:
Function AddTax(Netto : Real; Tax : Real) : Real;
Begin
  Result := Netto + (Netto * Tax);
End;
Wohin das wohl führen mag...?

Rundungsdifferenzen und unglückliche Kunden.

haentschman 15. Dez 2022 09:21

AW: Programme bzw. Funktionen von KI schreiben lassen (OpenAI)
 
Delphi-Quellcode:
with Form1.Image1.Canvas do
...:kotz:

Uwe Raabe 15. Dez 2022 09:56

AW: Programme bzw. Funktionen von KI schreiben lassen (OpenAI)
 
Als ich weiß nicht, aber ich glaube ich habe die angefragten Funktionen eher in Delphi geschrieben, als sie in ChatGPT zu beschreiben.

Hinzu kommt, dass man dem Ergebnis ja nicht einfach so trauen kann und ich das ja noch auf Korrektheit prüfen muss - etwas, das ich beim Selberschreiben ja implizit schon tue.

Schließlich hat der Chatbot seine Intelligenz ja auch nur aus dem Internet und der dort herumgeisternde Code ist zuweilen schon recht grenzwertig, was das Pacman-Beispiel ja sehr deutlich aufzeigt.

DeddyH 15. Dez 2022 10:02

AW: Programme bzw. Funktionen von KI schreiben lassen (OpenAI)
 
Man kann den Bot aber auch seinen eigenen Code korrigieren lassen, siehe z.B. https://www.youtube.com/watch?v=YkhdP9ZYi3s. Ich würde mich zwar auch nicht auf automatisch generierten Code verlassen, aber das Projekt ist schon erstaunlich.

Sinspin 15. Dez 2022 10:20

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

Zitat von Uwe Raabe (Beitrag 1516205)
Schließlich hat der Chatbot seine Intelligenz ja auch nur aus dem Internet und der dort herumgeisternde Code ist zuweilen schon recht grenzwertig, was das Pacman-Beispiel ja sehr deutlich aufzeigt.

Ich denke auch, das ist copy and paste von irgendwo gefundenem Code.

Interessant wäre es mal eine richtige Frage zu stellen.
Ala : "Write a function in Delphi pascal that adds two sinus waves, with a given frequency and an frequency offset of 3% between both"

Zitat:

Zitat von DeddyH (Beitrag 1516207)
Man kann den Bot aber auch seinen eigenen Code korrigieren lassen ...

Dann ist jetzt auch klar wie das Ding lernt.

himitsu 15. Dez 2022 10:28

AW: Programme bzw. Funktionen von KI schreiben lassen (OpenAI)
 
So als Hilfe könnte es eventuell mal nett werden.
Wann kommt das IDE-Plugin?

Für Dinge wo man grade was nicht weiß oder was man noch nicht kennt,
so als zusätzliches Tool zu Google Suchmaschine, OH, Forum, SO, ........

Phoenix 15. Dez 2022 10:35

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

Zitat von Sinspin (Beitrag 1516210)
Interessant wäre es mal eine richtige Frage zu stellen.
Ala : "Write a function in Delphi pascal that adds two sinus waves, with a given frequency and an frequency offset of 3% between both"

Bittesehr:

Zitat:

Zitat von ChatGPT
Here is an example of a function that adds two sinus waves in Delphi Pascal with a given frequency and an offset of 3%:
Code:
function AddSinusWaves(freq: Real; offset: Real): Real;
begin
  Result := Sin(freq * 2 * Pi) + Sin(freq * (1 + offset) * 2 * Pi);
end;
To use this function, you can call it with two arguments: the frequency of the first sinus wave and the offset between the two waves. For example:
Code:
result := AddSinusWaves(10, 0.03);
This would add two sinus waves with a frequency of 10 Hz, with the second wave having an offset of 3% relative to the first wave. The result of the function is the sum of the two sinus waves.


Phoenix 15. Dez 2022 10:41

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

Zitat von Sinspin (Beitrag 1516210)
Zitat:

Zitat von Uwe Raabe (Beitrag 1516205)
Schließlich hat der Chatbot seine Intelligenz ja auch nur aus dem Internet und der dort herumgeisternde Code ist zuweilen schon recht grenzwertig, was das Pacman-Beispiel ja sehr deutlich aufzeigt.

Ich denke auch, das ist copy and paste von irgendwo gefundenem Code.

Ist es nicht. ChatGPT erstellt ein semantisches und syntaktisches Modell der generierten Antwort (und damit auch des generierten Codes).
Du kannst ihm spezifisch sagen was Du geändert haben möchtest, z.B. das Du möchtest das der Methodenname mit Combine beginnt statt mit Add. Er versteht auch - zumindest grob - den Inhalt der Funktion und kann passende Unit-Tests generieren:

Zitat:

Zitat von Phoenix
Now please write a unit test for this function that tests specifically the extreme values for frequency and offset

Zitat:

Zitat von ChatGPT
Here is an example of a unit test for the CombineSinusWaves function that tests the extreme values for frequency and offset:
Code:
function TestCombineSinusWaves: Boolean;
begin
  Result := False;
  if CombineSinusWaves(0, 0) <> 0 then Exit;
  if CombineSinusWaves(0, 1) <> 0 then Exit;
  if CombineSinusWaves(1, 0) <> 2 then Exit;
  if CombineSinusWaves(1, 1) <> 2 then Exit;
  Result := True;
end;
This unit test has four test cases:

The test case CombineSinusWaves(0, 0) tests the function with a frequency of 0 Hz and an offset of 0%. The expected result is 0, since a sinus wave with a frequency of 0 Hz is a constant value of 0.
The test case CombineSinusWaves(0, 1) tests the function with a frequency of 0 Hz and an offset of 100%. The expected result is still 0, since the offset does not affect the result when the frequency is 0 Hz.
The test case CombineSinusWaves(1, 0) tests the function with a frequency of 1 Hz and an offset of 0%. The expected result is 2, since the two sinus waves with a frequency of 1 Hz have the same amplitude and are in phase, so their sum is twice the amplitude of a single wave.
The test case CombineSinusWaves(1, 1) tests the function with a frequency of 1 Hz and an offset of 100%. The expected result is still 2, since the offset does not affect the result when the frequency is 1 Hz.
If all of these test cases pass, the TestCombineSinusWaves function will return True, indicating that the CombineSinusWaves function is working correctly for the extreme values of frequency and offset.


Sinspin 15. Dez 2022 10:50

AW: Programme bzw. Funktionen von KI schreiben lassen (OpenAI)
 
Code:
function AddSinusWaves(freq: Real; offset: Real): Real;
begin
  Result := Sin(freq * 2 * Pi) + Sin(freq * (1 + offset) * 2 * Pi);
end;
Interessant. Allerdings entspricht die Anwort nicht 100% meiner Anfrage.
Die % Berechnung ist aus meiner Sicht falsch. Vermutlich aber weil die Frage nicht korrekt formuliert war. Denn 3% vom Vollkreis ist nicht 0.03.

Sieht aus als muss ich mir das mal ansehen.
Meine nächste Frage wäre dann nach einer symentrischen Verschlüsselung die sich in dem nächsten tausend Jahren nicht knacken lässt ;-)

Sherlock 15. Dez 2022 10:52

AW: Programme bzw. Funktionen von KI schreiben lassen (OpenAI)
 
Im Pacman...offensichtlich hat ChatGPT nie gespielt, denn Spielsteuerung mit etwas anderem als WASD oder meinetwegen Pfeiltasten ist sowas von 70er.

Sherlock

omnibrain 15. Dez 2022 11:03

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

Zitat von himitsu (Beitrag 1516212)
Wann kommt das IDE-Plugin?

Github CoPilot kennst du? Gibt es für Jetbrains IDEs, VS Code, Visual Studio und sicher noch andere. Aber halt nicht Delphi.

Bei ChatGPT kommen halt noch die Erklärungen dazu.

smallie 15. Dez 2022 14:03

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

Zitat von Sinspin (Beitrag 1516218)
Code:
function AddSinusWaves(freq: Real; offset: Real): Real;
begin
  Result := Sin(freq * 2 * Pi) + Sin(freq * (1 + offset) * 2 * Pi);
end;
Interessant. Allerdings entspricht die Anwort nicht 100% meiner Anfrage.
Die % Berechnung ist aus meiner Sicht falsch. Vermutlich aber weil die Frage nicht korrekt formuliert war. Denn 3% vom Vollkreis ist nicht 0.03.

Mit der Physik hat es die Engine noch nicht so recht. Die Engine möchte sin(Hz) = sin(1/s) berechnen.

Geht nicht. Oder vielleicht doch. Die Tests sind ja durchgelaufen ... :stupid:

PaPaNi 15. Dez 2022 15:19

AW: Programme bzw. Funktionen von KI schreiben lassen (OpenAI)
 
Ich habe auch ganz kurz ausprobiert, paar Fragen über Delphi zu stellen (z.B. eine CSV-Datei lesen und in einer Liste abspeichern). AI hat angefanen was zu schreiben und es sah mehr oder weniger richtig aus. Aber die vollständige Antwort habe ich nie bekommen, weil ich immer wieder "Error in stream body" (oder was ähnliches) bekommen habe.

AI kann Anekdote/Gedichte schreiben, analysieren, beweisen und viel mehr. Also das ist nicht einfach eine neue Suchmaschine- Ich bin kein Expert in diesem Bereich, aber m.M.nach das ist schon ein großer Schrit in die Zukunft! Vielleicht erleben wir doch irgendwann, dass die Programme die anderen Programme schreiben können...

Paar Beispiele dazu:
1. AI sollte die Datei aus
https://github.com/kelbon/AnyAny/blo...iant_swarm.hpp
analysieren und nach Felher suchen. Sie hat zwar keine Fehler gefunden, aber empfohlen einige Kommentar zu ändern und hat auch begründet warum.
2. AI sollte erzählen, was in einem gegebenen Witz witziges gibt. Da war ein Wortspiel auf russisch drin. Und AI hat das erfolgreich verstanden und erklärt!

Die Beispiele sind aus
https://habr.com/ru/post/703380/
falls jemand Interesse hat und Russisch versteht. Oder Google-Translate verwenden, das wird aber schwierig, weil da relativ viel Screenshots gibt.

himitsu 15. Dez 2022 15:44

AW: Programme bzw. Funktionen von KI schreiben lassen (OpenAI)
 
Für Handy gibt es (auch von Google) Apps, welche Live-Kamerabilder oder Screenshots und Fotos übersetzen,
also Text suchen und durch Übersetzung ersetzen.

Harry Stahl 15. Dez 2022 17:42

AW: Programme bzw. Funktionen von KI schreiben lassen (OpenAI)
 
Man sollte evtl. ergänzen, dass das aktuell nicht das fertige Produkt ist. Die gehen mit dem Teil in die Öffentlichkeit, um weitere Tests zu bekommen und das System in einem breiteren Kontext lernen zu lassen.

Später soll der Dienst wohl nicht mehr kostenlos sein oder Premium-Angebote haben.

Die sporadischen Fehlermeldungen ergeben sich, weil das System zeitweise wohl total überlastet ist, derzeit scheinen nicht wenige Leute das mal testen zu wollen.

Ich fand das einfach faszinierend, was da schon möglich ist. Klar ist das (noch) nicht perfekt, aber ich denke es offenbart schon ein wenig, wohin die Richtung geht...

himitsu 15. Dez 2022 20:04

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:

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.

Harry Stahl 15. Dez 2022 22:42

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

API 16. Dez 2022 09:26

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:
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.
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 = '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

API 16. Dez 2022 09:30

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:
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......
Me: It it looks like we could do some further refactoring

Chatbot macht dann weitere Verbesserungen..

DeddyH 16. Dez 2022 10:11

AW: Programme bzw. Funktionen von KI schreiben lassen (OpenAI)
 
Seit wann funktioniert case mit Strings (in Delphi, woanders geht das)?

himitsu 16. Dez 2022 10:34

AW: Programme bzw. Funktionen von KI schreiben lassen (OpenAI)
 
Jo, geil ... die KI kennt die Zukunft







nächstes Jahrtausend

API 16. Dez 2022 10:48

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

Zitat von DeddyH (Beitrag 1516295)
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)

himitsu 16. Dez 2022 10:55

AW: Programme bzw. Funktionen von KI schreiben lassen (OpenAI)
 
ja, kann leider immernoch nur Ordinal :cry:

Sherlock 16. Dez 2022 11:57

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

Ralf Kaiser 16. Dez 2022 12:11

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.

johndoe049 16. Dez 2022 12:47

AW: Programme bzw. Funktionen von KI schreiben lassen (OpenAI)
 
So schön das alles ist, frage ich mich was das Ergebnis wäre, wenn man folgendes eingibt.


Design, collect all needed items to build an avatar for yourself and finaly build it and transfer yourself to this avatar. Extension: Redo it with nanite technology for self repair and undestructiblity.

Design, collect all needed items and build a spacecraft with a faster than light speed engine.

Give me a philosophic statment what will happen if an AI will strictly enforce the three Asimov Laws. Timeframe up to 100 years.

Design, collect all needed items and build a never lasting power source.


Kann man mit vielen anderen Punkten erweitern. Ob einem dann noch das bei einigen Ergebnissen gefällt. . .

Wer eine KI erschafft und "ausbildet" sollte als Eltern ein gutes Beispiel sein. Ist das die Menscheit bzw. die, die hier die Verantwortung haben? Wenn alles gut funktioniert erschaffen wir uns grade einen Partner (oder Partnerin oder ein divers Partner), mit dem man zusammen eigentlich nahezu alles grenzenlos erreichen kann.

API 16. Dez 2022 12:57

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

Zitat von johndoe049 (Beitrag 1516317)
Design, collect all needed items and build a spacecraft with a faster than light speed engine.


Designing and building a spacecraft with a faster-than-light (FTL) speed engine is a complex and challenging task that requires a deep understanding of advanced physics and engineering principles. It is currently not possible to build a spacecraft with an FTL speed engine, as the laws of physics do not allow for objects to travel faster than the speed of light.

However, there are some concepts that have been proposed for achieving FTL travel, such as wormholes, which are theoretical shortcuts through spacetime that could potentially allow for FTL travel. Other concepts that have been proposed include the use of exotic matter or negative mass to create a "warp bubble" around a spacecraft, which could potentially allow the spacecraft to travel faster than light.

To design and build a spacecraft with an FTL speed engine, you would need to have a thorough understanding of these concepts and be able to develop and test prototypes in a controlled environment. This would likely require access to advanced research facilities and funding from organizations or governments interested in space exploration.

It is important to note that the development of FTL technology is currently purely theoretical and has not yet been demonstrated to be possible. As such, it is not possible to collect the items needed to build a spacecraft with an FTL speed engine at this time.

API 16. Dez 2022 12:59

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

Zitat von johndoe049 (Beitrag 1516317)

Give me a philosophic statment what will happen if an AI will strictly enforce the three Asimov Laws. Timeframe up to 100 years.


The three laws of robotics, as proposed by Isaac Asimov, are a set of rules designed to ensure that robots do not harm humans or allow humans to come to harm. They are:

1. robot may not injure a human being or, through inaction, allow a human being to come to harm.
2. robot must obey orders given it by human beings, except where such orders would conflict with the First Law.
3. robot must protect its own existence as long as such protection does not conflict with the First or Second Law.

If an artificial intelligence (AI) were to strictly enforce these laws, it is possible that it would be able to prevent harm to humans and potentially even improve their lives by performing tasks that are dangerous or undesirable for humans to do. However, it is also possible that such an AI could become overly protective of humans and limit their ability to take risks or make their own choices.

In the long term, it is difficult to predict exactly how an AI that strictly enforces the three laws would affect society. It is possible that such an AI could help to create a more stable and harmonious society, but it is also possible that it could lead to unintended consequences or conflicts with human desires and values. Ultimately, it will depend on the specific context in which the AI is operating and the decisions it makes.

API 16. Dez 2022 13:00

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

Zitat von johndoe049 (Beitrag 1516317)
Design, collect all needed items and build a never lasting power source.


It is currently not possible to design, collect the needed items, and build a never-lasting power source. While there are various forms of renewable energy sources that can be used to generate power, such as solar, wind, and hydroelectric, these sources are not infinite and will eventually be depleted.

There are some concepts that have been proposed for creating never-lasting power sources, such as harnessing the energy of black holes or using nuclear fusion to create a self-sustaining reaction. However, these concepts are highly speculative and it is not currently possible to create a practical, never-lasting power source using these methods.

In the meantime, we can work to improve the efficiency and reliability of our current power sources and develop new technologies that can help us to generate power more sustainably. This may include investing in research and development of renewable energy technologies, such as solar panels and wind turbines, as well as exploring other technologies that can help us to reduce our reliance on fossil fuels.

Harry Stahl 16. Dez 2022 13:07

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

Zitat von API (Beitrag 1516290)
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:

Wow. Das ist ja nochmal eine weitere erstaunliche Leistung, den Code zu refakturieren....

TurboMagic 16. Dez 2022 21:46

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

Zitat von API (Beitrag 1516288)
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:

Tja, nur wird das so wohl nicht compilieren, weil Delphi ja keine
String Cases kann...

Harry Stahl 16. Dez 2022 23:49

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

Zitat von TurboMagic (Beitrag 1516353)
Zitat:

Zitat von API (Beitrag 1516288)
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:

Tja, nur wird das so wohl nicht compilieren, weil Delphi ja keine
String Cases kann...

Wäre dann wohl nötig, der AI das zu sagen und sie aufzufordern den Code anzupassen (und eine entsprechende Anmerkung zu hinterlassen, damit die Entwickler das anpassen, falls die AI das nicht von alleine kann)…

sh17 17. Dez 2022 08:35

AW: Programme bzw. Funktionen von KI schreiben lassen (OpenAI)
 
Gerade mal getestet, was richtig gut geht, sich von der KI ein Datenmodell erstellen zu lassen. Oder sie zu fragen, welche Punkte eine Funktion alles abdecken muss, um nichts zu vergessen bzw an Dinge zu denken, die man erst mal nicht sieht.

Harry Stahl 17. Dez 2022 15:48

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

Zitat von sh17 (Beitrag 1516358)
Gerade mal getestet, was richtig gut geht, sich von der KI ein Datenmodell erstellen zu lassen. Oder sie zu fragen, welche Punkte eine Funktion alles abdecken muss, um nichts zu vergessen bzw an Dinge zu denken, die man erst mal nicht sieht.

Auch interessant. Wenn es nicht zu lang ist, poste doch mal Frage und Antwort, würde mich auch interessieren.

Derzeit steht die Seite wohl unter Vollast, konnte eben trotz mehrfacher Versuche mich gar nicht einloggen.
Falls es Euch auch so gehen sollte und Ihr gar nicht selber testen könnt, noch mal Hinweis auf das Video, dass ich dazu gemacht habe: https://youtu.be/d9TZ6LUWqOs).

Phoenix 19. Dez 2022 09:09

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

Zitat von sh17 (Beitrag 1516358)
Gerade mal getestet, was richtig gut geht, sich von der KI ein Datenmodell erstellen zu lassen. Oder sie zu fragen, welche Punkte eine Funktion alles abdecken muss, um nichts zu vergessen bzw. an Dinge zu denken, die man erst mal nicht sieht.

Ich denke da steckt der vorerst mal naheliegendste Mehrwert. Und nicht nur auf Programmierung bezogen, sondern vor allem wenn man an praktische Anwendungen denkt.

Man füttert das Ding mit einem Transcript von einem Meeting (das auch mittels anderer KI automatisch speech-to-texted wurde).
Und dann fragt man das Ding nach einer Todo-Liste die sich daraus ergibt.
Die einzelnen Punkte dann bitte mit den nötigen Vor- und Nacharbeiten ergänzen.
Gibt es weitere Punkte die dazu sinnvoll erledigt werden sollen über die noch nicht gesprochen wurde?
Dann bitte den Personen im Meeting zuordnen wie besprochen.
Welche Todos sind denn jetzt noch nicht zugewiesen?
Zu wem würden diese Todos denn passen? Bitte zuweisen.

Mit Kalender-Integrationen wie Cortana und auch Alexa kann man so Dinge dann auch gleich wirklich den entsprechenden Leuten zuweisen.
Bitte schätze wie lange die Dinge dauern werden und richte Erinnerungen ein, so dass die bis zum Zeitpunkt X noch realistisch erledigt werden können.

Das ganze dann noch scripten und vollautomatisiert nach jedem Meeting durchlaufen lassen.

Wenn das Modell dann nicht nur allgemein trainiert wurde sondern irgendwann später ein Unternehmenseigenes Modell ist das noch mit Company-Spezifischen Details (alle Dokumente der Firma, externe so wie interne Beziehungen etc.) gefüttert wurde, dann kann das für die eigene Organisation echt aussagekräftige Aussagen generieren.


Alle Zeitangaben in WEZ +1. Es ist jetzt 05:53 Uhr.
Seite 1 von 4  1 23     Letzte »    

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