Hi all, very excited to see all the new features in 4.1 - and also the fixes and improvements. Bravo!
I got curious about the Applescript building using AI - and need a bit of help there… for those who are AI savvy, please forgive me…
I launched the new Script Editor (Data > New > Script…) - it gives me the screen @BLUEFROG showed very recently. Nice!!
I have free ChatGPT (and maybe this is already wrong), it looks like the editor recognized it (the icon). Then I typed “Create a clipboard text list with the names of the selected records” in the AI field, pressed return, and nothing happened.
I am not surprised, as I am a total rookie in this - can someone help a bit understanding what I am already outright doing wrong?
Did you enter the API key in Settings > AI > Chat? P.S: O4 (mini) was able to create a working although not really beautiful script using your prompt:
-- Prepare a list to collect record names
set recordNameList to {}
tell application id "DNtp"
-- Attempt to retrieve the user's selection
try
set selectedRecords to the selection
on error errMsg
display dialog "Error retrieving selection: " & errMsg buttons {"OK"} default button 1
return
end try
-- Ensure at least one record is selected
if selectedRecords is missing value or (count of selectedRecords) = 0 then
display dialog "No records selected." buttons {"OK"} default button 1
return
end if
-- Collect the name of each selected record
repeat with aRecord in selectedRecords
try
set recordTitle to the name of aRecord
on error
set recordTitle to ""
end try
set end of recordNameList to recordTitle
end repeat
end tell
-- Convert the list of names into a newline-delimited string
set AppleScript's text item delimiters to linefeed
set clipboardText to recordNameList as string
set AppleScript's text item delimiters to ""
-- Copy the result to the clipboard
set the clipboard to clipboardText
A simple hand-crafted script looks like this - obviously a lot less error handling & comments
tell application id "DNtp"
set recordNames to name of selected records
set AppleScript's text item delimiters to linefeed
set clipboardText to recordNames as string
set AppleScript's text item delimiters to ""
set the clipboard to clipboardText
end tell
Not to mention that AI error handling is often utterly pointless. Like
Why on earth would it not be possible to get the name of a record in DT? If that kind of error happened, something would be terribly wrong. And then, instead of raising all hell, the code just ignores the error and sets the result to the empty string.
But even before that, something is very messed up with my OpenAi credentials - it says I am a valid (email) username, I reset the password, it accepted, than now it errors out saying the credentials are invalid (plus a bunch of gobbledeegook text).
And my variation written but unposted earlier, with a slight change to cache the text item delimiters - a very good habit to be in, @uimike –
set od to AppleScript's text item delimiters
tell application id "DNtp"
set recNames to (name of (selected records))
set AppleScript's text item delimiters to linefeed
set the clipboard to (recNames as string)
set AppleScript's text item delimiters to od
end tell
Indeed, thanks Jim - maybe I’ll just put playing with AI & AS/js in the backburner for now. When you did enable this functionality, did you foresee getting deluged by people concocting all manners of script monsters using AI?
The Script Editor window and (Script) Assistant are one of the major features in the Europa release intended to encourage people to explore automation, with some assistance as needed. It also nicely provides the required handlers for the different types of scripts normally used in DEVONthink (and also documented in the Automation chapter).
PS: @cgrunenberg, could we add the triggered scripts as an option? Though less frequently used, they still have use cases, especially where an intervallic but more impromptu action is needed.
Their usage is actually discouraged, they’re not even assignable anymore via the Info > Generic inspector. Most things can already be handled by smart rules instead.
Did you go to the OpenAI’s API platform to signup and get an API key?
As is noted in the help and blog post and these forums, having a ChatGPT account is not the same as having an API key. And yes, you will need to give them a nominal amount of money to do anything “useful”. That applies to pretty much all commercial AI.
I did, Jim. I had signed on to it months ago (when DT launched the AI capabilities) - I also have a ChatGTP free desktop app, but I knew both things were separate. And I remember getting an API key. But now OpenAI is having a hard time with my email and password… I reset, it said OK, but nope. Maybe I’ll try and contact them. So the issue is not even paying, I just can’t get logged in.
In the Script Editor, I could see a previous (masked) API Key.
I will try and get a Claude API Key in the meantime.