Spaces:
Sleeping
Sleeping
def init_params(text, request: gr.Request):
Browse files
app.py
CHANGED
@@ -617,7 +617,26 @@ def generate_chinese_essay_idea(model, user_prompt, chinese_essay_title_input):
|
|
617 |
|
618 |
return content
|
619 |
|
620 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
621 |
CSS = """
|
622 |
.accordion-prompts {
|
623 |
background-color: orange;
|
@@ -1622,7 +1641,7 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue=gr.themes.colors.blue, secondary
|
|
1622 |
)
|
1623 |
|
1624 |
# =====中文作文工具=====
|
1625 |
-
with gr.Tab("中文作文工具"):
|
1626 |
# 輸入題目、輸出靈感
|
1627 |
with gr.Row():
|
1628 |
chinese_write_idea_prompt = """
|
@@ -1794,5 +1813,10 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue=gr.themes.colors.blue, secondary
|
|
1794 |
outputs=[chinese_full_paragraph_save_output, chinese_full_audio_output]
|
1795 |
)
|
1796 |
|
|
|
|
|
|
|
|
|
|
|
1797 |
|
1798 |
demo.launch()
|
|
|
617 |
|
618 |
return content
|
619 |
|
620 |
+
|
621 |
+
def init_params(text, request: gr.Request):
|
622 |
+
if request:
|
623 |
+
print("Request headers dictionary:", request.headers)
|
624 |
+
print("IP address:", request.client.host)
|
625 |
+
print("Query parameters:", dict(request.query_params))
|
626 |
+
# url = request.url
|
627 |
+
print("Request URL:", request.url)
|
628 |
+
|
629 |
+
chinese_idea_tab = gr.update(visible=True)
|
630 |
+
|
631 |
+
# check if origin is from junyiacademy
|
632 |
+
origin = request.headers.get("origin", "")
|
633 |
+
if "junyiacademy.org" in origin or "junyiacademy.appspot.com" in origin:
|
634 |
+
chinese_idea_tab = gr.update(visible=False)
|
635 |
+
|
636 |
+
|
637 |
+
return chinese_idea_tab
|
638 |
+
|
639 |
+
|
640 |
CSS = """
|
641 |
.accordion-prompts {
|
642 |
background-color: orange;
|
|
|
1641 |
)
|
1642 |
|
1643 |
# =====中文作文工具=====
|
1644 |
+
with gr.Tab("中文作文工具") as chinese_idea_tab:
|
1645 |
# 輸入題目、輸出靈感
|
1646 |
with gr.Row():
|
1647 |
chinese_write_idea_prompt = """
|
|
|
1813 |
outputs=[chinese_full_paragraph_save_output, chinese_full_audio_output]
|
1814 |
)
|
1815 |
|
1816 |
+
demo.load(
|
1817 |
+
init_params,
|
1818 |
+
inputs =[],
|
1819 |
+
outputs = [chinese_idea_tab]
|
1820 |
+
)
|
1821 |
|
1822 |
demo.launch()
|