Skip to content

Commit

Permalink
Add Claude 3 and Pyodide sandboxing (#237)
Browse files Browse the repository at this point in the history
Adds pyodide WebWorker to run Python scripts, thanks to idea by Shreya.

* Add sandbox option to Python eval nodes.

* Add new Anthropic models

* Disable guards for Python evals on server

* Fix bug with detecting async func in runOverResponses

---------

Co-authored-by: Shreya Shankar <ss.shankar505@gmail.com>
  • Loading branch information
ianarawjo and shreyashankar committed Mar 6, 2024
1 parent 0a45383 commit 0f4275b
Show file tree
Hide file tree
Showing 32 changed files with 706 additions and 235 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ __pycache__/
*.py[cod]
*$py.class

# Docker
packages/
jobs/

# C extensions
*.so

Expand Down
6 changes: 5 additions & 1 deletion chainforge/flask_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,11 @@ def makeFetchCall():
ret.headers.add('Access-Control-Allow-Origin', '*')
return ret
else:
return jsonify({'error': 'API request to Anthropic failed'})
err_msg = "API request to Anthropic failed"
ret = response.json()
if "error" in ret and "message" in ret["error"]:
err_msg += ": " + ret["error"]["message"]
return jsonify({'error': err_msg})


@app.route('/app/callDalai', methods=['POST'])
Expand Down
7 changes: 6 additions & 1 deletion chainforge/react-server/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
module.exports = {
ignorePatterns: ["node_modules/**", "build/**", "craco.config.js"],
ignorePatterns: [
"node_modules/**",
"build/**",
"craco.config.js",
"src/backend/pyodide/**",
],
extends: [
"semistandard",
"plugin:react/recommended",
Expand Down
8 changes: 5 additions & 3 deletions chainforge/react-server/build/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
{
"files": {
"main.css": "/static/css/main.85149714.css",
"main.js": "/static/js/main.19a7c43a.js",
"main.js": "/static/js/main.6a995798.js",
"static/js/477.650352c6.chunk.js": "/static/js/477.650352c6.chunk.js",
"static/js/787.4c72bb55.chunk.js": "/static/js/787.4c72bb55.chunk.js",
"index.html": "/index.html",
"main.85149714.css.map": "/static/css/main.85149714.css.map",
"main.19a7c43a.js.map": "/static/js/main.19a7c43a.js.map",
"main.6a995798.js.map": "/static/js/main.6a995798.js.map",
"477.650352c6.chunk.js.map": "/static/js/477.650352c6.chunk.js.map",
"787.4c72bb55.chunk.js.map": "/static/js/787.4c72bb55.chunk.js.map"
},
"entrypoints": [
"static/css/main.85149714.css",
"static/js/main.19a7c43a.js"
"static/js/main.6a995798.js"
]
}
2 changes: 1 addition & 1 deletion chainforge/react-server/build/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><script async src="https://www.googletagmanager.com/gtag/js?id=G-RN3FDBLMCR"></script><script>function gtag(){dataLayer.push(arguments)}window.dataLayer=window.dataLayer||[],gtag("js",new Date),gtag("config","G-RN3FDBLMCR")</script><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="A visual programming environment for prompt engineering"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>ChainForge</title><script defer="defer" src="/static/js/main.19a7c43a.js"></script><link href="/static/css/main.85149714.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><script async src="https://www.googletagmanager.com/gtag/js?id=G-RN3FDBLMCR"></script><script>function gtag(){dataLayer.push(arguments)}window.dataLayer=window.dataLayer||[],gtag("js",new Date),gtag("config","G-RN3FDBLMCR")</script><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="A visual programming environment for prompt engineering"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>ChainForge</title><script defer="defer" src="/static/js/main.6a995798.js"></script><link href="/static/css/main.85149714.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
3 changes: 3 additions & 0 deletions chainforge/react-server/build/static/js/477.650352c6.chunk.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions chainforge/react-server/craco.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ const webpack = require("webpack");
const isDevelopment = process.env.NODE_ENV !== "production";

module.exports = {
eslint: {
enable: false,
},
webpack: {
configure: {
resolve: {
Expand Down
43 changes: 42 additions & 1 deletion chainforge/react-server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions chainforge/react-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"@codemirror/lang-python": "^6.1.2",
"@emoji-mart/data": "^1.1.2",
"@emoji-mart/react": "^1.1.1",
"@fontsource/geist-mono": "^5.0.1",
"@google-ai/generativelanguage": "^0.2.0",
"@google/generative-ai": "^0.1.3",
"@mantine/core": "^6.0.9",
Expand Down Expand Up @@ -76,6 +77,7 @@
"react": "^18.2.0",
"react-ace": "^10.1.0",
"react-beautiful-dnd": "^13.1.1",
"react-confetti-explosion": "^2.1.2",
"react-csv": "^2.2.2",
"react-device-detect": "^2.2.3",
"react-dom": "^18.2.0",
Expand All @@ -101,7 +103,7 @@
"typescript": "^5.1.3"
},
"scripts": {
"start": "craco start",
"start": "npx prettier -w . && npx eslint . && craco start",
"build": "npx prettier -w . && npx eslint . && craco build",
"test": "npx prettier -w . && npx eslint . && craco test",
"eject": "react-scripts eject",
Expand Down Expand Up @@ -136,6 +138,7 @@
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-react": "^7.33.2",
"jest": "^27.5.1"
"jest": "^27.5.1",
"worker-loader": "^3.0.8"
}
}
Loading

0 comments on commit 0f4275b

Please sign in to comment.