forked from ruvnet/rUv-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
super_coder.py
141 lines (119 loc) · 6.33 KB
/
super_coder.py
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
from interpreter import interpreter
def launch_super_coder():
while True:
print("\nSuper Coder Menu:")
print("1. Create New Application from Prompt")
print("2. Load from Template")
print("3. Autonomous Coding")
print("4. Advanced Settings")
print("5. Manage Prompt Folder")
print("6. Return to Main Menu")
super_coder_choice = input("Enter your choice (1-6): ")
# Set interpreter to auto-run
interpreter.auto_run = True
if super_coder_choice == "1":
app_name = input("Enter the name of the new application: ")
app_prompt = input("Enter the prompt to specify the application: ")
print(f"✅ New application {app_name} setup initiated.")
while True:
print("\nDo you want to:")
print("1. Continue development")
print("2. Provide guidance")
print("3. Return to Super Coder Menu")
choice = input("Enter your choice (1-3): ")
if choice == "1":
print("Continuing development...")
response = interpreter.chat(f"Continue developing the {app_name} application based on the prompt: {app_prompt}")
print(response)
elif choice == "2":
guidance = input("Enter your guidance: ")
response = interpreter.chat(f"Provide guidance for the current development of {app_name}: {guidance}")
print(response)
elif choice == "3":
break
else:
print("Invalid choice. Please try again.")
elif super_coder_choice == "2":
print("\nAvailable Templates:")
print("1. PyTorch Application")
print("2. Machine Learning Pipeline")
print("3. Mergekit Integration")
print("4. Go Back")
template_choice = input("Enter your choice (1-4): ")
template_instructions = {
"1": "Create a PyTorch application template with basic structure and dependencies.",
"2": "Create a machine learning pipeline template with data preprocessing, model training, and evaluation steps.",
"3": "Create a template that demonstrates the integration of Mergekit library for advanced functionality."
}
if template_choice in template_instructions:
instruction = template_instructions[template_choice]
print(f"Loading {instruction.split()[2]} template...")
# Execute the interpreter chat command with the given instruction
response = interpreter.chat(instruction)
print(response)
print(f"✅ Template for {instruction.split()[2]} loaded successfully!")
elif template_choice == "4":
continue
else:
print("Invalid choice. Please try again.")
elif super_coder_choice == "3":
print("Autonomous Coding Mode")
prompt = input("Enter your coding prompt: ")
while True:
try:
auto_steps = int(input("Enter the number of automatic steps before user input (0 for manual mode): "))
break
except ValueError:
print("Invalid input. Please enter a valid integer.")
while True:
try:
additional_steps = int(input("Enter the number of additional steps after the initial steps (0 for no additional steps): "))
break
except ValueError:
print("Invalid input. Please enter a valid integer.")
def autonomous_coding(prompt, steps, additional_steps):
if steps == 0:
while True:
print("\nDo you want to:")
print("1. Continue development")
print("2. Provide guidance")
print("3. Return to Super Coder Menu")
choice = input("Enter your choice (1-3): ")
if choice == "1":
print("Continuing development...")
response = interpreter.chat(f"Continue developing the code based on the previous prompt: {prompt}")
print(response)
elif choice == "2":
guidance = input("Enter your guidance: ")
response = interpreter.chat(f"Provide guidance for the current development: {guidance}")
print(response)
elif choice == "3":
break
else:
print("Invalid choice. Please try again.")
else:
for i in range(steps):
print(f"\nAutonomous Coding Step {i+1}/{steps}")
response = interpreter.chat(f"Continue developing the code autonomously based on the prompt: {prompt}")
print(response)
if additional_steps > 0:
for i in range(additional_steps):
print(f"\nAdditional Autonomous Coding Step {i+1}/{additional_steps}")
response = interpreter.chat(f"Continue developing the code autonomously based on the prompt: {prompt}")
print(response)
autonomous_coding(prompt, 0, 0)
autonomous_coding(prompt, auto_steps, additional_steps)
elif super_coder_choice == "4":
# Placeholder for advanced settings
print("Advanced Settings functionality to be implemented.")
elif super_coder_choice == "5":
# Placeholder for managing prompt folder
print("Manage Prompt Folder functionality to be implemented.")
elif super_coder_choice == "6":
print("Returning to the main menu...")
break
else:
print("Invalid choice. Please try again.")
print("Super Coder session completed successfully!")
if __name__ == "__main__":
launch_super_coder()