#作者 Panel 52pojie.cn
import tkinter as tk
import openai
import os
def get_text():
if os.path.exists("User\\question.txt"):
fileque = open('User\\question.txt', 'r')
que = fileque.read();
openai.api_key = "你的密钥"
response_data = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[{"role": "user", "content": que + ",这段汇编代码实现了什么样的功能"}]
)
content = response_data['choices'][0]['message']['content']
file = open('User\\answer.txt', 'w')
file.write(content)
file.close()
print("算法分析完成!\n所在位置为:当前目录User\\answer.txt")
else:
print("你还没有在question.txt中输入你需要分析的汇编代码")
# 创建窗口
root = tk.Tk()
root.geometry("500x250")
root.title("汇编算法分析工具 By Panel")
root.resizable(0, 0)
if os.path.exists("User"):
print('a')
else:
os.mkdir("User")
with open('User\\question.txt', 'w') as f:
f.write('汇编放这里')
f.close()
# 创建文本输入框1
entry1 = tk.Entry(root, width=90)
entry1.grid(row=0, column=0, padx=10, pady=10)
entry1.insert(0,"待分析的汇编代码为本目录下的User\\question.txt,里面放入你要分析汇编代码")
# 创建文本输入框2
entry2 = tk.Entry(root, width=90)
entry2.grid(row=1, column=0, padx=10, pady=10)
entry2.insert(0,"算法分析结果为本目录下的User\\answer.txt,里面存了算法分析结果")
# 创建按钮
button = tk.Button(root, text="开始分析", command=get_text)
button.place(relx=0.5, rely=0.5, anchor="center")
# 进入主循环
root.mainloop()