Spaces:
Running
on
Zero
Running
on
Zero
Upload llmdolphin.py
Browse files- llmdolphin.py +9 -6
llmdolphin.py
CHANGED
|
@@ -355,6 +355,13 @@ def select_dolphin_language(lang: str):
|
|
| 355 |
return gr.update(value=get_dolphin_sysprompt())
|
| 356 |
|
| 357 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 358 |
@spaces.GPU
|
| 359 |
def dolphin_respond(
|
| 360 |
message: str,
|
|
@@ -430,7 +437,6 @@ def dolphin_respond(
|
|
| 430 |
yield [(outputs, None)]
|
| 431 |
|
| 432 |
|
| 433 |
-
@timeout_decorator.timeout(15, use_signals=False)
|
| 434 |
def dolphin_parse(
|
| 435 |
history: list[tuple[str, str]],
|
| 436 |
):
|
|
@@ -440,8 +446,7 @@ def dolphin_parse(
|
|
| 440 |
msg = history[-1][0]
|
| 441 |
except Exception:
|
| 442 |
return ""
|
| 443 |
-
|
| 444 |
-
raw_prompt = re.sub(r'[*/:_"#]|\n', ' ', ", ".join(m)).lower() if m else ""
|
| 445 |
prompts = []
|
| 446 |
if dolphin_sysprompt_mode == "Japanese to Danbooru Dictionary" and is_japanese(raw_prompt):
|
| 447 |
prompts = list_uniq(jatags_to_danbooru_tags(to_list_ja(raw_prompt)) + ["nsfw", "explicit"])
|
|
@@ -528,7 +533,6 @@ def dolphin_respond_auto(
|
|
| 528 |
yield [(outputs, None)]
|
| 529 |
|
| 530 |
|
| 531 |
-
@timeout_decorator.timeout(15, use_signals=False)
|
| 532 |
def dolphin_parse_simple(
|
| 533 |
message: str,
|
| 534 |
history: list[tuple[str, str]],
|
|
@@ -540,8 +544,7 @@ def dolphin_parse_simple(
|
|
| 540 |
msg = history[-1][0]
|
| 541 |
except Exception:
|
| 542 |
return ""
|
| 543 |
-
|
| 544 |
-
raw_prompt = re.sub(r'[*/:_"#]|\n', ' ', ", ".join(m)).lower() if m else ""
|
| 545 |
prompts = []
|
| 546 |
if dolphin_sysprompt_mode == "Japanese to Danbooru Dictionary" and is_japanese(raw_prompt):
|
| 547 |
prompts = list_uniq(jatags_to_danbooru_tags(to_list_ja(raw_prompt)) + ["nsfw", "explicit"])
|
|
|
|
| 355 |
return gr.update(value=get_dolphin_sysprompt())
|
| 356 |
|
| 357 |
|
| 358 |
+
@timeout_decorator.timeout(15)
|
| 359 |
+
def get_raw_prompt(msg: str):
|
| 360 |
+
import re
|
| 361 |
+
m = re.findall(r'/GENBEGIN/((?:.|\s)+?)/GENEND/', msg)
|
| 362 |
+
return re.sub(r'[*/:_"#]|\n', ' ', ", ".join(m)).lower() if m else ""
|
| 363 |
+
|
| 364 |
+
|
| 365 |
@spaces.GPU
|
| 366 |
def dolphin_respond(
|
| 367 |
message: str,
|
|
|
|
| 437 |
yield [(outputs, None)]
|
| 438 |
|
| 439 |
|
|
|
|
| 440 |
def dolphin_parse(
|
| 441 |
history: list[tuple[str, str]],
|
| 442 |
):
|
|
|
|
| 446 |
msg = history[-1][0]
|
| 447 |
except Exception:
|
| 448 |
return ""
|
| 449 |
+
raw_prompt = get_raw_prompt(msg)
|
|
|
|
| 450 |
prompts = []
|
| 451 |
if dolphin_sysprompt_mode == "Japanese to Danbooru Dictionary" and is_japanese(raw_prompt):
|
| 452 |
prompts = list_uniq(jatags_to_danbooru_tags(to_list_ja(raw_prompt)) + ["nsfw", "explicit"])
|
|
|
|
| 533 |
yield [(outputs, None)]
|
| 534 |
|
| 535 |
|
|
|
|
| 536 |
def dolphin_parse_simple(
|
| 537 |
message: str,
|
| 538 |
history: list[tuple[str, str]],
|
|
|
|
| 544 |
msg = history[-1][0]
|
| 545 |
except Exception:
|
| 546 |
return ""
|
| 547 |
+
raw_prompt = get_raw_prompt(msg)
|
|
|
|
| 548 |
prompts = []
|
| 549 |
if dolphin_sysprompt_mode == "Japanese to Danbooru Dictionary" and is_japanese(raw_prompt):
|
| 550 |
prompts = list_uniq(jatags_to_danbooru_tags(to_list_ja(raw_prompt)) + ["nsfw", "explicit"])
|