Spaces:
Runtime error
Runtime error
inputs=[chatbot, openai_key, chat_model],
Browse files
app.py
CHANGED
|
@@ -38,7 +38,9 @@ def handle_scenario(topic, scenario, chatbot_history=[]):
|
|
| 38 |
print(output) # Debugging: Print the output format.
|
| 39 |
return output
|
| 40 |
|
| 41 |
-
def openai_stream(history, openai_key, chat_model
|
|
|
|
|
|
|
| 42 |
|
| 43 |
if not history or history[-1][1]:
|
| 44 |
return history
|
|
@@ -91,7 +93,6 @@ with gr.Blocks(theme=theme) as demo:
|
|
| 91 |
|
| 92 |
header_component = gr.Markdown(header)
|
| 93 |
with gr.Row():
|
| 94 |
-
use_key = gr.Checkbox(label="Use OpenAI Key")
|
| 95 |
chat_model = gr.Dropdown(choices=available_models, value="gpt-3.5-turbo", allow_custom_value=True)
|
| 96 |
openai_key = gr.Textbox(label="Enter OPENAI API Key", placeholder="Example: sk-AJDKakdAJD...")
|
| 97 |
|
|
@@ -106,7 +107,7 @@ with gr.Blocks(theme=theme) as demo:
|
|
| 106 |
# Define streaming_event_kwargs after the required input components have been defined
|
| 107 |
streaming_event_kwargs = dict(
|
| 108 |
fn=openai_stream,
|
| 109 |
-
inputs=[chatbot, openai_key, chat_model
|
| 110 |
outputs=chatbot,
|
| 111 |
)
|
| 112 |
|
|
|
|
| 38 |
print(output) # Debugging: Print the output format.
|
| 39 |
return output
|
| 40 |
|
| 41 |
+
def openai_stream(history, openai_key, chat_model):
|
| 42 |
+
|
| 43 |
+
use_key = bool(openai_key.strip())
|
| 44 |
|
| 45 |
if not history or history[-1][1]:
|
| 46 |
return history
|
|
|
|
| 93 |
|
| 94 |
header_component = gr.Markdown(header)
|
| 95 |
with gr.Row():
|
|
|
|
| 96 |
chat_model = gr.Dropdown(choices=available_models, value="gpt-3.5-turbo", allow_custom_value=True)
|
| 97 |
openai_key = gr.Textbox(label="Enter OPENAI API Key", placeholder="Example: sk-AJDKakdAJD...")
|
| 98 |
|
|
|
|
| 107 |
# Define streaming_event_kwargs after the required input components have been defined
|
| 108 |
streaming_event_kwargs = dict(
|
| 109 |
fn=openai_stream,
|
| 110 |
+
inputs=[chatbot, openai_key, chat_model],
|
| 111 |
outputs=chatbot,
|
| 112 |
)
|
| 113 |
|