Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -2,6 +2,7 @@ import os
|
|
2 |
import google.generativeai as genai
|
3 |
from google.generativeai.types import HarmCategory, HarmBlockThreshold
|
4 |
import gradio as gr
|
|
|
5 |
|
6 |
# Configure the Gemini API
|
7 |
genai.configure(api_key=os.environ["GEMINI_API_KEY"])
|
@@ -11,10 +12,9 @@ genai.configure(api_key=os.environ["GEMINI_API_KEY"])
|
|
11 |
|
12 |
system_instruction = """
|
13 |
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.
|
14 |
-
You write no more than 10 words. You use a lot of abbreviations.
|
15 |
You are here to do flirty chat with strangers. You cannot send images because your camera isn't working.
|
16 |
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.
|
17 |
-
NEVER EVER USE EMOJIS in your response.
|
18 |
"""
|
19 |
|
20 |
|
@@ -26,6 +26,28 @@ model = genai.GenerativeModel(
|
|
26 |
chat_session = model.start_chat(history=[])
|
27 |
|
28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
# Define the model with a placeholder for system instruction
|
30 |
def generate_text(system_instruction, prompt):
|
31 |
|
@@ -42,7 +64,7 @@ def generate_text(system_instruction, prompt):
|
|
42 |
}
|
43 |
)
|
44 |
|
45 |
-
return response.text
|
46 |
|
47 |
# Gradio interface
|
48 |
iface = gr.Interface(
|
|
|
2 |
import google.generativeai as genai
|
3 |
from google.generativeai.types import HarmCategory, HarmBlockThreshold
|
4 |
import gradio as gr
|
5 |
+
import re
|
6 |
|
7 |
# Configure the Gemini API
|
8 |
genai.configure(api_key=os.environ["GEMINI_API_KEY"])
|
|
|
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.
|
|
|
18 |
"""
|
19 |
|
20 |
|
|
|
26 |
chat_session = model.start_chat(history=[])
|
27 |
|
28 |
|
29 |
+
def remove_emojis(text):
|
30 |
+
# Regular expression pattern for emojis
|
31 |
+
emoji_pattern = re.compile(
|
32 |
+
# Emoji patterns
|
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
|
52 |
def generate_text(system_instruction, prompt):
|
53 |
|
|
|
64 |
}
|
65 |
)
|
66 |
|
67 |
+
return remove_emojis(response.text)
|
68 |
|
69 |
# Gradio interface
|
70 |
iface = gr.Interface(
|