File size: 1,690 Bytes
d87b93c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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()