hammad-python 0.0.29__py3-none-any.whl → 0.0.31__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ham/__init__.py +10 -0
- {hammad_python-0.0.29.dist-info → hammad_python-0.0.31.dist-info}/METADATA +6 -32
- hammad_python-0.0.31.dist-info/RECORD +6 -0
- hammad/__init__.py +0 -84
- hammad/_internal.py +0 -256
- hammad/_main.py +0 -226
- hammad/cache/__init__.py +0 -40
- hammad/cache/base_cache.py +0 -181
- hammad/cache/cache.py +0 -169
- hammad/cache/decorators.py +0 -261
- hammad/cache/file_cache.py +0 -80
- hammad/cache/ttl_cache.py +0 -74
- hammad/cli/__init__.py +0 -33
- hammad/cli/animations.py +0 -573
- hammad/cli/plugins.py +0 -867
- hammad/cli/styles/__init__.py +0 -55
- hammad/cli/styles/settings.py +0 -139
- hammad/cli/styles/types.py +0 -358
- hammad/cli/styles/utils.py +0 -634
- hammad/data/__init__.py +0 -90
- hammad/data/collections/__init__.py +0 -49
- hammad/data/collections/collection.py +0 -326
- hammad/data/collections/indexes/__init__.py +0 -37
- hammad/data/collections/indexes/qdrant/__init__.py +0 -1
- hammad/data/collections/indexes/qdrant/index.py +0 -723
- hammad/data/collections/indexes/qdrant/settings.py +0 -94
- hammad/data/collections/indexes/qdrant/utils.py +0 -210
- hammad/data/collections/indexes/tantivy/__init__.py +0 -1
- hammad/data/collections/indexes/tantivy/index.py +0 -426
- hammad/data/collections/indexes/tantivy/settings.py +0 -40
- hammad/data/collections/indexes/tantivy/utils.py +0 -176
- hammad/data/configurations/__init__.py +0 -35
- hammad/data/configurations/configuration.py +0 -564
- hammad/data/models/__init__.py +0 -50
- hammad/data/models/extensions/__init__.py +0 -4
- hammad/data/models/extensions/pydantic/__init__.py +0 -42
- hammad/data/models/extensions/pydantic/converters.py +0 -759
- hammad/data/models/fields.py +0 -546
- hammad/data/models/model.py +0 -1078
- hammad/data/models/utils.py +0 -280
- hammad/data/sql/__init__.py +0 -24
- hammad/data/sql/database.py +0 -576
- hammad/data/sql/types.py +0 -127
- hammad/data/types/__init__.py +0 -75
- hammad/data/types/file.py +0 -431
- hammad/data/types/multimodal/__init__.py +0 -36
- hammad/data/types/multimodal/audio.py +0 -200
- hammad/data/types/multimodal/image.py +0 -182
- hammad/data/types/text.py +0 -1308
- hammad/formatting/__init__.py +0 -33
- hammad/formatting/json/__init__.py +0 -27
- hammad/formatting/json/converters.py +0 -158
- hammad/formatting/text/__init__.py +0 -63
- hammad/formatting/text/converters.py +0 -723
- hammad/formatting/text/markdown.py +0 -131
- hammad/formatting/yaml/__init__.py +0 -26
- hammad/formatting/yaml/converters.py +0 -5
- hammad/genai/__init__.py +0 -217
- hammad/genai/a2a/__init__.py +0 -32
- hammad/genai/a2a/workers.py +0 -552
- hammad/genai/agents/__init__.py +0 -59
- hammad/genai/agents/agent.py +0 -1973
- hammad/genai/agents/run.py +0 -1024
- hammad/genai/agents/types/__init__.py +0 -42
- hammad/genai/agents/types/agent_context.py +0 -13
- hammad/genai/agents/types/agent_event.py +0 -128
- hammad/genai/agents/types/agent_hooks.py +0 -220
- hammad/genai/agents/types/agent_messages.py +0 -31
- hammad/genai/agents/types/agent_response.py +0 -125
- hammad/genai/agents/types/agent_stream.py +0 -327
- hammad/genai/graphs/__init__.py +0 -125
- hammad/genai/graphs/_utils.py +0 -190
- hammad/genai/graphs/base.py +0 -1828
- hammad/genai/graphs/plugins.py +0 -316
- hammad/genai/graphs/types.py +0 -638
- hammad/genai/models/__init__.py +0 -1
- hammad/genai/models/embeddings/__init__.py +0 -43
- hammad/genai/models/embeddings/model.py +0 -226
- hammad/genai/models/embeddings/run.py +0 -163
- hammad/genai/models/embeddings/types/__init__.py +0 -37
- hammad/genai/models/embeddings/types/embedding_model_name.py +0 -75
- hammad/genai/models/embeddings/types/embedding_model_response.py +0 -76
- hammad/genai/models/embeddings/types/embedding_model_run_params.py +0 -66
- hammad/genai/models/embeddings/types/embedding_model_settings.py +0 -47
- hammad/genai/models/language/__init__.py +0 -57
- hammad/genai/models/language/model.py +0 -1098
- hammad/genai/models/language/run.py +0 -878
- hammad/genai/models/language/types/__init__.py +0 -40
- hammad/genai/models/language/types/language_model_instructor_mode.py +0 -47
- hammad/genai/models/language/types/language_model_messages.py +0 -28
- hammad/genai/models/language/types/language_model_name.py +0 -239
- hammad/genai/models/language/types/language_model_request.py +0 -127
- hammad/genai/models/language/types/language_model_response.py +0 -217
- hammad/genai/models/language/types/language_model_response_chunk.py +0 -56
- hammad/genai/models/language/types/language_model_settings.py +0 -89
- hammad/genai/models/language/types/language_model_stream.py +0 -600
- hammad/genai/models/language/utils/__init__.py +0 -28
- hammad/genai/models/language/utils/requests.py +0 -421
- hammad/genai/models/language/utils/structured_outputs.py +0 -135
- hammad/genai/models/model_provider.py +0 -4
- hammad/genai/models/multimodal.py +0 -47
- hammad/genai/models/reranking.py +0 -26
- hammad/genai/types/__init__.py +0 -1
- hammad/genai/types/base.py +0 -215
- hammad/genai/types/history.py +0 -290
- hammad/genai/types/tools.py +0 -507
- hammad/logging/__init__.py +0 -35
- hammad/logging/decorators.py +0 -834
- hammad/logging/logger.py +0 -1018
- hammad/mcp/__init__.py +0 -53
- hammad/mcp/client/__init__.py +0 -35
- hammad/mcp/client/client.py +0 -624
- hammad/mcp/client/client_service.py +0 -400
- hammad/mcp/client/settings.py +0 -178
- hammad/mcp/servers/__init__.py +0 -26
- hammad/mcp/servers/launcher.py +0 -1161
- hammad/runtime/__init__.py +0 -32
- hammad/runtime/decorators.py +0 -142
- hammad/runtime/run.py +0 -299
- hammad/service/__init__.py +0 -49
- hammad/service/create.py +0 -527
- hammad/service/decorators.py +0 -283
- hammad/types.py +0 -288
- hammad/typing/__init__.py +0 -435
- hammad/web/__init__.py +0 -43
- hammad/web/http/__init__.py +0 -1
- hammad/web/http/client.py +0 -944
- hammad/web/models.py +0 -275
- hammad/web/openapi/__init__.py +0 -1
- hammad/web/openapi/client.py +0 -740
- hammad/web/search/__init__.py +0 -1
- hammad/web/search/client.py +0 -1023
- hammad/web/utils.py +0 -472
- hammad_python-0.0.29.dist-info/RECORD +0 -135
- {hammad → ham}/py.typed +0 -0
- {hammad_python-0.0.29.dist-info → hammad_python-0.0.31.dist-info}/WHEEL +0 -0
- {hammad_python-0.0.29.dist-info → hammad_python-0.0.31.dist-info}/licenses/LICENSE +0 -0
hammad/formatting/__init__.py
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
"""hammad.formatting"""
|
2
|
-
|
3
|
-
from typing import TYPE_CHECKING
|
4
|
-
from .._internal import create_getattr_importer
|
5
|
-
|
6
|
-
if TYPE_CHECKING:
|
7
|
-
from . import json
|
8
|
-
from .json import (
|
9
|
-
convert_to_json_schema
|
10
|
-
)
|
11
|
-
from . import text
|
12
|
-
from .text import (
|
13
|
-
convert_to_text,
|
14
|
-
convert_type_to_text,
|
15
|
-
convert_docstring_to_text
|
16
|
-
)
|
17
|
-
from . import yaml
|
18
|
-
|
19
|
-
__all__ = (
|
20
|
-
"json",
|
21
|
-
"convert_to_json_schema",
|
22
|
-
"text",
|
23
|
-
"convert_to_text",
|
24
|
-
"convert_type_to_text",
|
25
|
-
"convert_docstring_to_text",
|
26
|
-
"yaml",
|
27
|
-
)
|
28
|
-
|
29
|
-
__getattr__ = create_getattr_importer(__all__)
|
30
|
-
|
31
|
-
|
32
|
-
def __dir__() -> list[str]:
|
33
|
-
return list(__all__)
|
@@ -1,27 +0,0 @@
|
|
1
|
-
"""hammad.formatting.json"""
|
2
|
-
|
3
|
-
from typing import TYPE_CHECKING
|
4
|
-
from ..._internal import create_getattr_importer
|
5
|
-
|
6
|
-
if TYPE_CHECKING:
|
7
|
-
from .converters import (
|
8
|
-
convert_to_json_schema,
|
9
|
-
convert_to_json,
|
10
|
-
encode_json,
|
11
|
-
decode_json,
|
12
|
-
)
|
13
|
-
|
14
|
-
__all__ = (
|
15
|
-
"convert_to_json_schema",
|
16
|
-
"convert_to_json",
|
17
|
-
"encode_json",
|
18
|
-
"decode_json",
|
19
|
-
)
|
20
|
-
|
21
|
-
|
22
|
-
__getattr__ = create_getattr_importer(__all__)
|
23
|
-
|
24
|
-
|
25
|
-
def __dir__() -> list[str]:
|
26
|
-
"""Get the attributes of the json module."""
|
27
|
-
return list(__all__)
|
@@ -1,158 +0,0 @@
|
|
1
|
-
"""hammad.formatting.json.converters
|
2
|
-
|
3
|
-
Contains various utility functions used when working with JSON data."""
|
4
|
-
|
5
|
-
import dataclasses
|
6
|
-
from typing import Any
|
7
|
-
import msgspec
|
8
|
-
from msgspec.json import encode as encode_json, decode as decode_json
|
9
|
-
|
10
|
-
from ...typing import get_type_description, inspection # type: ignore
|
11
|
-
|
12
|
-
__all__ = (
|
13
|
-
"SchemaError",
|
14
|
-
"convert_to_json_schema",
|
15
|
-
"encode",
|
16
|
-
"decode",
|
17
|
-
)
|
18
|
-
|
19
|
-
|
20
|
-
class SchemaError(Exception):
|
21
|
-
"""An exception raised when a schema utility raises an error."""
|
22
|
-
|
23
|
-
|
24
|
-
def convert_to_json_schema(t: Any) -> dict:
|
25
|
-
"""Converts various objects, types, and interfaces into
|
26
|
-
a JSON schema.
|
27
|
-
|
28
|
-
Args:
|
29
|
-
t: The object, type, or interface to convert to a JSON schema.
|
30
|
-
|
31
|
-
Returns:
|
32
|
-
A JSON schema as a dictionary.
|
33
|
-
"""
|
34
|
-
from dataclasses import is_dataclass, fields as dataclass_fields
|
35
|
-
import inspect
|
36
|
-
from typing import get_type_hints
|
37
|
-
|
38
|
-
schema = {"type": "object", "properties": {}}
|
39
|
-
|
40
|
-
# Handle msgspec Struct
|
41
|
-
try:
|
42
|
-
if isinstance(t, type) and issubclass(t, msgspec.Struct):
|
43
|
-
struct_info = msgspec.structs.fields(t)
|
44
|
-
for field in struct_info:
|
45
|
-
field_type = field.type
|
46
|
-
field_schema = {
|
47
|
-
"type": get_type_description(field_type),
|
48
|
-
"description": f"Field of type {get_type_description(field_type)}",
|
49
|
-
}
|
50
|
-
if field.default is not msgspec.NODEFAULT:
|
51
|
-
field_schema["default"] = field.default
|
52
|
-
schema["properties"][field.name] = field_schema
|
53
|
-
return schema
|
54
|
-
except (ImportError, AttributeError):
|
55
|
-
pass
|
56
|
-
|
57
|
-
# Handle Pydantic models
|
58
|
-
try:
|
59
|
-
from pydantic import BaseModel
|
60
|
-
|
61
|
-
if isinstance(t, type) and issubclass(t, BaseModel):
|
62
|
-
pydantic_schema = (
|
63
|
-
t.model_json_schema() if hasattr(t, "model_json_schema") else t.schema()
|
64
|
-
)
|
65
|
-
return pydantic_schema
|
66
|
-
except ImportError:
|
67
|
-
pass
|
68
|
-
|
69
|
-
# Handle dataclasses
|
70
|
-
if is_dataclass(t):
|
71
|
-
if isinstance(t, type):
|
72
|
-
# Class-level dataclass
|
73
|
-
for field in dataclass_fields(t):
|
74
|
-
field_type = field.type
|
75
|
-
field_schema = {
|
76
|
-
"type": get_type_description(field_type),
|
77
|
-
"description": f"Field of type {get_type_description(field_type)}",
|
78
|
-
}
|
79
|
-
if field.default is not dataclasses.MISSING:
|
80
|
-
field_schema["default"] = field.default
|
81
|
-
elif field.default_factory is not dataclasses.MISSING:
|
82
|
-
field_schema["default"] = "factory function"
|
83
|
-
schema["properties"][field.name] = field_schema
|
84
|
-
else:
|
85
|
-
# Instance-level dataclass
|
86
|
-
for field in dataclass_fields(t):
|
87
|
-
field_type = field.type
|
88
|
-
field_schema = {
|
89
|
-
"type": get_type_description(field_type),
|
90
|
-
"description": f"Field of type {get_type_description(field_type)}",
|
91
|
-
"value": getattr(t, field.name, None),
|
92
|
-
}
|
93
|
-
schema["properties"][field.name] = field_schema
|
94
|
-
return schema
|
95
|
-
|
96
|
-
# Handle regular classes with type hints (including abstract classes)
|
97
|
-
if inspect.isclass(t):
|
98
|
-
try:
|
99
|
-
type_hints = get_type_hints(t)
|
100
|
-
for name, type_hint in type_hints.items():
|
101
|
-
schema["properties"][name] = {
|
102
|
-
"type": get_type_description(type_hint),
|
103
|
-
"description": f"Field of type {get_type_description(type_hint)}",
|
104
|
-
}
|
105
|
-
except (NameError, AttributeError):
|
106
|
-
pass
|
107
|
-
return schema
|
108
|
-
|
109
|
-
# Handle dictionary
|
110
|
-
if isinstance(t, dict):
|
111
|
-
for key, value in t.items():
|
112
|
-
schema["properties"][key] = {
|
113
|
-
"type": type(value).__name__,
|
114
|
-
"description": f"Field of type {type(value).__name__}",
|
115
|
-
"example": value,
|
116
|
-
}
|
117
|
-
return schema
|
118
|
-
|
119
|
-
# Handle basic types and type hints
|
120
|
-
origin = inspection.get_origin(t)
|
121
|
-
if origin is not None:
|
122
|
-
args = inspection.get_args(t)
|
123
|
-
if origin is list and args:
|
124
|
-
return {"type": "array", "items": {"type": get_type_description(args[0])}}
|
125
|
-
elif origin is dict and len(args) == 2:
|
126
|
-
return {
|
127
|
-
"type": "object",
|
128
|
-
"additionalProperties": {"type": get_type_description(args[1])},
|
129
|
-
"description": f"Object with {get_type_description(args[0])} keys",
|
130
|
-
}
|
131
|
-
elif origin is tuple and args:
|
132
|
-
return {
|
133
|
-
"type": "array",
|
134
|
-
"items": [{"type": get_type_description(arg)} for arg in args],
|
135
|
-
"minItems": len(args),
|
136
|
-
"maxItems": len(args),
|
137
|
-
}
|
138
|
-
elif inspection.is_union_type(t):
|
139
|
-
if inspection.is_optional_type(t):
|
140
|
-
non_none_args = [arg for arg in args if arg is not type(None)]
|
141
|
-
if non_none_args:
|
142
|
-
return {
|
143
|
-
"type": get_type_description(non_none_args[0]),
|
144
|
-
"nullable": True,
|
145
|
-
}
|
146
|
-
else:
|
147
|
-
return {"anyOf": [{"type": get_type_description(arg)} for arg in args]}
|
148
|
-
elif inspection.is_literal_type(t) and args:
|
149
|
-
return {"enum": list(args)}
|
150
|
-
|
151
|
-
# Default to string representation of type
|
152
|
-
return {"type": get_type_description(t)}
|
153
|
-
|
154
|
-
|
155
|
-
def convert_to_json(
|
156
|
-
target: Any,
|
157
|
-
) -> str:
|
158
|
-
return encode_json(target).decode()
|
@@ -1,63 +0,0 @@
|
|
1
|
-
"""hammad.formatting.text
|
2
|
-
|
3
|
-
Contains resources for working with text / markdown formatting."""
|
4
|
-
|
5
|
-
from typing import TYPE_CHECKING
|
6
|
-
from ..._internal import create_getattr_importer
|
7
|
-
|
8
|
-
if TYPE_CHECKING:
|
9
|
-
from .converters import (
|
10
|
-
convert_collection_to_text,
|
11
|
-
convert_dataclass_to_text,
|
12
|
-
convert_dict_to_text,
|
13
|
-
convert_docstring_to_text,
|
14
|
-
convert_function_to_text,
|
15
|
-
convert_pydantic_to_text,
|
16
|
-
convert_type_to_text,
|
17
|
-
convert_to_text,
|
18
|
-
)
|
19
|
-
from .markdown import (
|
20
|
-
markdown_blockquote,
|
21
|
-
markdown_bold,
|
22
|
-
markdown_code,
|
23
|
-
markdown_code_block,
|
24
|
-
markdown_heading,
|
25
|
-
markdown_horizontal_rule,
|
26
|
-
markdown_italic,
|
27
|
-
markdown_link,
|
28
|
-
markdown_list_item,
|
29
|
-
markdown_table,
|
30
|
-
markdown_table_row,
|
31
|
-
)
|
32
|
-
|
33
|
-
|
34
|
-
__all__ = (
|
35
|
-
# hammad.text.converters
|
36
|
-
"convert_collection_to_text",
|
37
|
-
"convert_dataclass_to_text",
|
38
|
-
"convert_dict_to_text",
|
39
|
-
"convert_docstring_to_text",
|
40
|
-
"convert_function_to_text",
|
41
|
-
"convert_pydantic_to_text",
|
42
|
-
"convert_type_to_text",
|
43
|
-
"convert_to_text",
|
44
|
-
# hammad.text.markdown
|
45
|
-
"markdown_blockquote",
|
46
|
-
"markdown_bold",
|
47
|
-
"markdown_code",
|
48
|
-
"markdown_code_block",
|
49
|
-
"markdown_heading",
|
50
|
-
"markdown_horizontal_rule",
|
51
|
-
"markdown_italic",
|
52
|
-
"markdown_link",
|
53
|
-
"markdown_list_item",
|
54
|
-
"markdown_table",
|
55
|
-
"markdown_table_row",
|
56
|
-
)
|
57
|
-
|
58
|
-
|
59
|
-
__getattr__ = create_getattr_importer(__all__)
|
60
|
-
|
61
|
-
|
62
|
-
def __dir__() -> list[str]:
|
63
|
-
return list(__all__)
|