Skip to main content

Build Python code using natural language as a universal interface

Project description

pycodeless

Warning This project is in a very early stage of development and may not always produce desired results. See the limitations section for more information.

Pycodeless integrates the power of LLMs into the Python programming language and allows you to use natural language as a universal interface for code generation.

Features

  • The @codeless decorator allows you to define your functions using natural language. All generated code is stored and can be edited or commited to your version control system.
  • Support for different language models to allow for better customization and offline usage.
  • Custom docstring formatting to allow for referencing objects across the whole codebase.

Installation

You can install pycodeless using pip:

pip install pycodeless

Usage

Following is a sample code using pycodeless.

from pycodeless import codeless


codeless.openai_api_key = (
    "Paste your OpenAI API key here or set the 'OPENAI_API_KEY' environment"
    "variable!"
)


@codeless
def greet(name: str) -> str:
    """
    Make greeting for a person with the given name
    """


@codeless
def spongebob_case(text: str) -> str:
    """
    Convert the passed text into spongebob case
    """


def main():
    print(spongebob_case(greet("Bob")))


if __name__ == "__main__":
    main()

Limitations

  • The current code generation and parsing features might be buggy, as there's currently no mechanism for telling whether an output from an LLM is actually runnable Python code.
  • The @codeless decorator may not work in all contexts.

Contribution

If you'd like to report a bug or have an idea for a cool feature, issues and pull requests are highly appreciated.

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

pycodeless-0.2.1.tar.gz (6.0 kB view hashes)

Uploaded Source

Built Distribution

pycodeless-0.2.1-py3-none-any.whl (7.7 kB view hashes)

Uploaded Python 3

Supported by

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