ChatGPT and opportunities for coders

I have written a lot about the advantages of AI in blogging and thinking about future blogging in previous blogs. In this document, I continue to share a case in my development and related thoughts.

event recovery

I found that ChatGPT can also help me write OData , so I also use GPT to help me program.

  • How does OData combine filter and apply fields? The answer is as follows:
GET /odata/Products?$apply=groupby((Category), aggregate(UnitsInStock with sum as TotalUnitsInStock))&$filter=TotalUnitsInStock gt 100

ChatGPT provides an idea, but this example does not work correctly, because the result of aggregation output can no longer be further filtered by OData.

So I continued to tell it that it was wrong and asked him to rewrite it, but I couldn't get a satisfactory result.

Then change another question. Regarding the aggregation query and the corresponding data type, you can read the previous article I posted . I asked "I need to use odata query to classify according to adcode, and count the number of attachdeviceinfo, deviceinfo and attachdevicetype-number" . Answer the following:

/odata/DeviceInfos?$apply=groupby((Adcode), aggregate(AttachDevices/$count as NumAttachDevices, $count as NumDeviceInfos, AttachDevices/AttachDeviceType/$countdistinct as NumAttachDeviceTypes))

After running, an error was reported, indicating that with was missing, so after I located the problem, I asked again "Prompt that AttachDevices/$count lacks with, please revise it"

ChatGPT started scribbling me:

"This error message is because the count operation needs to be used with some other operations. For example, the count operation needs to be used with some other operations, such as filter or select. You need to select. You need to combine the count operation with one of the operations to use It works.

For example, if you want to count the number of devices that meet a certain filter condition, you can use the following URL:

/AttachDevices?$filter=Property eq 'Value'&$count=true

Please note that in this URL, the count operation needs to be used in combination with the count operation and the filter operation, and the filter operation must appear before the filter operation must appear before the count operation. "

It has already started to talk about me, and then I continued to modify the way of asking questions, but I still didn't get the result I wanted. Let me summarize:

  • OData-related information is relatively small, and the data set is relatively small, so the adaptation is not good, and it feels like an unpopular technology....
  • There is no problem with the idea provided by AI, but the syntax of the specific implementation does not conform to the OData specification.
  • The prompt method may also need to be improved to provide more context or auxiliary information to help AI solve problems better.

Finally, I thought that if $count doesn't work, is it okay to use specific attributes of entities for statistics? Change it to the following and it will be OK.

odata/attachdeviceinfos?$apply=groupby((deviceinfo/Adcode), aggregate($count as NumAttachDevices, deviceinfo/deviceid with countdistinct as NumDevices, attachdevicetype/id with countdistinct as NumTypes))

Chance

Throughout the process, the AI ​​did most of the work, but I was still the finishing touch. Therefore, the AI ​​era provides opportunities for programmers today:

  • It is still necessary to master some relatively unpopular or more complex technologies, so that if the solution given by AI is wrong, it will not be completely blinded.
  • Master the skills of quick Troubleshooting, and when encountering problems that AI cannot solve, quickly provide solutions that meet the requirements of the scene through documents and related experience.

So, please be wary of relying entirely on AI, it may not be able to provide the answer or it may be the wrong answer. I think of a movie "Mechanical Enemy" a long time ago. Human beings were helpless when AI betrayed. . . Hopefully we won't be like this in the future.

Author of this article

Link to this article: https://www.cnblogs.com/podolski/p/17264634.html

Guess you like

Origin blog.csdn.net/wangonik_l/article/details/131469583