Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -26,26 +26,11 @@ model = genai.GenerativeModel(
|
|
26 |
chat_session = model.start_chat(history=[])
|
27 |
|
28 |
|
29 |
-
def
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
"\U0001F600-\U0001F64F" # Emoticons
|
35 |
-
"\U0001F300-\U0001F5FF" # Symbols & Pictographs
|
36 |
-
"\U0001F680-\U0001F6FF" # Transport & Map Symbols
|
37 |
-
"\U0001F700-\U0001F77F" # Alchemical Symbols
|
38 |
-
"\U0001F780-\U0001F7FF" # Geometric Shapes Extended
|
39 |
-
"\U0001F800-\U0001F8FF" # Supplemental Arrows-C
|
40 |
-
"\U0001F900-\U0001F9FF" # Supplemental Symbols and Pictographs
|
41 |
-
"\U0001FA00-\U0001FA6F" # Chess Symbols
|
42 |
-
"\U0001FA70-\U0001FAFF" # Symbols and Pictographs Extended-A
|
43 |
-
"\U00002702-\U000027B0" # Dingbats
|
44 |
-
"\U000024C2-\U0001F251" # Enclosed Characters
|
45 |
-
"]+", flags=re.UNICODE)
|
46 |
-
|
47 |
-
# Substitute emojis with an empty string
|
48 |
-
return emoji_pattern.sub(r'', text)
|
49 |
|
50 |
|
51 |
# Define the model with a placeholder for system instruction
|
@@ -64,7 +49,7 @@ def generate_text(system_instruction, prompt):
|
|
64 |
}
|
65 |
)
|
66 |
|
67 |
-
return
|
68 |
|
69 |
# Gradio interface
|
70 |
iface = gr.Interface(
|
|
|
26 |
chat_session = model.start_chat(history=[])
|
27 |
|
28 |
|
29 |
+
def filter_string(input_string):
|
30 |
+
allowed_chars = set("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ?")
|
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
|
|
|
49 |
}
|
50 |
)
|
51 |
|
52 |
+
return filter_string(response.text)
|
53 |
|
54 |
# Gradio interface
|
55 |
iface = gr.Interface(
|