Skip to main content

A toolbox to build your own assistant for in the terminal.

Project description

bespoken


██████╗ ███████╗███████╗██████╗  ██████╗ ██╗  ██╗███████╗███╗   ██╗
██╔══██╗██╔════╝██╔════╝██╔══██╗██╔═══██╗██║ ██╔╝██╔════╝████╗  ██║
██████╔╝█████╗  ███████╗██████╔╝██║   ██║█████╔╝ █████╗  ██╔██╗ ██║
██╔══██╗██╔══╝  ╚════██║██╔═══╝ ██║   ██║██╔═██╗ ██╔══╝  ██║╚██╗██║
██████╔╝███████╗███████║██║     ╚██████╔╝██║  ██╗███████╗██║ ╚████║
╚═════╝ ╚══════╝╚══════╝╚═╝      ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═╝  ╚═══╝


A terminal chat experience that you can configure yourself.

Installation

Basic installation:

uv pip install bespoken

Usage

This library uses llm under the hood to provide you with building blocks to make LLM chat interfaces from the commandline. Here's an example:

demo

This interface was defined via below:

from bespoken import chat
from bespoken.tools import FileTool, TodoTools, PlaywrightTool

chat(
    model_name="anthropic/claude-3-5-sonnet-20240620",
    tools=[FileTool("edit.py")],
    system_prompt="You are a coding assistant that can make edits to a single file.",
    debug=True,
)

Features

Autocomplete

Tab completion for commands and file paths. Use @file.py to get file path suggestions, "/" + TAB> to autocomplete commands or use arrow keys for command history.

parrot

Custom slash commands

Define your own /commands that either send text to the LLM or trigger interactive functions:

def save_conversation():
    """Save conversation to file"""
    filename = ui.input("Filename: ")
    return f"Saved to {filename}"

chat(
    ...,
    slash_commands={
        "/save": save_conversation,
        "/formal": "Please respond in a formal manner.",
    }
)

Why?

The goal is to host a bunch of tools that you can pass to the LLM, but the main idea here is that you can also make it easy to constrain the chat. The FileTool, for example, only allows the LLM to make edits to a single file declared upfront. This significantly reduces any injection risks and still covers a lot of use-cases. It is also a nice exercise to make tools like claude code feel less magical, and you can also swap out the LLM with any other one as you see fit.

This project is in early days at the moment, but it feels exciting to work on!

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

bespoken-0.2.2.tar.gz (26.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bespoken-0.2.2-py3-none-any.whl (24.0 kB view details)

Uploaded Python 3

File details

Details for the file bespoken-0.2.2.tar.gz.

File metadata

  • Download URL: bespoken-0.2.2.tar.gz
  • Upload date:
  • Size: 26.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.6

File hashes

Hashes for bespoken-0.2.2.tar.gz
Algorithm Hash digest
SHA256 c8533f91aeeaa6638a5762a74a46f8b5df82e0df476746fe88cce1247f17e14e
MD5 e6578e8e082824c3f61ed420746fcbc7
BLAKE2b-256 a3816e9b6238104e8e5b8ed8969736ea415c8efa6d7c4e95610bb392f0d057d3

See more details on using hashes here.

File details

Details for the file bespoken-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: bespoken-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 24.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.6

File hashes

Hashes for bespoken-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 21340c09ffc2031c29335a4ec3870b54158867c26095934ee6a2576e1d0c9981
MD5 358d5f79a8a3a11cc71f8901dee549d3
BLAKE2b-256 2e12b3124c82d42d7afa04f15ed08b3e691ac6a0611f1c9d69220ecb280d1117

See more details on using hashes here.

Supported by

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