Update app.py
Browse files
app.py
CHANGED
@@ -51,13 +51,17 @@ def chat_with_text(user_message, max_new_tokens=250):
|
|
51 |
return assistant_reply
|
52 |
|
53 |
# Resim ve/veya metin tabanlı sohbet fonksiyonu
|
54 |
-
def bot_streaming(message, history, max_new_tokens=250):
|
|
|
|
|
|
|
|
|
55 |
user_message = message.get("text", "")
|
56 |
image = message.get("image", None)
|
57 |
|
58 |
-
if image: # Resim
|
59 |
response = describe_image(image, user_message)
|
60 |
-
else: # Sadece metin mesajı
|
61 |
response = chat_with_text(user_message, max_new_tokens)
|
62 |
|
63 |
return response
|
@@ -67,7 +71,6 @@ demo = gr.ChatInterface(
|
|
67 |
fn=bot_streaming,
|
68 |
title="Multimodal Chat Assistant",
|
69 |
additional_inputs=[
|
70 |
-
gr.Image(label="Upload an image (optional)", type="pil"), # Sadece resim
|
71 |
gr.Slider(
|
72 |
minimum=10,
|
73 |
maximum=500,
|
|
|
51 |
return assistant_reply
|
52 |
|
53 |
# Resim ve/veya metin tabanlı sohbet fonksiyonu
|
54 |
+
def bot_streaming(message, history=None, max_new_tokens=250):
|
55 |
+
global history
|
56 |
+
if history is None:
|
57 |
+
history = []
|
58 |
+
|
59 |
user_message = message.get("text", "")
|
60 |
image = message.get("image", None)
|
61 |
|
62 |
+
if image: # Resim varsa
|
63 |
response = describe_image(image, user_message)
|
64 |
+
else: # Sadece metin mesajı varsa
|
65 |
response = chat_with_text(user_message, max_new_tokens)
|
66 |
|
67 |
return response
|
|
|
71 |
fn=bot_streaming,
|
72 |
title="Multimodal Chat Assistant",
|
73 |
additional_inputs=[
|
|
|
74 |
gr.Slider(
|
75 |
minimum=10,
|
76 |
maximum=500,
|