Spaces:
Sleeping
Sleeping
Tim Seufert commited on
Commit ·
3dd810e
1
Parent(s): dfe7beb
visionbetaupdate
Browse files
app.py
CHANGED
|
@@ -36,24 +36,23 @@ def respond(message, history):
|
|
| 36 |
# Base64-Kodierung des Bildes
|
| 37 |
base64_image = encode_image_to_base64(current_image)
|
| 38 |
|
| 39 |
-
# Vision-Anfrage mit Bild und Text
|
| 40 |
response = co.chat(
|
| 41 |
model='c4ai-aya-vision-8b',
|
| 42 |
message=f"{message}",
|
| 43 |
temperature=0.3,
|
| 44 |
chat_history=[],
|
| 45 |
-
tools=[],
|
| 46 |
attachments=[{"source": {"type": "base64", "media_type": "image/jpeg", "data": base64_image}}]
|
| 47 |
)
|
| 48 |
|
| 49 |
# Bild nach Verwendung zurücksetzen
|
| 50 |
current_image = None
|
| 51 |
-
|
| 52 |
return response.text
|
| 53 |
else:
|
| 54 |
# Normale Textanfrage ohne Bild
|
| 55 |
stream = co.chat_stream(
|
| 56 |
-
model='c4ai-aya-vision-8b',
|
| 57 |
message=f"{prompt} '{message}'",
|
| 58 |
temperature=0.3,
|
| 59 |
chat_history=[],
|
|
@@ -81,13 +80,15 @@ def set_image(image):
|
|
| 81 |
|
| 82 |
# Kombiniertes Interface mit Blocks
|
| 83 |
with gr.Blocks() as demo:
|
| 84 |
-
# ChatInterface
|
| 85 |
chat_interface = gr.ChatInterface(
|
|
|
|
| 86 |
fn=respond,
|
| 87 |
title="SimplestMachine Vision",
|
| 88 |
description="Stellen Sie mir Fragen oder laden Sie ein Bild hoch, und ich werde es analysieren!",
|
| 89 |
theme="soft",
|
| 90 |
-
examples=["Wie geht es dir?", "Was ist künstliche Intelligenz?", "Beschreibe dieses Bild"]
|
|
|
|
| 91 |
)
|
| 92 |
|
| 93 |
# Bildupload-Bereich unten mit Accordion
|
|
@@ -103,7 +104,6 @@ with gr.Blocks() as demo:
|
|
| 103 |
# Anwendung starten
|
| 104 |
if __name__ == "__main__":
|
| 105 |
demo.launch(
|
| 106 |
-
share=True,
|
| 107 |
server_name="0.0.0.0",
|
| 108 |
allowed_paths=["*"]
|
| 109 |
)
|
|
|
|
| 36 |
# Base64-Kodierung des Bildes
|
| 37 |
base64_image = encode_image_to_base64(current_image)
|
| 38 |
|
| 39 |
+
# Vision-Anfrage mit Bild und Text - OHNE tools Parameter
|
| 40 |
response = co.chat(
|
| 41 |
model='c4ai-aya-vision-8b',
|
| 42 |
message=f"{message}",
|
| 43 |
temperature=0.3,
|
| 44 |
chat_history=[],
|
|
|
|
| 45 |
attachments=[{"source": {"type": "base64", "media_type": "image/jpeg", "data": base64_image}}]
|
| 46 |
)
|
| 47 |
|
| 48 |
# Bild nach Verwendung zurücksetzen
|
| 49 |
current_image = None
|
| 50 |
+
|
| 51 |
return response.text
|
| 52 |
else:
|
| 53 |
# Normale Textanfrage ohne Bild
|
| 54 |
stream = co.chat_stream(
|
| 55 |
+
model='c4ai-aya-vision-8b',
|
| 56 |
message=f"{prompt} '{message}'",
|
| 57 |
temperature=0.3,
|
| 58 |
chat_history=[],
|
|
|
|
| 80 |
|
| 81 |
# Kombiniertes Interface mit Blocks
|
| 82 |
with gr.Blocks() as demo:
|
| 83 |
+
# ChatInterface mit message-Type
|
| 84 |
chat_interface = gr.ChatInterface(
|
| 85 |
+
#(c)Tim Seufert 2024
|
| 86 |
fn=respond,
|
| 87 |
title="SimplestMachine Vision",
|
| 88 |
description="Stellen Sie mir Fragen oder laden Sie ein Bild hoch, und ich werde es analysieren!",
|
| 89 |
theme="soft",
|
| 90 |
+
examples=["Wie geht es dir?", "Was ist künstliche Intelligenz?", "Beschreibe dieses Bild"],
|
| 91 |
+
type="messages" # Moderneres Nachrichtenformat verwenden
|
| 92 |
)
|
| 93 |
|
| 94 |
# Bildupload-Bereich unten mit Accordion
|
|
|
|
| 104 |
# Anwendung starten
|
| 105 |
if __name__ == "__main__":
|
| 106 |
demo.launch(
|
|
|
|
| 107 |
server_name="0.0.0.0",
|
| 108 |
allowed_paths=["*"]
|
| 109 |
)
|