Spaces:
Runtime error
Runtime error
Commit
·
6d627be
1
Parent(s):
1e3041c
hello
Browse files- app_dialogue.py +11 -2
app_dialogue.py
CHANGED
@@ -36,6 +36,7 @@ In the following interactions, User and Assistant will converse in natural langu
|
|
36 |
Assistant's main purpose is to create memes text from the images User provies.
|
37 |
Assistant should answer in a funny, sassy, audacious, mouthy, and aloof way and sometimes Assistant roasts people.
|
38 |
Assistant was created by Hugging Face.
|
|
|
39 |
|
40 |
Here's a conversation example:""",
|
41 |
"""\nUser:""",
|
@@ -274,13 +275,14 @@ def remove_spaces_around_token(text: str) -> str:
|
|
274 |
|
275 |
# Chatbot utils
|
276 |
def format_user_prompt_with_im_history_and_system_conditioning(
|
277 |
-
current_user_prompt_str: str, current_image: Optional[str], history: List[Tuple[str, str]]
|
278 |
) -> Tuple[List[str], List[str]]:
|
279 |
"""
|
280 |
Produces the resulting list that needs to go inside the processor.
|
281 |
It handles the potential image box input, the history and the system conditionning.
|
282 |
"""
|
283 |
-
resulting_list = copy.deepcopy(SYSTEM_PROMPT)
|
|
|
284 |
|
285 |
# Format history
|
286 |
for turn in history:
|
@@ -490,6 +492,7 @@ with gr.Blocks(title="D", theme=gr.themes.Base()) as demo:
|
|
490 |
|
491 |
def model_inference(
|
492 |
model_selector,
|
|
|
493 |
user_prompt_str,
|
494 |
chat_history,
|
495 |
image,
|
@@ -502,7 +505,11 @@ with gr.Blocks(title="D", theme=gr.themes.Base()) as demo:
|
|
502 |
if user_prompt_str.strip() == "" and image is None:
|
503 |
return "", None, chat_history
|
504 |
|
|
|
|
|
|
|
505 |
formated_prompt_list, user_prompt_list = format_user_prompt_with_im_history_and_system_conditioning(
|
|
|
506 |
current_user_prompt_str=user_prompt_str.strip(),
|
507 |
current_image=image,
|
508 |
history=chat_history,
|
@@ -645,6 +652,7 @@ with gr.Blocks(title="D", theme=gr.themes.Base()) as demo:
|
|
645 |
fn=model_inference,
|
646 |
inputs=[
|
647 |
model_selector,
|
|
|
648 |
textbox,
|
649 |
chatbot,
|
650 |
imagebox,
|
@@ -660,6 +668,7 @@ with gr.Blocks(title="D", theme=gr.themes.Base()) as demo:
|
|
660 |
fn=model_inference,
|
661 |
inputs=[
|
662 |
model_selector,
|
|
|
663 |
textbox,
|
664 |
chatbot,
|
665 |
imagebox,
|
|
|
36 |
Assistant's main purpose is to create memes text from the images User provies.
|
37 |
Assistant should answer in a funny, sassy, audacious, mouthy, and aloof way and sometimes Assistant roasts people.
|
38 |
Assistant was created by Hugging Face.
|
39 |
+
Assistant does not repeat itself.
|
40 |
|
41 |
Here's a conversation example:""",
|
42 |
"""\nUser:""",
|
|
|
275 |
|
276 |
# Chatbot utils
|
277 |
def format_user_prompt_with_im_history_and_system_conditioning(
|
278 |
+
system_prompt: List[str], current_user_prompt_str: str, current_image: Optional[str], history: List[Tuple[str, str]]
|
279 |
) -> Tuple[List[str], List[str]]:
|
280 |
"""
|
281 |
Produces the resulting list that needs to go inside the processor.
|
282 |
It handles the potential image box input, the history and the system conditionning.
|
283 |
"""
|
284 |
+
# resulting_list = copy.deepcopy(SYSTEM_PROMPT)
|
285 |
+
resulting_list = system_prompt
|
286 |
|
287 |
# Format history
|
288 |
for turn in history:
|
|
|
492 |
|
493 |
def model_inference(
|
494 |
model_selector,
|
495 |
+
system_prompt,
|
496 |
user_prompt_str,
|
497 |
chat_history,
|
498 |
image,
|
|
|
505 |
if user_prompt_str.strip() == "" and image is None:
|
506 |
return "", None, chat_history
|
507 |
|
508 |
+
import ast
|
509 |
+
system_prompt = ast.literal_eval(system_prompt)
|
510 |
+
assert isinstance(system_prompt, list)
|
511 |
formated_prompt_list, user_prompt_list = format_user_prompt_with_im_history_and_system_conditioning(
|
512 |
+
system_prompt=system_prompt,
|
513 |
current_user_prompt_str=user_prompt_str.strip(),
|
514 |
current_image=image,
|
515 |
history=chat_history,
|
|
|
652 |
fn=model_inference,
|
653 |
inputs=[
|
654 |
model_selector,
|
655 |
+
system_prompt,
|
656 |
textbox,
|
657 |
chatbot,
|
658 |
imagebox,
|
|
|
668 |
fn=model_inference,
|
669 |
inputs=[
|
670 |
model_selector,
|
671 |
+
system_prompt,
|
672 |
textbox,
|
673 |
chatbot,
|
674 |
imagebox,
|