Biochemistry3.0 / app.py
ziyadsuper2017's picture
test.py
f1da378
raw
history blame
1.34 kB
import tkinter as tk
import cohere
# Initialize the Cohere client
co = cohere.Client('mTeiGiDIpi4R7perkfRnMnCmi5jJzM8QziDVPrG8') # Replace with your API key
# Create a function to generate text based on user input
def generate_text():
prompt = input_box.get("1.0", "end-1c") # Get the text from the input box
response = co.generate(
model='9b2e329d-7542-4c44-8f8c-cac03a6c4f5a-ft',
prompt=prompt
)
output_text.config(state="normal") # Allow editing of the output box
output_text.delete("1.0", "end") # Clear the previous output
output_text.insert("1.0", response.generations[0].text) # Display the new output
output_text.config(state="disabled") # Disable editing of the output box
# Create the main GUI window
root = tk.Tk()
root.title("Cohere Text Generation")
# Create an input box
input_label = tk.Label(root, text="Enter your prompt:")
input_label.pack()
input_box = tk.Text(root, height=5, width=40)
input_box.pack()
# Create a button to generate text
generate_button = tk.Button(root, text="Generate", command=generate_text)
generate_button.pack()
# Create an output box
output_label = tk.Label(root, text="Generated Text:")
output_label.pack()
output_text = tk.Text(root, height=10, width=40, state="disabled")
output_text.pack()
# Start the GUI event loop
root.mainloop()