guoj5 commited on
Commit
8e80adf
·
1 Parent(s): d721e91

Add application file

Browse files
Dockerfile ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 使用官方 Python 3.9
2
+ FROM python:3.9
3
+
4
+ # 创建一个非root用户 (Hugging Face官方示例里常见)
5
+ RUN useradd -m -u 1000 user
6
+ USER user
7
+
8
+ # 把 ~/.local/bin 加进 PATH,便于 pip 安装脚本等
9
+ ENV PATH="/home/user/.local/bin:$PATH"
10
+
11
+ # 切换到 /app 目录
12
+ WORKDIR /app
13
+
14
+ # 先复制 requirements.txt 并安装依赖
15
+ COPY requirements.txt .
16
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
17
+
18
+ # 再把当前所有代码复制到 /app
19
+ # (此时已含你编译好的前端文件,位于你的 backend/static/ 下)
20
+ COPY . /app
21
+
22
+ # 最终启动命令:监听 0.0.0.0:7860
23
+ CMD ["python", "app.py", "--host=0.0.0.0", "--port", "7860"]
backend/.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ .env
backend/Example.txt ADDED
@@ -0,0 +1,174 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ This is an example of representing a Zebra Puzzle using a Z3-based Python code:
2
+
3
+ There are 5 Producers in this puzzle.
4
+
5
+ Categories and possible items:
6
+ - Shirt: black, green, orange, pink, red
7
+ - Name: Barbara, Isabella, Jane, Nicole, Rachel
8
+ - Jam: apricot, cherry, fig, raspberry, watermelon
9
+ - Size: 10 oz, 12 oz, 14 oz, 20 oz, 6 oz
10
+ - Source: backyard, farmers' coop, local grocer, organic farm, wild pickings
11
+
12
+ Clues:
13
+ - The producer whose jam comes from Wild pickings is in the fourth position.
14
+ - The producer selling Cherry jam is somewhere to the right of the one wearing a Green shirt.
15
+ - Isabella is selling Cherry jam.
16
+ - The producer wearing a Pink shirt is somewhere between the producer whose jam source is the Backyard and the one selling Watermelon jam, in that order.
17
+ - The producer selling 14 oz jars is somewhere to the right of the one wearing a Green shirt.
18
+ - The producer with 14 oz jars is next to the one selling Raspberry jam.
19
+ - The Raspberry jam producer is positioned at one of the ends.
20
+ - Barbara is next to the producer whose jam source is the Organic farm.
21
+ - Jane is located somewhere between Nicole and Isabella, in that order.
22
+ - The producer of Fig jam sources the fruit from an Organic farm.
23
+ - The producer with 10 oz jars is at one of the ends.
24
+ - The Raspberry jam producer is somewhere to the right of the one wearing a Green shirt.
25
+ - The producer with 12 oz jars is next to the one who has 6 oz jars.
26
+ - Isabella is next to the producer wearing a Black shirt.
27
+ - The producer with 6 oz jars is next to the one whose source is the Local grocer.
28
+ - The producer with 6 oz jars is in the second position.
29
+ - Rachel's source of fruit is the Farmers' coop.
30
+ - Barbara is next to Nicole.
31
+ - The producer wearing an Orange shirt gets her fruit from the Backyard.
32
+ - The producer with 12 oz jars is in the very first position.
33
+
34
+ ```python
35
+ from z3 import *
36
+ import json
37
+ import sys
38
+
39
+ # Define all categories in a single list of tuples:
40
+ # (House is implicit; each row's first column will be the house number.)
41
+ categories = [
42
+ ("Shirt", ["black", "green", "orange", "pink", "red"]),
43
+ ("Name", ["Barbara", "Isabella", "Jane", "Nicole", "Rachel"]),
44
+ ("Jam", ["apricot", "cherry", "fig", "raspberry", "watermelon"]),
45
+ ("Size", ["10 oz", "12 oz", "14 oz", "20 oz", "6 oz"]),
46
+ ("Source", ["backyard", "farmers' coop", "local grocer", "organic farm", "wild pickings"])
47
+ ]
48
+
49
+ # No need to change here, automatically processing
50
+ NUM_POSITIONS = len(categories[0][1])
51
+
52
+ item_to_cat_and_index = {}
53
+ for cat_idx, (_, item_list) in enumerate(categories):
54
+ for item_idx, item_str in enumerate(item_list):
55
+ item_to_cat_and_index[item_str] = (cat_idx, item_idx)
56
+
57
+ Vars = []
58
+ for cat_idx, (cat_name, item_list) in enumerate(categories):
59
+ var = IntVector(cat_name, len(item_list))
60
+ Vars.append(var)
61
+
62
+ s = Solver()
63
+
64
+ for cat_idx, (cat_name, item_list) in enumerate(categories):
65
+ for item_idx, item_str in enumerate(item_list):
66
+ s.add(Vars[cat_idx][item_idx] >= 1, Vars[cat_idx][item_idx] <= NUM_POSITIONS)
67
+ s.add(Distinct(Vars[cat_idx]))
68
+
69
+ def pos(item_str):
70
+ (cat_idx, item_idx) = item_to_cat_and_index[item_str]
71
+ return Vars[cat_idx][item_idx]
72
+
73
+ # All clues here
74
+ # The producer whose jam comes from Wild pickings is in the fourth position.
75
+ s.add(pos("wild pickings") == 4)
76
+
77
+ # The producer selling Cherry jam is somewhere to the right of the one wearing a Green shirt.
78
+ s.add(pos("cherry") > pos("green"))
79
+
80
+ # Isabella is selling Cherry jam.
81
+ s.add(pos("Isabella") == pos("cherry"))
82
+
83
+ # The producer wearing a Pink shirt is somewhere between the producer whose jam source is the Backyard and the one selling Watermelon jam, in that order.
84
+ s.add(And(pos("backyard") < pos("pink"), pos("pink") < pos("watermelon")))
85
+
86
+ # The producer selling 14 oz jars is somewhere to the right of the one wearing a Green shirt.
87
+ s.add(pos("14 oz") > pos("green"))
88
+
89
+ # The producer with 14 oz jars is next to the one selling Raspberry jam.
90
+ s.add(Abs(pos("14 oz") - pos("raspberry")) == 1)
91
+
92
+ # The Raspberry jam producer is positioned at one of the ends.
93
+ s.add(Or(pos("raspberry") == 1, pos("raspberry") == NUM_POSITIONS))
94
+
95
+ # Barbara is next to the producer whose jam source is the Organic farm.
96
+ s.add(Abs(pos("Barbara") - pos("organic farm")) == 1)
97
+
98
+ # Jane is located somewhere between Nicole and Isabella, in that order.
99
+ s.add(And(pos("Nicole") < pos("Jane"), pos("Jane") < pos("Isabella")))
100
+
101
+ # The producer of Fig jam sources the fruit from an Organic farm.
102
+ s.add(pos("fig") == pos("organic farm"))
103
+
104
+ # The producer with 10 oz jars is at one of the ends.
105
+ s.add(Or(pos("10 oz") == 1, pos("10 oz") == NUM_POSITIONS))
106
+
107
+ # The Raspberry jam producer is somewhere to the right of the one wearing a Green shirt.
108
+ s.add(pos("raspberry") > pos("green"))
109
+
110
+ # The producer with 12 oz jars is next to the one who has 6 oz jars.
111
+ s.add(Abs(pos("12 oz") - pos("6 oz")) == 1)
112
+
113
+ # Isabella is next to the producer wearing a Black shirt.
114
+ s.add(Abs(pos("Isabella") - pos("black")) == 1)
115
+
116
+ # The producer with 6 oz jars is next to the one whose source is the Local grocer.
117
+ s.add(Abs(pos("6 oz") - pos("local grocer")) == 1)
118
+
119
+ # The producer with 6 oz jars is in the second position.
120
+ s.add(pos("6 oz") == 2)
121
+
122
+ # Rachel's source of fruit is the Farmers' coop.
123
+ s.add(pos("Rachel") == pos("farmers' coop"))
124
+
125
+ # Barbara is next to Nicole.
126
+ s.add(Abs(pos("Barbara") - pos("Nicole")) == 1)
127
+
128
+ # The producer wearing an Orange shirt gets her fruit from the Backyard.
129
+ s.add(pos("orange") == pos("backyard"))
130
+
131
+ # The producer with 12 oz jars is in the very first position.
132
+ s.add(pos("12 oz") == 1)
133
+
134
+ # Solve the puzzle
135
+ if s.check() == sat:
136
+ m = s.model()
137
+ rows = []
138
+ header = ["House"] + [cat_name for cat_name, _ in categories]
139
+ for position in range(1, NUM_POSITIONS + 1):
140
+ row = [str(position)]
141
+ for cat_idx, (cat_name, item_list) in enumerate(categories):
142
+ for item_idx, item_str in enumerate(item_list):
143
+ if m.evaluate(Vars[cat_idx][item_idx]).as_long() == position:
144
+ row.append(item_str)
145
+ break
146
+ rows.append(row)
147
+ result_dict = {"header": header, "rows": rows}
148
+
149
+ cnt = 1
150
+ block = []
151
+ for cat_idx, (cat_name, item_list) in enumerate(categories):
152
+ for i in range(NUM_POSITIONS):
153
+ block.append(Vars[cat_idx][i] != m[Vars[cat_idx][i]])
154
+ s.add(Or(block))
155
+ while s.check() == sat:
156
+ m = s.model()
157
+ cnt += 1
158
+ block = []
159
+ for cat_idx, (cat_name, item_list) in enumerate(categories):
160
+ for i in range(NUM_POSITIONS):
161
+ block.append(Vars[cat_idx][i] != m[Vars[cat_idx][i]])
162
+ s.add(Or(block))
163
+
164
+ if cnt == 1:
165
+ # Output the solution as a JSON string.
166
+ print(json.dumps(result_dict))
167
+ else:
168
+ print(json.dumps({"error": "Multiple solutions found."}))
169
+ else:
170
+ print(json.dumps({"error": "No solution found."}))
171
+ sys.stdout.flush() # Force immediate output
172
+ ```
173
+
174
+ Based on this example, write a similar Z3-based Python code by changing only categories and constraints to represent the puzzle given below.
backend/app.py ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # app.py
2
+ from flask import Flask, request, jsonify, send_from_directory
3
+ from flask_cors import CORS
4
+ import os
5
+
6
+ from puzzle_dataset import get_puzzle_by_index
7
+ from solver import solve_puzzle
8
+
9
+ app = Flask(__name__)
10
+ CORS(app) # 如果前后端分开端口,可能需要 CORS
11
+
12
+ # 读取 Example.txt 作为默认 sys_content(若用户没给就用默认)
13
+ BASE_DIR = os.path.dirname(os.path.abspath(__file__))
14
+ example_path = os.path.join(BASE_DIR, "Example.txt")
15
+ with open(example_path, "r", encoding="utf-8") as f:
16
+ DEFAULT_SYS_CONTENT = f.read()
17
+
18
+ app = Flask(__name__, static_folder='static', static_url_path='')
19
+
20
+ @app.route('/')
21
+ def index():
22
+ # 返回静态文件夹下编译好的 index.html
23
+ return send_from_directory(app.static_folder, 'index.html')
24
+
25
+ @app.route("/get_puzzle", methods=["GET"])
26
+ def get_puzzle():
27
+ """
28
+ 前端通过 query param ?index=xxx 获取 puzzle 内容和 expected_solution
29
+ """
30
+ idx_str = request.args.get("index", "0")
31
+ try:
32
+ idx = int(idx_str)
33
+ except ValueError:
34
+ return jsonify({"success": False, "error": "Index must be an integer"}), 400
35
+
36
+ puzzle, solution = get_puzzle_by_index(idx)
37
+ if puzzle is None or solution is None:
38
+ return jsonify({"success": False, "error": "Invalid puzzle index"}), 404
39
+
40
+ return jsonify({
41
+ "success": True,
42
+ "index": idx,
43
+ "puzzle": puzzle,
44
+ "expected_solution": solution
45
+ })
46
+
47
+
48
+ @app.route("/solve", methods=["POST"])
49
+ def solve():
50
+ """
51
+ 前端 POST { index, puzzle, expected_solution, sysContent }
52
+ 调用 solve_puzzle,并返回比对结果和执行的 python code
53
+ """
54
+ data = request.get_json()
55
+ puzzle_index = data.get("index")
56
+ puzzle_text = data.get("puzzle")
57
+ expected_solution = data.get("expected_solution")
58
+ sys_content = data.get("sys_content", DEFAULT_SYS_CONTENT)
59
+
60
+ if puzzle_index is None or puzzle_text is None or expected_solution is None:
61
+ return jsonify({"success": False, "error": "Missing puzzle data"}), 400
62
+
63
+ result = solve_puzzle(puzzle_index, puzzle_text, expected_solution, sys_content)
64
+ # result 里包含: success, solution, attempts, generatedCode, modelResponse, etc.
65
+
66
+ return jsonify({
67
+ "success": True,
68
+ "result": result
69
+ })
70
+
71
+
72
+ @app.route("/default_sys_content", methods=["GET"])
73
+ def get_default_sys_content():
74
+ """
75
+ 返回默认的 sys_content (Example.txt) 给前端展示或编辑
76
+ """
77
+ return jsonify({
78
+ "success": True,
79
+ "sysContent": DEFAULT_SYS_CONTENT
80
+ })
81
+
82
+
83
+ if __name__ == "__main__":
84
+ app.run(host="0.0.0.0", port=7860, debug=False)
backend/deep_convert.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+
3
+ def deep_convert(obj):
4
+ if isinstance(obj, np.ndarray):
5
+ return [deep_convert(x) for x in obj]
6
+ elif isinstance(obj, dict):
7
+ return {k: deep_convert(v) for k, v in obj.items()}
8
+ elif isinstance(obj, list):
9
+ return [deep_convert(x) for x in obj]
10
+ else:
11
+ return obj
backend/puzzle_dataset.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # puzzle_dataset.py
2
+ import pandas as pd
3
+ import os
4
+ from dotenv import load_dotenv
5
+ from huggingface_hub import login
6
+ from deep_convert import deep_convert
7
+
8
+ df = None
9
+
10
+ def init_dataset():
11
+ global df
12
+ if df is not None:
13
+ return
14
+
15
+ load_dotenv()
16
+ hf_token = os.getenv("HF_TOKEN")
17
+ login(token=hf_token)
18
+
19
+ # 加载 parquet 数据
20
+ df = pd.read_parquet("hf://datasets/WildEval/ZebraLogic/grid_mode/test-00000-of-00001.parquet")
21
+
22
+ def get_puzzle_by_index(idx: int):
23
+ """
24
+ 返回 (puzzle_text, expected_solution) 二元组
25
+ """
26
+ global df
27
+ if df is None:
28
+ init_dataset()
29
+
30
+ # 简单判断 index 是否越界
31
+ if idx < 0 or idx >= len(df):
32
+ return None, None
33
+
34
+ row = df.iloc[idx]
35
+ return row['puzzle'], deep_convert(row['solution'])
backend/solver.py ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # solver.py
2
+ import sys
3
+ import re
4
+ import json
5
+ import os
6
+ import subprocess
7
+ from deep_convert import deep_convert
8
+ from openai import OpenAI
9
+ from dotenv import load_dotenv
10
+
11
+ def solve_puzzle(index, puzzle, expected_solution, sys_content):
12
+ """
13
+ 使用 sys_content + puzzle 调用模型,生成 Z3 Python 代码,
14
+ 运行并比对输出是否与 expected_solution 相同。
15
+ """
16
+ load_dotenv()
17
+ client = OpenAI(
18
+ api_key=os.getenv("GEMINI_API_KEY"),
19
+ base_url="https://generativelanguage.googleapis.com/v1beta/openai/"
20
+ )
21
+
22
+ messages = [
23
+ {"role": "user", "content": sys_content}, # 先把 sys_content 放进去
24
+ {"role": "user", "content": puzzle}, # 再放 puzzle
25
+ ]
26
+ attempts = 0
27
+ current_solution = None
28
+
29
+ while attempts < 3:
30
+ attempts += 1
31
+ response = client.chat.completions.create(
32
+ model="gemini-2.0-flash",
33
+ messages=messages,
34
+ temperature=0.0,
35
+ stream=False
36
+ )
37
+ content = response.choices[0].message.content
38
+ messages.append(response.choices[0].message)
39
+
40
+ # 提取 code
41
+ code_blocks = re.findall(r"```(?:python)?(.*?)```", content, re.DOTALL)
42
+ if not code_blocks:
43
+ messages.append({"role": "user", "content": "Please write a complete Python code in your response. Try again."})
44
+ continue
45
+
46
+ code_to_run = code_blocks[0].strip()
47
+ result = subprocess.run(
48
+ [sys.executable, "-c", code_to_run],
49
+ stdout=subprocess.PIPE,
50
+ stderr=subprocess.PIPE,
51
+ text=True
52
+ )
53
+ output = result.stdout.strip()
54
+ # print(output)
55
+
56
+ try:
57
+ current_solution = json.loads(output)
58
+ except json.JSONDecodeError:
59
+ messages.append({"role": "user", "content": "Your output is not valid JSON. Please ensure your code prints the solution as a JSON dictionary."})
60
+ continue
61
+
62
+ if 'rows' in current_solution.keys() and current_solution['rows'] == deep_convert(expected_solution)['rows']:
63
+ return {
64
+ "index": index,
65
+ "success": True,
66
+ "solution": current_solution,
67
+ "attempts": attempts,
68
+ "generatedCode": code_to_run,
69
+ "modelResponse": content
70
+ }
71
+ else:
72
+ messages.append({"role": "user", "content": "The solution does not match the expected answer. Please check your categories and constraints and provide the complete code again."})
73
+
74
+ return {
75
+ "index": index,
76
+ "success": False,
77
+ "solution": current_solution,
78
+ "attempts": attempts,
79
+ "generatedCode": code_to_run,
80
+ "modelResponse": content
81
+ }
backend/static/asset-manifest.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "files": {
3
+ "main.css": "/static/css/main.e6c13ad2.css",
4
+ "main.js": "/static/js/main.ee989f30.js",
5
+ "static/js/453.8ab44547.chunk.js": "/static/js/453.8ab44547.chunk.js",
6
+ "index.html": "/index.html",
7
+ "main.e6c13ad2.css.map": "/static/css/main.e6c13ad2.css.map",
8
+ "main.ee989f30.js.map": "/static/js/main.ee989f30.js.map",
9
+ "453.8ab44547.chunk.js.map": "/static/js/453.8ab44547.chunk.js.map"
10
+ },
11
+ "entrypoints": [
12
+ "static/css/main.e6c13ad2.css",
13
+ "static/js/main.ee989f30.js"
14
+ ]
15
+ }
backend/static/favicon.ico ADDED
backend/static/index.html ADDED
@@ -0,0 +1 @@
 
 
1
+ <!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>React App</title><script defer="defer" src="/static/js/main.ee989f30.js"></script><link href="/static/css/main.e6c13ad2.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
backend/static/logo192.png ADDED
backend/static/logo512.png ADDED
backend/static/manifest.json ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "short_name": "React App",
3
+ "name": "Create React App Sample",
4
+ "icons": [
5
+ {
6
+ "src": "favicon.ico",
7
+ "sizes": "64x64 32x32 24x24 16x16",
8
+ "type": "image/x-icon"
9
+ },
10
+ {
11
+ "src": "logo192.png",
12
+ "type": "image/png",
13
+ "sizes": "192x192"
14
+ },
15
+ {
16
+ "src": "logo512.png",
17
+ "type": "image/png",
18
+ "sizes": "512x512"
19
+ }
20
+ ],
21
+ "start_url": ".",
22
+ "display": "standalone",
23
+ "theme_color": "#000000",
24
+ "background_color": "#ffffff"
25
+ }
backend/static/robots.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ # https://www.robotstxt.org/robotstxt.html
2
+ User-agent: *
3
+ Disallow:
backend/static/static/css/main.e6c13ad2.css ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ body{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;margin:0}code{font-family:source-code-pro,Menlo,Monaco,Consolas,Courier New,monospace}
2
+ /*# sourceMappingURL=main.e6c13ad2.css.map*/
backend/static/static/css/main.e6c13ad2.css.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"static/css/main.e6c13ad2.css","mappings":"AAAA,KAKE,kCAAmC,CACnC,iCAAkC,CAJlC,mIAEY,CAHZ,QAMF,CAEA,KACE,uEAEF","sources":["index.css"],"sourcesContent":["body {\n margin: 0;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',\n 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',\n sans-serif;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n\ncode {\n font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',\n monospace;\n}\n"],"names":[],"sourceRoot":""}
backend/static/static/js/453.8ab44547.chunk.js ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ "use strict";(self.webpackChunkfrontend=self.webpackChunkfrontend||[]).push([[453],{453:(e,t,n)=>{n.r(t),n.d(t,{getCLS:()=>y,getFCP:()=>g,getFID:()=>C,getLCP:()=>P,getTTFB:()=>D});var i,r,a,o,u=function(e,t){return{name:e,value:void 0===t?-1:t,delta:0,entries:[],id:"v2-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12)}},c=function(e,t){try{if(PerformanceObserver.supportedEntryTypes.includes(e)){if("first-input"===e&&!("PerformanceEventTiming"in self))return;var n=new PerformanceObserver((function(e){return e.getEntries().map(t)}));return n.observe({type:e,buffered:!0}),n}}catch(e){}},f=function(e,t){var n=function n(i){"pagehide"!==i.type&&"hidden"!==document.visibilityState||(e(i),t&&(removeEventListener("visibilitychange",n,!0),removeEventListener("pagehide",n,!0)))};addEventListener("visibilitychange",n,!0),addEventListener("pagehide",n,!0)},s=function(e){addEventListener("pageshow",(function(t){t.persisted&&e(t)}),!0)},m=function(e,t,n){var i;return function(r){t.value>=0&&(r||n)&&(t.delta=t.value-(i||0),(t.delta||void 0===i)&&(i=t.value,e(t)))}},v=-1,d=function(){return"hidden"===document.visibilityState?0:1/0},p=function(){f((function(e){var t=e.timeStamp;v=t}),!0)},l=function(){return v<0&&(v=d(),p(),s((function(){setTimeout((function(){v=d(),p()}),0)}))),{get firstHiddenTime(){return v}}},g=function(e,t){var n,i=l(),r=u("FCP"),a=function(e){"first-contentful-paint"===e.name&&(f&&f.disconnect(),e.startTime<i.firstHiddenTime&&(r.value=e.startTime,r.entries.push(e),n(!0)))},o=window.performance&&performance.getEntriesByName&&performance.getEntriesByName("first-contentful-paint")[0],f=o?null:c("paint",a);(o||f)&&(n=m(e,r,t),o&&a(o),s((function(i){r=u("FCP"),n=m(e,r,t),requestAnimationFrame((function(){requestAnimationFrame((function(){r.value=performance.now()-i.timeStamp,n(!0)}))}))})))},h=!1,T=-1,y=function(e,t){h||(g((function(e){T=e.value})),h=!0);var n,i=function(t){T>-1&&e(t)},r=u("CLS",0),a=0,o=[],v=function(e){if(!e.hadRecentInput){var t=o[0],i=o[o.length-1];a&&e.startTime-i.startTime<1e3&&e.startTime-t.startTime<5e3?(a+=e.value,o.push(e)):(a=e.value,o=[e]),a>r.value&&(r.value=a,r.entries=o,n())}},d=c("layout-shift",v);d&&(n=m(i,r,t),f((function(){d.takeRecords().map(v),n(!0)})),s((function(){a=0,T=-1,r=u("CLS",0),n=m(i,r,t)})))},E={passive:!0,capture:!0},w=new Date,L=function(e,t){i||(i=t,r=e,a=new Date,F(removeEventListener),S())},S=function(){if(r>=0&&r<a-w){var e={entryType:"first-input",name:i.type,target:i.target,cancelable:i.cancelable,startTime:i.timeStamp,processingStart:i.timeStamp+r};o.forEach((function(t){t(e)})),o=[]}},b=function(e){if(e.cancelable){var t=(e.timeStamp>1e12?new Date:performance.now())-e.timeStamp;"pointerdown"==e.type?function(e,t){var n=function(){L(e,t),r()},i=function(){r()},r=function(){removeEventListener("pointerup",n,E),removeEventListener("pointercancel",i,E)};addEventListener("pointerup",n,E),addEventListener("pointercancel",i,E)}(t,e):L(t,e)}},F=function(e){["mousedown","keydown","touchstart","pointerdown"].forEach((function(t){return e(t,b,E)}))},C=function(e,t){var n,a=l(),v=u("FID"),d=function(e){e.startTime<a.firstHiddenTime&&(v.value=e.processingStart-e.startTime,v.entries.push(e),n(!0))},p=c("first-input",d);n=m(e,v,t),p&&f((function(){p.takeRecords().map(d),p.disconnect()}),!0),p&&s((function(){var a;v=u("FID"),n=m(e,v,t),o=[],r=-1,i=null,F(addEventListener),a=d,o.push(a),S()}))},k={},P=function(e,t){var n,i=l(),r=u("LCP"),a=function(e){var t=e.startTime;t<i.firstHiddenTime&&(r.value=t,r.entries.push(e),n())},o=c("largest-contentful-paint",a);if(o){n=m(e,r,t);var v=function(){k[r.id]||(o.takeRecords().map(a),o.disconnect(),k[r.id]=!0,n(!0))};["keydown","click"].forEach((function(e){addEventListener(e,v,{once:!0,capture:!0})})),f(v,!0),s((function(i){r=u("LCP"),n=m(e,r,t),requestAnimationFrame((function(){requestAnimationFrame((function(){r.value=performance.now()-i.timeStamp,k[r.id]=!0,n(!0)}))}))}))}},D=function(e){var t,n=u("TTFB");t=function(){try{var t=performance.getEntriesByType("navigation")[0]||function(){var e=performance.timing,t={entryType:"navigation",startTime:0};for(var n in e)"navigationStart"!==n&&"toJSON"!==n&&(t[n]=Math.max(e[n]-e.navigationStart,0));return t}();if(n.value=n.delta=t.responseStart,n.value<0||n.value>performance.now())return;n.entries=[t],e(n)}catch(e){}},"complete"===document.readyState?setTimeout(t,0):addEventListener("load",(function(){return setTimeout(t,0)}))}}}]);
2
+ //# sourceMappingURL=453.8ab44547.chunk.js.map
backend/static/static/js/453.8ab44547.chunk.js.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"static/js/453.8ab44547.chunk.js","mappings":"oLAAA,IAAIA,EAAEC,EAAEC,EAAEC,EAAEC,EAAE,SAASJ,EAAEC,GAAG,MAAM,CAACI,KAAKL,EAAEM,WAAM,IAASL,GAAG,EAAEA,EAAEM,MAAM,EAAEC,QAAQ,GAAGC,GAAG,MAAMC,OAAOC,KAAKC,MAAM,KAAKF,OAAOG,KAAKC,MAAM,cAAcD,KAAKE,UAAU,MAAM,EAAEC,EAAE,SAAShB,EAAEC,GAAG,IAAI,GAAGgB,oBAAoBC,oBAAoBC,SAASnB,GAAG,CAAC,GAAG,gBAAgBA,KAAK,2BAA2BoB,MAAM,OAAO,IAAIlB,EAAE,IAAIe,qBAAqB,SAASjB,GAAG,OAAOA,EAAEqB,aAAaC,IAAIrB,EAAE,IAAI,OAAOC,EAAEqB,QAAQ,CAACC,KAAKxB,EAAEyB,UAAS,IAAKvB,CAAC,CAAC,CAAC,MAAMF,GAAG,CAAC,EAAE0B,EAAE,SAAS1B,EAAEC,GAAG,IAAIC,EAAE,SAASA,EAAEC,GAAG,aAAaA,EAAEqB,MAAM,WAAWG,SAASC,kBAAkB5B,EAAEG,GAAGF,IAAI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ASxE,GAAG,IAAIC,EAAEC,EAAEE,EAAE,QAAQH,EAAE,WAAW,IAAI,IAAIA,EAAE6C,YAAY2B,iBAAiB,cAAc,IAAI,WAAW,IAAIzE,EAAE8C,YAAY4B,OAAOzE,EAAE,CAAC6D,UAAU,aAAanB,UAAU,GAAG,IAAI,IAAIzC,KAAKF,EAAE,oBAAoBE,GAAG,WAAWA,IAAID,EAAEC,GAAGW,KAAK8D,IAAI3E,EAAEE,GAAGF,EAAE4E,gBAAgB,IAAI,OAAO3E,CAAC,CAAjL,GAAqL,GAAGC,EAAEI,MAAMJ,EAAEK,MAAMN,EAAE4E,cAAc3E,EAAEI,MAAM,GAAGJ,EAAEI,MAAMwC,YAAYlC,MAAM,OAAOV,EAAEM,QAAQ,CAACP,GAAGD,EAAEE,EAAE,CAAC,MAAMF,GAAG,CAAC,EAAE,aAAa2B,SAASmD,WAAWvC,WAAWtC,EAAE,GAAG6B,iBAAiB,QAAQ,WAAW,OAAOS,WAAWtC,EAAE,EAAE,GAAG,C","sources":["../node_modules/web-vitals/dist/web-vitals.js"],"sourcesContent":["var e,t,n,i,r=function(e,t){return{name:e,value:void 0===t?-1:t,delta:0,entries:[],id:\"v2-\".concat(Date.now(),\"-\").concat(Math.floor(8999999999999*Math.random())+1e12)}},a=function(e,t){try{if(PerformanceObserver.supportedEntryTypes.includes(e)){if(\"first-input\"===e&&!(\"PerformanceEventTiming\"in self))return;var n=new PerformanceObserver((function(e){return e.getEntries().map(t)}));return n.observe({type:e,buffered:!0}),n}}catch(e){}},o=function(e,t){var n=function n(i){\"pagehide\"!==i.type&&\"hidden\"!==document.visibilityState||(e(i),t&&(removeEventListener(\"visibilitychange\",n,!0),removeEventListener(\"pagehide\",n,!0)))};addEventListener(\"visibilitychange\",n,!0),addEventListener(\"pagehide\",n,!0)},u=function(e){addEventListener(\"pageshow\",(function(t){t.persisted&&e(t)}),!0)},c=function(e,t,n){var i;return function(r){t.value>=0&&(r||n)&&(t.delta=t.value-(i||0),(t.delta||void 0===i)&&(i=t.value,e(t)))}},f=-1,s=function(){return\"hidden\"===document.visibilityState?0:1/0},m=function(){o((function(e){var t=e.timeStamp;f=t}),!0)},v=function(){return f<0&&(f=s(),m(),u((function(){setTimeout((function(){f=s(),m()}),0)}))),{get firstHiddenTime(){return f}}},d=function(e,t){var n,i=v(),o=r(\"FCP\"),f=function(e){\"first-contentful-paint\"===e.name&&(m&&m.disconnect(),e.startTime<i.firstHiddenTime&&(o.value=e.startTime,o.entries.push(e),n(!0)))},s=window.performance&&performance.getEntriesByName&&performance.getEntriesByName(\"first-contentful-paint\")[0],m=s?null:a(\"paint\",f);(s||m)&&(n=c(e,o,t),s&&f(s),u((function(i){o=r(\"FCP\"),n=c(e,o,t),requestAnimationFrame((function(){requestAnimationFrame((function(){o.value=performance.now()-i.timeStamp,n(!0)}))}))})))},p=!1,l=-1,h=function(e,t){p||(d((function(e){l=e.value})),p=!0);var n,i=function(t){l>-1&&e(t)},f=r(\"CLS\",0),s=0,m=[],v=function(e){if(!e.hadRecentInput){var t=m[0],i=m[m.length-1];s&&e.startTime-i.startTime<1e3&&e.startTime-t.startTime<5e3?(s+=e.value,m.push(e)):(s=e.value,m=[e]),s>f.value&&(f.value=s,f.entries=m,n())}},h=a(\"layout-shift\",v);h&&(n=c(i,f,t),o((function(){h.takeRecords().map(v),n(!0)})),u((function(){s=0,l=-1,f=r(\"CLS\",0),n=c(i,f,t)})))},T={passive:!0,capture:!0},y=new Date,g=function(i,r){e||(e=r,t=i,n=new Date,w(removeEventListener),E())},E=function(){if(t>=0&&t<n-y){var r={entryType:\"first-input\",name:e.type,target:e.target,cancelable:e.cancelable,startTime:e.timeStamp,processingStart:e.timeStamp+t};i.forEach((function(e){e(r)})),i=[]}},S=function(e){if(e.cancelable){var t=(e.timeStamp>1e12?new Date:performance.now())-e.timeStamp;\"pointerdown\"==e.type?function(e,t){var n=function(){g(e,t),r()},i=function(){r()},r=function(){removeEventListener(\"pointerup\",n,T),removeEventListener(\"pointercancel\",i,T)};addEventListener(\"pointerup\",n,T),addEventListener(\"pointercancel\",i,T)}(t,e):g(t,e)}},w=function(e){[\"mousedown\",\"keydown\",\"touchstart\",\"pointerdown\"].forEach((function(t){return e(t,S,T)}))},L=function(n,f){var s,m=v(),d=r(\"FID\"),p=function(e){e.startTime<m.firstHiddenTime&&(d.value=e.processingStart-e.startTime,d.entries.push(e),s(!0))},l=a(\"first-input\",p);s=c(n,d,f),l&&o((function(){l.takeRecords().map(p),l.disconnect()}),!0),l&&u((function(){var a;d=r(\"FID\"),s=c(n,d,f),i=[],t=-1,e=null,w(addEventListener),a=p,i.push(a),E()}))},b={},F=function(e,t){var n,i=v(),f=r(\"LCP\"),s=function(e){var t=e.startTime;t<i.firstHiddenTime&&(f.value=t,f.entries.push(e),n())},m=a(\"largest-contentful-paint\",s);if(m){n=c(e,f,t);var d=function(){b[f.id]||(m.takeRecords().map(s),m.disconnect(),b[f.id]=!0,n(!0))};[\"keydown\",\"click\"].forEach((function(e){addEventListener(e,d,{once:!0,capture:!0})})),o(d,!0),u((function(i){f=r(\"LCP\"),n=c(e,f,t),requestAnimationFrame((function(){requestAnimationFrame((function(){f.value=performance.now()-i.timeStamp,b[f.id]=!0,n(!0)}))}))}))}},P=function(e){var t,n=r(\"TTFB\");t=function(){try{var t=performance.getEntriesByType(\"navigation\")[0]||function(){var e=performance.timing,t={entryType:\"navigation\",startTime:0};for(var n in e)\"navigationStart\"!==n&&\"toJSON\"!==n&&(t[n]=Math.max(e[n]-e.navigationStart,0));return t}();if(n.value=n.delta=t.responseStart,n.value<0||n.value>performance.now())return;n.entries=[t],e(n)}catch(e){}},\"complete\"===document.readyState?setTimeout(t,0):addEventListener(\"load\",(function(){return setTimeout(t,0)}))};export{h as getCLS,d as getFCP,L as getFID,F as getLCP,P as getTTFB};\n"],"names":["e","t","n","i","r","name","value","delta","entries","id","concat","Date","now","Math","floor","random","a","PerformanceObserver","supportedEntryTypes","includes","self","getEntries","map","observe","type","buffered","o","document","visibilityState","removeEventListener","addEventListener","u","persisted","c","f","s","m","timeStamp","v","setTimeout","firstHiddenTime","d","disconnect","startTime","push","window","performance","getEntriesByName","requestAnimationFrame","p","l","h","hadRecentInput","length","takeRecords","T","passive","capture","y","g","w","E","entryType","target","cancelable","processingStart","forEach","S","L","b","F","once","P","getEntriesByType","timing","max","navigationStart","responseStart","readyState"],"sourceRoot":""}
backend/static/static/js/main.ee989f30.js ADDED
The diff for this file is too large to render. See raw diff
 
backend/static/static/js/main.ee989f30.js.LICENSE.txt ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @license React
3
+ * react-dom-client.production.js
4
+ *
5
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+
11
+ /**
12
+ * @license React
13
+ * react-dom.production.js
14
+ *
15
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
16
+ *
17
+ * This source code is licensed under the MIT license found in the
18
+ * LICENSE file in the root directory of this source tree.
19
+ */
20
+
21
+ /**
22
+ * @license React
23
+ * react-jsx-runtime.production.js
24
+ *
25
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
26
+ *
27
+ * This source code is licensed under the MIT license found in the
28
+ * LICENSE file in the root directory of this source tree.
29
+ */
30
+
31
+ /**
32
+ * @license React
33
+ * react.production.js
34
+ *
35
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
36
+ *
37
+ * This source code is licensed under the MIT license found in the
38
+ * LICENSE file in the root directory of this source tree.
39
+ */
40
+
41
+ /**
42
+ * @license React
43
+ * scheduler.production.js
44
+ *
45
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
46
+ *
47
+ * This source code is licensed under the MIT license found in the
48
+ * LICENSE file in the root directory of this source tree.
49
+ */
backend/static/static/js/main.ee989f30.js.map ADDED
The diff for this file is too large to render. See raw diff
 
frontend/.gitignore ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2
+
3
+ # dependencies
4
+ /node_modules
5
+ /.pnp
6
+ .pnp.js
7
+
8
+ # testing
9
+ /coverage
10
+
11
+ # production
12
+ /build
13
+
14
+ # misc
15
+ .DS_Store
16
+ .env.local
17
+ .env.development.local
18
+ .env.test.local
19
+ .env.production.local
20
+
21
+ npm-debug.log*
22
+ yarn-debug.log*
23
+ yarn-error.log*
frontend/README.md ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Getting Started with Create React App
2
+
3
+ This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4
+
5
+ ## Available Scripts
6
+
7
+ In the project directory, you can run:
8
+
9
+ ### `npm start`
10
+
11
+ Runs the app in the development mode.\
12
+ Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
13
+
14
+ The page will reload when you make changes.\
15
+ You may also see any lint errors in the console.
16
+
17
+ ### `npm test`
18
+
19
+ Launches the test runner in the interactive watch mode.\
20
+ See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21
+
22
+ ### `npm run build`
23
+
24
+ Builds the app for production to the `build` folder.\
25
+ It correctly bundles React in production mode and optimizes the build for the best performance.
26
+
27
+ The build is minified and the filenames include the hashes.\
28
+ Your app is ready to be deployed!
29
+
30
+ See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
31
+
32
+ ### `npm run eject`
33
+
34
+ **Note: this is a one-way operation. Once you `eject`, you can't go back!**
35
+
36
+ If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
37
+
38
+ Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
39
+
40
+ You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
41
+
42
+ ## Learn More
43
+
44
+ You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
45
+
46
+ To learn React, check out the [React documentation](https://reactjs.org/).
47
+
48
+ ### Code Splitting
49
+
50
+ This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
51
+
52
+ ### Analyzing the Bundle Size
53
+
54
+ This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
55
+
56
+ ### Making a Progressive Web App
57
+
58
+ This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
59
+
60
+ ### Advanced Configuration
61
+
62
+ This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
63
+
64
+ ### Deployment
65
+
66
+ This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
67
+
68
+ ### `npm run build` fails to minify
69
+
70
+ This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
frontend/package-lock.json ADDED
The diff for this file is too large to render. See raw diff
 
frontend/package.json ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "frontend",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "dependencies": {
6
+ "@testing-library/dom": "^10.4.0",
7
+ "@testing-library/jest-dom": "^6.6.3",
8
+ "@testing-library/react": "^16.2.0",
9
+ "@testing-library/user-event": "^13.5.0",
10
+ "react": "^19.0.0",
11
+ "react-dom": "^19.0.0",
12
+ "react-scripts": "5.0.1",
13
+ "web-vitals": "^2.1.4"
14
+ },
15
+ "scripts": {
16
+ "start": "react-scripts start",
17
+ "build": "react-scripts build",
18
+ "test": "react-scripts test",
19
+ "eject": "react-scripts eject"
20
+ },
21
+ "eslintConfig": {
22
+ "extends": [
23
+ "react-app",
24
+ "react-app/jest"
25
+ ]
26
+ },
27
+ "browserslist": {
28
+ "production": [
29
+ ">0.2%",
30
+ "not dead",
31
+ "not op_mini all"
32
+ ],
33
+ "development": [
34
+ "last 1 chrome version",
35
+ "last 1 firefox version",
36
+ "last 1 safari version"
37
+ ]
38
+ }
39
+ }
frontend/public/favicon.ico ADDED
frontend/public/index.html ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
7
+ <meta name="theme-color" content="#000000" />
8
+ <meta
9
+ name="description"
10
+ content="Web site created using create-react-app"
11
+ />
12
+ <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
13
+ <!--
14
+ manifest.json provides metadata used when your web app is installed on a
15
+ user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
16
+ -->
17
+ <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
18
+ <!--
19
+ Notice the use of %PUBLIC_URL% in the tags above.
20
+ It will be replaced with the URL of the `public` folder during the build.
21
+ Only files inside the `public` folder can be referenced from the HTML.
22
+
23
+ Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
24
+ work correctly both with client-side routing and a non-root public URL.
25
+ Learn how to configure a non-root public URL by running `npm run build`.
26
+ -->
27
+ <title>React App</title>
28
+ </head>
29
+ <body>
30
+ <noscript>You need to enable JavaScript to run this app.</noscript>
31
+ <div id="root"></div>
32
+ <!--
33
+ This HTML file is a template.
34
+ If you open it directly in the browser, you will see an empty page.
35
+
36
+ You can add webfonts, meta tags, or analytics to this file.
37
+ The build step will place the bundled scripts into the <body> tag.
38
+
39
+ To begin the development, run `npm start` or `yarn start`.
40
+ To create a production bundle, use `npm run build` or `yarn build`.
41
+ -->
42
+ </body>
43
+ </html>
frontend/public/logo192.png ADDED
frontend/public/logo512.png ADDED
frontend/public/manifest.json ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "short_name": "React App",
3
+ "name": "Create React App Sample",
4
+ "icons": [
5
+ {
6
+ "src": "favicon.ico",
7
+ "sizes": "64x64 32x32 24x24 16x16",
8
+ "type": "image/x-icon"
9
+ },
10
+ {
11
+ "src": "logo192.png",
12
+ "type": "image/png",
13
+ "sizes": "192x192"
14
+ },
15
+ {
16
+ "src": "logo512.png",
17
+ "type": "image/png",
18
+ "sizes": "512x512"
19
+ }
20
+ ],
21
+ "start_url": ".",
22
+ "display": "standalone",
23
+ "theme_color": "#000000",
24
+ "background_color": "#ffffff"
25
+ }
frontend/public/robots.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ # https://www.robotstxt.org/robotstxt.html
2
+ User-agent: *
3
+ Disallow:
frontend/src/App.css ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .App {
2
+ text-align: center;
3
+ }
4
+
5
+ .App-logo {
6
+ height: 40vmin;
7
+ pointer-events: none;
8
+ }
9
+
10
+ @media (prefers-reduced-motion: no-preference) {
11
+ .App-logo {
12
+ animation: App-logo-spin infinite 20s linear;
13
+ }
14
+ }
15
+
16
+ .App-header {
17
+ background-color: #282c34;
18
+ min-height: 100vh;
19
+ display: flex;
20
+ flex-direction: column;
21
+ align-items: center;
22
+ justify-content: center;
23
+ font-size: calc(10px + 2vmin);
24
+ color: white;
25
+ }
26
+
27
+ .App-link {
28
+ color: #61dafb;
29
+ }
30
+
31
+ @keyframes App-logo-spin {
32
+ from {
33
+ transform: rotate(0deg);
34
+ }
35
+ to {
36
+ transform: rotate(360deg);
37
+ }
38
+ }
frontend/src/App.js ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // frontend/src/App.js
2
+ import React, { useState, useEffect } from 'react';
3
+
4
+ function App() {
5
+ // 用于存储 puzzle index 及其 puzzle 数据
6
+ const [puzzleIndex, setPuzzleIndex] = useState(0);
7
+ const [puzzleText, setPuzzleText] = useState("");
8
+ const [expectedSolution, setExpectedSolution] = useState(null);
9
+
10
+ // sysContent 如果用户不改,就用默认 Example.txt
11
+ const [sysContent, setSysContent] = useState("");
12
+
13
+ // 交互结果
14
+ const [modelResponse, setModelResponse] = useState("");
15
+ const [generatedCode, setGeneratedCode] = useState("");
16
+ const [executionSuccess, setExecutionSuccess] = useState(null);
17
+ const [attempts, setAttempts] = useState(0);
18
+
19
+ // 前端先获取默认 sysContent
20
+ useEffect(() => {
21
+ fetch("http://localhost:5000/default_sys_content")
22
+ .then(res => res.json())
23
+ .then(data => {
24
+ if(data.success) {
25
+ setSysContent(data.sysContent);
26
+ }
27
+ })
28
+ .catch(e => console.error(e));
29
+ }, []);
30
+
31
+ // 当 puzzleIndex 改变时,自动获取对应 puzzle
32
+ useEffect(() => {
33
+ fetch(`http://localhost:5000/get_puzzle?index=${puzzleIndex}`)
34
+ .then(res => res.json())
35
+ .then(data => {
36
+ if(data.success) {
37
+ setPuzzleText(data.puzzle);
38
+ setExpectedSolution(data.expected_solution);
39
+ } else {
40
+ console.error("获取 puzzle 失败", data.error);
41
+ setPuzzleText("");
42
+ setExpectedSolution(null);
43
+ }
44
+ })
45
+ .catch(e => console.error(e));
46
+ }, [puzzleIndex]);
47
+
48
+ const handleSolve = () => {
49
+ if(!puzzleText || !expectedSolution) {
50
+ alert("puzzle 或 expectedSolution 不完整");
51
+ return;
52
+ }
53
+ const payload = {
54
+ index: puzzleIndex,
55
+ puzzle: puzzleText,
56
+ expected_solution: expectedSolution,
57
+ sys_content: sysContent
58
+ };
59
+
60
+ fetch("http://localhost:5000/solve", {
61
+ method: "POST",
62
+ headers: { "Content-Type": "application/json" },
63
+ body: JSON.stringify(payload)
64
+ })
65
+ .then(res => res.json())
66
+ .then(data => {
67
+ if(!data.success) {
68
+ alert("后端处理错误: " + data.error);
69
+ return;
70
+ }
71
+ const result = data.result;
72
+ setModelResponse(result.modelResponse || "");
73
+ setGeneratedCode(result.generatedCode || "");
74
+ setExecutionSuccess(result.success);
75
+ setAttempts(result.attempts || 0);
76
+ })
77
+ .catch(e => console.error(e));
78
+ };
79
+
80
+ return (
81
+ <div style={{ margin: 20 }}>
82
+ <h1>Zebra Puzzle Demo</h1>
83
+
84
+ <div style={{ marginBottom: 20 }}>
85
+ <label>选择 puzzle index (0 - 999): </label>
86
+ <input
87
+ type="number"
88
+ value={puzzleIndex}
89
+ onChange={(e) => setPuzzleIndex(Number(e.target.value))}
90
+ min={0}
91
+ max={999}
92
+ />
93
+ <button onClick={() => setPuzzleIndex(puzzleIndex)}>Load Puzzle</button>
94
+ </div>
95
+
96
+ <div style={{ marginBottom: 20 }}>
97
+ <h3>Puzzle Text</h3>
98
+ <pre>{puzzleText}</pre>
99
+ <h3>Expected Solution</h3>
100
+ <pre>{JSON.stringify(expectedSolution, null, 2)}</pre>
101
+ </div>
102
+
103
+ <div style={{ marginBottom: 20 }}>
104
+ <h3>sys_content (可编辑)</h3>
105
+ <textarea
106
+ rows={10}
107
+ cols={80}
108
+ value={sysContent}
109
+ onChange={(e) => setSysContent(e.target.value)}
110
+ />
111
+ </div>
112
+
113
+ <div style={{ marginBottom: 20 }}>
114
+ <button onClick={handleSolve}>Solve Puzzle with LLM</button>
115
+ </div>
116
+
117
+ <div>
118
+ <h2>Result</h2>
119
+ <p>Success: {executionSuccess === null ? "N/A" : executionSuccess ? "✅" : "❌"}</p>
120
+ <p>Attempts: {attempts}</p>
121
+ <h3>Generated Code</h3>
122
+ <pre>{generatedCode}</pre>
123
+ <h3>Model Response</h3>
124
+ <pre>{modelResponse}</pre>
125
+ </div>
126
+ </div>
127
+ );
128
+ }
129
+
130
+ export default App;
frontend/src/App.test.js ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ import { render, screen } from '@testing-library/react';
2
+ import App from './App';
3
+
4
+ test('renders learn react link', () => {
5
+ render(<App />);
6
+ const linkElement = screen.getByText(/learn react/i);
7
+ expect(linkElement).toBeInTheDocument();
8
+ });
frontend/src/index.css ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ body {
2
+ margin: 0;
3
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4
+ 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5
+ sans-serif;
6
+ -webkit-font-smoothing: antialiased;
7
+ -moz-osx-font-smoothing: grayscale;
8
+ }
9
+
10
+ code {
11
+ font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12
+ monospace;
13
+ }
frontend/src/index.js ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from 'react';
2
+ import ReactDOM from 'react-dom/client';
3
+ import './index.css';
4
+ import App from './App';
5
+ import reportWebVitals from './reportWebVitals';
6
+
7
+ const root = ReactDOM.createRoot(document.getElementById('root'));
8
+ root.render(
9
+ <React.StrictMode>
10
+ <App />
11
+ </React.StrictMode>
12
+ );
13
+
14
+ // If you want to start measuring performance in your app, pass a function
15
+ // to log results (for example: reportWebVitals(console.log))
16
+ // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
17
+ reportWebVitals();
frontend/src/logo.svg ADDED
frontend/src/reportWebVitals.js ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const reportWebVitals = onPerfEntry => {
2
+ if (onPerfEntry && onPerfEntry instanceof Function) {
3
+ import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
4
+ getCLS(onPerfEntry);
5
+ getFID(onPerfEntry);
6
+ getFCP(onPerfEntry);
7
+ getLCP(onPerfEntry);
8
+ getTTFB(onPerfEntry);
9
+ });
10
+ }
11
+ };
12
+
13
+ export default reportWebVitals;
frontend/src/setupTests.js ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ // jest-dom adds custom jest matchers for asserting on DOM nodes.
2
+ // allows you to do things like:
3
+ // expect(element).toHaveTextContent(/react/i)
4
+ // learn more: https://github.com/testing-library/jest-dom
5
+ import '@testing-library/jest-dom';
requirements.txt ADDED
Binary file (1.67 kB). View file