Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -19,7 +19,6 @@ def generate_response(user_input):
|
|
| 19 |
else:
|
| 20 |
prompt = f"You said: {user_input}"
|
| 21 |
|
| 22 |
-
|
| 23 |
# Generate a response using the OpenAI API
|
| 24 |
response = openai.Completion.create(
|
| 25 |
model="text-davinci-003",
|
|
@@ -49,17 +48,6 @@ def openai_chat_history(input, history):
|
|
| 49 |
return output, history
|
| 50 |
else:
|
| 51 |
return "", history
|
| 52 |
-
history = []
|
| 53 |
-
while True:
|
| 54 |
-
# Get user input
|
| 55 |
-
user_input = input("You:")
|
| 56 |
-
|
| 57 |
-
# Generate response and update chat history
|
| 58 |
-
response, history = openai_chat_history(user_input, history)
|
| 59 |
-
|
| 60 |
-
# Print response
|
| 61 |
-
print("Bot:", response)
|
| 62 |
-
|
| 63 |
|
| 64 |
# Define the conversation prompt
|
| 65 |
conversation_prompt = "Welcome to ChatRobo, kindly type in your enquiries: "
|
|
@@ -67,8 +55,8 @@ conversation_prompt = "Welcome to ChatRobo, kindly type in your enquiries: "
|
|
| 67 |
# Set up the Gradio interface
|
| 68 |
block = gr.Interface(
|
| 69 |
fn=openai_chat_history,
|
| 70 |
-
inputs=[gr.inputs.Textbox(placeholder=conversation_prompt)],
|
| 71 |
-
outputs=[gr.outputs.Textbox(label="ChatRobo Output")]
|
| 72 |
)
|
| 73 |
|
| 74 |
# Launch the Gradio interface
|
|
@@ -76,3 +64,4 @@ block.launch()
|
|
| 76 |
|
| 77 |
|
| 78 |
|
|
|
|
|
|
| 19 |
else:
|
| 20 |
prompt = f"You said: {user_input}"
|
| 21 |
|
|
|
|
| 22 |
# Generate a response using the OpenAI API
|
| 23 |
response = openai.Completion.create(
|
| 24 |
model="text-davinci-003",
|
|
|
|
| 48 |
return output, history
|
| 49 |
else:
|
| 50 |
return "", history
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
# Define the conversation prompt
|
| 53 |
conversation_prompt = "Welcome to ChatRobo, kindly type in your enquiries: "
|
|
|
|
| 55 |
# Set up the Gradio interface
|
| 56 |
block = gr.Interface(
|
| 57 |
fn=openai_chat_history,
|
| 58 |
+
inputs=[gr.inputs.Textbox(placeholder=conversation_prompt), gr.inputs.Label("Chat History")],
|
| 59 |
+
outputs=[gr.outputs.Textbox(label="ChatRobo Output"), gr.outputs.Label("Updated Chat History")]
|
| 60 |
)
|
| 61 |
|
| 62 |
# Launch the Gradio interface
|
|
|
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
+
|