Spaces:
Sleeping
Sleeping
lordspline
commited on
Commit
•
3bf7116
1
Parent(s):
b35f5f1
Upload folder using huggingface_hub
Browse files
README.md
CHANGED
@@ -25,4 +25,7 @@ Setup:
|
|
25 |
|
26 |
Barebones Demo:
|
27 |
|
28 |
-
|
|
|
|
|
|
|
|
25 |
|
26 |
Barebones Demo:
|
27 |
|
28 |
+
|
29 |
+
|
30 |
+
https://github.com/lordspline/DevOn/assets/74811063/6de8ba85-3f43-415b-8fd9-eff6b2ed29c5
|
31 |
+
|
agent.py
CHANGED
@@ -10,12 +10,11 @@ import os
|
|
10 |
|
11 |
load_dotenv(".env.local")
|
12 |
|
13 |
-
replit_email = os.getenv("REPLIT_EMAIL")
|
14 |
-
replit_password = os.getenv("REPLIT_PASSWORD")
|
15 |
|
16 |
-
multion_api_key = os.getenv("MULTION_API_KEY")
|
17 |
# multion.login(use_api=True, multion_api_key=multion_api_key)
|
18 |
-
multion = MultiOn(api_key=multion_api_key)
|
19 |
|
20 |
# runpod_url = os.getenv("RUNPOD_URL")
|
21 |
|
@@ -23,38 +22,53 @@ image_temp = "https://miro.medium.com/v2/resize:fit:1200/0*n-2bW82Z6m6U2bij.jpeg
|
|
23 |
|
24 |
|
25 |
class DevOn:
|
26 |
-
def __init__(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
self.editor_image = editor_image
|
28 |
self.browser_image = browser_image
|
29 |
self.scratchpad_image = scratchpad_image
|
30 |
self.local = os.getenv("WHERE_EXECUTE") == "local"
|
31 |
|
32 |
-
self.
|
|
|
|
|
|
|
|
|
|
|
33 |
url="https://replit.com/login", local=self.local, include_screenshot=True
|
34 |
)
|
35 |
self.programmer_logged_in = False
|
36 |
# self.editor_image = self.programmer.screenshot
|
37 |
-
self.editor_image = multion.sessions.screenshot(
|
38 |
session_id=self.programmer.session_id
|
39 |
).screenshot
|
40 |
print(self.editor_image)
|
41 |
time.sleep(1)
|
42 |
# print(self.programmer)
|
43 |
|
44 |
-
self.researcher = multion.sessions.create(
|
45 |
url="https://www.google.com", local=self.local, include_screenshot=True
|
46 |
)
|
47 |
# self.browser_image = self.researcher.screenshot
|
48 |
-
self.browser_image = multion.sessions.screenshot(
|
49 |
session_id=self.researcher.session_id
|
50 |
).screenshot
|
51 |
time.sleep(1)
|
52 |
|
53 |
-
self.notetaker = multion.sessions.create(
|
54 |
url="https://anotepad.com/", local=self.local, include_screenshot=True
|
55 |
)
|
56 |
# self.scratchpad_image = self.notetaker.screenshot
|
57 |
-
self.scratchpad_image = multion.sessions.screenshot(
|
58 |
session_id=self.notetaker.session_id
|
59 |
).screenshot
|
60 |
time.sleep(1)
|
@@ -63,17 +77,17 @@ class DevOn:
|
|
63 |
self.task = ""
|
64 |
self.plan = ""
|
65 |
self.messages = []
|
66 |
-
self.client = OpenAI()
|
67 |
|
68 |
def programmer_login(self):
|
69 |
if self.local:
|
70 |
cmd = "Create a new Python REPL."
|
71 |
else:
|
72 |
cmd = "Log in with the email {email} and the password {password}. Then create a new Python REPL.".format(
|
73 |
-
email=replit_email, password=replit_password
|
74 |
)
|
75 |
while True:
|
76 |
-
self.programmer = multion.sessions.step(
|
77 |
self.programmer.session_id,
|
78 |
cmd=cmd + "\n\n" + programmer_notes,
|
79 |
url="https://replit.com/login",
|
@@ -81,7 +95,7 @@ class DevOn:
|
|
81 |
)
|
82 |
print(self.programmer)
|
83 |
print(
|
84 |
-
multion.sessions.screenshot(
|
85 |
session_id=self.programmer.session_id
|
86 |
).screenshot
|
87 |
)
|
@@ -91,7 +105,7 @@ class DevOn:
|
|
91 |
if self.programmer.status == "DONE":
|
92 |
break
|
93 |
|
94 |
-
self.editor_image = multion.sessions.screenshot(
|
95 |
session_id=self.programmer.session_id
|
96 |
).screenshot
|
97 |
time.sleep(1)
|
@@ -163,7 +177,7 @@ class DevOn:
|
|
163 |
elif action_func == "programmer":
|
164 |
action_arg = action.split(" ", 1)[1]
|
165 |
while True:
|
166 |
-
self.programmer = multion.sessions.step(
|
167 |
self.programmer.session_id,
|
168 |
cmd=action_arg + "\n\n" + programmer_notes,
|
169 |
url="https://replit.com/login",
|
@@ -200,7 +214,7 @@ class DevOn:
|
|
200 |
# yield ("", self.editor_image, self.browser_image, self.scratchpad_image)
|
201 |
if self.programmer.status == "DONE":
|
202 |
break
|
203 |
-
self.editor_image = multion.sessions.screenshot(
|
204 |
session_id=self.programmer.session_id
|
205 |
).screenshot
|
206 |
print(self.editor_image)
|
@@ -209,7 +223,7 @@ class DevOn:
|
|
209 |
elif action_func == "researcher":
|
210 |
action_arg = action.split(" ", 1)[1]
|
211 |
while True:
|
212 |
-
self.researcher = multion.sessions.step(
|
213 |
self.researcher.session_id,
|
214 |
cmd=action_arg,
|
215 |
url="https://www.google.com",
|
@@ -229,7 +243,7 @@ class DevOn:
|
|
229 |
# yield ("", self.editor_image, self.browser_image, self.scratchpad_image)
|
230 |
if self.researcher.status == "DONE":
|
231 |
break
|
232 |
-
self.browser_image = multion.sessions.screenshot(
|
233 |
session_id=self.researcher.session_id
|
234 |
).screenshot
|
235 |
print(self.browser_image)
|
@@ -238,7 +252,7 @@ class DevOn:
|
|
238 |
elif action_func == "notetaker":
|
239 |
action_arg = action.split(" ", 1)[1]
|
240 |
while True:
|
241 |
-
self.notetaker = multion.sessions.step(
|
242 |
self.notetaker.session_id,
|
243 |
cmd=action_arg + "\n\n" + notetaker_notes,
|
244 |
url="https://anotepad.com/",
|
@@ -258,7 +272,7 @@ class DevOn:
|
|
258 |
# yield ("", self.editor_image, self.browser_image, self.scratchpad_image)
|
259 |
if self.notetaker.status == "DONE":
|
260 |
break
|
261 |
-
self.scratchpad_image = multion.sessions.screenshot(
|
262 |
session_id=self.notetaker.session_id
|
263 |
).screenshot
|
264 |
print(self.scratchpad_image)
|
|
|
10 |
|
11 |
load_dotenv(".env.local")
|
12 |
|
13 |
+
# replit_email = os.getenv("REPLIT_EMAIL")
|
14 |
+
# replit_password = os.getenv("REPLIT_PASSWORD")
|
15 |
|
16 |
+
# multion_api_key = os.getenv("MULTION_API_KEY")
|
17 |
# multion.login(use_api=True, multion_api_key=multion_api_key)
|
|
|
18 |
|
19 |
# runpod_url = os.getenv("RUNPOD_URL")
|
20 |
|
|
|
22 |
|
23 |
|
24 |
class DevOn:
|
25 |
+
def __init__(
|
26 |
+
self,
|
27 |
+
editor_image,
|
28 |
+
browser_image,
|
29 |
+
scratchpad_image,
|
30 |
+
multion_api_key,
|
31 |
+
openai_api_key,
|
32 |
+
replit_email,
|
33 |
+
replit_password,
|
34 |
+
):
|
35 |
+
print(multion_api_key, openai_api_key)
|
36 |
self.editor_image = editor_image
|
37 |
self.browser_image = browser_image
|
38 |
self.scratchpad_image = scratchpad_image
|
39 |
self.local = os.getenv("WHERE_EXECUTE") == "local"
|
40 |
|
41 |
+
self.multion = MultiOn(api_key=multion_api_key)
|
42 |
+
|
43 |
+
self.replit_email = replit_email
|
44 |
+
self.replit_password = replit_password
|
45 |
+
|
46 |
+
self.programmer = self.multion.sessions.create(
|
47 |
url="https://replit.com/login", local=self.local, include_screenshot=True
|
48 |
)
|
49 |
self.programmer_logged_in = False
|
50 |
# self.editor_image = self.programmer.screenshot
|
51 |
+
self.editor_image = self.multion.sessions.screenshot(
|
52 |
session_id=self.programmer.session_id
|
53 |
).screenshot
|
54 |
print(self.editor_image)
|
55 |
time.sleep(1)
|
56 |
# print(self.programmer)
|
57 |
|
58 |
+
self.researcher = self.multion.sessions.create(
|
59 |
url="https://www.google.com", local=self.local, include_screenshot=True
|
60 |
)
|
61 |
# self.browser_image = self.researcher.screenshot
|
62 |
+
self.browser_image = self.multion.sessions.screenshot(
|
63 |
session_id=self.researcher.session_id
|
64 |
).screenshot
|
65 |
time.sleep(1)
|
66 |
|
67 |
+
self.notetaker = self.multion.sessions.create(
|
68 |
url="https://anotepad.com/", local=self.local, include_screenshot=True
|
69 |
)
|
70 |
# self.scratchpad_image = self.notetaker.screenshot
|
71 |
+
self.scratchpad_image = self.multion.sessions.screenshot(
|
72 |
session_id=self.notetaker.session_id
|
73 |
).screenshot
|
74 |
time.sleep(1)
|
|
|
77 |
self.task = ""
|
78 |
self.plan = ""
|
79 |
self.messages = []
|
80 |
+
self.client = OpenAI(api_key=openai_api_key)
|
81 |
|
82 |
def programmer_login(self):
|
83 |
if self.local:
|
84 |
cmd = "Create a new Python REPL."
|
85 |
else:
|
86 |
cmd = "Log in with the email {email} and the password {password}. Then create a new Python REPL.".format(
|
87 |
+
email=self.replit_email, password=self.replit_password
|
88 |
)
|
89 |
while True:
|
90 |
+
self.programmer = self.multion.sessions.step(
|
91 |
self.programmer.session_id,
|
92 |
cmd=cmd + "\n\n" + programmer_notes,
|
93 |
url="https://replit.com/login",
|
|
|
95 |
)
|
96 |
print(self.programmer)
|
97 |
print(
|
98 |
+
self.multion.sessions.screenshot(
|
99 |
session_id=self.programmer.session_id
|
100 |
).screenshot
|
101 |
)
|
|
|
105 |
if self.programmer.status == "DONE":
|
106 |
break
|
107 |
|
108 |
+
self.editor_image = self.multion.sessions.screenshot(
|
109 |
session_id=self.programmer.session_id
|
110 |
).screenshot
|
111 |
time.sleep(1)
|
|
|
177 |
elif action_func == "programmer":
|
178 |
action_arg = action.split(" ", 1)[1]
|
179 |
while True:
|
180 |
+
self.programmer = self.multion.sessions.step(
|
181 |
self.programmer.session_id,
|
182 |
cmd=action_arg + "\n\n" + programmer_notes,
|
183 |
url="https://replit.com/login",
|
|
|
214 |
# yield ("", self.editor_image, self.browser_image, self.scratchpad_image)
|
215 |
if self.programmer.status == "DONE":
|
216 |
break
|
217 |
+
self.editor_image = self.multion.sessions.screenshot(
|
218 |
session_id=self.programmer.session_id
|
219 |
).screenshot
|
220 |
print(self.editor_image)
|
|
|
223 |
elif action_func == "researcher":
|
224 |
action_arg = action.split(" ", 1)[1]
|
225 |
while True:
|
226 |
+
self.researcher = self.multion.sessions.step(
|
227 |
self.researcher.session_id,
|
228 |
cmd=action_arg,
|
229 |
url="https://www.google.com",
|
|
|
243 |
# yield ("", self.editor_image, self.browser_image, self.scratchpad_image)
|
244 |
if self.researcher.status == "DONE":
|
245 |
break
|
246 |
+
self.browser_image = self.multion.sessions.screenshot(
|
247 |
session_id=self.researcher.session_id
|
248 |
).screenshot
|
249 |
print(self.browser_image)
|
|
|
252 |
elif action_func == "notetaker":
|
253 |
action_arg = action.split(" ", 1)[1]
|
254 |
while True:
|
255 |
+
self.notetaker = self.multion.sessions.step(
|
256 |
self.notetaker.session_id,
|
257 |
cmd=action_arg + "\n\n" + notetaker_notes,
|
258 |
url="https://anotepad.com/",
|
|
|
272 |
# yield ("", self.editor_image, self.browser_image, self.scratchpad_image)
|
273 |
if self.notetaker.status == "DONE":
|
274 |
break
|
275 |
+
self.scratchpad_image = self.multion.sessions.screenshot(
|
276 |
session_id=self.notetaker.session_id
|
277 |
).screenshot
|
278 |
print(self.scratchpad_image)
|
app.py
CHANGED
@@ -8,6 +8,10 @@ image_temp = "https://miro.medium.com/v2/resize:fit:1200/0*n-2bW82Z6m6U2bij.jpeg
|
|
8 |
# editor_image=image_temp, browser_image=image_temp, scratchpad_image=image_temp
|
9 |
# )
|
10 |
devon = None
|
|
|
|
|
|
|
|
|
11 |
|
12 |
|
13 |
def add_message(history, message):
|
@@ -18,7 +22,37 @@ def add_message(history, message):
|
|
18 |
return history, gr.MultimodalTextbox(value=None, interactive=False)
|
19 |
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
def bot(history):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
for r in devon.run(history[-1][0]):
|
23 |
text, editor_image, browser_image, scratchpad_image = r
|
24 |
if type(text) == str:
|
@@ -31,6 +65,13 @@ def bot(history):
|
|
31 |
|
32 |
|
33 |
with gr.Blocks(css="footer {visibility: hidden}") as demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
with gr.Row():
|
35 |
with gr.Column():
|
36 |
chatbot = gr.Chatbot(
|
@@ -38,7 +79,9 @@ with gr.Blocks(css="footer {visibility: hidden}") as demo:
|
|
38 |
)
|
39 |
|
40 |
chat_input = gr.MultimodalTextbox(
|
41 |
-
value={
|
|
|
|
|
42 |
interactive=True,
|
43 |
file_types=["image"],
|
44 |
placeholder="Enter message or upload file...",
|
@@ -81,11 +124,13 @@ with gr.Blocks(css="footer {visibility: hidden}") as demo:
|
|
81 |
)
|
82 |
bot_msg.then(lambda: gr.MultimodalTextbox(interactive=True), None, [chat_input])
|
83 |
|
|
|
|
|
|
|
|
|
|
|
84 |
# chatbot.like(print_like_dislike, None, None)
|
85 |
|
86 |
if __name__ == "__main__":
|
87 |
-
devon = DevOn(
|
88 |
-
editor_image=image_temp, browser_image=image_temp, scratchpad_image=image_temp
|
89 |
-
)
|
90 |
demo.queue()
|
91 |
demo.launch()
|
|
|
8 |
# editor_image=image_temp, browser_image=image_temp, scratchpad_image=image_temp
|
9 |
# )
|
10 |
devon = None
|
11 |
+
multion_api_key = ""
|
12 |
+
openai_api_key = ""
|
13 |
+
replit_email = ""
|
14 |
+
replit_password = ""
|
15 |
|
16 |
|
17 |
def add_message(history, message):
|
|
|
22 |
return history, gr.MultimodalTextbox(value=None, interactive=False)
|
23 |
|
24 |
|
25 |
+
def multion_api_key_update(x):
|
26 |
+
global multion_api_key
|
27 |
+
multion_api_key = x
|
28 |
+
|
29 |
+
|
30 |
+
def openai_api_key_update(x):
|
31 |
+
global openai_api_key
|
32 |
+
openai_api_key = x
|
33 |
+
|
34 |
+
|
35 |
+
def replit_email_update(x):
|
36 |
+
global replit_email
|
37 |
+
replit_email = x
|
38 |
+
|
39 |
+
|
40 |
+
def replit_password_update(x):
|
41 |
+
global replit_password
|
42 |
+
replit_password = x
|
43 |
+
|
44 |
+
|
45 |
def bot(history):
|
46 |
+
devon = DevOn(
|
47 |
+
editor_image=image_temp,
|
48 |
+
browser_image=image_temp,
|
49 |
+
scratchpad_image=image_temp,
|
50 |
+
multion_api_key=multion_api_key,
|
51 |
+
openai_api_key=openai_api_key,
|
52 |
+
replit_email=replit_email,
|
53 |
+
replit_password=replit_password,
|
54 |
+
)
|
55 |
+
|
56 |
for r in devon.run(history[-1][0]):
|
57 |
text, editor_image, browser_image, scratchpad_image = r
|
58 |
if type(text) == str:
|
|
|
65 |
|
66 |
|
67 |
with gr.Blocks(css="footer {visibility: hidden}") as demo:
|
68 |
+
with gr.Row():
|
69 |
+
with gr.Column():
|
70 |
+
multion_api_key_in = gr.Textbox(label="MultiOn API Key")
|
71 |
+
openai_api_key_in = gr.Textbox(label="OpenAI API Key")
|
72 |
+
with gr.Column():
|
73 |
+
replit_email_in = gr.Textbox(label="Replit Email")
|
74 |
+
replit_password_in = gr.Textbox(label="Replit Password")
|
75 |
with gr.Row():
|
76 |
with gr.Column():
|
77 |
chatbot = gr.Chatbot(
|
|
|
79 |
)
|
80 |
|
81 |
chat_input = gr.MultimodalTextbox(
|
82 |
+
value={
|
83 |
+
"text": "benchmark the perplexity api's resposne time with the api key abcdef"
|
84 |
+
},
|
85 |
interactive=True,
|
86 |
file_types=["image"],
|
87 |
placeholder="Enter message or upload file...",
|
|
|
124 |
)
|
125 |
bot_msg.then(lambda: gr.MultimodalTextbox(interactive=True), None, [chat_input])
|
126 |
|
127 |
+
multion_api_key_in.change(multion_api_key_update, multion_api_key_in)
|
128 |
+
openai_api_key_in.change(openai_api_key_update, openai_api_key_in)
|
129 |
+
replit_email_in.change(replit_email_update, replit_email_in)
|
130 |
+
replit_password_in.change(replit_password_update, replit_password_in)
|
131 |
+
|
132 |
# chatbot.like(print_like_dislike, None, None)
|
133 |
|
134 |
if __name__ == "__main__":
|
|
|
|
|
|
|
135 |
demo.queue()
|
136 |
demo.launch()
|