GithubHelp home page GithubHelp logo

stephen-bunn / prompt-toolkit-action-completer Goto Github PK

View Code? Open in Web Editor NEW
6.0 3.0 1.0 2.33 MB

A fairly simple method for registering callables as prompt-toolkit completions

Home Page: https://prompt-toolkit-action-completer.readthedocs.io/en/latest/

License: ISC License

Python 100.00%
prompt-toolkit python completer

prompt-toolkit-action-completer's Introduction

Hey ๐Ÿ‘‹ I'm Stephen

I'm a "full-stack" dev who mainly uses free time to create small tools for myself. Most of my professional time has been spent working with Python, Rust, or various JS frontends. Mainly my experience has been focused on web development and internal engineering tools.

If you would like to view more information about my experience, you can skim my resume at bunn.io. If you are interested in contacting me about open opportunities, please reach out with an email to [email protected].

Otherwise, you can find me on Mastodon.

prompt-toolkit-action-completer's People

Contributors

stephen-bunn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

mitchenall

prompt-toolkit-action-completer's Issues

Dependency on `typing-extensions` not declared in setup

Summary

pyproject.toml is missing the install dependency on typing-extensions which is necessary for the Protocol typings declared in completer.py.
Probably causing users issues as a dependency is missing.

Warrants a hotfix release.

Talk about the steps you took to produce the bug:

  1. Install release v1.1.0 in a clean virtual environment through pip
  2. Try to import and create an instance of ActionCompleter

These are some technical details that will also us help out:

  • Project Version: 1.1.0
  • Python Version: 3.8
  • Operating System: Mac OSX

Issue Checklist

  • I checked for duplicate issues ๐Ÿ‘
  • I made sure to fill out the steps I took to produce the bug ๐Ÿ˜‰
  • I made sure to drink a glass of water ๐Ÿฅ›

Thanks! โค๏ธ

Pipelines support

Summary

Pipelines provide powerful operations such as passing execution results and executing multiple commands in a single code.
They comes primarily after the action, but checking the pipeline with each function is tedious and inefficient.

Potential Implementations

Split the strings with pipeline characters such as "&&" and "|", group the string into an object array with the pipeline type, and execute them in order from the beginning.

Risks or Caveats

  1. In some cases, methods needs to recognize the pipeline character as an argument
  2. Depending on the return type of the function, it can be difficult to implement "|" (such as None)

Issue Checklist

  • I checked for duplicate issues ๐Ÿ‘
  • I made sure to fill out the potential implementations ๐Ÿ˜‰
  • I made sure to document the risks and caveats of my request โœŒ๏ธ
  • I made sure to drink a glass of water ๐Ÿฅ›

Thanks! โค๏ธ

Include the name of the Action's parent trigger in the Action class

Summary

It would be useful for the user to be able to understand what the action's trigger name is directly off of the action in custom callable completers and validators. When building a custom callable completer, I currently have no text name of the action to use for generating the completion. Including the name will help users to generate better completion messages and such.

Potential Implementations

On registration of a new action, we will need to mark the name it was registered under on the action itself. This should be done in the types.ActionGroup.action decorator as well as validated in the Action.__attrs_post_init__ call.

Risks or Caveats

  • It's not necessarily sustainable for external users to use the action's trigger name on the action itself. This trigger name lacks context into its sibling actions or groups included in the action's current group.
  • We are duplicating data somewhat by storing the trigger name in both the group containing the action and the action itself.
  • This will also affect the current context extraction utility. We will no longer need to include the parent name in the context tuple.
  • When building the Action manually, we will need to include the trigger name multiple times (once in the group and once in the action)

Issue Checklist

  • I checked for duplicate issues ๐Ÿ‘
  • I made sure to fill out the potential implementations ๐Ÿ˜‰
  • I made sure to document the risks and caveats of my request โœŒ๏ธ
  • I made sure to drink a glass of water ๐Ÿฅ›

Thanks! โค๏ธ

Action completion raises warning from fuzzywuzzy when entering `.` as input

Summary

Assumingly for any prompt, entering a starting . or similar punctuation character will raise the following warning:

WARNING:root:Applied processor reduces input query to empty string, all comparisons will have score 0. [Query: '.']

Why fuzzywuzzy or python-levenstien decides it's appropriate to raise a warning in this case is beyond me.
In any case, we need to silence it.

Bug Details

Using any completer with an action and parameter defined:

from action_completer import ActionCompleter
from prompt_toolkit.completion import PathCompleter

completer = ActionCompleter()

@completer.action("hello-world")
@completer.param(PathCompleter())
def _action(my_path: str):
	print(f"Hello, World!, also {my_path}"


prompt("$> ", completer=completer)

By entering a . as the input to the prompt, the following warning is raised:

WARNING:root:Applied processor reduces input query to empty string, all comparisons will have score 0. [Query: '.']

These are some technical details that will also us help out:

  • Project Version: 1.0.0
  • Python Version: 3.8
  • Operating System: Ubuntu 10.04

Issue Checklist

  • I checked for duplicate issues ๐Ÿ‘
  • I made sure to fill out the steps I took to produce the bug ๐Ÿ˜‰
  • I made sure to drink a glass of water ๐Ÿฅ›

Thanks! โค๏ธ

Auto format `display` and `display_meta` strings with `value` if supplied

Summary

I commonly run into annoyances with the fact that I have to build a callable just to include the value of the current action parameter in the display or display_meta strings.
So I think it would be valuable to autoformat {value} in the given string with the current parameter value.

Potential Implementations

In https://github.com/stephen-bunn/prompt-toolkit-action-completer/blob/master/src/action_completer/completer.py#L301-L360 we would need to first call .format(value=text) in all calls to get_dynamic_value.
That should honestly be all we need to do for this.

Risks or Caveats

Little to no risk as this is just a straight-up feature add.
If for some reason someone out there is using {value} in their display or display_meta text already, they will experience breakages.

Issue Checklist

  • I checked for duplicate issues ๐Ÿ‘
  • I made sure to fill out the potential implementations ๐Ÿ˜‰
  • I made sure to document the risks and caveats of my request โœŒ๏ธ
  • I made sure to drink a glass of water ๐Ÿฅ›

Thanks! โค๏ธ

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.