developer
developer copied to clipboard
Suggestion: lookup API docs before building code
Problem
Often, generated code encounters issues with third-party dependencies like Stripe, UI libraries, etc., leading to inaccurate output or "hallucinations".
Solution
A potential solution is to include the specific API definitions in the prompt. However, this could be optimized in the following ways:
Option 1: Use a Static List of Predefined APIs
We can create a repository subfolder containing API definitions for commonly used and popular libraries such as Stripe, MUI, NextJS, and so on. This would modify our workflow as follows:
- Query the prompt to identify which common libraries are being used.
- If available, fetch the API definitions from the static list.
- Incorporate these definitions into the prompt.
Option 2: Utilize a Dynamic Online List of APIs (Advanced)
Development of a simple web crawler could be done to obtain the latest API documentation from the internet. The new workflow would be:
- In the initial prompt, identify any mentions of third-party libraries.
- Proceed to search the internet for these libraries' specifications.
- Retrieve and condense the information found.
- Apply this condensed information when generating code from the prompt.