本项目的功能包括调用LLM实现对程序源代码进行注释和总结,编写或修改Python程序并进行测试。 运行前需要在api.py填写自己使用的LLM的api域名和api key。 以下为实现注释和总结功能的程序:“添加注释.py”用于获取当前目录下“code”文件夹中相应格式的文件并进行注释,默认读取.py文件,如果需要读取其它文件要修改程序。“描述源码.py”用于生成对获取当前目录下“code”文件夹中相应格式的文件的功能描述并保存为同名txt文件,默认读取.py文件,如果需要读取其它文件要修改程序。“总结源码.py”用于读取“描述源码.py”生成的txt文件并总结这个程序的功能。总结后的内容输出到当前目录的summarize.txt文件“提问功能.py”用于读取“描述源码.py”生成的txt文件并输入内容对程序功能进行提问。 以下为实现编程和和测试功能的程序:“编程-测试.py”用于根据要求编写Python程序并进行测试,如果输入为空则读取当前目录question.txt中的编程要求,编写后的程序保存到code.py。“修改-测试.py”用于根据要求修改程序并进行测试,如果输入为空则读取当前目录question.txt中的修改要求,修改后的程序保存到code.py。如果编程或修改经过一定次数仍然达不到要求则结束程序。 一般来说,添加注释和描述源码功能对LLM要求不高,但如果程序中包含大量与要求的语言不同的注释,逻辑能力较差的LLM可能使用不符合要求的语言。总结源码和提问功能需要使用逻辑能力强的LLM,并且对于规模较大的项目总结效果一般。编程和修改功能需要使用编程能力较好的LLM或根据编程要求进行选择。 本项目使用LLM辅助编写,提示词保存在与相应. py文件同名的txt文件中。 本项目提供中文和英文版本,均使用对应语言的文件名提交到仓库,但api. py用于中文版本,对应的api_en. py用于英文版本。release中分开提供两种语言的版本。英文版本编程的提示词使用LLM进行翻译,api_en. py中的提示词使用常规翻译软件进行翻译,不保证准确。如果您确定翻译有误可以给出修改建议。
The project includes calling LLM to comment and summarize the source code, writing or modifying Python programs, and testing them. Before running it's required to fill in your own LLM API domain name and api key in the "api.py" file.
Here are some functions of this program:
- "Add comments.py": It is used for getting all files from current directory under folder named 'code' with a specific format, which can be python or others. And it will add relevant comment to these codes.
- "Describe code.py": This function generates description text file (with the same name as your source code in txt form). It is used for generating functional description of all files from current directory under folder named 'code'.
- "Summarize code.py": To read a generated by above program and then summarizes it.
- "Ask question.py": To input relevant question about this project or specific file.
And here are some functions to help you write, modify Python codes:
- "Write & Test Code.py": This function is used for writing your python code according the requirements. If there's no requirement provided (empty), it will read a text from current directory named 'question.txt' and execute.
- "Modify & Test Code.py": Similar to above program but this one modifies existing codes instead of generating new ones.
Usually, commenting or summarize functions do not require high-level language understanding. But if there are many comments in different languages than the required target, a LLM with poor logical reasoning may produce non-compliant comment lines. Summarization and asking question function requires strong logic reasoning from your chosen LLM model. And for large scale project, its summarizing ability usually does not meet expectations.
Both Chinese and English versions of this project are provided (use corresponding language file names to submit). But "api.py" is used in the Chinese version while "api_en.py" works with English one. Release package offers two languages separately.
For each source code you're working on, please follow these steps:
- Place your Python codes under 'code' folder of current directory
- Run 'add comments.py' to add relevant comment lines into them
- Save the result file name as '<your_source_code_file_name>.txt'
- Run 'describe code.py' and provide input source files or simply use default behavior for reading from 'code' folder.
- Run 'summarize code.py', it will read your txt generated by above program to summarize this function.
- To ask a question, run the "Ask Question.py" file
- For coding-related tasks like writing new codes and testing them or modifying existing ones:
- Run either of these two programs 'Write & Test Code.py' (for generating code) or 'Modify & Test Code.py' (for modifying source code).
- If there's no requirement provided, it will read a text from current directory named 'question.txt'.
- Input the specific requirements and run this program to generate or modify your Python codes.
For both versions of the project, I have kept the prompt words in corresponding .txt files for each .py file.
Please note that English version uses LLM translation service on programming-related prompts (in "api_en.py"). The accuracy is not guaranteed so if you find any mistakes please provide us with your modifications suggestions.