Skip to main content

No project description provided

Project description

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!'}

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.36.tar.gz (434.2 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.36-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: hammad_python-0.0.36.tar.gz
  • Upload date:
  • Size: 434.2 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.36.tar.gz
Algorithm Hash digest
SHA256 4878c9f484c8b7690ed95973426a5a0e41446089eef0399086c899e0683d3478
MD5 324acc1e7517574095d0b48b347cf9bd
BLAKE2b-256 0af1463f30b9a88d6dff8e589046253a84610abb2992bee772261aa4dd7d8472

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hammad_python-0.0.36-py3-none-any.whl
  • Upload date:
  • Size: 5.3 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.36-py3-none-any.whl
Algorithm Hash digest
SHA256 ad778e7237d0e496fb7b8b92764166a4b4274d0b95aa19d5cbf119b5170470c3
MD5 9fc6c3d83bd83b274366b7d115e9bef2
BLAKE2b-256 a78001b443410e5581666dc381e4fd54f9a7737435fae58dbe6a1445890af7c2

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