The application discloses a
programming assistance method and device based on generative AI and a medium, relates to the technical field of intelligent
programming, and comprises the following steps: sorting a state fragment set and establishing a unified scanning sequence, calculating the connection value between a function item state fragment and an interface item state fragment, determining the uniquely connected interface item state fragment and mode item state fragment, and then generating a target trajectory set, a constraint chain set, and corresponding slot set and reference fragment set; constructing a training sample and training a
code generation model according to the target trajectory set, the constraint chain set, the slot set and the reference fragment set, generating a candidate patch set through the trained
code generation model, performing consistency checking on each candidate patch and forming a consistency
record set; and the application improves the pertinence and localizability of
programming assistance by determining the uniquely connected interface item state fragment and mode item state fragment.