Spaces:
				
			
			
	
			
			
		Runtime error
		
	
	
	
			
			
	
	
	
	
		
		
		Runtime error
		
	
		RongkangXiong
		
	commited on
		
		
					Commit 
							
							·
						
						9540cf9
	
1
								Parent(s):
							
							55ef4ac
								
add crazy_functions 解析一个Rect项目
Browse files- crazy_functions/解析项目源代码.py +74 -39
 - functional_crazy.py +6 -0
 
    	
        crazy_functions/解析项目源代码.py
    CHANGED
    
    | 
         @@ -1,7 +1,9 @@ 
     | 
|
| 1 | 
         
             
            from predict import predict_no_ui
         
     | 
| 2 | 
         
             
            from toolbox import CatchException, report_execption, write_results_to_file, predict_no_ui_but_counting_down
         
     | 
| 
         | 
|
| 3 | 
         
             
            fast_debug = False
         
     | 
| 4 | 
         | 
| 
         | 
|
| 5 | 
         
             
            def 解析源代码(file_manifest, project_folder, top_p, temperature, chatbot, history, systemPromptTxt):
         
     | 
| 6 | 
         
             
                import time, glob, os
         
     | 
| 7 | 
         
             
                print('begin analysis on:', file_manifest)
         
     | 
| 
         @@ -9,20 +11,22 @@ def 解析源代码(file_manifest, project_folder, top_p, temperature, chatbot, 
     | 
|
| 9 | 
         
             
                    with open(fp, 'r', encoding='utf-8') as f:
         
     | 
| 10 | 
         
             
                        file_content = f.read()
         
     | 
| 11 | 
         | 
| 12 | 
         
            -
                    prefix = "接下来请你逐文件分析下面的工程" if index==0 else ""
         
     | 
| 13 | 
         
             
                    i_say = prefix + f'请对下面的程序文件做一个概述文件名是{os.path.relpath(fp, project_folder)},文件代码是 ```{file_content}```'
         
     | 
| 14 | 
         
             
                    i_say_show_user = prefix + f'[{index}/{len(file_manifest)}] 请对下面的程序文件做一个概述: {os.path.abspath(fp)}'
         
     | 
| 15 | 
         
             
                    chatbot.append((i_say_show_user, "[Local Message] waiting gpt response."))
         
     | 
| 16 | 
         
             
                    yield chatbot, history, '正常'
         
     | 
| 17 | 
         | 
| 18 | 
         
            -
                    if not fast_debug: 
     | 
| 19 | 
         
             
                        msg = '正常'
         
     | 
| 20 | 
         | 
| 21 | 
         
             
                        # ** gpt request **
         
     | 
| 22 | 
         
            -
                        gpt_say = yield from predict_no_ui_but_counting_down(i_say, i_say_show_user, chatbot, top_p, temperature, 
     | 
| 
         | 
|
| 23 | 
         | 
| 24 | 
         
             
                        chatbot[-1] = (i_say_show_user, gpt_say)
         
     | 
| 25 | 
         
            -
                        history.append(i_say_show_user); 
     | 
| 
         | 
|
| 26 | 
         
             
                        yield chatbot, history, msg
         
     | 
| 27 | 
         
             
                        if not fast_debug: time.sleep(2)
         
     | 
| 28 | 
         | 
| 
         @@ -31,45 +35,48 @@ def 解析源代码(file_manifest, project_folder, top_p, temperature, chatbot, 
     | 
|
| 31 | 
         
             
                chatbot.append((i_say, "[Local Message] waiting gpt response."))
         
     | 
| 32 | 
         
             
                yield chatbot, history, '正常'
         
     | 
| 33 | 
         | 
| 34 | 
         
            -
                if not fast_debug: 
     | 
| 35 | 
         
             
                    msg = '正常'
         
     | 
| 36 | 
         
             
                    # ** gpt request **
         
     | 
| 37 | 
         
            -
                    gpt_say = yield from predict_no_ui_but_counting_down(i_say, i_say, chatbot, top_p, temperature, 
     | 
| 38 | 
         
            -
             
     | 
| 
         | 
|
| 39 | 
         
             
                    chatbot[-1] = (i_say, gpt_say)
         
     | 
| 40 | 
         
            -
                    history.append(i_say); 
     | 
| 
         | 
|
| 41 | 
         
             
                    yield chatbot, history, msg
         
     | 
| 42 | 
         
             
                    res = write_results_to_file(history)
         
     | 
| 43 | 
         
             
                    chatbot.append(("完成了吗?", res))
         
     | 
| 44 | 
         
             
                    yield chatbot, history, msg
         
     | 
| 45 | 
         | 
| 46 | 
         | 
| 47 | 
         
            -
             
     | 
| 48 | 
         
            -
             
     | 
| 49 | 
         
             
            @CatchException
         
     | 
| 50 | 
         
             
            def 解析项目本身(txt, top_p, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
         
     | 
| 51 | 
         
            -
                history = [] 
     | 
| 52 | 
         
             
                import time, glob, os
         
     | 
| 53 | 
         
             
                file_manifest = [f for f in glob.glob('./*.py') if ('test_project' not in f) and ('gpt_log' not in f)] + \
         
     | 
| 54 | 
         
            -
                                [f for f in glob.glob('./crazy_functions/*.py') if 
     | 
| 
         | 
|
| 55 | 
         
             
                for index, fp in enumerate(file_manifest):
         
     | 
| 56 | 
         
             
                    # if 'test_project' in fp: continue
         
     | 
| 57 | 
         
             
                    with open(fp, 'r', encoding='utf-8') as f:
         
     | 
| 58 | 
         
             
                        file_content = f.read()
         
     | 
| 59 | 
         | 
| 60 | 
         
            -
                    prefix = "接下来请你分析自己的程序构成,别紧张," if index==0 else ""
         
     | 
| 61 | 
         
             
                    i_say = prefix + f'请对下面的程序文件做一个概述文件名是{fp},文件代码是 ```{file_content}```'
         
     | 
| 62 | 
         
             
                    i_say_show_user = prefix + f'[{index}/{len(file_manifest)}] 请对下面的程序文件做一个概述: {os.path.abspath(fp)}'
         
     | 
| 63 | 
         
             
                    chatbot.append((i_say_show_user, "[Local Message] waiting gpt response."))
         
     | 
| 64 | 
         
             
                    yield chatbot, history, '正常'
         
     | 
| 65 | 
         | 
| 66 | 
         
            -
                    if not fast_debug: 
     | 
| 67 | 
         
             
                        # ** gpt request **
         
     | 
| 68 | 
         
             
                        # gpt_say = predict_no_ui(inputs=i_say, top_p=top_p, temperature=temperature)
         
     | 
| 69 | 
         
            -
                        gpt_say = yield from predict_no_ui_but_counting_down(i_say, i_say_show_user, chatbot, top_p, temperature, 
     | 
| 
         | 
|
| 70 | 
         | 
| 71 | 
         
             
                        chatbot[-1] = (i_say_show_user, gpt_say)
         
     | 
| 72 | 
         
            -
                        history.append(i_say_show_user); 
     | 
| 
         | 
|
| 73 | 
         
             
                        yield chatbot, history, '正常'
         
     | 
| 74 | 
         
             
                        time.sleep(2)
         
     | 
| 75 | 
         | 
| 
         @@ -77,32 +84,35 @@ def 解析项目本身(txt, top_p, temperature, chatbot, history, systemPromptTx 
     | 
|
| 77 | 
         
             
                chatbot.append((i_say, "[Local Message] waiting gpt response."))
         
     | 
| 78 | 
         
             
                yield chatbot, history, '正常'
         
     | 
| 79 | 
         | 
| 80 | 
         
            -
                if not fast_debug: 
     | 
| 81 | 
         
             
                    # ** gpt request **
         
     | 
| 82 | 
         
             
                    # gpt_say = predict_no_ui(inputs=i_say, top_p=top_p, temperature=temperature, history=history)
         
     | 
| 83 | 
         
            -
                    gpt_say = yield from predict_no_ui_but_counting_down(i_say, i_say, chatbot, top_p, temperature, history=history, 
     | 
| 
         | 
|
| 84 | 
         | 
| 85 | 
         
             
                    chatbot[-1] = (i_say, gpt_say)
         
     | 
| 86 | 
         
            -
                    history.append(i_say); 
     | 
| 
         | 
|
| 87 | 
         
             
                    yield chatbot, history, '正常'
         
     | 
| 88 | 
         
             
                    res = write_results_to_file(history)
         
     | 
| 89 | 
         
             
                    chatbot.append(("完成了吗?", res))
         
     | 
| 90 | 
         
             
                    yield chatbot, history, '正常'
         
     | 
| 91 | 
         | 
| 
         | 
|
| 92 | 
         
             
            @CatchException
         
     | 
| 93 | 
         
             
            def 解析一个Python项目(txt, top_p, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
         
     | 
| 94 | 
         
            -
                history = [] 
     | 
| 95 | 
         
             
                import glob, os
         
     | 
| 96 | 
         
             
                if os.path.exists(txt):
         
     | 
| 97 | 
         
             
                    project_folder = txt
         
     | 
| 98 | 
         
             
                else:
         
     | 
| 99 | 
         
             
                    if txt == "": txt = '空空如也的输入栏'
         
     | 
| 100 | 
         
            -
                    report_execption(chatbot, history, a 
     | 
| 101 | 
         
             
                    yield chatbot, history, '正常'
         
     | 
| 102 | 
         
             
                    return
         
     | 
| 103 | 
         
             
                file_manifest = [f for f in glob.glob(f'{project_folder}/**/*.py', recursive=True)]
         
     | 
| 104 | 
         
             
                if len(file_manifest) == 0:
         
     | 
| 105 | 
         
            -
                    report_execption(chatbot, history, a 
     | 
| 106 | 
         
             
                    yield chatbot, history, '正常'
         
     | 
| 107 | 
         
             
                    return
         
     | 
| 108 | 
         
             
                yield from 解析源代码(file_manifest, project_folder, top_p, temperature, chatbot, history, systemPromptTxt)
         
     | 
| 
         @@ -110,40 +120,41 @@ def 解析一个Python项目(txt, top_p, temperature, chatbot, history, systemPr 
     | 
|
| 110 | 
         | 
| 111 | 
         
             
            @CatchException
         
     | 
| 112 | 
         
             
            def 解析一个C项目的头文件(txt, top_p, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
         
     | 
| 113 | 
         
            -
                history = [] 
     | 
| 114 | 
         
             
                import glob, os
         
     | 
| 115 | 
         
             
                if os.path.exists(txt):
         
     | 
| 116 | 
         
             
                    project_folder = txt
         
     | 
| 117 | 
         
             
                else:
         
     | 
| 118 | 
         
             
                    if txt == "": txt = '空空如也的输入栏'
         
     | 
| 119 | 
         
            -
                    report_execption(chatbot, history, a 
     | 
| 120 | 
         
             
                    yield chatbot, history, '正常'
         
     | 
| 121 | 
         
             
                    return
         
     | 
| 122 | 
         
            -
                file_manifest = [f for f in glob.glob(f'{project_folder}/**/*.h', recursive=True)] 
     | 
| 123 | 
         
            -
             
     | 
| 124 | 
         
            -
             
     | 
| 125 | 
         
             
                if len(file_manifest) == 0:
         
     | 
| 126 | 
         
            -
                    report_execption(chatbot, history, a 
     | 
| 127 | 
         
             
                    yield chatbot, history, '正常'
         
     | 
| 128 | 
         
             
                    return
         
     | 
| 129 | 
         
             
                yield from 解析源代码(file_manifest, project_folder, top_p, temperature, chatbot, history, systemPromptTxt)
         
     | 
| 130 | 
         | 
| 
         | 
|
| 131 | 
         
             
            @CatchException
         
     | 
| 132 | 
         
             
            def 解析一个C项目(txt, top_p, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
         
     | 
| 133 | 
         
            -
                history = [] 
     | 
| 134 | 
         
             
                import glob, os
         
     | 
| 135 | 
         
             
                if os.path.exists(txt):
         
     | 
| 136 | 
         
             
                    project_folder = txt
         
     | 
| 137 | 
         
             
                else:
         
     | 
| 138 | 
         
             
                    if txt == "": txt = '空空如也的输入栏'
         
     | 
| 139 | 
         
            -
                    report_execption(chatbot, history, a 
     | 
| 140 | 
         
             
                    yield chatbot, history, '正常'
         
     | 
| 141 | 
         
             
                    return
         
     | 
| 142 | 
         
            -
                file_manifest = [f for f in glob.glob(f'{project_folder}/**/*.h', recursive=True)] 
     | 
| 143 | 
         
             
                                [f for f in glob.glob(f'{project_folder}/**/*.cpp', recursive=True)] + \
         
     | 
| 144 | 
         
             
                                [f for f in glob.glob(f'{project_folder}/**/*.c', recursive=True)]
         
     | 
| 145 | 
         
             
                if len(file_manifest) == 0:
         
     | 
| 146 | 
         
            -
                    report_execption(chatbot, history, a 
     | 
| 147 | 
         
             
                    yield chatbot, history, '正常'
         
     | 
| 148 | 
         
             
                    return
         
     | 
| 149 | 
         
             
                yield from 解析源代码(file_manifest, project_folder, top_p, temperature, chatbot, history, systemPromptTxt)
         
     | 
| 
         @@ -151,39 +162,63 @@ def 解析一个C项目(txt, top_p, temperature, chatbot, history, systemPromptT 
     | 
|
| 151 | 
         | 
| 152 | 
         
             
            @CatchException
         
     | 
| 153 | 
         
             
            def 解析一个Java项目(txt, top_p, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
         
     | 
| 154 | 
         
            -
                history = [] 
     | 
| 155 | 
         
             
                import glob, os
         
     | 
| 156 | 
         
             
                if os.path.exists(txt):
         
     | 
| 157 | 
         
             
                    project_folder = txt
         
     | 
| 158 | 
         
             
                else:
         
     | 
| 159 | 
         
             
                    if txt == "": txt = '空空如也的输入栏'
         
     | 
| 160 | 
         
            -
                    report_execption(chatbot, history, a 
     | 
| 161 | 
         
             
                    yield chatbot, history, '正常'
         
     | 
| 162 | 
         
             
                    return
         
     | 
| 163 | 
         
            -
                file_manifest = [f for f in glob.glob(f'{project_folder}/**/*.java', recursive=True)] 
     | 
| 164 | 
         
             
                                [f for f in glob.glob(f'{project_folder}/**/*.jar', recursive=True)] + \
         
     | 
| 165 | 
         
             
                                [f for f in glob.glob(f'{project_folder}/**/*.xml', recursive=True)] + \
         
     | 
| 166 | 
         
             
                                [f for f in glob.glob(f'{project_folder}/**/*.sh', recursive=True)]
         
     | 
| 167 | 
         
             
                if len(file_manifest) == 0:
         
     | 
| 168 | 
         
            -
                    report_execption(chatbot, history, a 
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 169 | 
         
             
                    yield chatbot, history, '正常'
         
     | 
| 170 | 
         
             
                    return
         
     | 
| 171 | 
         
             
                yield from 解析源代码(file_manifest, project_folder, top_p, temperature, chatbot, history, systemPromptTxt)
         
     | 
| 172 | 
         | 
| 
         | 
|
| 173 | 
         
             
            @CatchException
         
     | 
| 174 | 
         
             
            def 解析一个Golang项目(txt, top_p, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
         
     | 
| 175 | 
         
            -
                history = [] 
     | 
| 176 | 
         
             
                import glob, os
         
     | 
| 177 | 
         
             
                if os.path.exists(txt):
         
     | 
| 178 | 
         
             
                    project_folder = txt
         
     | 
| 179 | 
         
             
                else:
         
     | 
| 180 | 
         
             
                    if txt == "": txt = '空空如也的输入栏'
         
     | 
| 181 | 
         
            -
                    report_execption(chatbot, history, a 
     | 
| 182 | 
         
             
                    yield chatbot, history, '正常'
         
     | 
| 183 | 
         
             
                    return
         
     | 
| 184 | 
         
             
                file_manifest = [f for f in glob.glob(f'{project_folder}/**/*.go', recursive=True)]
         
     | 
| 185 | 
         
             
                if len(file_manifest) == 0:
         
     | 
| 186 | 
         
            -
                    report_execption(chatbot, history, a 
     | 
| 187 | 
         
             
                    yield chatbot, history, '正常'
         
     | 
| 188 | 
         
             
                    return
         
     | 
| 189 | 
         
             
                yield from 解析源代码(file_manifest, project_folder, top_p, temperature, chatbot, history, systemPromptTxt)
         
     | 
| 
         | 
|
| 1 | 
         
             
            from predict import predict_no_ui
         
     | 
| 2 | 
         
             
            from toolbox import CatchException, report_execption, write_results_to_file, predict_no_ui_but_counting_down
         
     | 
| 3 | 
         
            +
             
     | 
| 4 | 
         
             
            fast_debug = False
         
     | 
| 5 | 
         | 
| 6 | 
         
            +
             
     | 
| 7 | 
         
             
            def 解析源代码(file_manifest, project_folder, top_p, temperature, chatbot, history, systemPromptTxt):
         
     | 
| 8 | 
         
             
                import time, glob, os
         
     | 
| 9 | 
         
             
                print('begin analysis on:', file_manifest)
         
     | 
| 
         | 
|
| 11 | 
         
             
                    with open(fp, 'r', encoding='utf-8') as f:
         
     | 
| 12 | 
         
             
                        file_content = f.read()
         
     | 
| 13 | 
         | 
| 14 | 
         
            +
                    prefix = "接下来请你逐文件分析下面的工程" if index == 0 else ""
         
     | 
| 15 | 
         
             
                    i_say = prefix + f'请对下面的程序文件做一个概述文件名是{os.path.relpath(fp, project_folder)},文件代码是 ```{file_content}```'
         
     | 
| 16 | 
         
             
                    i_say_show_user = prefix + f'[{index}/{len(file_manifest)}] 请对下面的程序文件做一个概述: {os.path.abspath(fp)}'
         
     | 
| 17 | 
         
             
                    chatbot.append((i_say_show_user, "[Local Message] waiting gpt response."))
         
     | 
| 18 | 
         
             
                    yield chatbot, history, '正常'
         
     | 
| 19 | 
         | 
| 20 | 
         
            +
                    if not fast_debug:
         
     | 
| 21 | 
         
             
                        msg = '正常'
         
     | 
| 22 | 
         | 
| 23 | 
         
             
                        # ** gpt request **
         
     | 
| 24 | 
         
            +
                        gpt_say = yield from predict_no_ui_but_counting_down(i_say, i_say_show_user, chatbot, top_p, temperature,
         
     | 
| 25 | 
         
            +
                                                                             history=[])  # 带超时倒计时
         
     | 
| 26 | 
         | 
| 27 | 
         
             
                        chatbot[-1] = (i_say_show_user, gpt_say)
         
     | 
| 28 | 
         
            +
                        history.append(i_say_show_user);
         
     | 
| 29 | 
         
            +
                        history.append(gpt_say)
         
     | 
| 30 | 
         
             
                        yield chatbot, history, msg
         
     | 
| 31 | 
         
             
                        if not fast_debug: time.sleep(2)
         
     | 
| 32 | 
         | 
| 
         | 
|
| 35 | 
         
             
                chatbot.append((i_say, "[Local Message] waiting gpt response."))
         
     | 
| 36 | 
         
             
                yield chatbot, history, '正常'
         
     | 
| 37 | 
         | 
| 38 | 
         
            +
                if not fast_debug:
         
     | 
| 39 | 
         
             
                    msg = '正常'
         
     | 
| 40 | 
         
             
                    # ** gpt request **
         
     | 
| 41 | 
         
            +
                    gpt_say = yield from predict_no_ui_but_counting_down(i_say, i_say, chatbot, top_p, temperature,
         
     | 
| 42 | 
         
            +
                                                                         history=history)  # 带超时倒计时
         
     | 
| 43 | 
         
            +
             
     | 
| 44 | 
         
             
                    chatbot[-1] = (i_say, gpt_say)
         
     | 
| 45 | 
         
            +
                    history.append(i_say);
         
     | 
| 46 | 
         
            +
                    history.append(gpt_say)
         
     | 
| 47 | 
         
             
                    yield chatbot, history, msg
         
     | 
| 48 | 
         
             
                    res = write_results_to_file(history)
         
     | 
| 49 | 
         
             
                    chatbot.append(("完成了吗?", res))
         
     | 
| 50 | 
         
             
                    yield chatbot, history, msg
         
     | 
| 51 | 
         | 
| 52 | 
         | 
| 
         | 
|
| 
         | 
|
| 53 | 
         
             
            @CatchException
         
     | 
| 54 | 
         
             
            def 解析项目本身(txt, top_p, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
         
     | 
| 55 | 
         
            +
                history = []  # 清空历史,以免输入溢出
         
     | 
| 56 | 
         
             
                import time, glob, os
         
     | 
| 57 | 
         
             
                file_manifest = [f for f in glob.glob('./*.py') if ('test_project' not in f) and ('gpt_log' not in f)] + \
         
     | 
| 58 | 
         
            +
                                [f for f in glob.glob('./crazy_functions/*.py') if
         
     | 
| 59 | 
         
            +
                                 ('test_project' not in f) and ('gpt_log' not in f)]
         
     | 
| 60 | 
         
             
                for index, fp in enumerate(file_manifest):
         
     | 
| 61 | 
         
             
                    # if 'test_project' in fp: continue
         
     | 
| 62 | 
         
             
                    with open(fp, 'r', encoding='utf-8') as f:
         
     | 
| 63 | 
         
             
                        file_content = f.read()
         
     | 
| 64 | 
         | 
| 65 | 
         
            +
                    prefix = "接下来请你分析自己的程序构成,别紧张," if index == 0 else ""
         
     | 
| 66 | 
         
             
                    i_say = prefix + f'请对下面的程序文件做一个概述文件名是{fp},文件代码是 ```{file_content}```'
         
     | 
| 67 | 
         
             
                    i_say_show_user = prefix + f'[{index}/{len(file_manifest)}] 请对下面的程序文件做一个概述: {os.path.abspath(fp)}'
         
     | 
| 68 | 
         
             
                    chatbot.append((i_say_show_user, "[Local Message] waiting gpt response."))
         
     | 
| 69 | 
         
             
                    yield chatbot, history, '正常'
         
     | 
| 70 | 
         | 
| 71 | 
         
            +
                    if not fast_debug:
         
     | 
| 72 | 
         
             
                        # ** gpt request **
         
     | 
| 73 | 
         
             
                        # gpt_say = predict_no_ui(inputs=i_say, top_p=top_p, temperature=temperature)
         
     | 
| 74 | 
         
            +
                        gpt_say = yield from predict_no_ui_but_counting_down(i_say, i_say_show_user, chatbot, top_p, temperature,
         
     | 
| 75 | 
         
            +
                                                                             history=[], long_connection=True)  # 带超时倒计时
         
     | 
| 76 | 
         | 
| 77 | 
         
             
                        chatbot[-1] = (i_say_show_user, gpt_say)
         
     | 
| 78 | 
         
            +
                        history.append(i_say_show_user);
         
     | 
| 79 | 
         
            +
                        history.append(gpt_say)
         
     | 
| 80 | 
         
             
                        yield chatbot, history, '正常'
         
     | 
| 81 | 
         
             
                        time.sleep(2)
         
     | 
| 82 | 
         | 
| 
         | 
|
| 84 | 
         
             
                chatbot.append((i_say, "[Local Message] waiting gpt response."))
         
     | 
| 85 | 
         
             
                yield chatbot, history, '正常'
         
     | 
| 86 | 
         | 
| 87 | 
         
            +
                if not fast_debug:
         
     | 
| 88 | 
         
             
                    # ** gpt request **
         
     | 
| 89 | 
         
             
                    # gpt_say = predict_no_ui(inputs=i_say, top_p=top_p, temperature=temperature, history=history)
         
     | 
| 90 | 
         
            +
                    gpt_say = yield from predict_no_ui_but_counting_down(i_say, i_say, chatbot, top_p, temperature, history=history,
         
     | 
| 91 | 
         
            +
                                                                         long_connection=True)  # 带超时倒计时
         
     | 
| 92 | 
         | 
| 93 | 
         
             
                    chatbot[-1] = (i_say, gpt_say)
         
     | 
| 94 | 
         
            +
                    history.append(i_say);
         
     | 
| 95 | 
         
            +
                    history.append(gpt_say)
         
     | 
| 96 | 
         
             
                    yield chatbot, history, '正常'
         
     | 
| 97 | 
         
             
                    res = write_results_to_file(history)
         
     | 
| 98 | 
         
             
                    chatbot.append(("完成了吗?", res))
         
     | 
| 99 | 
         
             
                    yield chatbot, history, '正常'
         
     | 
| 100 | 
         | 
| 101 | 
         
            +
             
     | 
| 102 | 
         
             
            @CatchException
         
     | 
| 103 | 
         
             
            def 解析一个Python项目(txt, top_p, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
         
     | 
| 104 | 
         
            +
                history = []  # 清空历史,以免输入溢出
         
     | 
| 105 | 
         
             
                import glob, os
         
     | 
| 106 | 
         
             
                if os.path.exists(txt):
         
     | 
| 107 | 
         
             
                    project_folder = txt
         
     | 
| 108 | 
         
             
                else:
         
     | 
| 109 | 
         
             
                    if txt == "": txt = '空空如也的输入栏'
         
     | 
| 110 | 
         
            +
                    report_execption(chatbot, history, a=f"解析项目: {txt}", b=f"找不到本地项目或无权访问: {txt}")
         
     | 
| 111 | 
         
             
                    yield chatbot, history, '正常'
         
     | 
| 112 | 
         
             
                    return
         
     | 
| 113 | 
         
             
                file_manifest = [f for f in glob.glob(f'{project_folder}/**/*.py', recursive=True)]
         
     | 
| 114 | 
         
             
                if len(file_manifest) == 0:
         
     | 
| 115 | 
         
            +
                    report_execption(chatbot, history, a=f"解析项目: {txt}", b=f"找不到任何python文件: {txt}")
         
     | 
| 116 | 
         
             
                    yield chatbot, history, '正常'
         
     | 
| 117 | 
         
             
                    return
         
     | 
| 118 | 
         
             
                yield from 解析源代码(file_manifest, project_folder, top_p, temperature, chatbot, history, systemPromptTxt)
         
     | 
| 
         | 
|
| 120 | 
         | 
| 121 | 
         
             
            @CatchException
         
     | 
| 122 | 
         
             
            def 解析一个C项目的头文件(txt, top_p, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
         
     | 
| 123 | 
         
            +
                history = []  # 清空历史,以免输入溢出
         
     | 
| 124 | 
         
             
                import glob, os
         
     | 
| 125 | 
         
             
                if os.path.exists(txt):
         
     | 
| 126 | 
         
             
                    project_folder = txt
         
     | 
| 127 | 
         
             
                else:
         
     | 
| 128 | 
         
             
                    if txt == "": txt = '空空如也的输入栏'
         
     | 
| 129 | 
         
            +
                    report_execption(chatbot, history, a=f"解析项目: {txt}", b=f"找不到本地项目或无权访问: {txt}")
         
     | 
| 130 | 
         
             
                    yield chatbot, history, '正常'
         
     | 
| 131 | 
         
             
                    return
         
     | 
| 132 | 
         
            +
                file_manifest = [f for f in glob.glob(f'{project_folder}/**/*.h', recursive=True)]  # + \
         
     | 
| 133 | 
         
            +
                # [f for f in glob.glob(f'{project_folder}/**/*.cpp', recursive=True)] + \
         
     | 
| 134 | 
         
            +
                # [f for f in glob.glob(f'{project_folder}/**/*.c', recursive=True)]
         
     | 
| 135 | 
         
             
                if len(file_manifest) == 0:
         
     | 
| 136 | 
         
            +
                    report_execption(chatbot, history, a=f"解析项目: {txt}", b=f"找不到任何.h头文件: {txt}")
         
     | 
| 137 | 
         
             
                    yield chatbot, history, '正常'
         
     | 
| 138 | 
         
             
                    return
         
     | 
| 139 | 
         
             
                yield from 解析源代码(file_manifest, project_folder, top_p, temperature, chatbot, history, systemPromptTxt)
         
     | 
| 140 | 
         | 
| 141 | 
         
            +
             
     | 
| 142 | 
         
             
            @CatchException
         
     | 
| 143 | 
         
             
            def 解析一个C项目(txt, top_p, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
         
     | 
| 144 | 
         
            +
                history = []  # 清空历史,以免输入溢出
         
     | 
| 145 | 
         
             
                import glob, os
         
     | 
| 146 | 
         
             
                if os.path.exists(txt):
         
     | 
| 147 | 
         
             
                    project_folder = txt
         
     | 
| 148 | 
         
             
                else:
         
     | 
| 149 | 
         
             
                    if txt == "": txt = '空空如也的输入栏'
         
     | 
| 150 | 
         
            +
                    report_execption(chatbot, history, a=f"解析项目: {txt}", b=f"找不到本地项目或无权访问: {txt}")
         
     | 
| 151 | 
         
             
                    yield chatbot, history, '正常'
         
     | 
| 152 | 
         
             
                    return
         
     | 
| 153 | 
         
            +
                file_manifest = [f for f in glob.glob(f'{project_folder}/**/*.h', recursive=True)] + \
         
     | 
| 154 | 
         
             
                                [f for f in glob.glob(f'{project_folder}/**/*.cpp', recursive=True)] + \
         
     | 
| 155 | 
         
             
                                [f for f in glob.glob(f'{project_folder}/**/*.c', recursive=True)]
         
     | 
| 156 | 
         
             
                if len(file_manifest) == 0:
         
     | 
| 157 | 
         
            +
                    report_execption(chatbot, history, a=f"解析项目: {txt}", b=f"找不到任何.h头文件: {txt}")
         
     | 
| 158 | 
         
             
                    yield chatbot, history, '正常'
         
     | 
| 159 | 
         
             
                    return
         
     | 
| 160 | 
         
             
                yield from 解析源代码(file_manifest, project_folder, top_p, temperature, chatbot, history, systemPromptTxt)
         
     | 
| 
         | 
|
| 162 | 
         | 
| 163 | 
         
             
            @CatchException
         
     | 
| 164 | 
         
             
            def 解析一个Java项目(txt, top_p, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
         
     | 
| 165 | 
         
            +
                history = []  # 清空历史,以免输入溢出
         
     | 
| 166 | 
         
             
                import glob, os
         
     | 
| 167 | 
         
             
                if os.path.exists(txt):
         
     | 
| 168 | 
         
             
                    project_folder = txt
         
     | 
| 169 | 
         
             
                else:
         
     | 
| 170 | 
         
             
                    if txt == "": txt = '空空如也的输入栏'
         
     | 
| 171 | 
         
            +
                    report_execption(chatbot, history, a=f"解析项目: {txt}", b=f"找不到本地项目或无权访问: {txt}")
         
     | 
| 172 | 
         
             
                    yield chatbot, history, '正常'
         
     | 
| 173 | 
         
             
                    return
         
     | 
| 174 | 
         
            +
                file_manifest = [f for f in glob.glob(f'{project_folder}/**/*.java', recursive=True)] + \
         
     | 
| 175 | 
         
             
                                [f for f in glob.glob(f'{project_folder}/**/*.jar', recursive=True)] + \
         
     | 
| 176 | 
         
             
                                [f for f in glob.glob(f'{project_folder}/**/*.xml', recursive=True)] + \
         
     | 
| 177 | 
         
             
                                [f for f in glob.glob(f'{project_folder}/**/*.sh', recursive=True)]
         
     | 
| 178 | 
         
             
                if len(file_manifest) == 0:
         
     | 
| 179 | 
         
            +
                    report_execption(chatbot, history, a=f"解析项目: {txt}", b=f"找不到任何java文件: {txt}")
         
     | 
| 180 | 
         
            +
                    yield chatbot, history, '正常'
         
     | 
| 181 | 
         
            +
                    return
         
     | 
| 182 | 
         
            +
                yield from 解析源代码(file_manifest, project_folder, top_p, temperature, chatbot, history, systemPromptTxt)
         
     | 
| 183 | 
         
            +
             
     | 
| 184 | 
         
            +
             
     | 
| 185 | 
         
            +
            @CatchException
         
     | 
| 186 | 
         
            +
            def 解析一个Rect项目(txt, top_p, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
         
     | 
| 187 | 
         
            +
                history = []  # 清空历史,以免输入溢出
         
     | 
| 188 | 
         
            +
                import glob, os
         
     | 
| 189 | 
         
            +
                if os.path.exists(txt):
         
     | 
| 190 | 
         
            +
                    project_folder = txt
         
     | 
| 191 | 
         
            +
                else:
         
     | 
| 192 | 
         
            +
                    if txt == "": txt = '空空如也的输入栏'
         
     | 
| 193 | 
         
            +
                    report_execption(chatbot, history, a=f"解析项目: {txt}", b=f"找不到本地项目或无权访问: {txt}")
         
     | 
| 194 | 
         
            +
                    yield chatbot, history, '正常'
         
     | 
| 195 | 
         
            +
                    return
         
     | 
| 196 | 
         
            +
                file_manifest = [f for f in glob.glob(f'{project_folder}/**/*.ts', recursive=True)] + \
         
     | 
| 197 | 
         
            +
                                [f for f in glob.glob(f'{project_folder}/**/*.tsx', recursive=True)] + \
         
     | 
| 198 | 
         
            +
                                [f for f in glob.glob(f'{project_folder}/**/*.json', recursive=True)] + \
         
     | 
| 199 | 
         
            +
                                [f for f in glob.glob(f'{project_folder}/**/*.js', recursive=True)] + \
         
     | 
| 200 | 
         
            +
                                [f for f in glob.glob(f'{project_folder}/**/*.jsx', recursive=True)]
         
     | 
| 201 | 
         
            +
                if len(file_manifest) == 0:
         
     | 
| 202 | 
         
            +
                    report_execption(chatbot, history, a=f"解析项目: {txt}", b=f"找不到任何Rect文件: {txt}")
         
     | 
| 203 | 
         
             
                    yield chatbot, history, '正常'
         
     | 
| 204 | 
         
             
                    return
         
     | 
| 205 | 
         
             
                yield from 解析源代码(file_manifest, project_folder, top_p, temperature, chatbot, history, systemPromptTxt)
         
     | 
| 206 | 
         | 
| 207 | 
         
            +
             
     | 
| 208 | 
         
             
            @CatchException
         
     | 
| 209 | 
         
             
            def 解析一个Golang项目(txt, top_p, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
         
     | 
| 210 | 
         
            +
                history = []  # 清空历史,以免输入溢出
         
     | 
| 211 | 
         
             
                import glob, os
         
     | 
| 212 | 
         
             
                if os.path.exists(txt):
         
     | 
| 213 | 
         
             
                    project_folder = txt
         
     | 
| 214 | 
         
             
                else:
         
     | 
| 215 | 
         
             
                    if txt == "": txt = '空空如也的输入栏'
         
     | 
| 216 | 
         
            +
                    report_execption(chatbot, history, a=f"解析项目: {txt}", b=f"找不到本地项目或无权访问: {txt}")
         
     | 
| 217 | 
         
             
                    yield chatbot, history, '正常'
         
     | 
| 218 | 
         
             
                    return
         
     | 
| 219 | 
         
             
                file_manifest = [f for f in glob.glob(f'{project_folder}/**/*.go', recursive=True)]
         
     | 
| 220 | 
         
             
                if len(file_manifest) == 0:
         
     | 
| 221 | 
         
            +
                    report_execption(chatbot, history, a=f"解析项目: {txt}", b=f"找不到任何golang文件: {txt}")
         
     | 
| 222 | 
         
             
                    yield chatbot, history, '正常'
         
     | 
| 223 | 
         
             
                    return
         
     | 
| 224 | 
         
             
                yield from 解析源代码(file_manifest, project_folder, top_p, temperature, chatbot, history, systemPromptTxt)
         
     | 
    	
        functional_crazy.py
    CHANGED
    
    | 
         @@ -16,6 +16,7 @@ def get_crazy_functionals(): 
     | 
|
| 16 | 
         
             
                from crazy_functions.解析项目源代码 import 解析一个C项目
         
     | 
| 17 | 
         
             
                from crazy_functions.解析项目源代码 import 解析一个Golang项目
         
     | 
| 18 | 
         
             
                from crazy_functions.解析项目源代码 import 解析一个Java项目
         
     | 
| 
         | 
|
| 19 | 
         
             
                from crazy_functions.高级功能函数模板 import 高阶功能模板函数
         
     | 
| 20 | 
         
             
                from crazy_functions.代码重写为全英文_多线程 import 全项目切换英文
         
     | 
| 21 | 
         | 
| 
         @@ -47,6 +48,11 @@ def get_crazy_functionals(): 
     | 
|
| 47 | 
         
             
                        "AsButton": False,  # 加入下拉菜单中
         
     | 
| 48 | 
         
             
                        "Function": 解析一个Java项目
         
     | 
| 49 | 
         
             
                    },
         
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 50 | 
         
             
                    "读Tex论文写摘要": {
         
     | 
| 51 | 
         
             
                        "Color": "stop",    # 按钮颜色
         
     | 
| 52 | 
         
             
                        "Function": 读文章写摘要
         
     | 
| 
         | 
|
| 16 | 
         
             
                from crazy_functions.解析项目源代码 import 解析一个C项目
         
     | 
| 17 | 
         
             
                from crazy_functions.解析项目源代码 import 解析一个Golang项目
         
     | 
| 18 | 
         
             
                from crazy_functions.解析项目源代码 import 解析一个Java项目
         
     | 
| 19 | 
         
            +
                from crazy_functions.解析项目源代码 import 解析一个Rect项目
         
     | 
| 20 | 
         
             
                from crazy_functions.高级功能函数模板 import 高阶功能模板函数
         
     | 
| 21 | 
         
             
                from crazy_functions.代码重写为全英文_多线程 import 全项目切换英文
         
     | 
| 22 | 
         | 
| 
         | 
|
| 48 | 
         
             
                        "AsButton": False,  # 加入下拉菜单中
         
     | 
| 49 | 
         
             
                        "Function": 解析一个Java项目
         
     | 
| 50 | 
         
             
                    },
         
     | 
| 51 | 
         
            +
                    "解析整个Java项目": {
         
     | 
| 52 | 
         
            +
                        "Color": "stop",  # 按钮颜色
         
     | 
| 53 | 
         
            +
                        "AsButton": False,  # 加入下拉菜单中
         
     | 
| 54 | 
         
            +
                        "Function": 解析一个Rect项目
         
     | 
| 55 | 
         
            +
                    },
         
     | 
| 56 | 
         
             
                    "读Tex论文写摘要": {
         
     | 
| 57 | 
         
             
                        "Color": "stop",    # 按钮颜色
         
     | 
| 58 | 
         
             
                        "Function": 读文章写摘要
         
     |