RamV commited on
Commit
db69a9f
·
1 Parent(s): 5356743

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -11
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 {RamV}!"
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
- # Test the chatbot
34
- while True:
35
- user_input = input("You: ")
36
- response = generate_response(user_input)
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="ChatRobo Output")]
43
  )
44
- block.launch()
 
 
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