import tkinter as tk from tkinter import messagebox import requests def generate_protocol(): # Get the user input from the text box user_input = input_text.get("1.0", tk.END).strip() # Make a request to the Claude AI API to generate the protocol api_key = "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" api_url = "https://api.anthropic.com/v1/complete" headers = { "Content-Type": "application/json", "X-API-Key": api_key } data = { "prompt": f"Generate an Opentrons Flex protocol based on the following requirements:\n{user_input}", "model": "claude-v1", "max_tokens_to_sample": 1000 } response = requests.post(api_url, headers=headers, json=data) if response.status_code == 200: protocol_code = response.json()["completion"] # Save the generated protocol as a Python file with open("generated_protocol.py", "w") as file: file.write(protocol_code) messagebox.showinfo("Success", "Protocol generated successfully!") else: messagebox.showerror("Error", "Failed to generate the protocol.") # Create the main window window = tk.Tk() window.title("Opentrons Flex Protocol Generator") # Create the input label and text box input_label = tk.Label(window, text="Enter protocol requirements:") input_label.pack() input_text = tk.Text(window, height=10, width=50) input_text.pack() # Create the generate button generate_button = tk.Button(window, text="Generate Protocol", command=generate_protocol) generate_button.pack() # Run the main event loop window.mainloop()