{"id":18562464,"url":"https://github.com/replit/replit-code-exec","last_synced_at":"2025-04-10T03:31:51.555Z","repository":{"id":194937148,"uuid":"692211167","full_name":"replit/replit-code-exec","owner":"replit","description":"A library that allows interacting with Replit's code-exec API","archived":true,"fork":false,"pushed_at":"2024-12-24T00:50:31.000Z","size":197,"stargazers_count":23,"open_issues_count":3,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-21T02:48:36.689Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/replit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-15T20:19:10.000Z","updated_at":"2025-02-11T18:30:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"f8922c2e-c48e-4af3-91cf-dd053027dfac","html_url":"https://github.com/replit/replit-code-exec","commit_stats":null,"previous_names":["replit/replit-code-exec"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/replit%2Freplit-code-exec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/replit%2Freplit-code-exec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/replit%2Freplit-code-exec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/replit%2Freplit-code-exec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/replit","download_url":"https://codeload.github.com/replit/replit-code-exec/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248151066,"owners_count":21056017,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T22:09:50.118Z","updated_at":"2025-04-10T03:31:46.535Z","avatar_url":"https://github.com/replit.png","language":"Python","readme":"# `replit-code-exec`\n\nAn interface to interact with Replit's code-exec API.\n\nThis is an interface for the simpler use cases of https://replit.com/@luisreplit/eval-python,\nwhich is a stateless API that is optimized to be called from AI Agents so that they can perform\nnumerical reasoning through the evaluation of generated Python code. In general, this allows\nthe execution of an untrusted snippet of Python code and returns whatever is printed to standard\noutput / standard error as the result. The execution is done inside an ephemeral unprivileged\ncontainer created on the fly running in Replit Deployments using\nhttps://github.com/omegaup/omegajail as code sandbox.\n\nTo set up your own copy of the API server, you need to follow these easy 2-3 steps (the second\nis optional):\n\n1. Open the https://replit.com/@luisreplit/eval-python in your browser and Fork it to your\n    account.\n2. (Optional): if you want to change the Docker container, run `evalctl image ${DOCKER_IMAGE}`\n    (e.g. `evalctl image python:3` or `evalctl image replco/python-kitchen-sink:latest`).\n    * Open `.replit` and change the `EVAL_FILENAME`, `EVAL_RUN_COMMAND`, `EVAL_ENV` to suite the\n      new container, if needed.\n3. Deploy the Repl! (just pressing `Run` is not enough)\n    * This is only compatible with the Autoscale Deployments.\n    * Make sure you set the `EVAL_TOKEN_AUTH` Deployments secrets when\n      doing so for authentication.\n\n## Sample usage\n\nHere is a small example of this library being used as a small math solver using OpenAI API:\n\n```python\nimport openai\nimport replit_code_exec\n\ncode_exec = replit_code_exec.build_code_exec(...)\n\ndef solve_math(prompt: str, model: str = 'gpt-3.5-turbo-0613') -\u003e str:\n    completion = openai.ChatCompletion.create(\n        model=model,\n        temperature=0.7,\n        functions=[code_exec.openai_schema],\n        function_call={\"name\": \"code_exec\"},\n        messages=[\n            {\n                \"role\": \"system\",\n                \"content\": (\"You are an assistant that knows how to solve math \" +\n                            \"problems by converting them into Python programs.\"),\n            },\n            {\n                \"role\": \"user\",\n                \"content\": (\"Please solve the following problem by creating a Python \" +\n                            \"program that prints the solution to standard output using \" +\n                            \"`print()`: \" + prompt),\n            },\n        ],\n    )\n    return code_exec.from_response(completion)\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freplit%2Freplit-code-exec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freplit%2Freplit-code-exec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freplit%2Freplit-code-exec/lists"}