██████╗ ███████╗███████╗██████╗ ██████╗ ██╗ ██╗███████╗███╗ ██╗
██╔══██╗██╔════╝██╔════╝██╔══██╗██╔═══██╗██║ ██╔╝██╔════╝████╗ ██║
██████╔╝█████╗ ███████╗██████╔╝██║ ██║█████╔╝ █████╗ ██╔██╗ ██║
██╔══██╗██╔══╝ ╚════██║██╔═══╝ ██║ ██║██╔═██╗ ██╔══╝ ██║╚██╗██║
██████╔╝███████╗███████║██║ ╚██████╔╝██║ ██╗███████╗██║ ╚████║
╚═════╝ ╚══════╝╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═══╝
A terminal chat experience that you can configure yourself.
Basic installation:
uv pip install bespoken
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:
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,
)
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.
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.",
}
)
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!