Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
commit
Vasek Mlejnsky7f7e744a04e1
diff --git a/.vscode/settings.json b/.vscode/settings.jsonindex 4f156b6c7..9c2a57186 100644--- a/.vscode/settings.json+++ b/.vscode/settings.json@@ -60,4 +60,8 @@"./api-service/.venv/bin/python",],"python.defaultInterpreterPath": "api-service/.venv/bin/python",+ "python.analysis.extraPaths": [+ "./**",+ "./api-service/.venv/bin/python"+ ],}\ No newline at end of filediff --git a/api-service/cf-worker-template/index.js b/api-service/cf-worker-template/index.jsindex 8d5c5d26c..7332064c6 100644--- a/api-service/cf-worker-template/index.js+++ b/api-service/cf-worker-template/index.js@@ -1,21 +1 @@-import { Router } from 'itty-router'--const router = Router()--async function handlepostRequest(request, env) {- const botAccessToken = env.SLACK_BOT_ACCESS_TOKEN;- const SlackREST = require('@sagi.io/workers-slack')- const SlackAPI = new SlackREST({ botAccessToken })-- const data = { channel: 'general', text: `User '${request.email}' selected pricing '${request.selectedPricing.type}' for $${request.selectedPricing.cost}` }- const result = await SlackAPI.chat.postMessage(data)-- return new Response('Ok', { status: 200 })-}--router.post('/', handlepostRequest)-router.get('*', () => new Response('Not found', { status: 404 }))--export default {- fetch: router.handle-}\ No newline at end of file+async function handlepostRequest(req, env) { const requestBody = req.json(); const botAccessToken = env.SLACK_BOT_ACCESS_TOKEN; const SlackREST = require('@sagi.io/workers-slack'); const SlackAPI = new SlackREST({ botAccessToken }); const data = { channel: 'general', text: `User '${requestBody.email}' selected pricing '${requestBody.selectedPricing.type}' for $${requestBody.selectedPricing.cost}` }; const result = await SlackAPI.chat.postMessage(data); return new Response('Ok', { status: 200 }); }\ No newline at end of filediff --git a/api-service/codegen/codegen.py b/api-service/codegen/codegen.pyindex 51118ca61..398047a22 100644--- a/api-service/codegen/codegen.py+++ b/api-service/codegen/codegen.py@@ -41,10 +41,10 @@ def generate_req_handler(print("REQ BODY BLOCK")print(req_body_str)- # Convert env vars to a markdown list enumerating env names on separate lines.+ # Convert env vars to Javascript comments, each on its on line for each env var.envs_str = ""for env in envs:- envs_str += f'- `{env["key"]}`\n'+ envs_str += f'// const {env["key"]} = `env.{env["key"]}`\n'prompt = PREFIX.format(method=method, envs=envs_str, request_body=req_body_str)@@ -56,8 +56,8 @@ def generate_req_handler(handler_code = executor.run(prompt).strip("`").strip()- content = playground.read_file('/code/package.json')- print('PACKAGE.JSON')+ content = playground.read_file("/code/package.json")+ print("PACKAGE.JSON")print(content)playground.close()diff --git a/api-service/codegen/prompt.py b/api-service/codegen/prompt.pyindex 994e31540..ab73a427f 100644--- a/api-service/codegen/prompt.py+++ b/api-service/codegen/prompt.py@@ -15,13 +15,8 @@ USE ONLY TOOLS THAT YOU HAVE ACCESS TO!You are building a serverless API with Cloudflare Workers using the `itty-router` package. The javascript code is in the form of ES modules.You need to complete the `handle{method}Request` function that handles the incoming {method} requests and return the whole completed code.-You can access environment variables through the `env` parameter. You have access to the following environment variables:-{envs}-You can install any package that you might need.-The incoming request content-type is application/json.-The incoming request payload looks like this:```{request_body}@@ -33,8 +28,14 @@ import {{ Router }} from 'itty-router'const router = Router()-async function handle{method}Request(request, env) {{- // TODO+async function handle{method}Request(req, env) {{+ // DO NOT USE `process.env` TO ACCES ENVIRONMENT VARIABLES. Instead, you access environment variables through the `env` parameter like this: `const myEnv = env.MY_ENV`.+ // You have access to the following environment variables:+ {envs}++ // The incoming request content-type is application/json. Make sure to correctly retrieve it.+ const requestBody = req.json()+ // TODO}}router.{method}('/', handle{method}Request)