update settings
Browse filesSigned-off-by: Zhang Jun <[email protected]>
- .gitignore +10 -1
- app.py +12 -4
- requirements.txt +2 -1
.gitignore
CHANGED
|
@@ -3,4 +3,13 @@ __pycache__/
|
|
| 3 |
.env
|
| 4 |
.DS_Store
|
| 5 |
venv/
|
| 6 |
-
.ipynb_checkpoints/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
.env
|
| 4 |
.DS_Store
|
| 5 |
venv/
|
| 6 |
+
.ipynb_checkpoints/
|
| 7 |
+
|
| 8 |
+
# Environment variables
|
| 9 |
+
.env
|
| 10 |
+
.env.local
|
| 11 |
+
.env.development.local
|
| 12 |
+
.env.test.local
|
| 13 |
+
.env.production.local
|
| 14 |
+
|
| 15 |
+
generated_website*
|
app.py
CHANGED
|
@@ -1,14 +1,22 @@
|
|
| 1 |
import os
|
| 2 |
import cv2
|
| 3 |
import time
|
|
|
|
| 4 |
import base64
|
| 5 |
import re
|
| 6 |
import gradio as gr
|
| 7 |
from openai import OpenAI
|
| 8 |
from concurrent.futures import ThreadPoolExecutor, as_completed
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
# --- Configuration ---
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
| 12 |
MODEL_NAME = "ernie-4.5-turbo-vl"
|
| 13 |
MAX_CONCURRENT_REQUESTS = 4
|
| 14 |
MAX_VIDEO_DURATION_SEC = 1800
|
|
@@ -99,7 +107,7 @@ def main_process(video_file, progress=gr.Progress()):
|
|
| 99 |
# 1. 初始化状态
|
| 100 |
yield "⏳ Initializing...", None, None, None
|
| 101 |
|
| 102 |
-
api_key =
|
| 103 |
if not api_key: raise gr.Error("Server Config Error: API KEY missing.")
|
| 104 |
if not video_file: raise gr.Error("Please upload a video.")
|
| 105 |
|
|
@@ -112,7 +120,7 @@ def main_process(video_file, progress=gr.Progress()):
|
|
| 112 |
if duration > MAX_VIDEO_DURATION_SEC:
|
| 113 |
raise gr.Error(f"Video too long ({duration/60:.1f}m). Limit is 30m.")
|
| 114 |
|
| 115 |
-
client = OpenAI(api_key=api_key, base_url=
|
| 116 |
|
| 117 |
# 2. 抽帧阶段
|
| 118 |
yield "🎞️ Step 1/3: Extracting video frames...", None, None, None
|
|
@@ -144,7 +152,7 @@ def main_process(video_file, progress=gr.Progress()):
|
|
| 144 |
progress(0.85, desc="Synthesizing code...")
|
| 145 |
html_code = aggregate_and_generate_webpage(client, chunk_summaries)
|
| 146 |
|
| 147 |
-
output_path = "
|
| 148 |
with open(output_path, "w", encoding="utf-8") as f:
|
| 149 |
f.write(html_code)
|
| 150 |
|
|
|
|
| 1 |
import os
|
| 2 |
import cv2
|
| 3 |
import time
|
| 4 |
+
import uuid
|
| 5 |
import base64
|
| 6 |
import re
|
| 7 |
import gradio as gr
|
| 8 |
from openai import OpenAI
|
| 9 |
from concurrent.futures import ThreadPoolExecutor, as_completed
|
| 10 |
+
from dotenv import load_dotenv
|
| 11 |
+
|
| 12 |
+
# Load environment variables from .env file
|
| 13 |
+
load_dotenv()
|
| 14 |
|
| 15 |
# --- Configuration ---
|
| 16 |
+
QIANFAN_URL = os.getenv("QIANFAN_URL", "")
|
| 17 |
+
QIANFAN_TOKEN = os.getenv("QIANFAN_TOKEN", "")
|
| 18 |
+
|
| 19 |
+
|
| 20 |
MODEL_NAME = "ernie-4.5-turbo-vl"
|
| 21 |
MAX_CONCURRENT_REQUESTS = 4
|
| 22 |
MAX_VIDEO_DURATION_SEC = 1800
|
|
|
|
| 107 |
# 1. 初始化状态
|
| 108 |
yield "⏳ Initializing...", None, None, None
|
| 109 |
|
| 110 |
+
api_key = QIANFAN_TOKEN
|
| 111 |
if not api_key: raise gr.Error("Server Config Error: API KEY missing.")
|
| 112 |
if not video_file: raise gr.Error("Please upload a video.")
|
| 113 |
|
|
|
|
| 120 |
if duration > MAX_VIDEO_DURATION_SEC:
|
| 121 |
raise gr.Error(f"Video too long ({duration/60:.1f}m). Limit is 30m.")
|
| 122 |
|
| 123 |
+
client = OpenAI(api_key=api_key, base_url=QIANFAN_URL)
|
| 124 |
|
| 125 |
# 2. 抽帧阶段
|
| 126 |
yield "🎞️ Step 1/3: Extracting video frames...", None, None, None
|
|
|
|
| 152 |
progress(0.85, desc="Synthesizing code...")
|
| 153 |
html_code = aggregate_and_generate_webpage(client, chunk_summaries)
|
| 154 |
|
| 155 |
+
output_path = f"generated_website_{uuid.uuid4().hex}.html"
|
| 156 |
with open(output_path, "w", encoding="utf-8") as f:
|
| 157 |
f.write(html_code)
|
| 158 |
|
requirements.txt
CHANGED
|
@@ -1,3 +1,4 @@
|
|
| 1 |
opencv-python-headless
|
| 2 |
openai
|
| 3 |
-
numpy
|
|
|
|
|
|
| 1 |
opencv-python-headless
|
| 2 |
openai
|
| 3 |
+
numpy
|
| 4 |
+
python-dotenv
|