Skip to content

Commit

Permalink
Improve details for projects used in ai with code execution blog post
Browse files Browse the repository at this point in the history
  • Loading branch information
debanjum committed Nov 21, 2024
1 parent 607655b commit 5c97c84
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/content/posts/ai-with-code-execution.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ However, these same models excel at writing code. By connecting an LLM to a code

### How it works

We've added an subtask in Khoj that generates Python code to execute in order to fulfill some user intent. This code can be as simple as a mathematical calculation or as complex as charting a graph. The AI assistant then executes this code in a sandboxed environment and returns the results to the user. You can see most of the relevant code in [run_code.py](https://github.com/khoj-ai/khoj/blob/master/src/khoj/processor/tools/run_code.py).
We've added a subtask in Khoj that generates Python code to execute in order to fulfill some user intent. This code can be as simple as a mathematical calculation or as complex as charting a graph. The AI agent then executes this code in a sandboxed environment and returns the results to the user. You can see most of the relevant code in [run_code.py](https://github.com/khoj-ai/khoj/blob/master/src/khoj/processor/tools/run_code.py).

Implementing code execution in AI systems comes with significant security considerations. Running arbitrary LLM-generated Python code, whether on local machines or cloud servers, presents obvious risks that need to be carefully managed. To address these concerns, we've leveraged a sandboxed solution using [Pyodide](https://pyodide.org/). By forking and adapting [Cohere's project Terrarium](https://github.com/cohere-ai/cohere-terrarium), we've developed an independently deployable sandbox in a Docker container, available through [our Terrarium fork on GitHub](https://github.com/khoj-ai/terrarium). Developers can access this functionality using the base image at `ghcr.io/khoj-ai/terrarium:latest`.
Implementing code execution in AI systems comes with significant security considerations. Running arbitrary LLM-generated Python code, whether on local machines or cloud servers, presents obvious risks that need to be carefully managed. To address these concerns, we've leveraged the excellent work done by [Pyoidide](https://pyoidide.org) to run python in a js sandbox and [Cohere's Terrarium](https://github.com/cohere-ai/cohere-terrarium) to containerize it as a service. We've wrapped into a publically accessible docker base image accessible at `ghcr.io/khoj-ai/terrarium:latest`. You can see the code on [our Terrarium fork on GitHub](https://github.com/khoj-ai/terrarium).

To run it, you can use the following command:

Expand Down

0 comments on commit 5c97c84

Please sign in to comment.