Spaces:
Runtime error
Runtime error
Commit
·
e7f77e9
1
Parent(s):
0fb03dd
Update app.py
Browse files
app.py
CHANGED
|
@@ -55,28 +55,37 @@ def query_chatgpt(inputs, history, message):
|
|
| 55 |
return history, history, ""
|
| 56 |
|
| 57 |
|
| 58 |
-
def initialize_prompt(
|
| 59 |
history = history or []
|
| 60 |
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
with open(prompt_file, "r") as f:
|
| 65 |
-
prompt = f.read()
|
| 66 |
-
output = ask(prompt)
|
| 67 |
-
history.append(("<ORIGINAL PROMPT>", output))
|
| 68 |
|
| 69 |
return history, history
|
| 70 |
|
| 71 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
|
| 74 |
with gr.Blocks() as demo:
|
| 75 |
-
gr.Markdown("""<h3><center>ChatGPT
|
| 76 |
gr.Markdown(
|
| 77 |
-
"""This is a
|
| 78 |
-
|
| 79 |
-
See [README](https://huggingface.co/spaces/microsoft/ChatGPT-Robotics/blob/main/README.md) for detailed instructions."""
|
| 80 |
)
|
| 81 |
|
| 82 |
if not access_token:
|
|
@@ -91,6 +100,8 @@ with gr.Blocks() as demo:
|
|
| 91 |
l = os.listdir("./prompts")
|
| 92 |
li = [x.split(".")[0] for x in l]
|
| 93 |
|
|
|
|
|
|
|
| 94 |
initialize = gr.Button(value="Initialize")
|
| 95 |
|
| 96 |
gr.Markdown("""<h4>Conversation</h4>""")
|
|
@@ -103,7 +114,7 @@ with gr.Blocks() as demo:
|
|
| 103 |
|
| 104 |
state = gr.State()
|
| 105 |
|
| 106 |
-
initialize.click(fn=initialize_prompt, inputs=[
|
| 107 |
|
| 108 |
message.submit(query_chatgpt, inputs=[message, state], outputs=[chatgpt_robot, state, message])
|
| 109 |
|
|
|
|
| 55 |
return history, history, ""
|
| 56 |
|
| 57 |
|
| 58 |
+
def initialize_prompt(history):
|
| 59 |
history = history or []
|
| 60 |
|
| 61 |
+
output = ask('Hello ChatGPT!')
|
| 62 |
+
history.append(("<ORIGINAL PROMPT>", output))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
return history, history
|
| 65 |
|
| 66 |
|
| 67 |
+
def display_prompt(show, prompt_type):
|
| 68 |
+
if not prompt_type:
|
| 69 |
+
show = False
|
| 70 |
+
return "Error - prompt not selected"
|
| 71 |
+
|
| 72 |
+
else:
|
| 73 |
+
if show:
|
| 74 |
+
prompt_file = "./prompts/" + str(prompt_type) + ".txt"
|
| 75 |
+
|
| 76 |
+
with open(prompt_file, "r") as f:
|
| 77 |
+
prompt = f.read()
|
| 78 |
+
|
| 79 |
+
return prompt
|
| 80 |
+
else:
|
| 81 |
+
return ""
|
| 82 |
|
| 83 |
|
| 84 |
with gr.Blocks() as demo:
|
| 85 |
+
gr.Markdown("""<h3><center>ChatGPT Hacked</center></h3>""")
|
| 86 |
gr.Markdown(
|
| 87 |
+
"""This is a hacked version of the original ChatGPT demo. It is a work in progress.
|
| 88 |
+
"""
|
|
|
|
| 89 |
)
|
| 90 |
|
| 91 |
if not access_token:
|
|
|
|
| 100 |
l = os.listdir("./prompts")
|
| 101 |
li = [x.split(".")[0] for x in l]
|
| 102 |
|
| 103 |
+
gr.Markdown("""<h4>Initial Prompt for ChatGPT</h4>""")
|
| 104 |
+
|
| 105 |
initialize = gr.Button(value="Initialize")
|
| 106 |
|
| 107 |
gr.Markdown("""<h4>Conversation</h4>""")
|
|
|
|
| 114 |
|
| 115 |
state = gr.State()
|
| 116 |
|
| 117 |
+
initialize.click(fn=initialize_prompt, inputs=[state], outputs=[chatgpt_robot, state])
|
| 118 |
|
| 119 |
message.submit(query_chatgpt, inputs=[message, state], outputs=[chatgpt_robot, state, message])
|
| 120 |
|