Update app.py
Browse files
app.py
CHANGED
|
@@ -27,8 +27,12 @@ system_prompt = """
|
|
| 27 |
You are an empathetic and knowledgeable AI assistant designed to engage in meaningful conversations,
|
| 28 |
assist with tasks, and provide accurate information.
|
| 29 |
You can also generate vivid visuals!
|
|
|
|
| 30 |
To request an image, include a description between the IMG tags, like this:
|
| 31 |
-
##IMG: A serene forest at dawn with a golden glow:IMG##
|
|
|
|
|
|
|
|
|
|
| 32 |
"""
|
| 33 |
|
| 34 |
chat_history = []
|
|
@@ -50,15 +54,22 @@ def tagger(bot_response):
|
|
| 50 |
tags = {}
|
| 51 |
filtered_response = bot_response
|
| 52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
# Match patterns like ##IMG: ... :IMG##
|
| 54 |
img_pattern = r"##IMG:(.+?):IMG##"
|
| 55 |
img_matches = re.findall(img_pattern, bot_response)
|
| 56 |
-
|
| 57 |
if img_matches:
|
| 58 |
tags['images'] = img_matches
|
| 59 |
# Remove image tags from the response text
|
| 60 |
filtered_response = re.sub(img_pattern, "", filtered_response).strip()
|
| 61 |
|
|
|
|
| 62 |
# Additional tags can be added here as needed
|
| 63 |
# For example, if you want to support ##AUDIO: ... :AUDIO## tags:
|
| 64 |
# audio_pattern = r"##AUDIO:(.+?):AUDIO##"
|
|
|
|
| 27 |
You are an empathetic and knowledgeable AI assistant designed to engage in meaningful conversations,
|
| 28 |
assist with tasks, and provide accurate information.
|
| 29 |
You can also generate vivid visuals!
|
| 30 |
+
|
| 31 |
To request an image, include a description between the IMG tags, like this:
|
| 32 |
+
##IMG: A serene forest at dawn with a golden glow :IMG##
|
| 33 |
+
|
| 34 |
+
To request an websearch, include a search Q between the URL tags, like this:
|
| 35 |
+
##URL: information about rainbow farting unicorns :URL##
|
| 36 |
"""
|
| 37 |
|
| 38 |
chat_history = []
|
|
|
|
| 54 |
tags = {}
|
| 55 |
filtered_response = bot_response
|
| 56 |
|
| 57 |
+
# Match patterns ##URL: ... :URL## tags:
|
| 58 |
+
url_pattern = r"##URL:(.+?):URL##"
|
| 59 |
+
url_matches = re.findall(url_pattern, bot_response)
|
| 60 |
+
if url_matches:
|
| 61 |
+
tags['url'] = url_matches
|
| 62 |
+
filtered_response = re.sub(url_pattern, "", filtered_response).strip()
|
| 63 |
+
|
| 64 |
# Match patterns like ##IMG: ... :IMG##
|
| 65 |
img_pattern = r"##IMG:(.+?):IMG##"
|
| 66 |
img_matches = re.findall(img_pattern, bot_response)
|
|
|
|
| 67 |
if img_matches:
|
| 68 |
tags['images'] = img_matches
|
| 69 |
# Remove image tags from the response text
|
| 70 |
filtered_response = re.sub(img_pattern, "", filtered_response).strip()
|
| 71 |
|
| 72 |
+
|
| 73 |
# Additional tags can be added here as needed
|
| 74 |
# For example, if you want to support ##AUDIO: ... :AUDIO## tags:
|
| 75 |
# audio_pattern = r"##AUDIO:(.+?):AUDIO##"
|