Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import subprocess
|
2 |
subprocess.check_call(["pip", "install", "--upgrade", "gradio"])
|
3 |
subprocess.check_call(["pip", "install", "-q", "openai"])
|
4 |
-
subprocess.check_call(["pip", "install", "transformers", "python-dotenv"])
|
5 |
import gradio as gr
|
6 |
from transformers import TFAutoModelForCausalLM, AutoTokenizer
|
7 |
import openai
|
@@ -16,7 +16,7 @@ def openai_chat(prompt):
|
|
16 |
return "My name is ChatSherman. How can I assist you today?"
|
17 |
else:
|
18 |
prompt = "I'm an AI chatbot named ChatSherman designed by a student named ShermanAI at the Department of Electronic and Information Engineering at The Hong Kong Polytechnic University to help you with your engineering questions. Also, I can assist with a wide range of topics and questions." + prompt
|
19 |
-
completions = openai.Completion.create(engine="text-davinci-003", prompt=prompt, max_tokens=
|
20 |
message = completions.choices[0].text
|
21 |
return message.strip()
|
22 |
|
|
|
1 |
import subprocess
|
2 |
subprocess.check_call(["pip", "install", "--upgrade", "gradio"])
|
3 |
subprocess.check_call(["pip", "install", "-q", "openai"])
|
4 |
+
subprocess.check_call(["pip", "install", "-q", "gradio", "transformers", "python-dotenv"])
|
5 |
import gradio as gr
|
6 |
from transformers import TFAutoModelForCausalLM, AutoTokenizer
|
7 |
import openai
|
|
|
16 |
return "My name is ChatSherman. How can I assist you today?"
|
17 |
else:
|
18 |
prompt = "I'm an AI chatbot named ChatSherman designed by a student named ShermanAI at the Department of Electronic and Information Engineering at The Hong Kong Polytechnic University to help you with your engineering questions. Also, I can assist with a wide range of topics and 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 |
|