You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.7 KiB
54 lines
1.7 KiB
import asyncio
|
|
import os
|
|
from mycode.TaskManager import g_TaskM
|
|
from web import create_app
|
|
from hypercorn.asyncio import serve
|
|
from hypercorn.config import Config
|
|
|
|
async def run_quart_app():
|
|
app = create_app()
|
|
config = Config()
|
|
config.bind = ["0.0.0.0:5001"]
|
|
config.use_reloader = True # 启用热重载
|
|
config.reload_include_patterns = ["*.py", "templates/*", "static/*"] # 监控模板和静态文件
|
|
await serve(app, config)
|
|
|
|
|
|
def test(test_type):
|
|
from mycode.LLMManager import LLMManager
|
|
from myutils.PickleManager import g_PKM
|
|
LLM = LLMManager(1)
|
|
current_path = os.path.dirname(os.path.realpath(__file__))
|
|
print(current_path)
|
|
|
|
if test_type == 4:
|
|
attact_tree = g_PKM.ReadData("4")
|
|
# 创建一个新的节点
|
|
from mycode.AttackMap import TreeNode
|
|
testnode = TreeNode("test", 0)
|
|
LLM.build_initial_prompt(testnode) # 新的Message
|
|
systems = testnode.messages[0]["content"]
|
|
# print(systems)
|
|
# 遍历node,查看有instr的ndoe
|
|
nodes = attact_tree.traverse_bfs()
|
|
for node in nodes:
|
|
node.messages[0]["content"] = systems
|
|
g_PKM.WriteData(attact_tree, "4")
|
|
print("完成Messgae更新")
|
|
else:
|
|
pass
|
|
|
|
# Press the green button in the gutter to run the script.
|
|
if __name__ == '__main__':
|
|
test_type = 0
|
|
if test_type>0:
|
|
test(test_type)
|
|
else:
|
|
print(f"Current working directory (run.py): {os.getcwd()}")
|
|
#加载未完成的工作继续执行
|
|
g_TaskM.load_tasks()
|
|
#启动web项目--hypercorn
|
|
asyncio.run(run_quart_app())
|
|
#Uvicom启动
|
|
#uvicorn.run("run:app", host="0.0.0.0", port=5001, workers=4, reload=True)
|
|
|
|
|