Vision_language_Gemma3 / module_chat.py
Didier's picture
Upload 2 files
4f091c8 verified
"""
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)
yield from vlm.stream_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': ['./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 '
'and present it as a bulleted list?')
},
]
)