DT4 Batch process - PDF (book) rename -- Please help - I don't know what I'm doing wrong

I’m trying to automate (using ChatGPT) a batch process that takes an ebook in PDF format, and renames the document [title]-[pubyear]-[author-lastname] – it worked for the first couple, then stopped working completely and I can’t see why. I’d be grateful for a second set of eyes, just while I’m learning to use AI in DT4.

This is the prompt:

Rename this ebook using only the book’s short title, the 4-digit publication year, and the author's last name. If the book was translated, add “-trans-” and the translator’s last name.

Format the filename exactly like this: lowercase-words-separated-by-dashes ending in -yyyy-author[-trans-translator]

Do not return any explanation, commentary, or punctuation. Return only the filename.

Examples:
changing-direction-2006-dekoven
poetics-1996-aristotle-trans-heath


Do you have money available in your OpenAI API account?

Yes, I have credit in my account

Hold the Option key and choose Help > Report bug to start a support ticket and we will look at the logs.

for me it works in O3 (Mini), while not in 4o (Mini) … last time I tested.

as @BLUEFROG and others have pointed out, it´s often a fine line of models, even within one ‘blend’ (OpenAI).

(generally, I do think this is a challenge introduced by introduction of AI into DT – actually one needs some (self-?)guidance as to how to fit the choice of models to the tasks as pertain to the DT-environment…
I think, over time it would be great (‘needed’) to have some resources on it, either as part of documentation, or from community side… or, both could interact, … crazy thought:laughing:)

Umm so that’s embarrassing… I just checked my OpenAI account and, yes… I somehow dropped from my $10 to minus a few cents… how this happened I have no clue as I’ve just been trying to get this Batch Process to work :see_no_evil_monkey: I have just added more credit and so far so good :+1: I will keep testing and if anything changes get back in touch. Thank you Bluefrog :sign_of_the_horns:

Just an aside, I could also technically fetch a ‘book summary’ and add this to comments for the book and add tags in this single process, or would I need to create another 2 processes?

1 Like

Just curious if you read the Getting Started > AI Explained section of the Help?

No worries and yet another logical answer to “a DEVONthink issue” :smiley:

Just an aside, I could also technically fetch a ‘book summary’ and add this to comments for the book and add tags in this single process, or would I need to create another 2 processes?

There would be no issue with chaining those actions into one batch configuration… unless you run out of money again :wink: Sorry! I couldn’t resist.

I was actually referring to the (great) documentation text:

The responses vary per AI engine, e.g., ChatGPT versus Claude, but can also vary per-model.

1 Like

Cheeky! :winking_face_with_tongue: This ‘testing’ and setup is working out to be quite expensive :see_no_evil_monkey: How much do you think $$$ it will take me to get the chaining part right :joy::sob:

Also, user feedback… it might be nice to get a little button we can click on to expand the prompt window so we can see the whole prompt. Kinda like here with two diagonal arows.

1 Like

You have used 45 million tokens already…

While the text field doesn’t support multiline text, you can expand the width of the batch processing window.

Are any of these properties available in Info > Properties after importing?

Anyway, most likely only the first page(s) are really necessary for this. A script that uses the command get chat response for message and only the first n characters of the text is probably a lot faster and cheaper.

… practically speaking: I think this (great + applaudable) move to external AI use will simply bring recurring challenges to a (naturally) heterogenuous user community.

so, I expect questions pop-up repeatedly, even more so given a) increased adoption (within DT); and b) continuously changing models + behaviors, c) the multitude of different scenarios (given DTs power)

so, there are logically two routes to take:

  1. face repeated, and probably snowballing help requests
  2. building a resource (guide) somehow

– but just to mention that, as (reasonable) option.
and this seems like a ‘natural’ case for ‘crowdsourced intelligence’ (wetware domain :grin:)

… of course, there are always alternative & ; like 3) frustrated / confused users etc. but let´s maybe not get into those… :sunflower:

:scream::exploding_head: but how… why so many?! I’ve just been trying to get this batch process working…

How can I achieve this? Clearly my way is not sustainable!

It will be impossible to provide an authoritative guide on AI. It’s a fast and ever-changing moving target. That’s why I wrote in broad strokes in the help and we give no specific recommendations about specific AI providers.

Also, there will be a lot of subjectivity on the topic. I like Claude as a default for most tasks, generally opting for Haiku but switching to Sonnet 3.7 for more in-depth tasks. On the other hand, Gemini Flash is good for very succinct results where you want to minimize chatter.

1 Like

I hear you.

all this will nevertheless not change the fact that people will be specifically encountering AI-model use in the DT setting.
… thus, these question will only increase (– I would say that is a reasonable assumption).

I think the critical notion in what you are saying – and why I was consciously using the tentative label of ‘guide’ – is 'authoritative´.
you did a great job, as has been repeatedly been pointed out, with the ‘help’ documents. and it´s a challenge on its own, exactly because it has to be ‘authoritative’ be the very nature of the format.

the challenge, if any one follows the reasonable proposal/idea (‘reasonable’, as I think, in times of wikis, howTos, forums, user sourced content, etc), is exactly to find a format for such a ‘thing’, with requirements being:

a) it shouldn´t come along as ‘authorative’ – and thus mislead people, in a field that – as you also say – is intrinsically complex. (of course this requires a certain understanding and ethos in community & user culture and its handling)

b) it should (and probably: couldn´t) be weighed on any individuals shoulder; … thus my excitation to think about (co-opted) community sourcing…

… again, just (my) thoughts.

I just have some empathy, actually looking into an expectable future, and anticipating how many of those questions will now rain down here, and on you specifically, “from here to eternity” … :laughing:

I’m not sure if this is in line with what @cgrunenberg is suggesting but here’s my interpretation of his comment using your prompt…

tell application id "DNtp"
	set limitedText to (paragraphs 1 thru 25 of (get plain text of (selected record 1)))
	
	set thePrompt to "Rename this ebook using " & limitedText & " If the book was translated, add “-trans-” and the translator’s last name.

Format the filename exactly like this: lowercase-words-separated-by-dashes ending in -yyyy-author[-trans-translator]

Do not return any explanation, commentary, or punctuation. Return only the filename.

Examples:
changing-direction-2006-dekoven
poetics-1996-aristotle-trans-heath"
	
	get chat response for message thePrompt engine Claude model "Claude 3.7 Sonnet" without tool calls
end tell

This gets the first 25 paragraphs of the document. This could be fewer… or more, as needed.
Running this on the DT3 manual yields: "devonthink-documentation-2023-devontechnologies".

PS: The length of your prompt contributes to the token use as well as the tokens from a document you’re querying about.


Token Usage…

Here is a batch configuration using an AI-generated title…

The above script was run on the same document.

Here is the input token usage…

2 Likes

Interesting, thank you Bluefrog for taking the time to help me with this. So this script uses the default AI setting in DT4 (in this case Claude) without need for me to reference my own API for the call? I have not added a Claude API as I don’t have one, only for ChatGPT - so I am assuming I need to update the script accordingly? Something like “get chat response for message thePrompt engine ChatGPT model “GPT-4o (Mini)” without tool calls”

You’re welcome and yes you’d need to adjust the engine and model for your specific situation.

Fascinating! Thank you for the visual! A huge difference! I will give the script a try! Much appreciated! :folded_hands: