Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import openai
|
|
|
|
| 2 |
|
| 3 |
# Set up OpenAI API credentials
|
| 4 |
openai.api_key = "YOUR_API_KEY"
|
|
@@ -8,7 +9,7 @@ def generate_response(user_input):
|
|
| 8 |
# Check if user input contains the phrase "who created you"
|
| 9 |
if "who created you" in user_input.lower():
|
| 10 |
# Generate a response that includes your name
|
| 11 |
-
chat_response = f"I was created by
|
| 12 |
else:
|
| 13 |
# Construct the prompt with the user input
|
| 14 |
prompt = f"You said: {user_input}"
|
|
@@ -30,18 +31,16 @@ def generate_response(user_input):
|
|
| 30 |
|
| 31 |
return chat_response
|
| 32 |
|
| 33 |
-
#
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
print("Chatbot:", response)
|
| 38 |
-
print("Welcome to the chatbot!\n")
|
| 39 |
-
block = gr.Interface(
|
| 40 |
-
fn=openai_chat_history,
|
| 41 |
inputs=[gr.inputs.Textbox(placeholder=conversation_prompt)],
|
| 42 |
-
outputs=[gr.outputs.Textbox(label="
|
| 43 |
)
|
| 44 |
-
|
|
|
|
|
|
|
| 45 |
|
| 46 |
|
| 47 |
|
|
|
|
| 1 |
import openai
|
| 2 |
+
import gradio as gr
|
| 3 |
|
| 4 |
# Set up OpenAI API credentials
|
| 5 |
openai.api_key = "YOUR_API_KEY"
|
|
|
|
| 9 |
# Check if user input contains the phrase "who created you"
|
| 10 |
if "who created you" in user_input.lower():
|
| 11 |
# Generate a response that includes your name
|
| 12 |
+
chat_response = f"I was created by RamV!"
|
| 13 |
else:
|
| 14 |
# Construct the prompt with the user input
|
| 15 |
prompt = f"You said: {user_input}"
|
|
|
|
| 31 |
|
| 32 |
return chat_response
|
| 33 |
|
| 34 |
+
# Define a Gradio interface for the chatbot
|
| 35 |
+
conversation_prompt = "Type here to chat with the bot!"
|
| 36 |
+
block = gr.Interface(
|
| 37 |
+
fn=generate_response,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
inputs=[gr.inputs.Textbox(placeholder=conversation_prompt)],
|
| 39 |
+
outputs=[gr.outputs.Textbox(label="Chatbot Output")]
|
| 40 |
)
|
| 41 |
+
|
| 42 |
+
# Launch the interface
|
| 43 |
+
block.launch()
|
| 44 |
|
| 45 |
|
| 46 |
|