Enhancing LLMs Interactions for Python: A Smart API Framework for Extracting and Utilizing Semantic Code Information
In order to engage with large language models (LLMs) in a meaningful way, it is necessary to create prompts that are both instructive and precise. However, especially when working with complicated codebases, basic prompts frequently fall short in providing adequate context or extracting useful insights. In order to overcome this difficulty, we introduce a brand-new system that uses FastAPI to automatically extract semantic data from Python codebases. In order to recognize import statements, custom functions, and class declarations, as well as how they are used within modules and classes, our system uses libest to parse and analyze Python source files. Furthermore, the framework facilitates extraction from particular branches, commits, or tags by supporting Git-based version control. We create distinctive, context-rich prompts for LLMs like OpenAI's GPT models by fusing these capabilities. By producing structured JSON answers, the API makes it easier to integrate with open-source LLM systems like ChatGPT. In addition to improving the caliber of interactions with LLMs, this method gives developers the ability to effectively query and comprehend intricate codebases. Lastly, we curate a dataset of Python repositories from GitHub based on size and activity criteria, and train a GPT-4 based model evaluated using BERTScore, BLEU, and ROUGE, achieving research-acceptable metrics.
Authors
- Nouman Ahmad
- Changsheng Zhang (ORCID: https://orcid.org/0000-0003-3762-1954)
Institutions
- Northeastern University (CN)
Publication Details
- Published
- 2025-06-20
- DOI
- https://doi.org/10.1109/caibda65784.2025.11182836
- Primary Topic
- Computational Physics and Python Applications
- Type
- article
- Field-Weighted Citation Impact
- 0.00