ChatGPT and LiveCode

Want to talk about something that isn't covered by another category?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Hutchboy
Posts: 51
Joined: Wed Aug 01, 2018 2:57 pm
Contact:

Re: ChatGPT and LiveCode

Post by Hutchboy » Thu Feb 08, 2024 2:34 pm

Hi,

A video series is an interesting idea. So...I asked my GPT buddy what it thought and it gave me the attached outline as a downloadable pdf. I asked it specifically to concentrate on workflow and not on learning LiveCode basics. I can have the GPT expand any or all sections and create scripts for the YouTube videos.

I am interested on any feedback on the attached outline.

I don't have experience creating YouTube videos but there are a few LiveCode YouTube videos that I think are well done that use screen captures. I might take a stab at this if I can create a quality product. Since I have archived all of my chats since I signed up for ChatGPT Plus, I have plenty of original material.

- Mike and my GPT buddy (I need a name..."Robo-Klaus"?)
Attachments
ChatGPT_LiveCode_Video_Series_Outline.pdf.zip
(3.44 KiB) Downloaded 35 times

stam
Posts: 2689
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: ChatGPT and LiveCode

Post by stam » Thu Feb 08, 2024 3:29 pm

Your PDF looks fine, that would be a great starting point.
Video captures are all you need and someone that can speak well on top of the video captures and engage audiences. Not everyone can do this well, and it is a key ingredient. If you feel hesitant about this I'm sure there are those who would volunteer.

The worst YouTube stuff I've seen are videos where someone plays back a video capture (often accelerated) with no VoiceOver at all, silence or sometimes text. These are much less engaging. Goes without saying, even with voiceovers you would need to be handy with video editing. Segments could be 3-5 minutes long, or at most 10 min (I would avoid 45 minute or longer segments as interest will wane).

Not sure if it's worth approaching LiveCode directly to get some support with this, as it would be a great promotional tool for them as well. Worst case scenario, they can only say 'No' if you email support at livecode dot com.

Done well, this is something that can be pushed to social media etc, which would be in LC Ltd's interest, could be post on their blog etc.

Hutchboy
Posts: 51
Joined: Wed Aug 01, 2018 2:57 pm
Contact:

Re: ChatGPT and LiveCode

Post by Hutchboy » Thu Feb 08, 2024 5:31 pm

Thanks for the feedback.

I like the idea of the shorter segments < 10 minutes and I agree VoiceOver is necessary. I think I have a few ways to do this. I'll work on a sample video and see if this is in my wheel house and how much time needs to be invested.

If I miraculously create something half-decent I will probably post it to my website initially to get feedback and only upload to YouTube when it is ready for primetime.

-Mike

mrcoollion
Posts: 720
Joined: Thu Sep 11, 2014 1:49 pm
Location: The Netherlands

Re: ChatGPT and LiveCode

Post by mrcoollion » Mon Mar 25, 2024 10:59 am

For anyone interested. I have set up a topic related to using LiveCode with AI.
See 'Learn AI and Contribute Topic'.

trevix
Posts: 964
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: ChatGPT and LiveCode

Post by trevix » Fri Apr 12, 2024 3:16 pm

Hello.
I am using the following code to get ChatGPT answers in LC10.

Code: Select all

on mouseUp pMouseButton
     put "https://api.openai.com/v1/chat/completions" into tURL
     put "XXXXXXXXXXXXXXXXX" into tKey --put here your token
     put "Content-Type: application/json;charset=utf-8" & return into tHeader
     put "Authorization: Bearer " & tKey & return after tHeader
     set the httpHeaders to tHeader
     put "gpt-3.5-turbo" into tModel
     put "user" into tRole
     put fld"Question" into tContent
     put merge("{"&quote&"role"&quote&": "&quote&"[[tRole]]"&quote&", "& \
           quote&"content"&quote&": "&quote&"[[tContent]]"&quote&"}") into tMessage
     
     put merge("{ "&quote&"model"&quote&": "&quote&"[[tModel]]"&quote&","& \
           quote&"messages"&quote&": [ [[tMessage]] ], "&quote&"temperature"& \
           quote&": 1, "&quote&"max_tokens"&quote&": 256, "&quote&"top_p"&quote&": 1, "& \
           quote&"frequency_penalty"&quote&": 0, "&quote&"presence_penalty"&quote&": 0 }") into tPayload
     
     post tPayload to url tURL
     put textDecode(it,"UTF-8") into it
     put jsonimport(it) into tArray
     if "error" is in the keys of tArray then
          put tArray["error"]["message"] into fld "answer"
     else
          put tArray["choices"][1]["message"]["content"] into BotAnswer
          put BotAnswer into fld "answer"
     end if
