Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Init playground [WIP]
Tomáš Valenta0fa2bb7fb8aa
diff --git a/api-service/app.py b/api-service/app.pyindex 33b0535c5..3c096a42b 100644--- a/api-service/app.py+++ b/api-service/app.py@@ -7,6 +7,7 @@ from flask_cors import CORSfrom codegen.base import generate_req_handlerfrom codegen.db.base import Database, DeploymentState+from playground_client.base import NodeJSPlaygroundurl = os.environ.get("SUPABASE_URL")key = os.environ.get("SUPABASE_KEY")@@ -46,6 +47,8 @@ def generate():db.create_deployment(run_id=run_id, project_id=project_id, route_id=route_id)+ playground = NodeJSPlayground()+final_prompt, js_code = generate_req_handler(run_id=run_id,db=db,@@ -53,6 +56,8 @@ def generate():method=method,)+ playground.close()+db.update_state(run_id=run_id, state=DeploymentState.Deploying)cf_worker_dir_path = (diff --git a/api-service/playground_client/main.py b/api-service/playground_client/base.pysimilarity index 90%rename from api-service/playground_client/main.pyrename to api-service/playground_client/base.pyindex a3911e71d..54b1d9ce8 100644--- a/api-service/playground_client/main.py+++ b/api-service/playground_client/base.py@@ -15,10 +15,16 @@ class Playground:self.client = openapi_client.ApiClient(configuration)self.api = openapi_client.DefaultApi(self.client)self.session = self.api.create_session(openapi_client.CreateSessionParams(env_id))+ self.is_closed = Falsedef __del__(self):- self.api.delete_session(self.session.id)- self.client.close()+ self.close()++ def close(self):+ if not self.is_closed:+ self.is_closed = True+ self.api.delete_session(self.session.id)+ self.client.close()def run_command(self, cmd: str):result = self.api.run_process(self.session.id, openapi_client.RunProcessParams(cmd))