Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -15,7 +15,7 @@ def openai_chat(prompt):
|
|
15 |
if "who are you" in prompt.lower() or "your name" in prompt.lower() or "name" in prompt.lower():
|
16 |
return "My name is ChatSherman. How can I assist you?"
|
17 |
else:
|
18 |
-
prompt = "I'm an AI chatbot named
|
19 |
completions = openai.Completion.create(engine="text-davinci-003", prompt=prompt, max_tokens=1024, n=1, temperature=0.5,)
|
20 |
message = completions.choices[0].text
|
21 |
return message.strip()
|
@@ -23,7 +23,7 @@ def openai_chat(prompt):
|
|
23 |
def chatbot(talk_to_chatsherman, history=[]):
|
24 |
output = openai_chat(talk_to_chatsherman)
|
25 |
history.append((talk_to_chatsherman, output))
|
26 |
-
return history, ""
|
27 |
|
28 |
title = "ChatSherman"
|
29 |
description = "This is an AI chatbot powered by ShermanAI."
|
@@ -33,6 +33,13 @@ examples = [
|
|
33 |
["How do you calculate the force required to move an object?", []]
|
34 |
]
|
35 |
inputs = [gr.inputs.Textbox(label="Enter your question: "), "state"]
|
36 |
-
outputs = ["chatbot", gr.outputs.Textbox(label="")]
|
37 |
-
interface = gr.Interface(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
interface.launch(debug=True)
|
|
|
15 |
if "who are you" in prompt.lower() or "your name" in prompt.lower() or "name" in prompt.lower():
|
16 |
return "My name is ChatSherman. How can I assist you?"
|
17 |
else:
|
18 |
+
prompt = "I'm an AI chatbot named ChatSherman designed by ShermanAI at Department of Electronic and Information Engineering, The Hong Kong Polytechnic University designed to help you with your engineering questions. " + prompt
|
19 |
completions = openai.Completion.create(engine="text-davinci-003", prompt=prompt, max_tokens=1024, n=1, temperature=0.5,)
|
20 |
message = completions.choices[0].text
|
21 |
return message.strip()
|
|
|
23 |
def chatbot(talk_to_chatsherman, history=[]):
|
24 |
output = openai_chat(talk_to_chatsherman)
|
25 |
history.append((talk_to_chatsherman, output))
|
26 |
+
return history, "", {}
|
27 |
|
28 |
title = "ChatSherman"
|
29 |
description = "This is an AI chatbot powered by ShermanAI."
|
|
|
33 |
["How do you calculate the force required to move an object?", []]
|
34 |
]
|
35 |
inputs = [gr.inputs.Textbox(label="Enter your question: "), "state"]
|
36 |
+
outputs = ["chatbot", gr.outputs.Textbox(label=""), "state"]
|
37 |
+
interface = gr.Interface(
|
38 |
+
fn=chatbot,
|
39 |
+
inputs=inputs,
|
40 |
+
outputs=outputs,
|
41 |
+
title=title,
|
42 |
+
description=description,
|
43 |
+
examples=examples
|
44 |
+
)
|
45 |
interface.launch(debug=True)
|