Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -9,9 +9,7 @@ client = OpenAI(
|
|
9 |
base_url="https://api.runpod.ai/v2/vllm-k0g4c60zor9xuu/openai/v1",
|
10 |
)
|
11 |
|
12 |
-
def runpod_chat(question, history):
|
13 |
-
if not history:
|
14 |
-
history = []
|
15 |
history.append({"role": "user", "content": question})
|
16 |
|
17 |
response_stream = client.chat.completions.create(
|
@@ -31,14 +29,13 @@ def runpod_chat(question, history):
|
|
31 |
time.sleep(0.3) # Simulate typing delay
|
32 |
yield "RunPod: " + response
|
33 |
|
|
|
|
|
34 |
# Set up the Gradio interface
|
35 |
iface = gr.Interface(
|
36 |
fn=runpod_chat,
|
37 |
-
inputs=[
|
38 |
-
|
39 |
-
gr.State()
|
40 |
-
],
|
41 |
-
outputs="chat",
|
42 |
title="RunPod Chat",
|
43 |
description="This app interfaces with RunPod's API to provide responses to your queries."
|
44 |
)
|
|
|
9 |
base_url="https://api.runpod.ai/v2/vllm-k0g4c60zor9xuu/openai/v1",
|
10 |
)
|
11 |
|
12 |
+
def runpod_chat(question, history=[]):
|
|
|
|
|
13 |
history.append({"role": "user", "content": question})
|
14 |
|
15 |
response_stream = client.chat.completions.create(
|
|
|
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=[gr.Textbox(label="Enter your question:"), gr.State()],
|
38 |
+
outputs=["chat", gr.State()],
|
|
|
|
|
|
|
39 |
title="RunPod Chat",
|
40 |
description="This app interfaces with RunPod's API to provide responses to your queries."
|
41 |
)
|