Spaces:
Runtime error
Runtime error
Dagfinn1962
commited on
Commit
•
76e7966
1
Parent(s):
6dce795
Update app.py
Browse files
app.py
CHANGED
@@ -95,12 +95,11 @@ def call_inf_server(prompt, openai_key):
|
|
95 |
return response
|
96 |
|
97 |
|
98 |
-
# Read the configuration file
|
99 |
-
config = configparser.ConfigParser()
|
100 |
-
config.read('config.ini')
|
101 |
|
102 |
-
|
103 |
-
|
|
|
|
|
104 |
|
105 |
|
106 |
with gr.Blocks(theme='HaleyCH/HaleyCH_Theme') as demo:
|
@@ -146,60 +145,4 @@ with gr.Blocks(theme='HaleyCH/HaleyCH_Theme') as demo:
|
|
146 |
elem_classes=["disclaimer"],
|
147 |
)
|
148 |
with gr.Row():
|
149 |
-
|
150 |
-
"[Privacy policy](https://gist.github.com/samhavens/c29c68cdcd420a9aa0202d0839876dac)",
|
151 |
-
elem_classes=["disclaimer"],
|
152 |
-
)
|
153 |
-
|
154 |
-
submit_event = msg.submit(
|
155 |
-
fn=conversation.user_turn,
|
156 |
-
inputs=[msg],
|
157 |
-
outputs=[msg, chatbot],
|
158 |
-
queue=False,
|
159 |
-
).then(
|
160 |
-
fn=conversation.bot_turn,
|
161 |
-
inputs=[system, chatbot, openai_key],
|
162 |
-
outputs=[chatbot],
|
163 |
-
queue=True, # Change `queue=True` to `keep_in_queue=True`
|
164 |
-
)
|
165 |
-
|
166 |
-
submit_click_event = submit.click(
|
167 |
-
fn=conversation.user_turn,
|
168 |
-
inputs=[msg],
|
169 |
-
outputs=[msg, chatbot],
|
170 |
-
queue=False,
|
171 |
-
).then(
|
172 |
-
fn=conversation.bot_turn,
|
173 |
-
inputs=[system, chatbot, openai_key],
|
174 |
-
outputs=[chatbot],
|
175 |
-
queue=True, # Change `queue=True` to `keep_in_queue=True`
|
176 |
-
)
|
177 |
-
|
178 |
-
stop.click(
|
179 |
-
fn=None,
|
180 |
-
inputs=None,
|
181 |
-
outputs=None,
|
182 |
-
cancels=[submit_event, submit_click_event],
|
183 |
-
queue=False,
|
184 |
-
)
|
185 |
-
clear.click(lambda: None, None, chatbot, queue=False).then(
|
186 |
-
fn=conversation.clear_history,
|
187 |
-
inputs=[chatbot],
|
188 |
-
outputs=[chatbot],
|
189 |
-
queue=False,
|
190 |
-
)
|
191 |
-
change.click(
|
192 |
-
fn=conversation.set_system_prompt,
|
193 |
-
inputs=[system],
|
194 |
-
outputs=[system],
|
195 |
-
queue=False,
|
196 |
-
)
|
197 |
-
reset.click(
|
198 |
-
fn=conversation.reset_system_prompt,
|
199 |
-
inputs=[],
|
200 |
-
outputs=[system],
|
201 |
-
queue=False,
|
202 |
-
)
|
203 |
-
|
204 |
-
|
205 |
-
demo.queue(max_size=36, concurrency_count=14).launch(debug=True)
|
|
|
95 |
return response
|
96 |
|
97 |
|
|
|
|
|
|
|
98 |
|
99 |
+
|
100 |
+
# Get the OpenAI key from the environment variable
|
101 |
+
openai_key = os.getenv("API_KEY")
|
102 |
+
|
103 |
|
104 |
|
105 |
with gr.Blocks(theme='HaleyCH/HaleyCH_Theme') as demo:
|
|
|
145 |
elem_classes=["disclaimer"],
|
146 |
)
|
147 |
with gr.Row():
|
148 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|