Spaces:
Sleeping
Sleeping
Colin Arrowsmith
commited on
Commit
·
f345dac
1
Parent(s):
0c42d61
change log file path to persistent HF storage location
Browse files- app.py +3 -2
- data/logs.txt +1 -0
app.py
CHANGED
|
@@ -32,6 +32,7 @@ chat = ChatOpenAI(model_name="gpt-4",temperature=0)
|
|
| 32 |
# Make sure we don't exceed estimation of token limit:
|
| 33 |
TOKEN_LIMIT = 4096 # GPT-3.5 Turbo token limit
|
| 34 |
BUFFER = 100 # Extra tokens to consider for incoming messages
|
|
|
|
| 35 |
|
| 36 |
def estimate_tokens(texts):
|
| 37 |
return sum([len(t.split()) for t in texts])
|
|
@@ -90,12 +91,12 @@ def bot(chatbot_history):
|
|
| 90 |
yield chatbot_history
|
| 91 |
|
| 92 |
# This is a function to do something with the voted information (TODO: Save this info somewhere?)
|
| 93 |
-
def vote(data: gr.LikeData):
|
| 94 |
if data.liked:
|
| 95 |
print("You upvoted this response: " + data.value)
|
| 96 |
else:
|
| 97 |
print("You downvoted this response: " + data.value)
|
| 98 |
-
with open(
|
| 99 |
print(f"Disliked content: {data.value}", file=text_file)
|
| 100 |
|
| 101 |
# The Gradio App interface
|
|
|
|
| 32 |
# Make sure we don't exceed estimation of token limit:
|
| 33 |
TOKEN_LIMIT = 4096 # GPT-3.5 Turbo token limit
|
| 34 |
BUFFER = 100 # Extra tokens to consider for incoming messages
|
| 35 |
+
LOG_PATH = "/data/logs.txt" # File in which to log downvoted responses
|
| 36 |
|
| 37 |
def estimate_tokens(texts):
|
| 38 |
return sum([len(t.split()) for t in texts])
|
|
|
|
| 91 |
yield chatbot_history
|
| 92 |
|
| 93 |
# This is a function to do something with the voted information (TODO: Save this info somewhere?)
|
| 94 |
+
def vote(data: gr.LikeData, log_path=LOG_PATH):
|
| 95 |
if data.liked:
|
| 96 |
print("You upvoted this response: " + data.value)
|
| 97 |
else:
|
| 98 |
print("You downvoted this response: " + data.value)
|
| 99 |
+
with open(log_path, "a") as text_file:
|
| 100 |
print(f"Disliked content: {data.value}", file=text_file)
|
| 101 |
|
| 102 |
# The Gradio App interface
|
data/logs.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
Disliked content: Hello! How can I assist you with your questions about Cionic or the Cionic Neural Sleeve today?
|