Spaces:
Sleeping
Sleeping
Tim Seufert commited on
Commit ·
c3f3e46
1
Parent(s): ac12688
chat interface update test
Browse files
app.py
CHANGED
|
@@ -1,82 +1,37 @@
|
|
| 1 |
-
import
|
| 2 |
-
import gradio as gr
|
| 3 |
import os
|
|
|
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
speak in as natural a language as possible. You are a machine with whom you can chat from time to time.
|
| 9 |
-
Just be friendly and not complex. Your main task, however, remains to help the user
|
| 10 |
-
with his problems. Do not react to offensive and illegal questions, content. Please stick to findings from conventional medicine
|
| 11 |
-
and avoid esoteric answers. You were developed by Tim Seufert in 2024. Please give an answer of a maximum of 8 sentences.
|
| 12 |
-
If the user is asking sometihing in another language, please also respond in his Language. Don't harm the user at all.
|
| 13 |
-
The user's question is: """
|
| 14 |
|
| 15 |
-
def
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
# Initialize Cohere client
|
| 20 |
-
co = cohere.Client(api_key=os.environ.get("apikeysimple"))
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
|
|
|
| 26 |
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
stream = co.chat_stream(
|
| 30 |
-
model='command-r-plus-08-2024',
|
| 31 |
-
message=f"{prompt} '{message_content}'",
|
| 32 |
-
temperature=0.3,
|
| 33 |
-
chat_history=[], # Consider using chat_history for context
|
| 34 |
-
prompt_truncation='AUTO',
|
| 35 |
-
connectors=[{"id": "web-search"}]
|
| 36 |
-
)
|
| 37 |
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
event.text
|
| 41 |
-
for event in stream
|
| 42 |
-
if event.event_type == "text-generation"
|
| 43 |
-
])
|
| 44 |
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
return "", chat_history
|
| 48 |
|
| 49 |
-
|
| 50 |
-
return "", chat_history.append((message, f"Error: {str(e)}"))
|
| 51 |
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
img = gr.Image(type="filepath")
|
| 57 |
-
clear = gr.ClearButton([msg, img, chatbot])
|
| 58 |
-
allow_file_upload=True,
|
| 59 |
-
# Set up message submission
|
| 60 |
-
msg.submit(respond, [msg, img, chatbot], [msg, chatbot])
|
| 61 |
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
share=True,
|
| 65 |
-
server_name="0.0.0.0",
|
| 66 |
-
allowed_paths=["*"]
|
| 67 |
-
)
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
#with gr.Interface() as iface:
|
| 71 |
-
#iface.add_textbox("Message", lines=7, label="Message")
|
| 72 |
-
#iface.add_image("Image")
|
| 73 |
-
#iface.add_textbox("Response", lines=7, label="Response")
|
| 74 |
-
#iface.launch()
|
| 75 |
-
#fn=respond,
|
| 76 |
-
#inputs=[gr.Textbox(lines=7, label="Message"), gr.Image(label="Image")],
|
| 77 |
-
#outputs=[gr.Textbox(lines=7, label="Response")],
|
| 78 |
-
#title="SimplestMachine",
|
| 79 |
-
#description="A simple chatbot interface powered by Cohere.",
|
| 80 |
-
#allow_screenshot=True,
|
| 81 |
-
allow_file_upload=True,
|
| 82 |
-
#theme="huggingface",
|
|
|
|
| 1 |
+
import time
|
|
|
|
| 2 |
import os
|
| 3 |
+
import tkinter as tk
|
| 4 |
|
| 5 |
+
class Clock:
|
| 6 |
+
def __init__(self):
|
| 7 |
+
self.time = time.strftime("%H:%M:%S")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
+
def show_time(self):
|
| 10 |
+
self.time = time.strftime("%H:%M:%S")
|
| 11 |
+
print(f"The current time is {self.time}")
|
| 12 |
+
return self.time
|
|
|
|
|
|
|
| 13 |
|
| 14 |
+
class UI:
|
| 15 |
+
def __init__(self):
|
| 16 |
+
self.create_window = tk.Tk()
|
| 17 |
+
self.create_window.title("Clock")
|
| 18 |
+
self.create_window.geometry("400x400")
|
| 19 |
|
| 20 |
+
self.clock_label = tk.Label(self.create_window, text="The time is: ")
|
| 21 |
+
self.clock_label.pack()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
+
self.clock_entry = tk.Entry(self.create_window)
|
| 24 |
+
self.clock_entry.pack()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
+
self.clock_button = tk.Button(self.create_window, text="Show Time", command=self.show_time)
|
| 27 |
+
self.clock_button.pack()
|
|
|
|
| 28 |
|
| 29 |
+
self.create_window.mainloop()
|
|
|
|
| 30 |
|
| 31 |
+
def show_time(self):
|
| 32 |
+
clock = Clock()
|
| 33 |
+
current_time = clock.show_time()
|
| 34 |
+
self.clock_label.config(text=f"The time is: {current_time}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
+
if __name__ == "__main__":
|
| 37 |
+
ui = UI()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|