Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -12,17 +12,17 @@ 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 |
-
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 a student 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()
|
22 |
|
23 |
def chatbot(talk_to_chatsherman, history=[]):
|
24 |
-
output = openai_chat(talk_to_chatsherman)
|
25 |
-
history.append((talk_to_chatsherman, output))
|
26 |
return history, history
|
27 |
|
28 |
title = "ChatSherman"
|
|
|
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 |
+
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 a student 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()
|
22 |
|
23 |
def chatbot(talk_to_chatsherman, history=[]):
|
24 |
+
output = openai_chat(talk_to_chatsherman)
|
25 |
+
history.append((talk_to_chatsherman, output))
|
26 |
return history, history
|
27 |
|
28 |
title = "ChatSherman"
|