jianghuyihei commited on
Commit
f985a01
1 Parent(s): d22849a
Files changed (1) hide show
  1. app.py +12 -10
app.py CHANGED
@@ -298,7 +298,7 @@ html_template = """
298
  <button onclick="fillTopic('Using LLM-based agent to generate idea')">Using LLM-based agent to generate idea</button>
299
  </div>
300
  </div>
301
- <div id="loading" class="loading">{{ loading_text }}</div>
302
  {% if error %}
303
  <div class="error">
304
  <div class="box">
@@ -307,17 +307,18 @@ html_template = """
307
  </div>
308
  </div>
309
  {% endif %}
310
- hideLoading();
311
  </div>
312
- <script>
313
  async function getUserId() {
314
- // 清除 sessionStorage 中的 user_id
315
- sessionStorage.removeItem("user_id");
316
- // 请求新的 user_id
317
- const response = await fetch("/user_id");
318
- const data = await response.json();
319
- const userId = data.user_id;
320
- sessionStorage.setItem("user_id", userId);
 
 
321
  console.log("User ID:", userId);
322
  }
323
  window.onload = getUserId;
@@ -381,6 +382,7 @@ async def get_user_id():
381
  user_id = str(uuid.uuid4())
382
  return {"user_id": user_id}
383
 
 
384
  @app.get("/", response_class=HTMLResponse)
385
  def form_get():
386
  return Template(html_template).render(idea= "This is a example of the idea geneartion", error=None, reply_count=reply_count,button_text="Generate",loading_text="Generating content, Usually takes 2-3 minutes, please wait...")
 
298
  <button onclick="fillTopic('Using LLM-based agent to generate idea')">Using LLM-based agent to generate idea</button>
299
  </div>
300
  </div>
301
+ <div id="loading" class="loading" display="none">{{ loading_text }}</div>
302
  {% if error %}
303
  <div class="error">
304
  <div class="box">
 
307
  </div>
308
  </div>
309
  {% endif %}
 
310
  </div>
311
+ <script>
312
  async function getUserId() {
313
+ // 检查 sessionStorage 中是否有 user_id
314
+ let userId = sessionStorage.getItem("user_id");
315
+ if (!userId) {
316
+ // 请求新的 user_id
317
+ const response = await fetch("/user_id");
318
+ const data = await response.json();
319
+ userId = data.user_id;
320
+ sessionStorage.setItem("user_id", userId);
321
+ }
322
  console.log("User ID:", userId);
323
  }
324
  window.onload = getUserId;
 
382
  user_id = str(uuid.uuid4())
383
  return {"user_id": user_id}
384
 
385
+
386
  @app.get("/", response_class=HTMLResponse)
387
  def form_get():
388
  return Template(html_template).render(idea= "This is a example of the idea geneartion", error=None, reply_count=reply_count,button_text="Generate",loading_text="Generating content, Usually takes 2-3 minutes, please wait...")