Spaces:
Runtime error
Runtime error
Save user id
Browse files
app.py
CHANGED
|
@@ -3,11 +3,14 @@ import gradio as gr
|
|
| 3 |
import torch
|
| 4 |
from transformers import AutoTokenizer
|
| 5 |
import json
|
|
|
|
|
|
|
| 6 |
|
| 7 |
tokenizer = AutoTokenizer.from_pretrained("gpt2")
|
| 8 |
|
| 9 |
# Global variable to store the latest obfuscation result
|
| 10 |
latest_obfuscation = {}
|
|
|
|
| 11 |
|
| 12 |
@spaces.GPU
|
| 13 |
def temp(text):
|
|
@@ -29,7 +32,9 @@ def save_feedback(feedback_rating, feedback_text):
|
|
| 29 |
save_data(latest_obfuscation)
|
| 30 |
|
| 31 |
def greet(input_text, length, function_words, grade_level, sarcasm, formality, voice, persuasive, descriptive, narrative, expository):
|
| 32 |
-
global latest_obfuscation
|
|
|
|
|
|
|
| 33 |
response = (
|
| 34 |
f"Hello!\n"
|
| 35 |
f"Input Text: {input_text}\n"
|
|
@@ -47,6 +52,8 @@ def greet(input_text, length, function_words, grade_level, sarcasm, formality, v
|
|
| 47 |
|
| 48 |
# Save the new obfuscation result and reset feedback
|
| 49 |
latest_obfuscation = {
|
|
|
|
|
|
|
| 50 |
"input_text": input_text,
|
| 51 |
"sliders": {
|
| 52 |
"length": length,
|
|
|
|
| 3 |
import torch
|
| 4 |
from transformers import AutoTokenizer
|
| 5 |
import json
|
| 6 |
+
from datetime import datetime
|
| 7 |
+
import uuid
|
| 8 |
|
| 9 |
tokenizer = AutoTokenizer.from_pretrained("gpt2")
|
| 10 |
|
| 11 |
# Global variable to store the latest obfuscation result
|
| 12 |
latest_obfuscation = {}
|
| 13 |
+
user_id = str(uuid.uuid4()) # Generate a unique session-specific user ID
|
| 14 |
|
| 15 |
@spaces.GPU
|
| 16 |
def temp(text):
|
|
|
|
| 32 |
save_data(latest_obfuscation)
|
| 33 |
|
| 34 |
def greet(input_text, length, function_words, grade_level, sarcasm, formality, voice, persuasive, descriptive, narrative, expository):
|
| 35 |
+
global latest_obfuscation, user_id
|
| 36 |
+
current_time = datetime.now().isoformat()
|
| 37 |
+
|
| 38 |
response = (
|
| 39 |
f"Hello!\n"
|
| 40 |
f"Input Text: {input_text}\n"
|
|
|
|
| 52 |
|
| 53 |
# Save the new obfuscation result and reset feedback
|
| 54 |
latest_obfuscation = {
|
| 55 |
+
"datetime": current_time,
|
| 56 |
+
"user_id": user_id,
|
| 57 |
"input_text": input_text,
|
| 58 |
"sliders": {
|
| 59 |
"length": length,
|