Skip to main content

Automatically generate an OpenAI Assistant interface for any python typer CLI.

Project description

TyperAssistant

Instantly turn any python Typer CLI in to a function-calling OpenAI assistant.

Example Typer app:

import getpass
import typer
from typerassistant import register_assistant

app = typer.Typer()
register_assistant(app)

@app.command()
def say_hello(name: str):
    print(f"Hello, {name}!")

@app.command()
def get_current_user():
    print(getpass.getuser())

if __name__ == "__main__":
    app()

Example CLI usage: python example_1.py ask "Please greet me by my name"

Installing

TyperAssistant uses poetry for a build system, so you can safely install it like you would any python package.

$ pip install typerassistant

Or, with poetry:

$ poetry add typerassistant

Usage

Please be aware that OpenAI's API incurs fees. See OpenAI's help article on the subject for more information.

A documentation pass is planned before the 1.0 release, but at this time the best way to learn how to use TyperAssistant's features is to go check out the examples/ directory. You can also see that the main typerassistant package only exports three members:

  • Assistant, a basic frontend for OpenAI's Assistant API that handles function calling and threads.
  • TyperAssistant, an Assistant subclass which wraps a Typer application.
  • register_assistant(app: Typer), a function which registers an "ask" command and automatically generates an appropriate assistant for your application.

Most use cases require only register_assistant(app) to begin working immediately!

Contributing

Patches are welcome, as are questions, suggestions, and example usecases! TyperAssistant is still in very early development, and I am hoping to find some excited collaborators to help build the roadmap to 1.0.

For now, please use the github Issues feature, but I plan to investigate further as needs dictate.

License

This software is licensed with the MIT license. Please see the file LICENSE for more information.

TyperAssistant is copyright Erich Blume, 2023.

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

typerassistant-0.3.1.tar.gz (9.8 kB view hashes)

Uploaded Source

Built Distribution

typerassistant-0.3.1-py3-none-any.whl (10.4 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