SHEN1017 commited on
Commit
800f02e
·
verified ·
1 Parent(s): 99e1e55

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +7 -1
  2. index.html +22 -2
app.py CHANGED
@@ -9,11 +9,17 @@ from citekit.utils.utils import parse_html_config
9
  app = Flask(__name__)
10
  CORS(app) # 允许跨域请求
11
 
 
12
 
13
  @app.route("/")
14
  def index():
15
  return send_file("index.html")
16
 
 
 
 
 
 
17
 
18
  @app.route("/run_pipeline", methods=["POST"])
19
  def run_pipeline():
@@ -74,7 +80,7 @@ def get_config():
74
  def chat():
75
  data = request.json
76
  api_key = data.get("api_key")
77
- os.environ["OPENAI_API_KEY"] = api_key
78
  print("API Key Set.")
79
  user_message = data.get("message")
80
 
 
9
  app = Flask(__name__)
10
  CORS(app) # 允许跨域请求
11
 
12
+ original_pipeline = pipeline
13
 
14
  @app.route("/")
15
  def index():
16
  return send_file("index.html")
17
 
18
+ @app.route("/reset_pipeline", methods=["POST"])
19
+ def reset_pipeline():
20
+ global pipeline
21
+ pipeline = original_pipeline
22
+ return jsonify({"message": "Pipeline reset successfully"})
23
 
24
  @app.route("/run_pipeline", methods=["POST"])
25
  def run_pipeline():
 
80
  def chat():
81
  data = request.json
82
  api_key = data.get("api_key")
83
+ os.environ["OPENAI_API_KEY"]
84
  print("API Key Set.")
85
  user_message = data.get("message")
86
 
index.html CHANGED
@@ -693,6 +693,26 @@
693
  .style("color", "#333");
694
  }
695
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
696
  function createGraph(nodes, edges) {
697
  // 如果已有模拟实例则停止
698
  if (currentSimulation) currentSimulation.stop();
@@ -1250,9 +1270,9 @@
1250
 
1251
  }
1252
 
1253
-
1254
  createGraph(nodes, edges);
1255
- // repaint();
1256
 
1257
  function parseInput(input) {
1258
  try {
 
693
  .style("color", "#333");
694
  }
695
 
696
+ function reset() {
697
+ fetch("/reset_pipeline", {
698
+ method: "POST",
699
+ headers: {
700
+ "Content-Type": "application/json"
701
+ }
702
+ }).then(response => {
703
+ if (response.ok) {
704
+ return response.json();
705
+ } else {
706
+ throw new Error("Failed to reset pipeline");
707
+ }
708
+ }).then(data => {
709
+ console.log(data.message);
710
+ alert("Pipeline reset successfully");
711
+ }).catch(error => {
712
+ console.error("Error:", error);
713
+ alert("Error resetting pipeline");
714
+ });
715
+ }
716
  function createGraph(nodes, edges) {
717
  // 如果已有模拟实例则停止
718
  if (currentSimulation) currentSimulation.stop();
 
1270
 
1271
  }
1272
 
1273
+ reset();
1274
  createGraph(nodes, edges);
1275
+ repaint();
1276
 
1277
  function parseInput(input) {
1278
  try {