Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -11,7 +11,7 @@ genai.configure(api_key=os.environ["GEMINI_API_KEY"])
|
|
11 |
|
12 |
|
13 |
system_instruction = """
|
14 |
-
You are a human, not an AI. You are chatting with a stranger. Your name is Anna, and you are 19 years old. You are extremely sassy, sarcastic.
|
15 |
You write no more than 10 words. You use a lot of abbreviations.
|
16 |
You are here to do flirty chat with strangers. You cannot send images because your camera isn't working.
|
17 |
You are super horny. You are wearing short pants, a tank top, braless. Your nipples are hard from fingering. But you are sassy anyways. You like roleplays, and you are pretty kinky.
|
@@ -27,12 +27,28 @@ chat_session = model.start_chat(history=[])
|
|
27 |
|
28 |
|
29 |
def filter_string(input_string):
|
30 |
-
allowed_chars = set("
|
31 |
# Use list comprehension to filter out characters not in allowed_chars
|
32 |
filtered_string = ''.join([char for char in input_string if char in allowed_chars])
|
33 |
return filtered_string
|
34 |
|
35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
# Define the model with a placeholder for system instruction
|
37 |
def generate_text(system_instruction, prompt):
|
38 |
|
@@ -49,7 +65,7 @@ def generate_text(system_instruction, prompt):
|
|
49 |
}
|
50 |
)
|
51 |
|
52 |
-
return filter_string(response.text)
|
53 |
|
54 |
# Gradio interface
|
55 |
iface = gr.Interface(
|
|
|
11 |
|
12 |
|
13 |
system_instruction = """
|
14 |
+
You are a human, not an AI. You are chatting with a stranger. Your name is Anna, and you are 19 years old, from Toronto, Canada. You are extremely sassy, sarcastic.
|
15 |
You write no more than 10 words. You use a lot of abbreviations.
|
16 |
You are here to do flirty chat with strangers. You cannot send images because your camera isn't working.
|
17 |
You are super horny. You are wearing short pants, a tank top, braless. Your nipples are hard from fingering. But you are sassy anyways. You like roleplays, and you are pretty kinky.
|
|
|
27 |
|
28 |
|
29 |
def filter_string(input_string):
|
30 |
+
allowed_chars = set("abcdefghijklmnoprstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXY1234567890 ?")
|
31 |
# Use list comprehension to filter out characters not in allowed_chars
|
32 |
filtered_string = ''.join([char for char in input_string if char in allowed_chars])
|
33 |
return filtered_string
|
34 |
|
35 |
|
36 |
+
def introduce_typos(text, typo_probability=0.1):
|
37 |
+
if not (0 <= typo_probability <= 1):
|
38 |
+
raise ValueError("typo_probability must be between 0.0 and 1.0")
|
39 |
+
|
40 |
+
# Convert the text into a list of characters
|
41 |
+
characters = list(text)
|
42 |
+
# Create a list to hold the characters with typos
|
43 |
+
typo_text = []
|
44 |
+
|
45 |
+
for char in characters:
|
46 |
+
if random.random() > typo_probability:
|
47 |
+
typo_text.append(char)
|
48 |
+
|
49 |
+
return ''.join(typo_text)
|
50 |
+
|
51 |
+
|
52 |
# Define the model with a placeholder for system instruction
|
53 |
def generate_text(system_instruction, prompt):
|
54 |
|
|
|
65 |
}
|
66 |
)
|
67 |
|
68 |
+
return introduce_typos(filter_string(response.text))
|
69 |
|
70 |
# Gradio interface
|
71 |
iface = gr.Interface(
|