Skip to content

Add CallbackFunction.from_python() method #109

@hcpchris

Description

@hcpchris

The CallbackFunction.from_python() method is intended to be a method which can convert an arbitrary Python callable (e.g. a function, typically) into a properly structured JavaScript function.

Because available Python transpiler libraries have proven to be ineffective (too limited, too slow, or both) the adopted strategy is to rely on generative AI to do the transpiling.

To that end, the .from_python() method should:

  • Support developers using OpenAI's GPT / Codex.
  • Support developers using Anthropic's Claude.
  • Support developers using Hugging Face.
  • Validate that the passed-in function is a callable.
  • Retrieve the source of the passed-in function. This will require the presence of the dill library, and the use of dill's getsource() function.
  • Authenticate against the AI tool using the user's supplied credentials (pulled from an environment variable or passed directly).
  • Support the passing of the function's source to the user's selected AI tool.
  • Retrieve the JavaScript function as a string.
  • Deserialize the JS function into a CallbackFunction instance.
  • Return the CallbackFunction.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions