developer icon indicating copy to clipboard operation
developer copied to clipboard

Suggestion: lookup API docs before building code

Open vood opened this issue 1 year ago • 0 comments

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:

  1. Query the prompt to identify which common libraries are being used.
  2. If available, fetch the API definitions from the static list.
  3. 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:

  1. In the initial prompt, identify any mentions of third-party libraries.
  2. Proceed to search the internet for these libraries' specifications.
  3. Retrieve and condense the information found.
  4. Apply this condensed information when generating code from the prompt.

vood avatar Jul 02 '23 15:07 vood