smol-ai / developer

the first library to let you embed a developer agent in your own app!
https://twitter.com/SmolModels
MIT License
11.76k stars 1.03k forks source link

Suggestion: lookup API docs before building code #113

Open vood opened 1 year ago

vood commented 1 year ago

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.