Skip to main content

hammad-python

Harmoniously Accelerated Micro-Modules (for) Application Development


hammad-python is an ecosystem of wrappers with the sole purpose of defining opinionated resources that I myself use in my projects and day to day work when building with Python.

The ecosystem is split into 4 main sub-packages:

  • hammad-python-core : Contains "stdlib" like resources such as converters, types, caching, etc. All of these resources can easily be implemented from scratch, and are built soley for convenience.
  • hammad-python-data : Contains a Collection class / system that implements a simple vector / non vector database system.
  • hammad-python-genai : Contains a collection of patterns for using Generative AI models as well as implementing concepts like Agentic Reasoning.
  • hammad-python-http : HTTP / API related resources and utilities. Contains resources related to MCP, HTTP, OpenAPI & GraphQL Servers.

Installation

You can install any of the sub-packages, or the main package through pip or uv.

pip install hammad-python

Quickstart

Easily Use Language Models With Various Tools & Patterns

from ham.genai import Agent, LanguageModel
from ham.http import SearchClient

client = SearchClient()

def search_web(query: str) -> str:
    return client.search(query)

# create your agent
# agents have rich functionality, and use `litellm` & `instructor` under the hood
agent = Agent(
    instructions = "You are a helpful assistant who can search the web",
    tools = [search_web]
)

print(agent.run("What is the weather in Tokyo?"))
>>> AgentResponse:
city='Tokyo' temperature=25.0 description='Clear sky'

>>> Model: openai/gpt-4o-mini
>>> Steps: 2
>>> Output Type: Response
>>> Total Tool Calls: 1

Vectorized & Searchable Collections

from ham.data import Collection

collection = Collection(vector=True)

collection.add("Rocks")
collection.add("Cucumber")
collection.add("Dragon")
collection.add("Apple")

# query the collection
for result in collection.query("Fruit"):
    print(result.item)
>>> Apple
>>> Cucumber
>>> Dragon
>>> Rocks

HTTP & API Resources

from ham.http import function_server

# instantly launch a server by decorating a function
@function_server(path="/some-endpoint", auto_start=True)
def some_endpoint(name : str) -> str:
    return f"Hello, {name}!"

Now in a separate file:

import requests

print(
    requests.post(
        "http://0.0.0.0:8000/some-endpoint",
        json = {"name": "John"}
    ).json()
)
>>> {'result' : 'Hello, John!'}

Metadata

Release files for hammad-python 0.0.38

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hammad-python 0.0.38
File Size Uploaded
hammad_python-0.0.38.tar.gz 434.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for hammad-python 0.0.38
File Interpreter ABI Platform
hammad_python-0.0.38-py3-none-any.whl Python 3 none any Details

Total release size: 439.3 kB

Release files / hammad_python-0.0.38.tar.gz

Download URL hammad_python-0.0.38.tar.gz
Size 434.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d300a6c48daecdf60a99fb07e25576d4beb34d1a2ffeaceada5029d5a0dc22f0
BLAKE2b-256 checksum
How to use checksums
1af6081360b06d72be9f922dc4d3e795e2b9ebf4e7bd615d2200653c5e114b2d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.11

Release files / hammad_python-0.0.38-py3-none-any.whl

Download URL hammad_python-0.0.38-py3-none-any.whl
Size 5.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e719ee198c0b17746c69468e1e54e11653d2e815e5928bc22adeac6ee997f63d
BLAKE2b-256 checksum
How to use checksums
aed43019bacbccfa25264b57c5c48e61769d702d39bcc1b84ad470693d841aa0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.11

Release history Release notifications | RSS feed

This release

0.0.38 This release

2 release files

0.0.37

2 release files

0.0.36

2 release files

0.0.35

2 release files

0.0.34

2 release files

0.0.33

2 release files

0.0.32

2 release files

0.0.31

2 release files

0.0.30

2 release files

0.0.29

2 release files

0.0.28

2 release files

0.0.27

2 release files

0.0.26

2 release files

0.0.25

2 release files

0.0.24

2 release files

0.0.23

2 release files

0.0.22

2 release files

0.0.21

2 release files

0.0.20

2 release files

0.0.19

2 release files

0.0.18

2 release files

0.0.17

2 release files

0.0.16

2 release files

0.0.13

2 release files

0.0.12

2 release files

0.0.11

2 release files

0.0.10

2 release files

0.0.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page