yunal / notes

just some notes
0 stars 0 forks source link

gpt4 context tracking #3

Open yunal opened 1 year ago

yunal commented 1 year ago

Further experiments with GPT4. The screenshots are from the playground.

gpt4 is clearly very good at keeping track of context that it can see. It easily trips up about what output a external program produces with given options - in particular it suggested using lsblk in various ways that would be easier to parse, but lost the device hierarchy information that my program needed.

But when asked to suggest enhancements to my code, which was using hashes and indexes (not regular expressions, which easily trips it up) it was rather good. I have this code:

image

which is used like this:

image

I asked: Do you have any comments on efficiency or idiom used?

It had some naive suggestions but also:

image

Here it misses the point that Power_On_Hours and Media_Wearout_Indicator needs two different column indexes to get the right parameter. so:

image

yunal commented 1 year ago

This very good and insightful stuff and shows high levels of context tracking and abstraction. The use of the // operator to use whatever is defined of Media_Wearout_Indicator and Wear_Leveling_Count is very nice and idiomatic perl.

The suggested code grows a bit verbose when it comes to picking out the values of the returned hash. It could be made shorter again by also passing references to the variables to store the values in directly in get_param argument hash. This would be satisfying from a pure technical view but the complexity of the abstraction IMHO makes it more obtuse and overall the readability is reduced IMHO.

yunal commented 1 year ago

But since I'm doing this, I might as well ask: image

yunal commented 1 year ago

This last suggestion is technically very sweet and concise, but IMHO less readable than the original code. I. Must. Resist.

yunal commented 1 year ago

image

yunal commented 1 year ago

I called it a junior programmer earlier, but it clearly catches on very fast.