alana-utilities
alat-rights/alana-utilities
Utilitários Python para prototipagem rápida com Claude
Ver no GitHubBiblioteca Python que simplifica a interação com Claude através de utilitários ergonômicos para prototipagem rápida. Oferece funções para gerar respostas, gerenciar histórico de mensagens, extrair conteúdo e criar exemplos few-shot com sintaxe reduzida.
Instalação
npx convez-ai alat-rights/alana-utilities1 comando no terminal: detecta o formato do repositório (marketplace ou plugin avulso) e instala via Claude Code. Requer Node 18+ e o Claude Code instalado.
Métricas
Casos de uso
- Acelerar desenvolvimento de protótipos que usam Claude
- Simplificar gerenciamento de histórico de conversas
- Extrair e processar outputs de Claude com regex
- Gerar prompts e exemplos few-shot programaticamente
Veredito

Ferramenta útil para acelerar prototipagem com Claude, reduzindo boilerplate da API Anthropic. Adequada para desenvolvimento não-produção, com API ergonômica mas ainda em desenvolvimento ativo sem garantias de compatibilidade retroativa.
README
A tradução para o português deste README ainda está na fila.
What is alana-utilities?
This library is designed to make interacting with Claude fast and easy. It is primarily targeted toward people writing non-production, prototype code. It prioritizes developer ergonomics.
It speeds up lots of things that I frequently find myself doing with Claude.
- Generating a response to a user and system prompt
alana.gen(user=..., system=...) - Creating and/or extending a list of MessageParams
alana.respond(message_content, role="user") - Extracting content from Claude's output using Regex
alana.get_xml(tag, content) - Generate a prompt or a Python list of few-shot examples
alana.gen_prompt&alana.few_shotrespectively
What is alana?
I am alana :)
Motivating Examples
I tested these, and I've tried to make sure my code was idiomatic in all cases. Sorry if I messed up! Please open a GitHub issue if you catch a mistake.
Continuing a list of messages using Anthropic API (adapted from Anthropic API documentation):
import anthropic
from anthropic.types import MessageParam
messages = [
MessageParam(
role="user",
content="Hello, Claude!"
),
]
output_text = anthropic.Anthropic().messages.create(
model="claude-3-opus-20240229",
max_tokens=1024,
messages=messages
).content[0].text
messages.append(
MessageParam(
role="assistant",
content=output_text
)
)
print(messages) # [{'role': 'user', 'content': 'Hello, Claude!'}, {'role': 'assistant', 'content': "Hello! It's nice to meet you. How are you doing today?"}]
Equivalent alana code:
import alana
messages = []
alana.gen(user="Hello, Claude!", messages=messages, model="opus", max_tokens=1024)
print(messages) # [{'role': 'user', 'content': 'Hello, Claude!'}, {'role': 'assistant', 'content': "Hello! It's nice to meet you. How are you doing today?"}]
Also, equivalent alana code thanks to defaults:
import alana
messages = []
alana.gen(user="Hello, Claude!", messages=messages)
print(messages) # [{'role': 'user', 'content': 'Hello, Claude!'}, {'role': 'assistant', 'content': "Hello! It's nice to meet you. How are you doing today?"}]
Install Instructions
pip install alana
🎵 Note: I have been making new releases frequently. Make sure your package is up-to-date!
⚠️ Warning: This library is in active early development! No guarantees are made for backward compatibility. The library is NOT production-ready.
Usage Instructions
- Import via
import alanaor, if you're brave,from alana import *. - Make your Anthropic API key available as an environment variable.
os.environ["ANTHROPIC_API_KEY"] = "..."
The documentation for this project is hosted at utils.alana.computer.
Philosophy
- Programming is too slow! This is doubly true when you're interacting with LLMs. By building nice utilities with sane defaults, I hope to speed up my (and maybe your) workflow.
- I make trade-offs to speed up the developer experience:
- I do not try hard to anticipate future upstream API changes. I'm also ok with breaking backward compatibility to make my functions more concise and more usable.
- Usability > Principles. While I don't relish in it, I'm ok with breaking conventions designed for large production libraries if it speeds up programmers who use
alana. The priority is to make the library intuitive and fast. - I don't try to serve every use-case.
- Simplicity is key. This library strives to be readable and straightforward.
Features
- Easy color print:
alana.red,alana.green,alana.blue,alana.yellow,alana.cyan. Tryalana.green("Hello!") - Easy pretty print with Sonnet (or an Anthropic model of your choice):
alana.pretty_print. Tryalana.pretty_print(t.arange(16, device='cpu').reshape(2,2,4)) - Make it easier to use the Anthropic API:
alana.gen, for easy Claude generations. Tryalana.gen(user="Hello, Claude!"). You can pass in amessagesparameter (a list of anthropic.types.MessageParams) either in place of or together with auserparameter.alana.respond, easily appending a user message to a list of MessageParams!alana.gen_examples,alana.gen_examples_listfor generating few-shot examples.alana.gen_prompt, for easy prompt generation (meta-prompt).alana.get_xml, for using regex to get XML tag contents from model outputs. ⚠️ Regex parsing of XML may be unreliable!alana.remove_xmlto strip certain XML tag-enclosed content from a string (along with the tags). This is primarily intended to get rid of "..." strings. ⚠️ Regex parsing of XML may be unreliable!
- A bunch of aliases (Try:
alana.few_shot,alana.n_shot, oralana.xml)
Contributing
Welcome! Thank you for considering making a contribution to alana-utilities.
Getting started
If you'd like to make a major refactor or breaking change, please open an Issue first. This way, I can review it to determine if it is within scope for this project.
There are no guarantees that your pull requests will be merged into the library. alana-utilities is essentially a hobby project, and there is currently only one maintainer.
In general, we follow the "fork-and-pull" Git workflow.
Style and formating
We are using Black for formatting and PyRight for type checking.
Before submitting a pull request, please run black . on your code. This saves us from failed CI runs.
To install and run Black:
$ pip install black
$ black .
To install and run PyRight:
$ pip install pyright
$ pyright .
Testing
There are simple tests written with unittest. I am working on extending the test suite.
You may need to provide your Anthropic API key as an environment variable to run all of the unit tests. See #10.
First install flaky plugin with pip:
$ pip install flaky
Next run:
$ python simple_tests.py
Coming Soon
- Generating alternative prompts given a prompt
- OpenAI model support
- Support for automatic "are you sure"/"are you confused" multi-turn prompting
- Automatic error checking (are there mistakes in this code, sanity checking of model outputs)
- Automatic model-switching on rate limit
- Support for quick-and-dirty unit-testing with Claude!
- Prompt test case generation and easy prompt testing