veadow commited on
Commit ·
b98f01d
1
Parent(s): c92ae50
force update: Question collecting app
Browse files- app.py +37 -6
- dist/assets/index-Csihf0YO.js +0 -0
- dist/assets/{index-Dc5g9i7z.css → index-Dsl7L5Tu.css} +1 -1
- dist/assets/index-hvRt1djY.js +0 -0
- dist/index.html +2 -2
- requirements.txt +1 -0
app.py
CHANGED
|
@@ -2,21 +2,49 @@ from flask import Flask, send_from_directory, request, jsonify
|
|
| 2 |
from flask_cors import CORS
|
| 3 |
import os
|
| 4 |
import requests
|
|
|
|
|
|
|
| 5 |
|
| 6 |
app = Flask(__name__)
|
| 7 |
CORS(app)
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
# DeepSeek API配置
|
| 10 |
API_KEY = os.environ.get('DEEPSEEK_API_KEY', '')
|
| 11 |
API_URL = 'https://api.deepseek.com/v1/chat/completions'
|
| 12 |
|
| 13 |
# 存储问题和分类
|
| 14 |
-
questions_store =
|
| 15 |
-
'categories': {},
|
| 16 |
-
'category_questions': {},
|
| 17 |
-
'category_summaries': {},
|
| 18 |
-
'question_details': {}
|
| 19 |
-
}
|
| 20 |
|
| 21 |
# 静态文件服务
|
| 22 |
@app.route('/')
|
|
@@ -137,6 +165,9 @@ def classify_question():
|
|
| 137 |
summary = summary_response.json()['choices'][0]['message']['content'].strip()
|
| 138 |
questions_store['category_summaries'][category] = summary
|
| 139 |
|
|
|
|
|
|
|
|
|
|
| 140 |
return jsonify({
|
| 141 |
'category': category,
|
| 142 |
'wordSummary': word_summary.strip(),
|
|
|
|
| 2 |
from flask_cors import CORS
|
| 3 |
import os
|
| 4 |
import requests
|
| 5 |
+
import json
|
| 6 |
+
from huggingface_hub import HfApi, HfFileSystem
|
| 7 |
|
| 8 |
app = Flask(__name__)
|
| 9 |
CORS(app)
|
| 10 |
|
| 11 |
+
# Hugging Face存储配置
|
| 12 |
+
HF_REPO = "Veadow/qqqqq-storage"
|
| 13 |
+
HF_FILE = "questions.json"
|
| 14 |
+
hf_api = HfApi()
|
| 15 |
+
hf_fs = HfFileSystem()
|
| 16 |
+
|
| 17 |
+
# 从Hugging Face加载数据
|
| 18 |
+
def load_from_hf():
|
| 19 |
+
try:
|
| 20 |
+
if hf_fs.exists(f"{HF_REPO}/{HF_FILE}"):
|
| 21 |
+
with hf_fs.open(f"{HF_REPO}/{HF_FILE}", "r") as f:
|
| 22 |
+
return json.load(f)
|
| 23 |
+
except Exception as e:
|
| 24 |
+
print(f"从Hugging Face加载数据失败: {e}")
|
| 25 |
+
return {
|
| 26 |
+
'categories': {},
|
| 27 |
+
'category_questions': {},
|
| 28 |
+
'category_summaries': {},
|
| 29 |
+
'question_details': {}
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
# 保存数据到Hugging Face
|
| 33 |
+
def save_to_hf(data):
|
| 34 |
+
try:
|
| 35 |
+
with hf_fs.open(f"{HF_REPO}/{HF_FILE}", "w") as f:
|
| 36 |
+
json.dump(data, f, ensure_ascii=False, indent=2)
|
| 37 |
+
return True
|
| 38 |
+
except Exception as e:
|
| 39 |
+
print(f"保存数据到Hugging Face失败: {e}")
|
| 40 |
+
return False
|
| 41 |
+
|
| 42 |
# DeepSeek API配置
|
| 43 |
API_KEY = os.environ.get('DEEPSEEK_API_KEY', '')
|
| 44 |
API_URL = 'https://api.deepseek.com/v1/chat/completions'
|
| 45 |
|
| 46 |
# 存储问题和分类
|
| 47 |
+
questions_store = load_from_hf()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
# 静态文件服务
|
| 50 |
@app.route('/')
|
|
|
|
| 165 |
summary = summary_response.json()['choices'][0]['message']['content'].strip()
|
| 166 |
questions_store['category_summaries'][category] = summary
|
| 167 |
|
| 168 |
+
# 保存数据到Hugging Face
|
| 169 |
+
save_to_hf(questions_store)
|
| 170 |
+
|
| 171 |
return jsonify({
|
| 172 |
'category': category,
|
| 173 |
'wordSummary': word_summary.strip(),
|
dist/assets/index-Csihf0YO.js
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
dist/assets/{index-Dc5g9i7z.css → index-Dsl7L5Tu.css}
RENAMED
|
@@ -1 +1 @@
|
|
| 1 |
-
#root{width:100vw;min-height:100vh;margin:0;padding:0;overflow:hidden}.home-container{position:relative;min-height:100vh;background:linear-gradient(135deg,#f5f7fa,#c3cfe2);padding:2rem;display:flex}.left-area{flex:1;position:relative;min-height:100vh}.form-toggle{position:fixed;top:15px;left:15px;background:#fffc;padding:.5rem 1rem;border-radius:5px;cursor:pointer;box-shadow:0 2px 8px #0000001a;z-index:20;transition:all .3s ease;font-size:.9rem;border:none;outline:none;min-width:100px;text-align:center}.form-toggle:hover{background:#fff;transform:translateY(-2px);box-shadow:0 3px 10px #00000026}.panel-toggle{position:fixed;top:50%;right:0;transform:translateY(-50%);background:#667eea;color:#fff;padding:1rem .3rem;border-radius:5px 0 0 5px;cursor:pointer;box-shadow:-1px 0 5px #0000001a;z-index:20;transition:all .5s ease;writing-mode:vertical-rl;text-orientation:mixed;white-space:nowrap;font-size:.8rem;width:20px;text-align:center;height:120px;display:flex;align-items:center;justify-content:center}.panel-toggle:hover{background:#5a6fe8;width:30px;box-shadow:-2px 0 8px #00000026;transform:translateY(-50%)}.right-panel:not(.hidden)+.panel-toggle{right:489px;border-radius:5px 0 0 5px;box-shadow:-1px 0 5px #0000001a}.question-form{position:absolute;left:1rem;top:3.5rem;z-index:10;background:#fff;padding:2rem;border-radius:10px;box-shadow:0 5px 15px #0000001a;max-width:600px;margin:0;transition:all .5s ease;transform-origin:top left}.question-form.hidden{max-width:400px;padding:1rem;transform:scale(.8);opacity:0;pointer-events:none}.question-form:not(.hidden){position:relative;max-width:600px;margin:4rem auto 2rem;transform:scale(1);opacity:1;pointer-events:auto}.question-form h2{margin-bottom:1rem;color:#333}.question-form textarea{width:100%;padding:1rem;border:1px solid #ddd;border-radius:5px;font-size:1rem;resize:vertical;min-height:100px;margin-bottom:1rem;box-sizing:border-box}.question-form button{background:#667eea;color:#fff;border:none;padding:.8rem 1.5rem;border-radius:5px;cursor:pointer;transition:background .3s}.question-form button:hover{background:#5a6fe8}.right-panel{position:fixed;top:0;right:0;width:30%;min-width:300px;height:100vh;background:#fff;box-shadow:-5px 0 15px #0000001a;padding:2rem;overflow-y:auto;z-index:15;transition:all .5s ease}.right-panel.hidden{transform:translate(100%);pointer-events:none}.right-panel h3{margin-bottom:1.5rem;color:#333;border-bottom:1px solid #eee;padding-bottom:.5rem}.category-details{margin-bottom:2rem;padding-bottom:2rem;border-bottom:1px solid #eee}.category-details:last-child{border-bottom:none;margin-bottom:0;padding-bottom:0}.category-details h4{color:#667eea;margin-bottom:1rem}.category-summary{background:#f5f7fa;padding:1rem;border-radius:5px;margin-bottom:1.5rem;font-size:.9rem;line-height:1.5}.category-questions{list-style:none;padding:0;margin-bottom:1.5rem}.category-questions li{padding:.8rem;border-bottom:1px solid #eee;text-align:left;font-size:.9rem}.category-questions li:last-child{border-bottom:none}.question-text{margin-bottom:.5rem;font-weight:500}.question-details{display:flex;flex-wrap:wrap;gap:.5rem;margin-top:.5rem}.word-summary{background:#667eea;color:#fff;padding:.2rem .5rem;border-radius:12px;font-size:.75rem;font-weight:500}.question-description{color:#666;font-size:.8rem;flex:1;min-width:200px}.clear-selection{background:#ff6b6b;color:#fff;border:none;padding:.6rem 1.2rem;border-radius:5px;cursor:pointer;transition:background .3s}.clear-selection:hover{background:#ee5a5a}.bubbles-container{position:absolute;top:0;left:0;width:70%;height:100%;overflow:hidden;pointer-events:none;z-index:1}.bubble{position:absolute;border-radius:50%;display:flex;align-items:center;justify-content:center;cursor:pointer;transition:all .3s ease;pointer-events:auto;box-shadow:0 4px 15px #0000001a;color:#fff;font-weight:500;text-align:center;padding:0 10px}.bubble:hover{transform:scale(1.1);z-index:100!important;box-shadow:0 6px 20px #00000026}.bubble-small{width:60px;height:60px;font-size:.8rem}.bubble-medium{width:100px;height:100px;font-size:1rem}.bubble-large{width:150px;height:150px;font-size:1.2rem}.bubble-fixed{position:absolute;right:32%;top:50px;z-index:20;opacity:0;transition:opacity .5s ease}.bubble-tooltip{position:fixed;background:#fff;padding:1rem;border-radius:5px;box-shadow:0 4px 15px #0000001a;z-index:1000;max-width:300px;transform:translateY(-100%);margin-top:-10px;pointer-events:none}.bubble-tooltip h4{margin:0 0 .5rem;color:#667eea;font-size:1rem}.bubble-tooltip p{margin:0;font-size:.9rem;line-height:1.4;color:#333}@media (max-width: 768px){.home-container{flex-direction:column}.form-toggle{position:relative;top:0;left:0;margin:1rem auto;display:inline-block}.question-form{position:relative;left:0;top:0;margin:1rem auto}.question-form.hidden{position:absolute;left:1rem;top:3.5rem}.panel-toggle{position:fixed;top:50%;right:0;transform:translateY(-50%)}.right-panel{position:fixed;width:80%;min-width:250px}.bubbles-container{width:100%;height:50vh}.bubble-fixed{right:10px;top:10px}}@media (max-width: 480px){.question-form{padding:1rem;max-width:90%}.question-form:not(.hidden){margin:2rem auto}.right-panel{width:90%}.bubble{font-size:.7rem}.bubble-small{width:50px;height:50px}.bubble-medium{width:80px;height:80px}.bubble-large{width:120px;height:120px}}:root{font-family:Inter,system-ui,Avenir,Helvetica,Arial,sans-serif;line-height:1.5;font-weight:400;color-scheme:light dark;color:#ffffffde;background-color:#242424;font-synthesis:none;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}a{font-weight:500;color:#646cff;text-decoration:inherit}a:hover{color:#535bf2}body{margin:0;display:flex;place-items:center;min-width:320px;min-height:100vh}#root{width:100vw;min-height:100vh;margin:0;padding:0;text-align:center;box-sizing:border-box}button{border-radius:8px;border:1px solid transparent;padding:.6em 1.2em;font-size:1em;font-weight:500;font-family:inherit;background-color:#1a1a1a;cursor:pointer;transition:border-color .25s}button:hover{border-color:#646cff}button:focus,button:focus-visible{outline:4px auto -webkit-focus-ring-color}@media (prefers-color-scheme: light){:root{color:#213547;background-color:#fff}a:hover{color:#747bff}button{background-color:#f9f9f9}}
|
|
|
|
| 1 |
+
#root{width:100vw;min-height:100vh;margin:0;padding:0;overflow:hidden}.home-container{position:relative;min-height:100vh;background:linear-gradient(135deg,#f5f7fa,#c3cfe2);padding:2rem;display:flex}.left-area{flex:1;position:relative;min-height:100vh}.form-toggle{position:fixed;top:15px;left:15px;background:#fffc;padding:.5rem 1rem;border-radius:5px;cursor:pointer;box-shadow:0 2px 8px #0000001a;z-index:20;transition:all .3s ease;font-size:.9rem;border:none;outline:none;min-width:100px;text-align:center}.form-toggle:hover{background:#fff;transform:translateY(-2px);box-shadow:0 3px 10px #00000026}.panel-toggle{position:fixed;top:50%;right:0;transform:translateY(-50%);background:#667eea;color:#fff;padding:1rem .3rem;border-radius:5px 0 0 5px;cursor:pointer;box-shadow:-1px 0 5px #0000001a;z-index:20;transition:all .5s ease;writing-mode:vertical-rl;text-orientation:mixed;white-space:nowrap;font-size:.8rem;width:20px;text-align:center;height:120px;display:flex;align-items:center;justify-content:center}.panel-toggle:hover{background:#5a6fe8;width:30px;box-shadow:-2px 0 8px #00000026;transform:translateY(-50%)}.right-panel:not(.hidden)+.panel-toggle{right:489px;border-radius:5px 0 0 5px;box-shadow:-1px 0 5px #0000001a}.question-form{position:absolute;left:1rem;top:3.5rem;z-index:10;background:#fff;padding:2rem;border-radius:10px;box-shadow:0 5px 15px #0000001a;max-width:600px;margin:0;transition:all .5s ease;transform-origin:top left}.question-form.hidden{max-width:400px;padding:1rem;transform:scale(.8);opacity:0;pointer-events:none}.question-form:not(.hidden){position:relative;max-width:600px;margin:4rem auto 2rem;transform:scale(1);opacity:1;pointer-events:auto}.question-form h2{margin-bottom:1rem;color:#333}.question-form textarea{width:100%;padding:1rem;border:1px solid #ddd;border-radius:5px;font-size:1rem;resize:vertical;min-height:100px;margin-bottom:1rem;box-sizing:border-box}.question-form button{background:#667eea;color:#fff;border:none;padding:.8rem 1.5rem;border-radius:5px;cursor:pointer;transition:background .3s}.question-form button:hover{background:#5a6fe8}.right-panel{position:fixed;top:0;right:0;width:30%;min-width:300px;height:100vh;background:#fff;box-shadow:-5px 0 15px #0000001a;padding:2rem;overflow-y:auto;z-index:15;transition:all .5s ease}.right-panel.hidden{transform:translate(100%);pointer-events:none;z-index:-1}.right-panel h3{margin-bottom:1.5rem;color:#333;border-bottom:1px solid #eee;padding-bottom:.5rem}.category-details{margin-bottom:2rem;padding-bottom:2rem;border-bottom:1px solid #eee}.category-details:last-child{border-bottom:none;margin-bottom:0;padding-bottom:0}.category-details h4{color:#667eea;margin-bottom:1rem}.category-summary{background:#f5f7fa;padding:1rem;border-radius:5px;margin-bottom:1.5rem;font-size:.9rem;line-height:1.5}.category-questions{list-style:none;padding:0;margin-bottom:1.5rem}.category-questions li{padding:.8rem;border-bottom:1px solid #eee;text-align:left;font-size:.9rem}.category-questions li:last-child{border-bottom:none}.question-text{margin-bottom:.5rem;font-weight:500}.question-details{display:flex;flex-wrap:wrap;gap:.5rem;margin-top:.5rem}.word-summary{background:#667eea;color:#fff;padding:.2rem .5rem;border-radius:12px;font-size:.75rem;font-weight:500}.question-description{color:#666;font-size:.8rem;flex:1;min-width:200px}.clear-selection{background:#ff6b6b;color:#fff;border:none;padding:.6rem 1.2rem;border-radius:5px;cursor:pointer;transition:background .3s}.clear-selection:hover{background:#ee5a5a}.bubbles-container{position:absolute;top:0;left:0;width:70%;height:100%;overflow:hidden;pointer-events:none;z-index:1}.bubble{position:absolute;border-radius:50%;display:flex;align-items:center;justify-content:center;cursor:pointer;transition:all .3s ease;pointer-events:auto;box-shadow:0 4px 15px #0000001a,inset 0 1px #fff3;color:#fff;font-weight:500;text-align:center;padding:0 10px;opacity:.85;-webkit-backdrop-filter:blur(5px);backdrop-filter:blur(5px)}.bubble:hover{transform:scale(1.1);z-index:100!important;box-shadow:0 6px 20px #00000026,inset 0 1px #ffffff4d;opacity:.95}@keyframes bubbleBounce{0%,to{transform:scale(1)}50%{transform:scale(1.1)}}.bubble-colliding{animation:bubbleBounce .3s ease-in-out}.bubble-small{width:60px;height:60px;font-size:.8rem}.bubble-medium{width:100px;height:100px;font-size:1rem}.bubble-large{width:150px;height:150px;font-size:1.2rem}.bubble-fixed{position:absolute;right:32%;top:50px;z-index:20;opacity:0;transition:opacity .5s ease}.bubble-tooltip{position:fixed;background:#fff;padding:1rem;border-radius:5px;box-shadow:0 4px 15px #0000001a;z-index:1000;max-width:300px;transform:translateY(-100%);margin-top:-10px;pointer-events:none}.bubble-tooltip h4{margin:0 0 .5rem;color:#667eea;font-size:1rem}.bubble-tooltip p{margin:0;font-size:.9rem;line-height:1.4;color:#333}@media (max-width: 768px){.home-container{flex-direction:column}.form-toggle{position:relative;top:0;left:0;margin:1rem auto;display:inline-block}.question-form{position:relative;left:0;top:0;margin:1rem auto}.question-form.hidden{position:absolute;left:1rem;top:3.5rem}.panel-toggle{position:fixed;top:50%;right:0;transform:translateY(-50%)}.right-panel{position:fixed;width:80%;min-width:250px}.bubbles-container{width:100%;height:50vh}.bubble-fixed{right:10px;top:10px}}@media (max-width: 480px){.question-form{padding:1rem;max-width:90%}.question-form:not(.hidden){margin:2rem auto}.right-panel{width:90%}.bubble{font-size:.7rem}.bubble-small{width:50px;height:50px}.bubble-medium{width:80px;height:80px}.bubble-large{width:120px;height:120px}}:root{font-family:Inter,system-ui,Avenir,Helvetica,Arial,sans-serif;line-height:1.5;font-weight:400;color-scheme:light dark;color:#ffffffde;background-color:#242424;font-synthesis:none;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}a{font-weight:500;color:#646cff;text-decoration:inherit}a:hover{color:#535bf2}body{margin:0;display:flex;place-items:center;min-width:320px;min-height:100vh}#root{width:100vw;min-height:100vh;margin:0;padding:0;text-align:center;box-sizing:border-box}button{border-radius:8px;border:1px solid transparent;padding:.6em 1.2em;font-size:1em;font-weight:500;font-family:inherit;background-color:#1a1a1a;cursor:pointer;transition:border-color .25s}button:hover{border-color:#646cff}button:focus,button:focus-visible{outline:4px auto -webkit-focus-ring-color}@media (prefers-color-scheme: light){:root{color:#213547;background-color:#fff}a:hover{color:#747bff}button{background-color:#f9f9f9}}
|
dist/assets/index-hvRt1djY.js
DELETED
|
The diff for this file is too large to render.
See raw diff
|
|
|
dist/index.html
CHANGED
|
@@ -5,8 +5,8 @@
|
|
| 5 |
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
| 6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 7 |
<title>提问收集网站</title>
|
| 8 |
-
<script type="module" crossorigin src="/assets/index-
|
| 9 |
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
| 10 |
</head>
|
| 11 |
<body>
|
| 12 |
<div id="root"></div>
|
|
|
|
| 5 |
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
| 6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 7 |
<title>提问收集网站</title>
|
| 8 |
+
<script type="module" crossorigin src="/assets/index-Csihf0YO.js"></script>
|
| 9 |
+
<link rel="stylesheet" crossorigin href="/assets/index-Dsl7L5Tu.css">
|
| 10 |
</head>
|
| 11 |
<body>
|
| 12 |
<div id="root"></div>
|
requirements.txt
CHANGED
|
@@ -1,3 +1,4 @@
|
|
| 1 |
Flask
|
| 2 |
Flask-Cors
|
| 3 |
requests
|
|
|
|
|
|
| 1 |
Flask
|
| 2 |
Flask-Cors
|
| 3 |
requests
|
| 4 |
+
huggingface_hub
|