ShermanAI commited on
Commit
32488d9
·
1 Parent(s): b96b583

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -12,7 +12,8 @@ load_dotenv() # load environment variables from .env file
12
  api_key = os.getenv("OPENAI_API_KEY") # access the value of the OPENAI_API_KEY environment variable
13
 
14
  def openai_chat(prompt):
15
- completions = openai.Completion.create(engine="text-davinci-003", prompt=prompt, max_tokens=1024, n=1, temperature=0.4,)
 
16
  message = completions.choices[0].text
17
  return message.strip()
18
 
@@ -24,11 +25,11 @@ def chatbot(talk_to_chatsherman, history=[]):
24
  title = "ChatSherman"
25
  description = "This is an AI chatbot powered by ShermanAI using GPT-3 model."
26
  examples = [
27
- ["Hello, how are you?", []],
28
- ["What's the meaning of life?", []],
29
- ["Tell me a joke.", []]
30
  ]
31
- inputs = [gr.inputs.Textbox(label="Talk to ChatSherman: "), "state"]
32
  outputs = ["chatbot", "state"]
33
  interface = gr.Interface(fn=chatbot, inputs=inputs, outputs=outputs, title=title, description=description, examples=examples)
34
  interface.launch(debug=True)
 
12
  api_key = os.getenv("OPENAI_API_KEY") # access the value of the OPENAI_API_KEY environment variable
13
 
14
  def openai_chat(prompt):
15
+ prompt = "I'm an AI chatbot designed to help you with your engineering questions. " + prompt
16
+ completions = openai.Completion.create(engine="text-davinci-003", prompt=prompt, max_tokens=1024, n=1, temperature=0.5,)
17
  message = completions.choices[0].text
18
  return message.strip()
19
 
 
25
  title = "ChatSherman"
26
  description = "This is an AI chatbot powered by ShermanAI using GPT-3 model."
27
  examples = [
28
+ ["What is the difference between a resistor and a capacitor?", []],
29
+ ["Can you explain the concept of electrical conductivity?", []],
30
+ ["How do you calculate the force required to move an object?", []]
31
  ]
32
+ inputs = [gr.inputs.Textbox(label="Enter your question: "), "state"]
33
  outputs = ["chatbot", "state"]
34
  interface = gr.Interface(fn=chatbot, inputs=inputs, outputs=outputs, title=title, description=description, examples=examples)
35
  interface.launch(debug=True)