|
import tkinter as tk |
|
from tkinter import messagebox |
|
import requests |
|
|
|
def generate_protocol(): |
|
|
|
user_input = input_text.get("1.0", tk.END).strip() |
|
|
|
|
|
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"] |
|
|
|
|
|
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.") |
|
|
|
|
|
window = tk.Tk() |
|
window.title("Opentrons Flex Protocol Generator") |
|
|
|
|
|
input_label = tk.Label(window, text="Enter protocol requirements:") |
|
input_label.pack() |
|
|
|
input_text = tk.Text(window, height=10, width=50) |
|
input_text.pack() |
|
|
|
|
|
generate_button = tk.Button(window, text="Generate Protocol", command=generate_protocol) |
|
generate_button.pack() |
|
|
|
|
|
window.mainloop() |