end mouseUp
But I alway get the following response, even if not having previous API request:
You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides ... api-errors.
I have a free plan with ChatGPT and I think this may be the issue...can someone confirm?
Thanks Trevix
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>

TJF
Posts: 1
Joined: Thu Apr 25, 2024 11:16 pm

Re: ChatGPT and LiveCode

Post by TJF » Fri May 03, 2024 1:28 am

To my suprise, it had no problem spitting out what looks to be legit code for an A* path finding algorithm, which would be useful for a simple RPG

function heuristicCostEstimate pStartNode, pEndNode
-- Calculate the heuristic cost estimate using Manhattan distance
return abs(pEndNode["x"] - pStartNode["x"]) + abs(pEndNode["y"] - pStartNode["y"])
end heuristicCostEstimate

function reconstructPath pCameFrom, pCurrentNode
-- Reconstruct the path from start to end based on the cameFrom list
put empty into tPath
put pCurrentNode into tNode
repeat until tNode is empty
put tNode & cr after tPath
put pCameFrom[tNode] into tNode
end repeat
return reverseLines(tPath)
end reconstructPath

on AStarPathfinding pStartNode, pEndNode, pGraph
-- Initialize open and closed lists
put empty into tOpenSet
put empty into tClosedSet
put pStartNode into tOpenSet

-- Initialize cameFrom and gScore dictionaries
put empty into tCameFrom
put empty into tGScore
put 0 into tGScore[pStartNode]

-- Initialize fScore dictionary with heuristic cost estimate
put heuristicCostEstimate(pStartNode, pEndNode) into tFScore
put tFScore into tFScore[pStartNode]

-- Loop until open set is empty
repeat until tOpenSet is empty
-- Find the node in open set with lowest fScore
put empty into tCurrentNode
put infinity into tLowestFScore
repeat for each line tNode in tOpenSet
if tFScore[tNode] < tLowestFScore then
put tNode into tCurrentNode
put tFScore[tNode] into tLowestFScore
end if
end repeat

-- If current node is the end node, reconstruct and return the path
if tCurrentNode = pEndNode then
return reconstructPath(tCameFrom, tCurrentNode)
end if

-- Move current node from open set to closed set
delete line tOpenSet[tCurrentNode] of tOpenSet
put tCurrentNode & cr after tClosedSet

-- Explore neighbors of current node
repeat for each key tNeighborNode in pGraph[tCurrentNode]
if tNeighborNode is among the lines of tClosedSet then
next repeat
end if

-- Calculate tentative gScore
put tGScore[tCurrentNode] + pGraph[tCurrentNode][tNeighborNode] into tTentativeGScore

-- Add neighbor node to open set if not already there
if tNeighborNode is not among the lines of tOpenSet then
put tNeighborNode & cr after tOpenSet
elseif tTentativeGScore >= tGScore[tNeighborNode] then
next repeat
end if

-- Record the best path so far
put tCurrentNode into tCameFrom[tNeighborNode]
put tTentativeGScore into tGScore[tNeighborNode]
put tTentativeGScore + heuristicCostEstimate(tNeighborNode, pEndNode) into tFScore[tNeighborNode]
end repeat
end repeat

-- No path found
return empty
end AStarPathfinding


This code defines three functions: heuristicCostEstimate, reconstructPath, and AStarPathfinding. The heuristicCostEstimate function calculates the heuristic cost estimate using Manhattan distance. The reconstructPath function reconstructs the path from the start to the end node based on the cameFrom list. Finally, the AStarPathfinding function implements the A* algorithm to find the shortest path from the start to the end node in a given graph.

You can use this code by passing the start node, end node, and the graph (represented as a dictionary where keys are nodes and values are dictionaries of neighbors with their corresponding edge costs) to the AStarPathfinding function. It will return the shortest path as a list of nodes.




Have not tested it yet, but I figured it would just say something about not knowing enough about the syntax. For sure it can do it in C or Python etc, but Livecode? I'm impressed.

Post Reply

Return to “Off-Topic”