Spaces:
Running
Running
Merge remote-tracking branch 'origin/master' into test-3-24
Browse files- functional_crazy.py +15 -12
functional_crazy.py
CHANGED
@@ -4,11 +4,14 @@ fast_debug = False
|
|
4 |
def 高阶功能模板函数(txt, top_p, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
|
5 |
for i in range(5):
|
6 |
i_say = f'我给出一个数字,你给出该数字的平方。我给出数字:{i}'
|
7 |
-
|
8 |
-
chatbot
|
9 |
-
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
12 |
|
13 |
|
14 |
def 解析项目本身(txt, top_p, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
|
@@ -22,7 +25,7 @@ def 解析项目本身(txt, top_p, temperature, chatbot, history, systemPromptTx
|
|
22 |
前言 = "接下来请你分析自己的程序构成,别紧张," if index==0 else ""
|
23 |
i_say = 前言 + f'请对下面的程序文件做一个概述文件名是{fp},文件代码是 ```{file_content}```'
|
24 |
i_say_show_user = 前言 + f'[{index}/{len(file_manifest)}] 请对下面的程序文件做一个概述: {os.path.abspath(fp)}'
|
25 |
-
chatbot.append((i_say_show_user, "[waiting gpt response
|
26 |
yield chatbot, history, '正常'
|
27 |
|
28 |
if not fast_debug:
|
@@ -35,7 +38,7 @@ def 解析项目本身(txt, top_p, temperature, chatbot, history, systemPromptTx
|
|
35 |
time.sleep(2)
|
36 |
|
37 |
i_say = f'根据以上你自己的分析,对程序的整体功能和构架做出概括。然后用一张markdown表格整理每个文件的功能(包括{file_manifest})。'
|
38 |
-
chatbot.append((i_say, "[waiting gpt response
|
39 |
yield chatbot, history, '正常'
|
40 |
|
41 |
if not fast_debug:
|
@@ -64,7 +67,7 @@ def 解析源代码(file_manifest, project_folder, top_p, temperature, chatbot,
|
|
64 |
前言 = "接下来请你逐文件分析下面的工程" if index==0 else ""
|
65 |
i_say = 前言 + f'请对下面的程序文件做一个概述文件名是{os.path.relpath(fp, project_folder)},文件代码是 ```{file_content}```'
|
66 |
i_say_show_user = 前言 + f'[{index}/{len(file_manifest)}] 请对下面的程序文件做一个概述: {os.path.abspath(fp)}'
|
67 |
-
chatbot.append((i_say_show_user, "[waiting gpt response
|
68 |
print('[1] yield chatbot, history')
|
69 |
yield chatbot, history, '正常'
|
70 |
|
@@ -89,7 +92,7 @@ def 解析源代码(file_manifest, project_folder, top_p, temperature, chatbot,
|
|
89 |
|
90 |
all_file = ', '.join([os.path.relpath(fp, project_folder) for index, fp in enumerate(file_manifest)])
|
91 |
i_say = f'根据以上你自己的分析,对程序的整体功能和构架做出概括。然后用一张markdown表格整理每个文件的功能(包括{all_file})。'
|
92 |
-
chatbot.append((i_say, "[waiting gpt response
|
93 |
yield chatbot, history, '正常'
|
94 |
|
95 |
if not fast_debug:
|
@@ -116,7 +119,7 @@ def 解析一个Python项目(txt, top_p, temperature, chatbot, history, systemPr
|
|
116 |
project_folder = txt
|
117 |
else:
|
118 |
if txt == "": txt = '空空如也的输入栏'
|
119 |
-
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"
|
120 |
yield chatbot, history, '正常'
|
121 |
return
|
122 |
file_manifest = [f for f in glob.glob(f'{project_folder}/**/*.py', recursive=True)]
|
@@ -134,14 +137,14 @@ def 解析一个C项目的头文件(txt, top_p, temperature, chatbot, history, s
|
|
134 |
project_folder = txt
|
135 |
else:
|
136 |
if txt == "": txt = '空空如也的输入栏'
|
137 |
-
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"
|
138 |
yield chatbot, history, '正常'
|
139 |
return
|
140 |
file_manifest = [f for f in glob.glob(f'{project_folder}/**/*.h', recursive=True)] # + \
|
141 |
# [f for f in glob.glob(f'{project_folder}/**/*.cpp', recursive=True)] + \
|
142 |
# [f for f in glob.glob(f'{project_folder}/**/*.c', recursive=True)]
|
143 |
if len(file_manifest) == 0:
|
144 |
-
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"
|
145 |
yield chatbot, history, '正常'
|
146 |
return
|
147 |
yield from 解析源代码(file_manifest, project_folder, top_p, temperature, chatbot, history, systemPromptTxt)
|
|
|
4 |
def 高阶功能模板函数(txt, top_p, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
|
5 |
for i in range(5):
|
6 |
i_say = f'我给出一个数字,你给出该数字的平方。我给出数字:{i}'
|
7 |
+
chatbot.append((i_say, "[Local Message] waiting gpt response."))
|
8 |
+
yield chatbot, history, '正常' # 由于请求gpt需要一段时间,我们先及时地做一次状态显示
|
9 |
+
|
10 |
+
gpt_say = predict_no_ui(inputs=i_say, top_p=top_p, temperature=temperature) # 请求gpt,需要一段时间
|
11 |
+
|
12 |
+
chatbot[-1] = (i_say, gpt_say)
|
13 |
+
history.append(i_say);history.append(gpt_say)
|
14 |
+
yield chatbot, history, '正常' # 显示
|
15 |
|
16 |
|
17 |
def 解析项目本身(txt, top_p, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
|
|
|
25 |
前言 = "接下来请你分析自己的程序构成,别紧张," if index==0 else ""
|
26 |
i_say = 前言 + f'请对下面的程序文件做一个概述文件名是{fp},文件代码是 ```{file_content}```'
|
27 |
i_say_show_user = 前言 + f'[{index}/{len(file_manifest)}] 请对下面的程序文件做一个概述: {os.path.abspath(fp)}'
|
28 |
+
chatbot.append((i_say_show_user, "[Local Message] waiting gpt response."))
|
29 |
yield chatbot, history, '正常'
|
30 |
|
31 |
if not fast_debug:
|
|
|
38 |
time.sleep(2)
|
39 |
|
40 |
i_say = f'根据以上你自己的分析,对程序的整体功能和构架做出概括。然后用一张markdown表格整理每个文件的功能(包括{file_manifest})。'
|
41 |
+
chatbot.append((i_say, "[Local Message] waiting gpt response."))
|
42 |
yield chatbot, history, '正常'
|
43 |
|
44 |
if not fast_debug:
|
|
|
67 |
前言 = "接下来请你逐文件分析下面的工程" if index==0 else ""
|
68 |
i_say = 前言 + f'请对下面的程序文件做一个概述文件名是{os.path.relpath(fp, project_folder)},文件代码是 ```{file_content}```'
|
69 |
i_say_show_user = 前言 + f'[{index}/{len(file_manifest)}] 请对下面的程序文件做一个概述: {os.path.abspath(fp)}'
|
70 |
+
chatbot.append((i_say_show_user, "[Local Message] waiting gpt response."))
|
71 |
print('[1] yield chatbot, history')
|
72 |
yield chatbot, history, '正常'
|
73 |
|
|
|
92 |
|
93 |
all_file = ', '.join([os.path.relpath(fp, project_folder) for index, fp in enumerate(file_manifest)])
|
94 |
i_say = f'根据以上你自己的分析,对程序的整体功能和构架做出概括。然后用一张markdown表格整理每个文件的功能(包括{all_file})。'
|
95 |
+
chatbot.append((i_say, "[Local Message] waiting gpt response."))
|
96 |
yield chatbot, history, '正常'
|
97 |
|
98 |
if not fast_debug:
|
|
|
119 |
project_folder = txt
|
120 |
else:
|
121 |
if txt == "": txt = '空空如也的输入栏'
|
122 |
+
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到本地项目或无权访问: {txt}")
|
123 |
yield chatbot, history, '正常'
|
124 |
return
|
125 |
file_manifest = [f for f in glob.glob(f'{project_folder}/**/*.py', recursive=True)]
|
|
|
137 |
project_folder = txt
|
138 |
else:
|
139 |
if txt == "": txt = '空空如也的输入栏'
|
140 |
+
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到本地项目或无权访问: {txt}")
|
141 |
yield chatbot, history, '正常'
|
142 |
return
|
143 |
file_manifest = [f for f in glob.glob(f'{project_folder}/**/*.h', recursive=True)] # + \
|
144 |
# [f for f in glob.glob(f'{project_folder}/**/*.cpp', recursive=True)] + \
|
145 |
# [f for f in glob.glob(f'{project_folder}/**/*.c', recursive=True)]
|
146 |
if len(file_manifest) == 0:
|
147 |
+
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"���不到任何.h头文件: {txt}")
|
148 |
yield chatbot, history, '正常'
|
149 |
return
|
150 |
yield from 解析源代码(file_manifest, project_folder, top_p, temperature, chatbot, history, systemPromptTxt)
|