You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2. Run `which openai` to get the full path of where the executable is
3. Copy the path and replace `/opt/homebrew/bin/openai` in the script with your path if it's different
4. Update ` set OPENAI_API_KEY to "xxx"` to use your OpenAI key
To use GPT3.5-turbo instead of gpt-4, change `/opt/homebrew/bin/openai api chat_completions.create -m gpt-4` to `-m gpt-3.5-turbo` or other model with larger context window.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
settheResultto theResult &character (random numberfrom1tolengthof theCharacters) of theCharacters
end repeat
return theResult
end randomString
# store filecontent into a temporary txt file and return the path to it
onstoreFileContent(filecontent)
setuniqueIdentifiertomy randomString(20)
setposixtmpfiletoPOSIX pathof (path to temporary items folder) & uniqueIdentifier &".txt"
try
setfhandletoopen for access posixtmpfile withwrite permission
write filecontent to fhandle as«class utf8»
close access fhandle
return posixtmpfile
on error
try
close access posixtmpfile
end try
end try
end storeFileContent
onprocessRecord(theRecord)
tellapplicationid"DNtp"
if type of theRecord astextis"group"or (wordcountof theRecord) is0thenreturn
setctoplaintextof theRecord
# cut c to be max 8000 chars long, if it's longer than 8000. otherwise take the entire content
iflengthof c >8000then
setctotext1thru8000of c
end if
setposixtmpfiletomy storeFileContent(c)
log"temporary filepath: "& posixtmpfile
setOPENAI_API_KEYto"xxx"
settheCommandto"OPENAI_API_KEY='"& OPENAI_API_KEY &"' /opt/homebrew/bin/openai api chat_completions.create -m gpt-4 -g system \"You are a program designed to generate filenames that could match the given text. Output exactly 1 filename that could fit the content and nothing else. Don't output a file extension, separate words by space. No preamble, no extra output, only output the filename. Keep it concise.\" -g user \"$(cat "& posixtmpfile &")\""