Spaces:
Runtime error
Runtime error
added examples
Browse files- app_dialogue.py +32 -6
app_dialogue.py
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
import os
|
2 |
-
|
3 |
import gradio as gr
|
4 |
|
5 |
|
@@ -446,11 +445,23 @@ with gr.Blocks(title="IDEFICS", theme=gr.themes.Base()) as demo:
|
|
446 |
with gr.Column(scale=1, min_width=20):
|
447 |
clear_btn = gr.ClearButton([textbox, chatbot])
|
448 |
cur_dir = os.path.dirname(os.path.abspath(__file__))
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
454 |
# examples=[
|
455 |
# [
|
456 |
# ("How many of these animals can we fit into an engine like that<fake_token_around_image><image:https://upload.wikimedia.org/wikipedia/commons/thumb/4/4e/Nassau_County_Police_Bell_407.jpg/1200px-Nassau_County_Police_Bell_407.jpg><fake_token_around_image>?", "The image shows a helicopter with a large engine, but it is not possible to determine the exact number of animals that can fit into it based on the image alone. The size and capacity of the helicopter's engine would depend on various factors, such as the size of the animals, the weight of the animals, and the size of the helicopter itself. However, it is safe to assume that the helicopter is designed to carry a limited number of animals, and it is not intended to be used as a means of transporting large groups of animals."),
|
@@ -459,6 +470,21 @@ with gr.Blocks(title="IDEFICS", theme=gr.themes.Base()) as demo:
|
|
459 |
# inputs = [chatbot]
|
460 |
# )
|
461 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
462 |
def format_prompt_with_history_and_system_conditioning(current_user_prompt, history):
|
463 |
resulting_text = SYSTEM_PROMPT
|
464 |
for turn in history:
|
|
|
1 |
import os
|
|
|
2 |
import gradio as gr
|
3 |
|
4 |
|
|
|
445 |
with gr.Column(scale=1, min_width=20):
|
446 |
clear_btn = gr.ClearButton([textbox, chatbot])
|
447 |
cur_dir = os.path.dirname(os.path.abspath(__file__))
|
448 |
+
|
449 |
+
def process_example(message: str) -> tuple[str, list[tuple[str, str]]]:
|
450 |
+
chat = model_inference(message, [], "greedy", 3, 1.0, 0, 512, 16, 1.0, 1.0, 50, 0.95, 0.95)
|
451 |
+
return '', chat
|
452 |
+
|
453 |
+
gr.Examples(examples=[
|
454 |
+
[f"{cur_dir}/examples/extreme_ironing.jpg", "What is unusual about this image?"],
|
455 |
+
[f"{cur_dir}/examples/waterview.jpg", "What are the things I should be cautious about when I visit here?"],
|
456 |
+
["m4-dialogue/images", "Describe this image"],
|
457 |
+
],
|
458 |
+
inputs=[textbox],
|
459 |
+
outputs=[textbox, chatbot],
|
460 |
+
fn=process_example,
|
461 |
+
cache_examples=True,
|
462 |
+
)
|
463 |
+
|
464 |
+
#gr.Examples(
|
465 |
# examples=[
|
466 |
# [
|
467 |
# ("How many of these animals can we fit into an engine like that<fake_token_around_image><image:https://upload.wikimedia.org/wikipedia/commons/thumb/4/4e/Nassau_County_Police_Bell_407.jpg/1200px-Nassau_County_Police_Bell_407.jpg><fake_token_around_image>?", "The image shows a helicopter with a large engine, but it is not possible to determine the exact number of animals that can fit into it based on the image alone. The size and capacity of the helicopter's engine would depend on various factors, such as the size of the animals, the weight of the animals, and the size of the helicopter itself. However, it is safe to assume that the helicopter is designed to carry a limited number of animals, and it is not intended to be used as a means of transporting large groups of animals."),
|
|
|
470 |
# inputs = [chatbot]
|
471 |
# )
|
472 |
|
473 |
+
|
474 |
+
#gr.Examples(
|
475 |
+
# examples=[
|
476 |
+
# 'Hello there! How are you doing?',
|
477 |
+
# 'Can you explain briefly to me what is the Python programming language?',
|
478 |
+
# 'Explain the plot of Cinderella in a sentence.',
|
479 |
+
# 'How many hours does it take a man to eat a Helicopter?',
|
480 |
+
# "Write a 100-word article on 'Benefits of Open-Source in AI research'",
|
481 |
+
# ],
|
482 |
+
# inputs=textbox,
|
483 |
+
# outputs=[textbox, chatbot],
|
484 |
+
# fn=process_example,
|
485 |
+
# cache_examples=True,
|
486 |
+
#)
|
487 |
+
|
488 |
def format_prompt_with_history_and_system_conditioning(current_user_prompt, history):
|
489 |
resulting_text = SYSTEM_PROMPT
|
490 |
for turn in history:
|