Code Monkey home page Code Monkey logo

bks1242 / gen-ai-code-execution-agent Goto Github PK

View Code? Open in Web Editor NEW

This project forked from denniszielke/gen-ai-code-execution-agent

0.0 0.0 0.0 365 KB

Secure Dynamic Session Agent for AI generated code execution built using OpenAI, Langchain and Azure Container Apps

Home Page: https://denniszielke.medium.com/secure-scalable-and-fast-execution-of-ai-generated-code-with-azure-container-apps-dynamic-sessions-32b758c245fa

License: MIT License

Shell 4.61% Python 12.23% Dockerfile 3.03% Bicep 80.12%

gen-ai-code-execution-agent's Introduction

Secure Dynamic Session for AI Agent code execution

This project demonstrates how to use the Azure Dynamic Session Service to safely execute AI generated code to interact with files in an isolated session. The code in the repository is using the following technologies:

  • Azure OpenAI (as LLM to process user requests and translate them dynamically into Python code)
  • Langchain (as as LLM orchestrator to leverage OpenAI and handle tool execution)
  • Streamlit (as frontend technology to host the user interface and upload/download files)
  • Azure Container Apps (as container runtime for the streamlit application)
  • Azure Dynamic Sessions (as host for executing LLM generated python code in a secure session)
  • Azure Developer CLI (as means to deploy all resources in the project to Azure)

Here is a high level diagram on how these components work together:

# reference an image in markdown

This architecture pattern might be relevant for you if any of the following requirements are applicable for your scenario:

  • You need to execute AI generated code on the fly
  • You need to isolate tool execution for different user sessions
  • You need to provide dedicated compute/filesystem resources for a user session
  • You need to scale out compute sessions in less than a second
  • You need to prevent generated code to connect to the network
  • You need to provide a secured filesystem per session

Quickstart

The recommended way to execute the deployment is to fork the repo and then start a GitHub Codespace because there you will have all the tools to deploy the resources, test the code and try out the whole story end-to-end. The project resources can be deployed into the following Azure regions:

  • eastus

echo "log into azure dev cli - only once"
azd auth login

echo "provisioning all the resources with the azure dev cli"
azd up

echo "get and set the value for AZURE_ENV_NAME"
source <(azd env get-values | grep AZURE_ENV_NAME)

echo "building and deploying the streamlit user interface"
bash ./azd-hooks/deploy.sh web $AZURE_ENV_NAME

Run the app locally

Navigate to the folder /src/web.


cd /src/web

echo "installing python packages"
pip install -r requirements.txt

echo "starting app"
python -m streamlit run app.py --server.port=8000

gen-ai-code-execution-agent's People

Contributors

denniszielke avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.