GPT-3 explains python codevreally well

Posted on
Sun Dec 04, 2022 10:25 pm
mundmc offline
User avatar
Posts: 1060
Joined: Sep 14, 2012

GPT-3 explains python codevreally well

Wow, I just noted this functionality today, and I think it's really great for learning Python.

I made an account at openai, entered the following code (which uses python shell scripting node.js code) from the "Alexa Command" Indigo implementation. Check the code, then check thr GPT-3 output below!

Code: Select all
#Python 3


import indigo
import subprocess
import time

debug = False
announcement = indigo.variables[1330859711].value  # Variable which contains text to speak
echo = "Kitchen Echo Show" # "ALEXACOMMAND_destination"

indigo.server.log (u'NODEJS [Announcement] = {} [Destination] = {}'.format(announcement, echo))

#echospeakerlist = echospeakerstring.split(",")
#for echo in echospeakerlist: TOO SLOW
command = u'node ~/Desktop/Alexa/send-alexa-command.js "ssml" "{}" "{}"'.format(announcement, echo)
p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)

if debug:   
   try:
      # Filter stdout
      for line in iter(p.stdout.readline, ''):
         sys.stdout.flush()
         # Print status
         indigo.server.log (">>> " + line.rstrip())
         sys.stdout.flush()
   except:
      sys.stdout.flush()

# Wait until process terminates (without using p.wait())
loop_count = 0
while p.poll() is None:
   # Process hasn't exited yet, let's wait some
   time.sleep(0.5)
   loop_count += 1
indigo.server.log (u'NODEJS Poll Loop Count = {}, Return Code = {}'.format(loop_count, p.returncode))


Here is the output:
Code: Select all
# Explanation of what the code does

# 1. The script is called by the Indigo server
# 2. The script reads the text to speak from the Indigo variable
# 3. The script calls the nodejs script to send the text to the Alexa device
# 4. The nodejs script sends the text to the Alexa device


Tell me that's not insane!

Edit: The Q&A section
Q: How do I add a new device in Indigo Domotics?

(Below is the response, a little off, but trying)

A: To add a new device in Indigo Domotics, open the Devices tab in the Indigo application and click the "+" button in the bottom left corner. Then, select the type of device you want to add and follow the on-screen instructions.

Posted on
Mon Dec 05, 2022 8:21 am
Different Computers offline
User avatar
Posts: 2533
Joined: Jan 02, 2016
Location: East Coast

Re: GPT-3 explains python codevreally well

I can't find a GPT-3 instance to do this stuff with. They're all overbooked. Any suggestions?

SmartThings refugee, so happy to be on Indigo. Monterey on a base M1 Mini w/Harmony Hub, Hue, DomoPad, Dynamic URL, Device Extensions, HomeKitLink, Grafana, Plex, uniFAP, Fantastic Weather, Nanoleaf, LED Simple Effects, Bond Home, Camect.

Posted on
Tue Dec 06, 2022 10:31 am
mundmc offline
User avatar
Posts: 1060
Joined: Sep 14, 2012

Re: GPT-3 explains python codevreally well

Different Computers wrote:
I can't find a GPT-3 instance to do this stuff with. They're all overbooked. Any suggestions?
I'm not sure if I'm following your question; I went to open AI, made an account, and gotten API key. I haven't use the API key yet, I have been doing everything from their website. Does that help?

Posted on
Wed Dec 07, 2022 8:51 am
Different Computers offline
User avatar
Posts: 2533
Joined: Jan 02, 2016
Location: East Coast

Re: GPT-3 explains python codevreally well

That does, thanks.

SmartThings refugee, so happy to be on Indigo. Monterey on a base M1 Mini w/Harmony Hub, Hue, DomoPad, Dynamic URL, Device Extensions, HomeKitLink, Grafana, Plex, uniFAP, Fantastic Weather, Nanoleaf, LED Simple Effects, Bond Home, Camect.

Posted on
Fri Dec 09, 2022 3:29 pm
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: GPT-3 explains python codevreally well

It is amazing. I'm finding its capabilities to be explain code snippets or create stories/descriptions/instructions (in a given tone or style) shockingly impressive.

Trying to have it create scripts (ex: "Create a python script that has Indigo set the brightness of all dimmable Z-Wave devices to 25%.") spits out what looks like legitimate scripts but definitely will not work for multiple reasons. It is a bit like the ultimate bullshitter when it comes to making something that looks legit or perfect (and it does so with great confidence :lol: ) without having much of a clue if it is correct. Another example is when asking for instructions on how to do something in Indigo it will create completely fictitious menu items and UI in the steps. I've seen similar problems when asking it for the best answer to more complex questions. It'll write something that sure sounds legit but is 100% incorrect. Still though, I'm a bit scared what GPT-4 will be able to do. :twisted:

Exciting times we live in, especially if you project out the pace of AI advances another 10 or 20 years.

Image

Posted on
Fri Dec 09, 2022 3:35 pm
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: GPT-3 explains python codevreally well

Some okay (and some bad) GPT-3 generated Indigo jokes:

Screen Shot 2022-12-09 at 3.32.27 PM.png
Screen Shot 2022-12-09 at 3.32.27 PM.png (224.03 KiB) Viewed 983 times


Screen Shot 2022-12-09 at 3.32.43 PM.png
Screen Shot 2022-12-09 at 3.32.43 PM.png (206.19 KiB) Viewed 983 times


Screen Shot 2022-12-09 at 3.32.57 PM.png
Screen Shot 2022-12-09 at 3.32.57 PM.png (79.16 KiB) Viewed 983 times


Screen Shot 2022-12-09 at 3.33.35 PM.png
Screen Shot 2022-12-09 at 3.33.35 PM.png (204.36 KiB) Viewed 983 times


Screen Shot 2022-12-09 at 3.37.36 PM.png
Screen Shot 2022-12-09 at 3.37.36 PM.png (116.51 KiB) Viewed 982 times

Image

Posted on
Fri Dec 09, 2022 5:09 pm
DaveL17 offline
User avatar
Posts: 6744
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: GPT-3 explains python codevreally well

I was looking at it this afternoon myself and I tried 3 or 4 of its suggestions to fix a problem I was having--which didn't work. The fifth one did, though. To be honest, I don't think it was the AI's fault that the first ones weren't the right answer. What I think it would probably be very good at is reviewing code to find ways to make it more streamlined or help spot where a bug might be.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sat Dec 10, 2022 9:10 am
mundmc offline
User avatar
Posts: 1060
Joined: Sep 14, 2012

Re: GPT-3 explains python codevreally well

Absolutely- I would not rely on it to interface directly with the Indigo DOM, but it seems really promising for natural language -> python scripting.

Matt, can you please post as Snoop Dogg from here on out?

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 6 guests