File size: 909 Bytes
fd0e912
 
c693731
fd0e912
4d991c9
c693731
fd0e912
 
 
 
 
 
edb8721
fd0e912
 
 
 
 
 
 
 
 
 
 
 
 
7fb9cbe
fd0e912
dd44da8
fd0e912
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
import gradio as gr
from transformers import pipeline

# Load the model pipeline
pipe = pipeline("image-text-to-text", model="deepseek-ai/deepseek-vl2-small", trust_remote_code=True)

def chatbot(user_input):
    """
    Function to process user input using the DeepSeek-VL2-Small model.
    """
    messages = [{"role": "user", "content": user_input}]
    response = pipe(messages)
    
    if isinstance(response, list) and len(response) > 0:
        return response[0]["generated_text"]  # Extract response text
    else:
        return "No response received."

# Create a Gradio interface
demo = gr.Interface(
    fn=chatbot,
    inputs=gr.Textbox(lines=2, placeholder="Ask something..."),
    outputs="text",
    title="DeepSeek-VL2 Chatbot",
    description="Ask questions and get AI-generated responses using DeepSeek-VL2-Small."
)

# Launch the Gradio app
if __name__ == "__main__":
    demo.launch()