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.38.tar.gz (434.1 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.38-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: hammad_python-0.0.38.tar.gz
  • Upload date:
  • Size: 434.1 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.38.tar.gz
Algorithm Hash digest
SHA256 d300a6c48daecdf60a99fb07e25576d4beb34d1a2ffeaceada5029d5a0dc22f0
MD5 b705063957f02d137a37623abe2e56b5
BLAKE2b-256 1af6081360b06d72be9f922dc4d3e795e2b9ebf4e7bd615d2200653c5e114b2d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hammad_python-0.0.38-py3-none-any.whl
  • Upload date:
  • Size: 5.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.38-py3-none-any.whl
Algorithm Hash digest
SHA256 e719ee198c0b17746c69468e1e54e11653d2e815e5928bc22adeac6ee997f63d
MD5 ad5f5f1ad5c144aaf40c07c499e29ba7
BLAKE2b-256 aed43019bacbccfa25264b57c5c48e61769d702d39bcc1b84ad470693d841aa0

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