Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Inject envs to wrangler file
Vasek Mlejnskya1e3c43986f4
diff --git a/api-service/app.py b/api-service/app.pyindex 30dd21dd1..d76c46a0e 100644--- a/api-service/app.py+++ b/api-service/app.py@@ -1,3 +1,4 @@+from typing import Dictimport osimport uuidimport subprocess@@ -21,11 +22,14 @@ def dump(obj):print("obj.%s = %r" % (attr, getattr(obj, attr)))-def replace_file_content(fp_in: str, fp_out: str, old: str, new: str) -> None:+def replace_file_content(fp_in: str, fp_out: str, pairs: Dict[str, str]) -> None:with open(fp_in, "rt") as fin:with open(fp_out, "wt") as fout:for line in fin:- fout.write(line.replace(old, new))+ for old, new in pairs.items():+ if old in line:+ line = line.replace(old, new)+ fout.write(line)@app.route("/health", methods=["GET"])@@ -44,7 +48,6 @@ def generate():method = body["method"]route = body["route"]envs = body["envs"]- print("ENVS")print(envs)db.create_deployment(run_id=run_id, project_id=project_id, route_id=route_id)@@ -70,12 +73,19 @@ def generate():with open(index_js_path, "w") as file:file.write(code)+ # Convert envs to the env vars string that looks like this:+ # KEY_1 = VALUE_1+ # KEY_2 = VALUE_2+ envs_str = ""+ for env in envs:+ print(env)+ if env["key"]:+ envs_str += f'{env["key"]} = "{env["value"]}"\n'# TODO: Update name in cf-worker-template/wrangler.template.tomlreplace_file_content(wrangler_template_path,wrangler_path,- "<NAME>",- f'"{project_id}"',+ {"<NAME>": f'"{project_id}2"', "<VARS>": envs_str},)# TODO: Call npm run deploydiff --git a/api-service/cf-worker-template/wrangler.template.toml b/api-service/cf-worker-template/wrangler.template.tomlindex abf88b9a1..a868f8c0f 100644--- a/api-service/cf-worker-template/wrangler.template.toml+++ b/api-service/cf-worker-template/wrangler.template.toml@@ -5,3 +5,6 @@ main = "./index.js"# route = ''compatibility_date = "2022-05-03"send_metrics = false++[vars]+<VARS>diff --git a/api-service/cf-worker-template/wrangler.toml b/api-service/cf-worker-template/wrangler.tomlindex 5f1abf473..1473c12ba 100644--- a/api-service/cf-worker-template/wrangler.toml+++ b/api-service/cf-worker-template/wrangler.toml@@ -1,7 +1,11 @@# This wrangler file will be injected withl values during runtime and saved as wrangler.toml-name = "meteo"+name = "meteo2"main = "./index.js"# route = ''compatibility_date = "2022-05-03"send_metrics = false++[vars]+API_KEY = "1234"+diff --git a/api-service/poetry.lock b/api-service/poetry.lockindex dab27e877..5937a8e9a 100644--- a/api-service/poetry.lock+++ b/api-service/poetry.lock@@ -1044,14 +1044,14 @@ testing = ["flake8 (<5)", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-chec[[package]]name = "langchain"-version = "0.0.106"+version = "0.0.107"description = "Building applications with LLMs through composability"category = "main"optional = falsepython-versions = ">=3.8.1,<4.0"files = [- {file = "langchain-0.0.106-py3-none-any.whl", hash = "sha256:4e340383853c5c5098b0d22c2cb2bb6022fefdbafa239f3e69f3c8caa35db2c7"},- {file = "langchain-0.0.106.tar.gz", hash = "sha256:d15325e1d8e6d4a05c248533dc859bb995de46e8e683f13ffe90935fadba354e"},+ {file = "langchain-0.0.107-py3-none-any.whl", hash = "sha256:161bfb185d7146d32f5483a134bfe353d98f1b383b637b31e45f234736500d5c"},+ {file = "langchain-0.0.107.tar.gz", hash = "sha256:a6d2c7236c7cf0c2d437cf0bde0626d9b5849589680132fc271b53d01bd7df3b"},][package.dependencies]@@ -2265,4 +2265,4 @@ testing = ["big-O", "flake8 (<5)", "jaraco.functools", "jaraco.itertools", "more[metadata]lock-version = "2.0"python-versions = ">=3.8.1,<4.0"-content-hash = "11a549cdeb1dd2abd5109c20c172a81df066fe400ccbb631a9d8896799bf0e63"+content-hash = "dbabed4f5615d62895f870fa45ba0938837e648e494cfe860009ccb71fad535a"diff --git a/api-service/pyproject.toml b/api-service/pyproject.tomlindex cf22c80d0..23c55c6ba 100644--- a/api-service/pyproject.toml+++ b/api-service/pyproject.toml@@ -9,7 +9,7 @@ python = ">=3.8.1,<4.0"flask = "^2.2.3"gunicorn = "^20.1.0"openai = "^0.27.0"-langchain = "^0.0.106"+langchain = "^0.0.107"supabase = "^1.0.1"flask-cors = "^3.0.10"cloudflare = "^2.11.1"diff --git a/components/Editor/index.tsx b/components/Editor/index.tsxindex 0db71f6c9..f6a395e6b 100644--- a/components/Editor/index.tsx+++ b/components/Editor/index.tsx@@ -58,8 +58,8 @@ function Editor({ project }: Props) {const deleteRoute = store.use.deleteRoute()const changeRoute = store.use.changeRoute()const addRoute = store.use.addRoute()+ const envs = store.use.envs()- const [envs, setEnvs] = useState<{ key: string, value: string }[]>([{ key: '', value: '' }])const [isInitializingDeploy, setIsInitializingDeploy] = useState(false)const [selectedRouteID, setSelectedRouteID] = useState(() => routes.length > 0 ? routes[0].id : undefined)const selectedRoute = routes.find(s => s.id === selectedRouteID)