The invention relates to a
code generation method based on reasoning
time extension. The method comprises the following steps: 1, in a scene without external information: step 1, generating an initial code draft with API (Application Program Interface) calling; 2, the
large model considers the influence of PythonAPI version evolution on
code migration according to a given rough code,
library requirements and version constraints, and generates a refined code with correct API calling; and 2, introducing a rough code retrieval scene by using external information: step 1, capturing a Python
library from PyPI and GitHub, and constructing an external
knowledge base; the method comprises the following steps of: 1, generating a rough
code snippet, 2, generating a rough
code snippet, and 3, generating a refined
code snippet subjected to knowledge enhancement by a
large model according to a given rough code,
library requirements, version constraints and retrieved knowledge snippets. The method can improve the
correctness of the API, is compatible with a deployment standard, and improves the
code generation capability of a
large model when the large model deals with API demand evolution.