Skip to main content

Personal Assistant on the command line

Project description

Yoda PA

Github CI PyPI version

Personal Assistant on the command line.

Yoda

Installation

pip install yodapa

yoda --help

Configure Yoda

yoda configure

Plugins

Yoda is designed to be extensible. You can write your own plugins or use the AI to generate one for you.

List plugins

The help command will list all the available plugins.

❯ yoda --help
                                                                            
 Usage: yoda [OPTIONS] COMMAND [ARGS]...                                    
                                                                            
╭─ Options ────────────────────────────────────────────────────────────────╮
│ --install-completion          Install completion for the current shell.  │
│ --show-completion             Show completion for the current shell, to  │
│                               copy it or customize the installation.     │
│ --help                        Show this message and exit.                │
╰──────────────────────────────────────────────────────────────────────────╯
╭─ Commands ───────────────────────────────────────────────────────────────╮
│ ai       AI command. Allows you to communicate with your local LLMs      │
│ config   Config management                                               │
│ dev                                                                      │
│ init     Init yoda configurations                                        │
│ plugin   Commands to manage plugins                                      │
│ url                                                                      │
╰──────────────────────────────────────────────────────────────────────────╯

You can find the details for each plugin with the --help flag. Some examples:

❯ yoda ai --help
                                                                            
 Usage: yoda ai [OPTIONS] COMMAND [ARGS]...                                 
                                                                            
 AI command. Allows you to communicate with your local LLMs                 
                                                                            
╭─ Options ────────────────────────────────────────────────────────────────╮
│ --help          Show this message and exit.                              │
╰──────────────────────────────────────────────────────────────────────────╯
╭─ Commands ───────────────────────────────────────────────────────────────╮
│ chat               Chat with the AI model based on the provided prompt.  │
│ generate-command   Generate code for a new plugin command based on the   │
│                    provided prompt.                                      │
╰──────────────────────────────────────────────────────────────────────────╯
❯ yoda dev --help
                                                                            
 Usage: yoda dev [OPTIONS] COMMAND [ARGS]...                                
                                                                            
╭─ Options ────────────────────────────────────────────────────────────────╮
│ --help          Show this message and exit.                              │
╰──────────────────────────────────────────────────────────────────────────╯
╭─ Commands ───────────────────────────────────────────────────────────────╮
│ checksite          Check if a site is up and running                     │
│ coinflip           Flip a coin!                                          │
│ generatepassword   Generates a secure password                           │
│ speedtest          Test your internet connection                         │
│ whois              Check whois info for a domain name                    │
╰──────────────────────────────────────────────────────────────────────────╯

Write your own plugin for Yoda

Simply create a class with the @yoda_plugin(name="plugin-name") decorator and add methods to it. The non-private methods will be automatically added as sub-commands to Yoda, with the command being the name you provide to the decorator.

import typer

app = typer.Typer(help="""
    Hi plugin. Say hello.

    Example:

        $ yoda hi hello --name MP

        $ yoda hi hello
    """)


@app.command()
def hello(name: str = None):
    """Say hello."""
    name = name or "Padawan"
    typer.echo(f"Hello {name}!")

Use AI to generate your own plugin

$ yoda ai generate-command weather "show weather for the provided location"

🤖 Generated code:

import requests
from typing import Optional

app = typer.Typer(help="""
    Show weather for a given location.

    Example:

        $ yoda weather London

        $ yoda weather -l London
    """)

@app.command()
def weather(location: str, units: Optional[str] = None):
    """Show the current weather for a given location."""
    # Set up your API key or database connection here
    api_key = "YOUR_API_KEY"
    db_conn = None  # Initialize your DB connection here
    
    # Use the requests library to make an HTTP request to the API
    url = f"https://api.openweathermap.org/data/2.5/weather?q={location}&appid={api_key}"
    response = requests.get(url)
    
    # If the response is successful, parse the JSON data and return it in a format that typer can display
    if response.status_code == 200:
        data = response.json()
        temperature = data["main"]["temp"]
        humidity = data["main"]["humidity"]
        wind = data["wind"]["speed"]
        pressure = data["main"]["pressure"]
        
        typer.echo(f"Weather for {location}:")
        typer.echo(f"\tTemperature: {temperature}°C")
        typer.echo(f"\tHumidity: {humidity}%")
        typer.echo(f"\tWind speed: {wind} m/s")
        typer.echo(f"\tPressure: {pressure} hPa")
        
    # If the response is not successful, print an error message
    else:
        typer.echo(f"Error: {response.status_code}")

.. or chat with Yoda:

 yoda ai chat "How are you?"
🤖 AI response:
I am well, young one. The Force is strong with me.

Development setup

# 1. Install poetry from their website: https://python-poetry.org/docs/#installation

# 2. Install dependencies and this package
poetry install

# 3. Activate the virtual environment
poetry shell

# Now you should be able to communicate with yoda
yoda --help

Testing

# Run tests when in the virtual environment
pytest

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

yodapa-2.0.2.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

yodapa-2.0.2-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file yodapa-2.0.2.tar.gz.

File metadata

  • Download URL: yodapa-2.0.2.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.9.20 Linux/6.8.0-1015-azure

File hashes

Hashes for yodapa-2.0.2.tar.gz
Algorithm Hash digest
SHA256 64ca1864260fc0ade83af5f79ff4be988d9cfb84a1f201ce906a64d17f04ba6c
MD5 dda412266084f5af01cc27f372f3775d
BLAKE2b-256 9d3d59edde8187119fbc8626fd87d667d08a11b352ef0aeceecffc6b8004e5a0

See more details on using hashes here.

File details

Details for the file yodapa-2.0.2-py3-none-any.whl.

File metadata

  • Download URL: yodapa-2.0.2-py3-none-any.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.9.20 Linux/6.8.0-1015-azure

File hashes

Hashes for yodapa-2.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2f54af6dd015f29a4072c58fbef9a3927668a86e8fa3d02d4710ec78ec48fa10
MD5 b9f73d4545382f062671788f84c1d1d8
BLAKE2b-256 ff6c75cc6f557adb861cd79f50b84b514815c4384be2d02ae9ad303529604298

See more details on using hashes here.

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