Skip to main content

No project description provided

Project description

hammad-python

Happily Accelerated Micro-Modules (for) Application Development

Introduction

The hammad-python library, is a mix of a love letter and collection of mixed resources for developing Python applications. This library is meant to be used for rapid prototyping and development, and is focused on providing styled placeholder tools for common patterns, tasks and workflows.

The package is currently built into the following structures:

  • hammad-python : Contains most core functionality and resources.
  • hammad-python[ai] : Contains easy to use resources for Generative AI related tasks such as generating completions with language models, or creating embeddings.
  • hammad-python[serve] : Contains FastAPI / Uvicorn based resources for serving and running applications.

Installation

You can install the package using pip or uv:

pip install hammad-python

# or install the `ai` extension
# pip install 'hammad-python[ai]'

# or install the `serve` extension
# pip install 'hammad-python[serve]'
uv pip install hammad-python

# or install the `ai` extension
# uv pip install 'hammad-python[ai]'

# or install the `serve` extension
# uv pip install 'hammad-python[serve]'

Basic Usage

Data Structures, Databases and Other Data Related Resources

Collections

Using hammad.data.collections is a simple way to create searchable collections of data using both bm25 and vector based search.

from hammad.data.collections import create_collection

# Create either a `vector` or `searchable` collection
col = create_collection(type = "searchable")

# add anything to the collection
col.add("This is some text")
col.add(5)
col.add({'text' : "this is a dictionary"})

# search the collection
print(col.query("text"))

Databases

Any collection can be either used as a standalone database, or can be added as one of the collections within a database. Databases provide a unified interface for handling both Searchable and Vector based collections.

from hammad.data.collections import create_collection
from hammad.data.databases import Database

# Create either a `vector` or `searchable` collection
col = create_collection(type = "searchable")

col.add("This is some text")

# Databases can either be created on memory or using a path
db = Database(location = "memory")

db.add_collection(col)

# search globally or within a single collection
print(db.query("text"))

Styling / Introspection Resources

The hammad-python package contains a variety of components that can be used to easily style, or run introspection (logging) on your code.

from hammad.cli import print, input, animate

# Use extended `rich` styling easily
print("Hello, World", bg_settings = {"title" : "This is a title"})

# Easily collect various forms of input in a single function
class User(BaseModel):
    name : str
    age : int

# TIP:
# you can style this the same way with `print`
user = input("Enter some information about yourself: ", schema = User)

# easily run a collection of prebuilt animations
animate("This is a rainbow!", type = "rainbow", duration = 2, refresh_rate = 20)

Using the various hammad.logging resources, you can both create custom & styled loggers, as well as easily inspect various aspects of your code during runtime.

from hammad.logging import Logger

# create standard / file based loggers easily
logger = Logger("hammad", level = "info", rich = Trues)

file_logger = Logger("hammad-file", level = "info", file = "hammad.log")

# log to the console
logger.info("This is an info message")

# Use the various `trace_` methods to run various introspection tasks
from hammad.logging import (
   trace,
   trace_cls,
   trace_function,
   trace_http
)

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

hammad_python-0.0.25.tar.gz (375.5 kB view details)

Uploaded Source

Built Distribution

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

hammad_python-0.0.25-py3-none-any.whl (290.2 kB view details)

Uploaded Python 3

File details

Details for the file hammad_python-0.0.25.tar.gz.

File metadata

  • Download URL: hammad_python-0.0.25.tar.gz
  • Upload date:
  • Size: 375.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for hammad_python-0.0.25.tar.gz
Algorithm Hash digest
SHA256 9513465e95fbb920dcd8927cf900dd14008ef46ca1c9b17b8a2bb0e90cd474ee
MD5 4152125a2438d86f9880d2c988e4dcd4
BLAKE2b-256 dff04f5252a47c47d0823ad17553f2dac29c040831d2eca9ca34cd8f2c03bf63

See more details on using hashes here.

File details

Details for the file hammad_python-0.0.25-py3-none-any.whl.

File metadata

  • Download URL: hammad_python-0.0.25-py3-none-any.whl
  • Upload date:
  • Size: 290.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for hammad_python-0.0.25-py3-none-any.whl
Algorithm Hash digest
SHA256 18bb339bcf2c4a5d762a55f0927bb1b4f368ed0bd5e53618d5c922d6ea4577b6
MD5 7bd93bc4296737422889f89308576c9d
BLAKE2b-256 2fa45474e7ba4d6ded4a7fdc3ec3014226378f63e3f80683eaa1c0135580d1cd

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