bstraehle commited on
Commit
1057e6a
1 Parent(s): 2de5e80

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -23
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.ChatInterface(
119
- chat,
120
- chatbot=gr.Chatbot(height=300),
121
- textbox=gr.Textbox(placeholder="Ask anything", container=False, scale=7),
122
- textbox2=gr.Textbox(placeholder="OpenAI API Key", container=False, scale=7),
123
- title="Python Code Generator",
124
- description="Generate, explain, fix, optimize, document, test, help, ... Can execute code when asked to.",
125
- clear_btn="Clear",
126
- retry_btn="Retry",
127
- undo_btn="Undo",
128
- examples=[
129
- ["Generate: NumPy/Pandas/Matplotlib & yfinance trading app", "sk-<BringYourOwn>"],
130
- ["Explain: r'^(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[\\W]).{8,}$'", "sk-<BringYourOwn>"],
131
- ["Fix: x = [5, 2, 1, 3, 4]; print(x.sort())", "sk-<BringYourOwn>"],
132
- ["Optimize: x = []; for i in range(0, 10000): x.append(i)", "sk-<BringYourOwn>"],
133
- ["Execute: Code to generate the first 20 fibbonaci numbers", "sk-<BringYourOwn>"],
134
- ],
135
- cache_examples=False,
136
- additional_inputs=[
137
- gr.Textbox("sk-", label="OpenAI API Key", type = "password"),
138
- ],
139
- ).launch()
 
 
 
 
 
 
 
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()