Skip to main content

Technology demonstrator self-adapting code

Project description

Readme

This is a simple demonstration project. More like this is possible at this point. Use at your own risk. This code is ultimately non-deterministic and nobody knows what might happen.

Importing this code will give a simple python script rudimentary way of fixing itself. This scripts registers itself as a global exception hook, retrieves the source code that failed, executes llm to fix the code, substitutes it back in and continues execution as if nothing happened.

Simple, eh?

Components

Configuration

Configuration area for the module. This is simply a python module that is loaded and referenced. Easy and flexible. Security is not a consideration since:

A) This project is meant to be a library / agent that is included within another project, having complete and total control of that project. B) We are running AI within our code and allowing it to make decisions on the fly. C) There is no end-user facing configuration planned at this point.

AI

System of selecting and listing available models. To be expanded later. Key functionality:

  • Assume that capability may change over time. There has to be a method of re-examining capabilities and adding to them.
  • Allow for models to be deleted, even if they were found before.
  • Allow to handle models (at least try to), even if they are new.
  • Optionally allow to download models?

Prompts

System of having and selecting one of multiple prompts. Key Functionality:

  • Some prompts work with some models, and not others.
  • Some prompts may require different information. Thankfully we can try different prompts and get an error if information is not available.
  • Each prompt should have some way of deciding if a model can be used to evaluate it.

Decorators

Currently only one decorator. Eventually others may be added. Decorator is capable of catching and monitoring a single function (for now), while recording information about that section of code.

Necromancer

Last ditch effort to respond to an unhandled exception. At this stage the program is effectively dead and the stack has unravelled. More testing is needed whether necromancer can restore a complex program, but should work for simple scripts.

Installation

Ollama

Need ollama installed together with pip install ollama.

Need to download an appropriate model and set it inside caretaker/config.py. While you are at it, feel free to improve on the prompt.

Issues and future work

There are several issues with this code. Some (most probably) are fixable.

  1. Simple scripts for now, cannot handle injecting into an object. Actually, I think it can, I just messed up with the stack and need to retrieve it properly.

  2. It only modifies the code in memory, does not write it back out to the filesystem.

  3. There needs to be a system to figure out which model from ollama to run, there may be prompts specific to models. We want this to figure out what to do even a year later, when models may be different. Could it download a model for itself and then run it?

  4. Catching it at global exception hook means the program is already dead. Restarting execution (if the failure happened in a loop, etc), is tricky.

  5. A lot of the above can be handled by introducing a decorator (coming next). That will allow me to catch errors at a specific section of a code, store and retrieve different versions of related code from a database, catch, re-run and return code as if nothing happened, store things like specific prompts and intents. Kind of like an advanced error handler.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aicaretaker-0.1.0.tar.gz (19.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

AICaretaker-0.1.0-py3-none-any.whl (18.0 kB view details)

Uploaded Python 3

File details

Details for the file aicaretaker-0.1.0.tar.gz.

File metadata

  • Download URL: aicaretaker-0.1.0.tar.gz
  • Upload date:
  • Size: 19.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for aicaretaker-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b8c73cb3a42f1b2ce7d04f2caeba01ecc1514773575f404ecd654c8fd30dbca0
MD5 170a0dea2fd0180f15ff06a608e3e0a5
BLAKE2b-256 7cc463b30a1eb3168c16f6348bbbc516ae7093ea3a45090611bf51d2b415edfd

See more details on using hashes here.

File details

Details for the file AICaretaker-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: AICaretaker-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for AICaretaker-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bf793e82991f4f23e7dfc4b4e5b4e080c2db844a62b11795ff10912658c261bb
MD5 ed2e70f09dd4f3a016a17c11eb23d66a
BLAKE2b-256 c0d641487628afeb7fa9caa62a7adbf6a3299d3c3923369dd44ec7b6c1422af3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page