Spaces:
Sleeping
Sleeping
Tim Seufert commited on
Commit ·
3998f6f
1
Parent(s): 2f3d984
model update
Browse files
app.py
CHANGED
|
@@ -18,13 +18,19 @@ api_key = os.environ.get("apikeysimple")
|
|
| 18 |
# Client außerhalb der Funktion initialisieren
|
| 19 |
co = cohere.Client(api_key=api_key)
|
| 20 |
|
| 21 |
-
def respond(message, history):
|
| 22 |
"""Einfache Antwortfunktion für das Gradio-Chatinterface"""
|
| 23 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
|
|
|
| 25 |
stream = co.chat_stream(
|
| 26 |
-
model='
|
| 27 |
-
message=f"{prompt} '{message}'",
|
| 28 |
temperature=0.3,
|
| 29 |
chat_history=[], # Consider using chat_history for context
|
| 30 |
prompt_truncation='AUTO',
|
|
@@ -57,6 +63,17 @@ demo = gr.ChatInterface(
|
|
| 57 |
#description2="SimplestMachine hat keinen Zugriff auf echtzeitinformationen. AI kann fehler machen.",
|
| 58 |
)
|
| 59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
# Anwendung starten
|
| 61 |
if __name__ == "__main__":
|
| 62 |
demo.launch(
|
|
|
|
| 18 |
# Client außerhalb der Funktion initialisieren
|
| 19 |
co = cohere.Client(api_key=api_key)
|
| 20 |
|
| 21 |
+
def respond(message, image, history):
|
| 22 |
"""Einfache Antwortfunktion für das Gradio-Chatinterface"""
|
| 23 |
try:
|
| 24 |
+
#Bildverarbeitung
|
| 25 |
+
image_context = ""
|
| 26 |
+
if image is not None:
|
| 27 |
+
image_context = "\nEin Bild wurde Hochgeladen."
|
| 28 |
+
|
| 29 |
|
| 30 |
+
# Chat stream erstellen
|
| 31 |
stream = co.chat_stream(
|
| 32 |
+
model='c4ai-aya-vision-8b',
|
| 33 |
+
message=f"{prompt} '{message}' {image_context}",
|
| 34 |
temperature=0.3,
|
| 35 |
chat_history=[], # Consider using chat_history for context
|
| 36 |
prompt_truncation='AUTO',
|
|
|
|
| 63 |
#description2="SimplestMachine hat keinen Zugriff auf echtzeitinformationen. AI kann fehler machen.",
|
| 64 |
)
|
| 65 |
|
| 66 |
+
#Gradio Interface für Bildverarbeitung
|
| 67 |
+
with gr.Blocks() as demo:
|
| 68 |
+
chatbot = gr.Chatbot()
|
| 69 |
+
with gr.Row():
|
| 70 |
+
txt = gr.Textbox(show_label=False, placeholder="Stellen Sie Ihre Frage...")
|
| 71 |
+
img = gr.Image(type="filepath", label="Bittw Bild hochladen oder Aufnehmen")
|
| 72 |
+
|
| 73 |
+
txt.submit(respond, [txt, img, chatbot], [chatbot])
|
| 74 |
+
clear = gr.Clearbutton(txt, img, chatbot)
|
| 75 |
+
|
| 76 |
+
|
| 77 |
# Anwendung starten
|
| 78 |
if __name__ == "__main__":
|
| 79 |
demo.launch(
|