Spaces:
Configuration error
Configuration error
Update app.py
Browse files
app.py
CHANGED
@@ -141,8 +141,15 @@ Here is the story:
|
|
141 |
|
142 |
# Function to save comment and score
|
143 |
def save_comment_score(chat_responses, score, comment, story_name, user_name, system_prompt):
|
144 |
-
|
145 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
timestamp = datetime.now(timezone.utc) - timedelta(hours=3) # Adjust to GMT-3
|
147 |
timestamp_str = timestamp.strftime("%Y-%m-%d %H:%M:%S")
|
148 |
model_name = selected_model
|
@@ -154,7 +161,7 @@ def save_comment_score(chat_responses, score, comment, story_name, user_name, sy
|
|
154 |
model_name,
|
155 |
system_prompt,
|
156 |
story_name,
|
157 |
-
|
158 |
score,
|
159 |
comment
|
160 |
])
|
@@ -165,7 +172,7 @@ def save_comment_score(chat_responses, score, comment, story_name, user_name, sy
|
|
165 |
except gspread.exceptions.WorksheetNotFound:
|
166 |
user_sheet = client.open(google_sheets_name).add_worksheet(title=user_name, rows="100", cols="20")
|
167 |
|
168 |
-
user_sheet.append_row([timestamp_str, user_name, model_name, system_prompt, story_name,
|
169 |
|
170 |
df = pd.DataFrame(data, columns=["Timestamp", "User Name", "Model Name", "System Prompt", "Story Name", "Chat History", "Score", "Comment"])
|
171 |
return df[["Chat History", "Score", "Comment"]], gr.update(value="") # Show only the required columns and clear the comment input box
|
|
|
141 |
|
142 |
# Function to save comment and score
|
143 |
def save_comment_score(chat_responses, score, comment, story_name, user_name, system_prompt):
|
144 |
+
full_chat_history = ""
|
145 |
+
|
146 |
+
# Create formatted chat history with roles
|
147 |
+
for message in chat_responses:
|
148 |
+
if message[0]: # User message
|
149 |
+
full_chat_history += f"User: {message[0]}\n"
|
150 |
+
if message[1]: # Assistant message
|
151 |
+
full_chat_history += f"Assistant: {message[1]}\n"
|
152 |
+
|
153 |
timestamp = datetime.now(timezone.utc) - timedelta(hours=3) # Adjust to GMT-3
|
154 |
timestamp_str = timestamp.strftime("%Y-%m-%d %H:%M:%S")
|
155 |
model_name = selected_model
|
|
|
161 |
model_name,
|
162 |
system_prompt,
|
163 |
story_name,
|
164 |
+
full_chat_history,
|
165 |
score,
|
166 |
comment
|
167 |
])
|
|
|
172 |
except gspread.exceptions.WorksheetNotFound:
|
173 |
user_sheet = client.open(google_sheets_name).add_worksheet(title=user_name, rows="100", cols="20")
|
174 |
|
175 |
+
user_sheet.append_row([timestamp_str, user_name, model_name, system_prompt, story_name, full_chat_history, score, comment])
|
176 |
|
177 |
df = pd.DataFrame(data, columns=["Timestamp", "User Name", "Model Name", "System Prompt", "Story Name", "Chat History", "Score", "Comment"])
|
178 |
return df[["Chat History", "Score", "Comment"]], gr.update(value="") # Show only the required columns and clear the comment input box
|