File size: 1,247 Bytes
73f064f aab9585 9ffdbf7 aab9585 9ffdbf7 aab9585 c0179c2 fc2060d 73f064f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
"""
File: module_chat.py
Description: A module for chat using text (+images) with a multimodal interface.
Author: Didier Guillevic
Date: 2025-03-16
"""
import gradio as gr
import vlm
def process(message, history):
"""Generate the model response given message and history
"""
messages = vlm.build_messages(message, history)
return vlm.get_response(messages)
#
# User interface
#
with gr.Blocks() as demo:
chat_interface = gr.ChatInterface(
fn=process,
#description="Chat with text or text+image.",
multimodal=True,
examples=[
"How can we rationalize quantum entanglement?",
"Peux-tu expliquer le terme 'quantum spin'?",
{
'files': ['./passport_jp.png',],
'text': 'Can you extract the information present in the image?'
},
{
'files': ['./sample_ID.jpeg',], 'text':
'Describe this image in a few words.'
},
{
'files': ['./sample_ID.jpeg',],
'text': 'Could you extract the information present in the image?'
},
],
cache_examples=False
)
if __name__ == "__main__":
demo.launch()
|