Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.
/ TyperAssistant Public archive

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

License

Notifications You must be signed in to change notification settings

eblume/TyperAssistant

Repository files navigation

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, 2024.

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages