Spaces:
Sleeping
Sleeping
lele
commited on
Commit
·
32dd6e8
1
Parent(s):
89ec0c4
new file: dist/assets/index-BMPVw0Me.js
Browse filesnew file: dist/assets/index-DCV377lj.css
new file: dist/index.html
new file: dist/vite.svg
modified: src/ai_infra.py
- .gitignore +2 -1
- app.py +19 -7
- dist/assets/index-BMPVw0Me.js +0 -0
- dist/assets/index-DCV377lj.css +1 -0
- dist/index.html +14 -0
- dist/vite.svg +1 -0
- src/ai_infra.py +12 -1
.gitignore
CHANGED
|
@@ -7,4 +7,5 @@ prompt_2.txt
|
|
| 7 |
.vscode
|
| 8 |
__pycache__
|
| 9 |
context_config.yaml
|
| 10 |
-
summary.md
|
|
|
|
|
|
| 7 |
.vscode
|
| 8 |
__pycache__
|
| 9 |
context_config.yaml
|
| 10 |
+
summary.md
|
| 11 |
+
notion_pusher
|
app.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
from flask import Flask, request, jsonify,
|
| 2 |
from src.ai_transform import classify_task_with_ai, modified_with_ai
|
| 3 |
from src.ai_infra import init_ai_config, get_ai_models
|
| 4 |
from src.utils import *
|
|
@@ -9,7 +9,10 @@ import json
|
|
| 9 |
if os.path.exists("secret.env"):
|
| 10 |
from dotenv import load_dotenv
|
| 11 |
load_dotenv("secret.env")
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
NOTION_TOKEN = os.environ.get("NOTION_TOKEN")
|
| 15 |
DB_ID = os.environ.get("DB_ID")
|
|
@@ -66,11 +69,19 @@ def init_items(items):
|
|
| 66 |
# items = ",".join(line.strip() for line in items.splitlines() if line.strip())
|
| 67 |
return items
|
| 68 |
|
| 69 |
-
@app.route("/", methods=["GET"])
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
def index():
|
| 71 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
-
@app.route("/get_ai_options", methods=["GET"])
|
| 74 |
def get_ai_options():
|
| 75 |
"""
|
| 76 |
返回可用的 AI 模型列表供前端下拉框使用。
|
|
@@ -81,7 +92,7 @@ def get_ai_options():
|
|
| 81 |
except Exception as e:
|
| 82 |
return jsonify({"ok": False, "error": f"Failed to load AI models: {str(e)}"}), 500
|
| 83 |
|
| 84 |
-
@app.route("/", methods=["POST"])
|
| 85 |
def push():
|
| 86 |
# items = request.get_json(force=True)
|
| 87 |
if request.content_type == 'text/plain':
|
|
@@ -131,6 +142,7 @@ def push():
|
|
| 131 |
# @app.route("/get", methods=["GET"])
|
| 132 |
def get_all_data():
|
| 133 |
"""
|
|
|
|
| 134 |
Retrieves all pages from a Notion database, handling pagination.
|
| 135 |
"""
|
| 136 |
url = f"https://api.notion.com/v1/databases/{DB_ID}/query"
|
|
@@ -161,7 +173,7 @@ def get_all_data():
|
|
| 161 |
|
| 162 |
return jsonify({"ok": True, "data": all_pages, "count": len(all_pages)})
|
| 163 |
|
| 164 |
-
@app.route("/get", methods=["GET"])
|
| 165 |
def get_data():
|
| 166 |
"""
|
| 167 |
通过 Notion API 的排序和页大小参数,获取最近创建的 5 条任务数据。
|
|
|
|
| 1 |
+
from flask import Flask, request, jsonify, send_from_directory
|
| 2 |
from src.ai_transform import classify_task_with_ai, modified_with_ai
|
| 3 |
from src.ai_infra import init_ai_config, get_ai_models
|
| 4 |
from src.utils import *
|
|
|
|
| 9 |
if os.path.exists("secret.env"):
|
| 10 |
from dotenv import load_dotenv
|
| 11 |
load_dotenv("secret.env")
|
| 12 |
+
import mimetypes
|
| 13 |
+
mimetypes.add_type('application/javascript', '.js', strict=True)
|
| 14 |
+
mimetypes.add_type('text/css', '.css', strict=True)
|
| 15 |
+
app = Flask(__name__, static_folder='./dist', static_url_path='')
|
| 16 |
|
| 17 |
NOTION_TOKEN = os.environ.get("NOTION_TOKEN")
|
| 18 |
DB_ID = os.environ.get("DB_ID")
|
|
|
|
| 69 |
# items = ",".join(line.strip() for line in items.splitlines() if line.strip())
|
| 70 |
return items
|
| 71 |
|
| 72 |
+
# @app.route("/", methods=["GET"])
|
| 73 |
+
# def index():
|
| 74 |
+
# return send_from_directory(app.static_folder, "index.html")
|
| 75 |
+
|
| 76 |
+
@app.route('/', methods=['GET'])
|
| 77 |
def index():
|
| 78 |
+
return send_from_directory("templates", "index.html")
|
| 79 |
+
|
| 80 |
+
# @app.route('/', methods=['GET'])
|
| 81 |
+
# def index():
|
| 82 |
+
# return app.send_static_file('index.html')
|
| 83 |
|
| 84 |
+
@app.route("/api/get_ai_options", methods=["GET"])
|
| 85 |
def get_ai_options():
|
| 86 |
"""
|
| 87 |
返回可用的 AI 模型列表供前端下拉框使用。
|
|
|
|
| 92 |
except Exception as e:
|
| 93 |
return jsonify({"ok": False, "error": f"Failed to load AI models: {str(e)}"}), 500
|
| 94 |
|
| 95 |
+
@app.route("/api/", methods=["POST"])
|
| 96 |
def push():
|
| 97 |
# items = request.get_json(force=True)
|
| 98 |
if request.content_type == 'text/plain':
|
|
|
|
| 142 |
# @app.route("/get", methods=["GET"])
|
| 143 |
def get_all_data():
|
| 144 |
"""
|
| 145 |
+
duplicate
|
| 146 |
Retrieves all pages from a Notion database, handling pagination.
|
| 147 |
"""
|
| 148 |
url = f"https://api.notion.com/v1/databases/{DB_ID}/query"
|
|
|
|
| 173 |
|
| 174 |
return jsonify({"ok": True, "data": all_pages, "count": len(all_pages)})
|
| 175 |
|
| 176 |
+
@app.route("/api/get", methods=["GET"])
|
| 177 |
def get_data():
|
| 178 |
"""
|
| 179 |
通过 Notion API 的排序和页大小参数,获取最近创建的 5 条任务数据。
|
dist/assets/index-BMPVw0Me.js
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
dist/assets/index-DCV377lj.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
:root{--color-bg-primary: #1a1a1a;--color-bg-secondary: #2c2c2c;--color-text-primary: #f0f0f0;--color-text-secondary: #ccc;--color-accent: #00bcd4;--color-accent-hover: #008ba3;--color-border-dark: #333;--color-border-light: #444}body{font-family:sans-serif;background-color:var(--color-bg-primary);color:var(--color-text-primary);margin:0;padding:0}h1{color:var(--color-accent)}.container{display:flex;gap:20px;width:100%;margin:0 auto}@media(max-width:768px){.container{flex-direction:column;gap:15px}}.Input[data-v-b5e1b1c1]{height:180px;width:100%}.form-controls[data-v-b5e1b1c1]{display:flex;align-items:center;margin-top:10px}button[data-v-b5e1b1c1]{padding:10px 15px;background-color:var(--color-accent);color:var(--color-bg-primary);border:none;border-radius:5px;cursor:pointer;transition:background-color .3s}.history-controls[data-v-a681b401]{display:flex;align-items:center;gap:10px}table[data-v-a681b401]{width:100%;border-collapse:collapse;margin-top:10px}th[data-v-a681b401],td[data-v-a681b401]{padding:8px;text-align:left;border-bottom:1px solid var(--color-border-light)}th[data-v-a681b401]{color:var(--color-accent)}.numberinput[data-v-a681b401]{width:20%;height:10%;line-height:38px;padding:0 10px;margin-left:10px}select[data-v-ecbf4ed7]{width:100%;padding:8px;border-radius:4px;border:1px solid var(--color-border-light, #444);background-color:var(--color-bg-secondary, #2c2c2c);color:var(--color-text-primary, #f0f0f0);-webkit-appearance:none;-moz-appearance:none;appearance:none}
|
dist/index.html
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!doctype html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-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>notion_pusher</title>
|
| 8 |
+
<script type="module" crossorigin src="/assets/index-BMPVw0Me.js"></script>
|
| 9 |
+
<link rel="stylesheet" crossorigin href="/assets/index-DCV377lj.css">
|
| 10 |
+
</head>
|
| 11 |
+
<body>
|
| 12 |
+
<div id="app"></div>
|
| 13 |
+
</body>
|
| 14 |
+
</html>
|
dist/vite.svg
ADDED
|
|
src/ai_infra.py
CHANGED
|
@@ -85,6 +85,17 @@ def init_ai_config(model: str = "default")-> dict[str, str]:
|
|
| 85 |
"model": "moonshotai/Kimi-K2-Instruct"
|
| 86 |
}
|
| 87 |
API_MODEL = "FREE"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
# extendable
|
| 89 |
else:
|
| 90 |
config = {
|
|
@@ -103,7 +114,7 @@ def get_ai_models() -> list:
|
|
| 103 |
defailt: gpt
|
| 104 |
"""
|
| 105 |
# 这些名称必须与 load_ai_config 中的 if/elif 分支匹配
|
| 106 |
-
return ["default", "gpt", "gemini", "deepseek", "kimi", "gpt-4o-mini", "stark"] # 假设这些是所有已定义的配置项 , "gpt-4o"
|
| 107 |
|
| 108 |
if __name__ == "__main__":
|
| 109 |
from dotenv import load_dotenv
|
|
|
|
| 85 |
"model": "moonshotai/Kimi-K2-Instruct"
|
| 86 |
}
|
| 87 |
API_MODEL = "FREE"
|
| 88 |
+
elif "qwen" in name:
|
| 89 |
+
config = {
|
| 90 |
+
"url": "https://miaodi.zeabur.app/v1",
|
| 91 |
+
"model": "qwen3-maxt"
|
| 92 |
+
}
|
| 93 |
+
API_MODEL = "FREE"
|
| 94 |
+
elif "glm" in name:
|
| 95 |
+
config = {
|
| 96 |
+
"url": "https://miaodi.zeabur.app/v1",
|
| 97 |
+
"model": "zai-org/GLM-4.5"
|
| 98 |
+
}
|
| 99 |
# extendable
|
| 100 |
else:
|
| 101 |
config = {
|
|
|
|
| 114 |
defailt: gpt
|
| 115 |
"""
|
| 116 |
# 这些名称必须与 load_ai_config 中的 if/elif 分支匹配
|
| 117 |
+
return ["default", "gpt", "gemini", "deepseek", "kimi", "gpt-4o-mini", "stark", "Qwen", "GLM"] # 假设这些是所有已定义的配置项 , "gpt-4o"
|
| 118 |
|
| 119 |
if __name__ == "__main__":
|
| 120 |
from dotenv import load_dotenv
|