Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -21,21 +21,26 @@ def runpod_chat(question, history=[]):
|
|
21 |
)
|
22 |
|
23 |
# Stream the response and add to history
|
24 |
-
|
25 |
for message in response_stream:
|
26 |
response = message.choices[0].delta.content
|
27 |
-
|
28 |
history.append({"role": "assistant", "content": response})
|
29 |
time.sleep(0.3) # Simulate typing delay
|
30 |
-
yield "RunPod: " + response
|
31 |
|
32 |
-
return history # Return updated history to maintain state
|
33 |
|
34 |
# Set up the Gradio interface
|
35 |
iface = gr.Interface(
|
36 |
fn=runpod_chat,
|
37 |
-
inputs=[
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
title="RunPod Chat",
|
40 |
description="This app interfaces with RunPod's API to provide responses to your queries."
|
41 |
)
|
|
|
21 |
)
|
22 |
|
23 |
# Stream the response and add to history
|
24 |
+
full_response = ""
|
25 |
for message in response_stream:
|
26 |
response = message.choices[0].delta.content
|
27 |
+
full_response += "RunPod: " + response + "\n"
|
28 |
history.append({"role": "assistant", "content": response})
|
29 |
time.sleep(0.3) # Simulate typing delay
|
|
|
30 |
|
31 |
+
return full_response, history # Return full response and updated history to maintain state
|
32 |
|
33 |
# Set up the Gradio interface
|
34 |
iface = gr.Interface(
|
35 |
fn=runpod_chat,
|
36 |
+
inputs=[
|
37 |
+
gr.Textbox(label="Enter your question:"),
|
38 |
+
gr.State()
|
39 |
+
],
|
40 |
+
outputs=[
|
41 |
+
gr.Textbox(label="Responses"),
|
42 |
+
gr.State()
|
43 |
+
],
|
44 |
title="RunPod Chat",
|
45 |
description="This app interfaces with RunPod's API to provide responses to your queries."
|
46 |
)
|