Spaces:
Runtime error
Runtime error
Commit
·
be83449
1
Parent(s):
68d5ef9
Update main.py
Browse files
main.py
CHANGED
|
@@ -17,21 +17,19 @@ from langchain import HuggingFaceHub
|
|
| 17 |
import requests
|
| 18 |
|
| 19 |
# 初始化Chatbot
|
| 20 |
-
|
| 21 |
repo_id = os.environ.get('repo_id')
|
| 22 |
-
port = os.getenv('port')
|
| 23 |
|
| 24 |
llm = HuggingFaceHub(repo_id=repo_id,
|
|
|
|
|
|
|
| 25 |
model_kwargs={"min_length":1024,
|
| 26 |
"max_new_tokens":5632, "do_sample":True,
|
| 27 |
"temperature":0.1,
|
| 28 |
"top_k":50,
|
| 29 |
"top_p":0.95, "eos_token_id":49155})
|
| 30 |
|
| 31 |
-
#prompt_template = """You are a very helpful AI assistant. Please response to the user's input question with as many details as possible.
|
| 32 |
-
#Question: {user_question}
|
| 33 |
-
#Helpful AI Repsonse:
|
| 34 |
-
#"""
|
| 35 |
|
| 36 |
prompt_template = """
|
| 37 |
<<SYS>>You are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature.
|
|
|
|
| 17 |
import requests
|
| 18 |
|
| 19 |
# 初始化Chatbot
|
| 20 |
+
hf_token = os.environ.get('HUGGINGFACEHUB_API_TOKEN')
|
| 21 |
repo_id = os.environ.get('repo_id')
|
| 22 |
+
#port = os.getenv('port')
|
| 23 |
|
| 24 |
llm = HuggingFaceHub(repo_id=repo_id,
|
| 25 |
+
#huggingfacehub_api_token="hf_p***K",
|
| 26 |
+
huggingfacehub_api_token=hf_token,
|
| 27 |
model_kwargs={"min_length":1024,
|
| 28 |
"max_new_tokens":5632, "do_sample":True,
|
| 29 |
"temperature":0.1,
|
| 30 |
"top_k":50,
|
| 31 |
"top_p":0.95, "eos_token_id":49155})
|
| 32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
prompt_template = """
|
| 35 |
<<SYS>>You are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature.
|