Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

Add routeID to deployment; Cleanup

Tomas Valenta10dc146af718
diff --git a/api-service/app.py b/api-service/app.py
index 0271a08a7..23f08692a 100644
--- a/api-service/app.py
+++ b/api-service/app.py
@@ -30,12 +30,14 @@ def health():
def generate():
body = request.json
- project_id = body["projectId"]
+ project_id = body["projectID"]
+ route_id = body["routeID"]
blocks = body["blocks"]
method = body["method"]
+ route = body["route"]
final_prompt, js_code = generate_req_handler(
- project_id=project_id, blocks=blocks, method=method
+ project_id=project_id, route_id=route_id, blocks=blocks, method=method
)
cf_worker_dir_path = (
diff --git a/api-service/codegen/base.py b/api-service/codegen/base.py
index 0c1ea57ec..b954b8f9d 100644
--- a/api-service/codegen/base.py
+++ b/api-service/codegen/base.py
@@ -7,12 +7,13 @@ from codegen.js_agent.base import create_js_agent
from codegen.prompt import PREFIX, SUFFIX
-def generate_req_handler(project_id: str, blocks: List[str], method: str) -> str:
+def generate_req_handler(project_id: str, route_id: str, blocks: List[str], method: str) -> str:
run_id = str(uuid.uuid4())
executor = create_js_agent(
run_id=run_id,
project_id=project_id,
+ route_id=route_id,
llm=OpenAI(temperature=0, max_tokens=1000),
# llm=OpenAI(temperature=0, model_name='code-davinci-002', max_tokens=1000),
# llm=OpenAIChat(temperature=0, max_tokens=1000),
diff --git a/api-service/codegen/db/base.py b/api-service/codegen/db/base.py
index 7a58d413e..646c2dbc0 100644
--- a/api-service/codegen/db/base.py
+++ b/api-service/codegen/db/base.py
@@ -5,12 +5,13 @@ class Database():
def __init__(self, url: str, key: str):
self.client = create_client(url, key)
- def push_logs(self, run_id: str, project_id: str, logs: List[str]) -> None:
+ def push_logs(self, run_id: str, project_id: str, route_id: str, logs: List[str]) -> None:
if len(logs) > 0:
self.client.table('deployments').upsert(
json={
'id': run_id,
'logs': logs,
'project_id': project_id,
+ 'route_id': route_id,
},
).execute()
\ No newline at end of file
diff --git a/api-service/codegen/js_agent/base.py b/api-service/codegen/js_agent/base.py
index 2e7f4f5a9..99be00570 100644
--- a/api-service/codegen/js_agent/base.py
+++ b/api-service/codegen/js_agent/base.py
@@ -18,6 +18,7 @@ from codegen.js_agent.callbacks.log import LoggerCallbackHandler
def create_js_agent(
run_id: str,
project_id: str,
+ route_id: str,
llm: BaseLLM,
tool: JavascriptEvalTool,
callback_manager: Optional[BaseCallbackManager] = None,
@@ -42,7 +43,7 @@ def create_js_agent(
cb_manager = SharedCallbackManager()
cb_manager.set_handler(LoggerCallbackHandler(
- run_id=run_id, project_id=project_id))
+ run_id=run_id, project_id=project_id, route_id=route_id))
return AgentExecutor.from_agent_and_tools(
agent=agent,
tools=tools,
diff --git a/api-service/codegen/js_agent/callbacks/log.py b/api-service/codegen/js_agent/callbacks/log.py
index c8dbc89e6..2e73db626 100644
--- a/api-service/codegen/js_agent/callbacks/log.py
+++ b/api-service/codegen/js_agent/callbacks/log.py
@@ -12,7 +12,7 @@ from codegen.db.base import Database
class LoggerCallbackHandler(BaseCallbackHandler):
"""Callback Handler that prints to std out."""
- def __init__(self, run_id: str, project_id: str, color: Optional[str] = None) -> None:
+ def __init__(self, run_id: str, project_id: str, route_id: str, color: Optional[str] = None) -> None:
"""Initialize callback handler."""
url = os.environ.get('SUPABASE_URL')
@@ -20,6 +20,7 @@ class LoggerCallbackHandler(BaseCallbackHandler):
self.db = Database(url, key)
self.run_id = run_id
+ self.route_id = route_id
self.project_id = project_id
self.color = color
self.logs = []
@@ -28,7 +29,7 @@ class LoggerCallbackHandler(BaseCallbackHandler):
if log is not None:
self.logs.append(log)
self.db.push_logs(run_id=self.run_id,
- project_id=self.project_id, logs=self.logs)
+ project_id=self.project_id, route_id=self.route_id, logs=self.logs)
def on_llm_start(
self, serialized: Dict[str, Any], prompts: List[str], **kwargs: Any