Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -15,14 +15,7 @@ def predict(api_key, user_input):
|
|
15 |
max_tokens=100)
|
16 |
|
17 |
response = completion.choices[0].text
|
18 |
-
|
19 |
-
# Simulate streaming by splitting the response and yielding parts with delays
|
20 |
-
words = response.split()
|
21 |
-
for i in range(0, len(words), 5): # Adjust the step to control chunk sizes
|
22 |
-
yield ' '.join(words[i:i+5])
|
23 |
-
time.sleep(1) # Adjust the sleep time to control the streaming speeded
|
24 |
-
|
25 |
-
#return response
|
26 |
|
27 |
def main():
|
28 |
description = "This is a simple interface to interact with OpenAI’s Chat Completion API. Please enter your API key and your message."
|
@@ -31,8 +24,8 @@ def main():
|
|
31 |
api_key_input = gr.Textbox(label="API Key", placeholder="Enter your API key here", show_label=True, type="password")
|
32 |
user_input = gr.Textbox(label="Your Message", placeholder="Enter your message here")
|
33 |
submit_btn = gr.Button("Submit")
|
34 |
-
|
35 |
-
|
36 |
|
37 |
submit_btn.click(fn=predict, inputs=[api_key_input, user_input], outputs=output)
|
38 |
|
|
|
15 |
max_tokens=100)
|
16 |
|
17 |
response = completion.choices[0].text
|
18 |
+
return response
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
def main():
|
21 |
description = "This is a simple interface to interact with OpenAI’s Chat Completion API. Please enter your API key and your message."
|
|
|
24 |
api_key_input = gr.Textbox(label="API Key", placeholder="Enter your API key here", show_label=True, type="password")
|
25 |
user_input = gr.Textbox(label="Your Message", placeholder="Enter your message here")
|
26 |
submit_btn = gr.Button("Submit")
|
27 |
+
|
28 |
+
output = gr.Textbox(label="LLM Response")
|
29 |
|
30 |
submit_btn.click(fn=predict, inputs=[api_key_input, user_input], outputs=output)
|
31 |
|