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.37.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.37-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: hammad_python-0.0.37.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.37.tar.gz
Algorithm Hash digest
SHA256 b619f7d241f104a5d14effa42e7e4bdf70aa7178a38f0c093ab261b6554dfe9e
MD5 cfa31a9f9e8d486fd6f595c0ef482247
BLAKE2b-256 e1b93d4ae4e64c9279a2d3e401020d25f0c7cfe79bd09736c252fa00a9f35ecb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hammad_python-0.0.37-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.37-py3-none-any.whl
Algorithm Hash digest
SHA256 d3e0cb5f0a5ed90070c98ee1ab59917b077b6d23d87040d6c62c045501be1a85
MD5 ec44bae1ee46ac8b7359f747a22c377c
BLAKE2b-256 525f38788b710e3550d70a42cda19e3b4fccde9184785929d1e3728dae6d0716

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