Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -25,15 +25,7 @@ init_history = [
|
|
25 |
4. 反轉结局:這是一個比較特別的结局,它通常在故事的最後出現,並且會對讀者產生一種意外的冲击和影響。
|
26 |
5. 寓言故事:這是一種用故事來說明一個道理或概念的故事,通常包含一個寓意或象徵性的元素。
|
27 |
|
28 |
-
這些故事公式只是故事創作中的一部分,不同的故事可能会有不同的結構和情節,但這些公式可以作為一個起點,幫助你開始創作出一個引人入勝的故事。''')
|
29 |
-
myChatMessage(role="user", content='''請為『發生在香港的現代版本《聖誕頌歌》電影,背景從西方的聖誕節換成中式的團年飯。
|
30 |
-
|
31 |
-
原版《聖誕頌歌》講述了一位名叫厄尼斯特·斯克魯奇(Ebenezer Scrooge)的富有商人的故事。
|
32 |
-
斯克魯奇是一個極度吝嗇和自私的人,在三個幽靈的拜訪下,斯克魯奇被帶回他的童年和青少年時期,看到了他曾經擁有的喜悅和幸福,也看到了他的貪婪和自私對他人造成的傷害。
|
33 |
-
他還看到了自己的墳墓,意識到他的小氣將使他成為一個被遺忘和不受人愛戴的人。
|
34 |
-
這些經歷改變了斯克魯奇的心態。最終,斯克魯奇成為一個讓人尊敬和受人愛戴的人,並體會到了聖誕節的真正意義。
|
35 |
-
|
36 |
-
』提議五個適合的公式。'''),
|
37 |
]
|
38 |
|
39 |
os.system("wget https://huggingface.co/npc0/chatglm3-6b-int4/resolve/main/chatglm3-ggml-q4_0.bin")
|
@@ -68,7 +60,7 @@ def predict(input, max_length, top_p, temperature, history):
|
|
68 |
elif input.isdigit():
|
69 |
input = '現在你作為一個專業的編劇,你需要為故事%s轉寫一段故事大綱提供一個完整的龍骨給之後的編劇用。' %input
|
70 |
else:
|
71 |
-
input = '請為『%s
|
72 |
response = ""
|
73 |
history.append(myChatMessage(role="user", content=input))
|
74 |
|
@@ -93,8 +85,8 @@ def predict(input, max_length, top_p, temperature, history):
|
|
93 |
|
94 |
yield postprocess(response), history
|
95 |
|
96 |
-
history.append(
|
97 |
-
yield
|
98 |
|
99 |
|
100 |
def reset_user_input():
|
@@ -103,11 +95,11 @@ def reset_user_input():
|
|
103 |
|
104 |
def reset_state():
|
105 |
history = gr.State(init_history)
|
106 |
-
return '', '', [], gr.Dropdown(value=None, interactive=False)
|
107 |
|
108 |
|
109 |
def allow_user_input():
|
110 |
-
return gr.Dropdown(interactive=True)
|
111 |
|
112 |
|
113 |
with gr.Blocks() as demo:
|
|
|
25 |
4. 反轉结局:這是一個比較特別的结局,它通常在故事的最後出現,並且會對讀者產生一種意外的冲击和影響。
|
26 |
5. 寓言故事:這是一種用故事來說明一個道理或概念的故事,通常包含一個寓意或象徵性的元素。
|
27 |
|
28 |
+
這些故事公式只是故事創作中的一部分,不同的故事可能会有不同的結構和情節,但這些公式可以作為一個起點,幫助你開始創作出一個引人入勝的故事。''')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
]
|
30 |
|
31 |
os.system("wget https://huggingface.co/npc0/chatglm3-6b-int4/resolve/main/chatglm3-ggml-q4_0.bin")
|
|
|
60 |
elif input.isdigit():
|
61 |
input = '現在你作為一個專業的編劇,你需要為故事%s轉寫一段故事大綱提供一個完整的龍骨給之後的編劇用。' %input
|
62 |
else:
|
63 |
+
input = '請為『%s』提議五個適合的公式。' %input
|
64 |
response = ""
|
65 |
history.append(myChatMessage(role="user", content=input))
|
66 |
|
|
|
85 |
|
86 |
yield postprocess(response), history
|
87 |
|
88 |
+
history.append(response_piece)
|
89 |
+
yield response_piece.content, history
|
90 |
|
91 |
|
92 |
def reset_user_input():
|
|
|
95 |
|
96 |
def reset_state():
|
97 |
history = gr.State(init_history)
|
98 |
+
return '', '', [], gr.Dropdown(["1", "2", "3", "4", "5"], label="Step2:進一步擴展的範例", value=None, interactive=False)
|
99 |
|
100 |
|
101 |
def allow_user_input():
|
102 |
+
return gr.Dropdown(["1", "2", "3", "4", "5"], label="Step2:進一步擴展的範例", interactive=True)
|
103 |
|
104 |
|
105 |
with gr.Blocks() as demo:
|