Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -114,26 +114,32 @@ def chat(message, history, openai_api_key):
|
|
114 |
content_values = extract_content_values(messages)
|
115 |
|
116 |
return content_values[0]
|
117 |
-
|
118 |
-
gr.
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
content_values = extract_content_values(messages)
|
115 |
|
116 |
return content_values[0]
|
117 |
+
|
118 |
+
def vote(data: gr.LikeData):
|
119 |
+
print("voted")
|
120 |
+
|
121 |
+
with gr.Blocks() as demo:
|
122 |
+
gr.ChatInterface(
|
123 |
+
chat,
|
124 |
+
chatbot=gr.Chatbot(height=300),
|
125 |
+
textbox=gr.Textbox(placeholder="Ask anything", container=False, scale=7),
|
126 |
+
title="Python Code Generator",
|
127 |
+
description="Generate, explain, fix, optimize, document, test, help, ... Can execute code when asked to.",
|
128 |
+
clear_btn="Clear",
|
129 |
+
retry_btn="Retry",
|
130 |
+
undo_btn="Undo",
|
131 |
+
examples=[
|
132 |
+
["Generate: NumPy/Pandas/Matplotlib & yfinance trading app", "sk-<BringYourOwn>"],
|
133 |
+
["Explain: r'^(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[\\W]).{8,}$'", "sk-<BringYourOwn>"],
|
134 |
+
["Fix: x = [5, 2, 1, 3, 4]; print(x.sort())", "sk-<BringYourOwn>"],
|
135 |
+
["Optimize: x = []; for i in range(0, 10000): x.append(i)", "sk-<BringYourOwn>"],
|
136 |
+
["Execute: Code to generate the first 20 fibbonaci numbers", "sk-<BringYourOwn>"],
|
137 |
+
],
|
138 |
+
cache_examples=False,
|
139 |
+
additional_inputs=[
|
140 |
+
gr.Textbox("sk-", label="OpenAI API Key", type = "password"),
|
141 |
+
],
|
142 |
+
),
|
143 |
+
chatbot.like(vote, None, None)
|
144 |
+
|
145 |
+
demo.launch()
|