Как сделать LLM более точным при проверке кода?Php

Кемеровские программисты php общаются здесь
Ответить
Anonymous
 Как сделать LLM более точным при проверке кода?

Сообщение Anonymous »

Я пытался заставить LLM помочь с проверкой кода, но у меня ничего не получилось.
Я хочу, чтобы LLM мог обнаруживать потенциальные ошибки в коде или даже давать предложение по оптимизации.
Ни один из протестированных мною LLM не смог решить довольно простой случай (gpt-4, o1, claude, qwen…)
Вот пример кода на PHP:
echo $data->status?->id == 4 ? "member1" : "non-member1";
echo !empty($data->status->id) && $data->status->id == 5 ? "member2" : "non-member2";

tldr: LLM должна сказать мне, что второй образец безопаснее, но он делает обратное
Я пробовал:
< pre class="lang-markdown Prettyprint-override"># first attempt
what is the difference between these code samples?
first sample: {{sample1}}
seconde sample: {{sample2}}

# first response (which is false btw)
The first sample is safer as it handles the case where $data->status might be null.
The second sample does not handle the case where $data->status might be null and will throw an error in such a scenario.

# my reply (then LLM agrees)
it seems you are wrong about the second sample, you said "Throws error if $data->status is null."
but the function 'empty' of PHP also check if the data is set, right?

# second attempt
I have these code samples.
define the concept and functions used.
give me the difference between the samples.
first sample: {{sample1}}
seconde sample: {{sample2}}

# response is more elaborate but in summary same wrong response as before


Подробнее здесь: https://stackoverflow.com/questions/792 ... ode-review
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Php»