Update app.py
Browse files
app.py
CHANGED
|
@@ -13,31 +13,31 @@ client = OpenAI(
|
|
| 13 |
)
|
| 14 |
|
| 15 |
# recording requests to Hugging Face dataset
|
| 16 |
-
DATASET_REPO_URL = "https://huggingface.co/datasets/jadend/mr_bot_requests"
|
| 17 |
-
DATA_FILENAME = "prompt_input.csv"
|
| 18 |
-
DATA_FILE = os.path.join("data", DATA_FILENAME)
|
| 19 |
|
| 20 |
-
HF_TOKEN = os.environ.get("HF_TOKEN")
|
| 21 |
|
| 22 |
-
repo = Repository(
|
| 23 |
-
|
| 24 |
-
)
|
| 25 |
|
| 26 |
# function to store the message to the Hugging Face site, if you would like to add more columns or information to track add it here
|
| 27 |
-
def store_message(prompt: str, temperature: str, response: str):
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
|
| 42 |
# defines who can enter the application with the secrets that are set up if used
|
| 43 |
user_db = {
|
|
@@ -52,7 +52,7 @@ def mr_bot(prompt, tokens, temperature):
|
|
| 52 |
max_tokens=tokens,
|
| 53 |
temperature=temperature,
|
| 54 |
)
|
| 55 |
-
store_message(prompt=prompt, temperature=temperature, response=response.choices[0].message.content)
|
| 56 |
|
| 57 |
return response.choices[0].message.content
|
| 58 |
|
|
|
|
| 13 |
)
|
| 14 |
|
| 15 |
# recording requests to Hugging Face dataset
|
| 16 |
+
# DATASET_REPO_URL = "https://huggingface.co/datasets/jadend/mr_bot_requests"
|
| 17 |
+
# DATA_FILENAME = "prompt_input.csv"
|
| 18 |
+
# DATA_FILE = os.path.join("data", DATA_FILENAME)
|
| 19 |
|
| 20 |
+
# HF_TOKEN = os.environ.get("HF_TOKEN")
|
| 21 |
|
| 22 |
+
# repo = Repository(
|
| 23 |
+
# local_dir="data", clone_from=DATASET_REPO_URL, use_auth_token=HF_TOKEN
|
| 24 |
+
# )
|
| 25 |
|
| 26 |
# function to store the message to the Hugging Face site, if you would like to add more columns or information to track add it here
|
| 27 |
+
# def store_message(prompt: str, temperature: str, response: str):
|
| 28 |
+
# if prompt:
|
| 29 |
+
# with open(DATA_FILE, "a") as csvfile:
|
| 30 |
+
# writer = csv.DictWriter(csvfile, fieldnames=["prompt", "temperature", "response", "time"])
|
| 31 |
+
# writer.writerow(
|
| 32 |
+
# {"prompt": prompt,
|
| 33 |
+
# "temperature": temperature,
|
| 34 |
+
# "response": response,
|
| 35 |
+
# "time": str(datetime.now())}
|
| 36 |
+
# )
|
| 37 |
+
# commit_url = repo.push_to_hub()
|
| 38 |
+
# print(commit_url)
|
| 39 |
+
#
|
| 40 |
+
# return
|
| 41 |
|
| 42 |
# defines who can enter the application with the secrets that are set up if used
|
| 43 |
user_db = {
|
|
|
|
| 52 |
max_tokens=tokens,
|
| 53 |
temperature=temperature,
|
| 54 |
)
|
| 55 |
+
# store_message(prompt=prompt, temperature=temperature, response=response.choices[0].message.content)
|
| 56 |
|
| 57 |
return response.choices[0].message.content
|
| 58 |
|