Dinfio Playground

Let's play with Dinfio!




ChatGPT

This is a simple conversation app with an AI using OpenAI ChatGPT.

' ChatGPT example in Dinfio
 
import openai
 
start
    setup()
 
    writeln("Welcome to ChatGPT example in Dinfio!")
    writeln("The following is a conversation with an AI.\n")
 
    while true
        write("You: ")
        question = readln()
 
        if question == ""; break; endif
 
        prompt &= question & "\n"
        write("AI: ...\r")
 
        result = openai.completion(prompt)
 
        prompt &= result & "\n"
        writeln("AI: " & result)
    endwhile
stop
 
function setup()
    global prompt = "Hello!\nHi!\n"
    openai.api_key = "Your Key"
stop

Screenshot:

Requirement: Dinfio 3.1.04 or later.


← Back to the Dinfio Playground / Download this program