typesdigital commited on
Commit
97c3f86
·
1 Parent(s): 529080b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -13
app.py CHANGED
@@ -1,8 +1,10 @@
 
1
  import openai
2
 
3
  # Set up the OpenAI API credentials
4
- openai.api_key = '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'
5
 
 
6
  def generate_response(prompt):
7
  # Set up the OpenAI API parameters
8
  model_engine = "text-davinci-002"
@@ -22,15 +24,22 @@ def generate_response(prompt):
22
 
23
  return generated_text
24
 
25
- def main():
26
- while True:
27
- # Prompt the user for input
28
- prompt = input("Ask for a health tip or benefit: ")
29
-
30
- # Generate a response using the OpenAI API
31
- response = generate_response(prompt)
32
-
33
- # Print the response
34
- print(response)
35
- if __name__ == '__main__':
36
- main()
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
  import openai
3
 
4
  # Set up the OpenAI API credentials
5
+ openai.api_key = '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''
6
 
7
+ # Define a function that takes a user's input as a prompt and uses the OpenAI API to generate a response
8
  def generate_response(prompt):
9
  # Set up the OpenAI API parameters
10
  model_engine = "text-davinci-002"
 
24
 
25
  return generated_text
26
 
27
+ # Define a Gradio interface for the medical bot
28
+ def medical_bot(prompt):
29
+ # Generate a response using the OpenAI API
30
+ response = generate_response(prompt)
31
+
32
+ # Return the response to the user
33
+ return response
34
+
35
+ # Set up the Gradio interface for the medical bot
36
+ interface = gr.Interface(
37
+ fn=medical_bot,
38
+ inputs=gr.inputs.Textbox(label="Ask for a health tip or benefit:"),
39
+ outputs="text",
40
+ title="Medical Bot",
41
+ description="Get health tips and benefits from the OpenAI API."
42
+ )
43
+
44
+ # Run the Gradio interface
45
+ interface.launch()