hammad-python 0.0.13__tar.gz → 0.0.15__tar.gz

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.
Files changed (246) hide show
  1. {hammad_python-0.0.13 → hammad_python-0.0.15}/.gitignore +0 -1
  2. hammad_python-0.0.15/PKG-INFO +184 -0
  3. hammad_python-0.0.15/README.md +136 -0
  4. hammad_python-0.0.15/deprecated/hammad/__init__.py +1 -0
  5. hammad_python-0.0.15/deprecated/hammad/ai/__init__.py +1 -0
  6. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/hammad/ai/completions/__init__.py +3 -2
  7. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/hammad/ai/completions/client.py +84 -129
  8. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/hammad/ai/completions/create.py +33 -9
  9. hammad_python-0.0.15/deprecated/hammad/ai/completions/settings.py +100 -0
  10. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/hammad/ai/completions/types.py +86 -5
  11. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/hammad/ai/completions/utils.py +112 -0
  12. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/hammad/ai/embeddings/__init__.py +2 -2
  13. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/hammad/ai/embeddings/client/fastembed_text_embeddings_client.py +1 -1
  14. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/hammad/ai/embeddings/client/litellm_embeddings_client.py +1 -1
  15. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/hammad/ai/embeddings/types.py +4 -4
  16. hammad_python-0.0.15/deprecated/hammad/cache/__init__.py +40 -0
  17. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/hammad/cli/__init__.py +2 -2
  18. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/hammad/cli/animations.py +8 -39
  19. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/hammad/cli/plugins.py +0 -4
  20. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/hammad/cli/styles/__init__.py +2 -2
  21. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/hammad/data/__init__.py +17 -2
  22. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/hammad/data/collections/__init__.py +2 -2
  23. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/hammad/data/collections/base_collection.py +1 -1
  24. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/hammad/data/collections/collection.py +1 -1
  25. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/hammad/data/collections/searchable_collection.py +8 -8
  26. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/hammad/data/collections/vector_collection.py +0 -7
  27. {hammad_python-0.0.13/hammad/configuration → hammad_python-0.0.15/deprecated/hammad/data/configurations}/__init__.py +2 -2
  28. {hammad_python-0.0.13/hammad/configuration → hammad_python-0.0.15/deprecated/hammad/data/configurations}/configuration.py +1 -1
  29. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/hammad/data/databases/__init__.py +2 -2
  30. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/hammad/data/databases/database.py +27 -13
  31. hammad_python-0.0.15/deprecated/hammad/data/models/__init__.py +33 -0
  32. {hammad_python-0.0.13/hammad → hammad_python-0.0.15/deprecated/hammad/data/models}/base/__init__.py +3 -3
  33. {hammad_python-0.0.13/hammad → hammad_python-0.0.15/deprecated/hammad/data/models}/pydantic/__init__.py +28 -16
  34. {hammad_python-0.0.13/hammad → hammad_python-0.0.15/deprecated/hammad/data/models}/pydantic/converters.py +11 -2
  35. {hammad_python-0.0.13/hammad → hammad_python-0.0.15/deprecated/hammad/data/models}/pydantic/models/__init__.py +3 -3
  36. {hammad_python-0.0.13/hammad → hammad_python-0.0.15/deprecated/hammad/data/models}/pydantic/models/arbitrary_model.py +1 -1
  37. {hammad_python-0.0.13/hammad → hammad_python-0.0.15/deprecated/hammad/data/models}/pydantic/models/cacheable_model.py +1 -1
  38. {hammad_python-0.0.13/hammad → hammad_python-0.0.15/deprecated/hammad/data/models}/pydantic/models/fast_model.py +1 -1
  39. {hammad_python-0.0.13/hammad → hammad_python-0.0.15/deprecated/hammad/data/models}/pydantic/models/function_model.py +1 -1
  40. {hammad_python-0.0.13/hammad → hammad_python-0.0.15/deprecated/hammad/data/models}/pydantic/models/subscriptable_model.py +1 -1
  41. hammad_python-0.0.15/deprecated/hammad/data/types/__init__.py +39 -0
  42. {hammad_python-0.0.13/hammad → hammad_python-0.0.15/deprecated/hammad/data}/types/file.py +2 -2
  43. {hammad_python-0.0.13/hammad → hammad_python-0.0.15/deprecated/hammad/data/types}/multimodal/__init__.py +2 -2
  44. {hammad_python-0.0.13/hammad → hammad_python-0.0.15/deprecated/hammad/data/types}/multimodal/audio.py +2 -2
  45. {hammad_python-0.0.13/hammad → hammad_python-0.0.15/deprecated/hammad/data/types}/multimodal/image.py +2 -2
  46. {hammad_python-0.0.13/hammad/text → hammad_python-0.0.15/deprecated/hammad/data/types}/text.py +4 -4
  47. hammad_python-0.0.15/deprecated/hammad/formatting/__init__.py +38 -0
  48. {hammad_python-0.0.13/hammad → hammad_python-0.0.15/deprecated/hammad/formatting}/json/__init__.py +3 -3
  49. {hammad_python-0.0.13/hammad → hammad_python-0.0.15/deprecated/hammad/formatting}/json/converters.py +2 -2
  50. {hammad_python-0.0.13/hammad → hammad_python-0.0.15/deprecated/hammad/formatting}/text/__init__.py +5 -24
  51. {hammad_python-0.0.13/hammad → hammad_python-0.0.15/deprecated/hammad/formatting}/text/converters.py +2 -2
  52. {hammad_python-0.0.13/hammad → hammad_python-0.0.15/deprecated/hammad/formatting}/text/markdown.py +1 -1
  53. {hammad_python-0.0.13/hammad → hammad_python-0.0.15/deprecated/hammad/formatting}/yaml/__init__.py +3 -7
  54. hammad_python-0.0.15/deprecated/hammad/formatting/yaml/converters.py +5 -0
  55. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/hammad/logging/__init__.py +2 -2
  56. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/hammad/logging/logger.py +2 -2
  57. hammad_python-0.0.15/deprecated/hammad/mcp/__init__.py +50 -0
  58. hammad_python-0.0.15/deprecated/hammad/mcp/client/__init__.py +1 -0
  59. hammad_python-0.0.15/deprecated/hammad/mcp/client/client.py +523 -0
  60. hammad_python-0.0.15/deprecated/hammad/mcp/client/client_service.py +393 -0
  61. hammad_python-0.0.15/deprecated/hammad/mcp/client/settings.py +178 -0
  62. hammad_python-0.0.15/deprecated/hammad/mcp/servers/__init__.py +1 -0
  63. hammad_python-0.0.15/deprecated/hammad/mcp/servers/launcher.py +1161 -0
  64. hammad_python-0.0.15/deprecated/hammad/performance/__init__.py +36 -0
  65. hammad_python-0.0.13/hammad/_core/_utils/_import_utils.py → hammad_python-0.0.15/deprecated/hammad/performance/imports.py +125 -76
  66. hammad_python-0.0.15/deprecated/hammad/performance/runtime/__init__.py +32 -0
  67. hammad_python-0.0.15/deprecated/hammad/performance/runtime/decorators.py +142 -0
  68. hammad_python-0.0.15/deprecated/hammad/performance/runtime/run.py +299 -0
  69. hammad_python-0.0.15/deprecated/hammad/service/__init__.py +49 -0
  70. hammad_python-0.0.15/deprecated/hammad/service/create.py +532 -0
  71. hammad_python-0.0.15/deprecated/hammad/service/decorators.py +285 -0
  72. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/hammad/web/__init__.py +2 -2
  73. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/hammad/web/http/client.py +1 -1
  74. hammad_python-0.0.15/deprecated/hammad/web/openapi/__init__.py +1 -0
  75. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/tests/ai/completions/test_ai_completions_create.py +4 -1
  76. hammad_python-0.0.13/tests/cache/test_cache_cache.py → hammad_python-0.0.15/deprecated/tests/cache/test_performance_cache.py +1 -1
  77. {hammad_python-0.0.13/tests/data → hammad_python-0.0.15/deprecated/tests/data/collections}/test_data_collections_searchable_collection.py +10 -10
  78. hammad_python-0.0.13/tests/base/test_base_fields.py → hammad_python-0.0.15/deprecated/tests/data/models/base/test_data_models_base_fields.py +3 -3
  79. hammad_python-0.0.13/tests/base/test_base_model.py → hammad_python-0.0.15/deprecated/tests/data/models/base/test_data_models_base_model.py +1 -1
  80. hammad_python-0.0.13/tests/pydantic/test_pydantic_converters.py → hammad_python-0.0.15/deprecated/tests/data/models/pydantic/test_models_pydantic_converters.py +37 -36
  81. hammad_python-0.0.13/tests/pydantic/test_pydantic_models.py → hammad_python-0.0.15/deprecated/tests/data/models/pydantic/test_models_pydantic_models.py +1 -1
  82. hammad_python-0.0.13/tests/text/test_text_text.py → hammad_python-0.0.15/deprecated/tests/data/types/test_data_types_text.py +1 -1
  83. {hammad_python-0.0.13/tests → hammad_python-0.0.15/deprecated/tests/formatting}/json/test_json_converters.py +1 -1
  84. {hammad_python-0.0.13/tests → hammad_python-0.0.15/deprecated/tests/formatting}/text/test_text_utils_converters.py +1 -1
  85. {hammad_python-0.0.13/tests → hammad_python-0.0.15/deprecated/tests/formatting}/text/test_text_utils_markdown_converters.py +1 -1
  86. hammad_python-0.0.15/deprecated/tests/mcp/test_mcp_client_services.py +404 -0
  87. hammad_python-0.0.15/deprecated/tests/mcp/test_mcp_server_services.py +555 -0
  88. hammad_python-0.0.15/deprecated/tests/performance/runtime/test_performance_runtime_decorators.py +66 -0
  89. hammad_python-0.0.15/deprecated/tests/performance/runtime/test_performance_runtime_run.py +98 -0
  90. hammad_python-0.0.15/deprecated/tests/service/test_service_create_service.py +177 -0
  91. hammad_python-0.0.15/deprecated/tests/service/test_service_serve_decorator.py +175 -0
  92. hammad_python-0.0.15/deprecated/tests/service/test_service_serve_mcp_decorator.py +204 -0
  93. hammad_python-0.0.15/hammad/__init__.py +178 -0
  94. hammad_python-0.0.15/hammad/_internal.py +237 -0
  95. hammad_python-0.0.15/hammad/cache/__init__.py +40 -0
  96. hammad_python-0.0.15/hammad/cache/base_cache.py +181 -0
  97. hammad_python-0.0.15/hammad/cache/cache.py +169 -0
  98. hammad_python-0.0.15/hammad/cache/decorators.py +261 -0
  99. hammad_python-0.0.15/hammad/cache/file_cache.py +80 -0
  100. hammad_python-0.0.15/hammad/cache/ttl_cache.py +74 -0
  101. hammad_python-0.0.15/hammad/cli/__init__.py +35 -0
  102. hammad_python-0.0.15/hammad/cli/_runner.py +265 -0
  103. hammad_python-0.0.15/hammad/cli/animations.py +573 -0
  104. hammad_python-0.0.15/hammad/cli/plugins.py +836 -0
  105. hammad_python-0.0.15/hammad/cli/styles/__init__.py +55 -0
  106. hammad_python-0.0.15/hammad/cli/styles/settings.py +139 -0
  107. hammad_python-0.0.15/hammad/cli/styles/types.py +358 -0
  108. hammad_python-0.0.15/hammad/cli/styles/utils.py +626 -0
  109. hammad_python-0.0.15/hammad/data/__init__.py +83 -0
  110. hammad_python-0.0.15/hammad/data/collections/__init__.py +44 -0
  111. hammad_python-0.0.15/hammad/data/collections/collection.py +260 -0
  112. hammad_python-0.0.15/hammad/data/collections/indexes/__init__.py +37 -0
  113. hammad_python-0.0.15/hammad/data/collections/indexes/qdrant/__init__.py +1 -0
  114. hammad_python-0.0.15/hammad/data/collections/indexes/qdrant/index.py +539 -0
  115. hammad_python-0.0.15/hammad/data/collections/indexes/qdrant/settings.py +94 -0
  116. hammad_python-0.0.15/hammad/data/collections/indexes/qdrant/utils.py +220 -0
  117. hammad_python-0.0.15/hammad/data/collections/indexes/tantivy/__init__.py +1 -0
  118. hammad_python-0.0.15/hammad/data/collections/indexes/tantivy/index.py +428 -0
  119. hammad_python-0.0.15/hammad/data/collections/indexes/tantivy/settings.py +51 -0
  120. hammad_python-0.0.15/hammad/data/collections/indexes/tantivy/utils.py +200 -0
  121. hammad_python-0.0.15/hammad/data/configurations/__init__.py +35 -0
  122. hammad_python-0.0.15/hammad/data/configurations/configuration.py +564 -0
  123. hammad_python-0.0.15/hammad/data/models/__init__.py +55 -0
  124. hammad_python-0.0.15/hammad/data/models/extensions/__init__.py +4 -0
  125. hammad_python-0.0.15/hammad/data/models/extensions/pydantic/__init__.py +42 -0
  126. hammad_python-0.0.15/hammad/data/models/extensions/pydantic/converters.py +759 -0
  127. hammad_python-0.0.15/hammad/data/models/fields.py +546 -0
  128. hammad_python-0.0.15/hammad/data/models/model.py +1078 -0
  129. hammad_python-0.0.15/hammad/data/models/utils.py +280 -0
  130. hammad_python-0.0.15/hammad/data/sql/__init__.py +23 -0
  131. hammad_python-0.0.15/hammad/data/sql/database.py +578 -0
  132. hammad_python-0.0.15/hammad/data/sql/types.py +136 -0
  133. hammad_python-0.0.15/hammad/data/types/__init__.py +39 -0
  134. hammad_python-0.0.15/hammad/data/types/file.py +358 -0
  135. hammad_python-0.0.15/hammad/data/types/multimodal/__init__.py +24 -0
  136. hammad_python-0.0.15/hammad/data/types/multimodal/audio.py +96 -0
  137. hammad_python-0.0.15/hammad/data/types/multimodal/image.py +80 -0
  138. hammad_python-0.0.15/hammad/data/types/text.py +1066 -0
  139. hammad_python-0.0.15/hammad/formatting/__init__.py +20 -0
  140. hammad_python-0.0.15/hammad/formatting/json/__init__.py +27 -0
  141. hammad_python-0.0.15/hammad/formatting/json/converters.py +158 -0
  142. hammad_python-0.0.15/hammad/formatting/text/__init__.py +63 -0
  143. hammad_python-0.0.15/hammad/formatting/text/converters.py +723 -0
  144. hammad_python-0.0.15/hammad/formatting/text/markdown.py +131 -0
  145. hammad_python-0.0.15/hammad/formatting/yaml/__init__.py +26 -0
  146. hammad_python-0.0.15/hammad/formatting/yaml/converters.py +5 -0
  147. hammad_python-0.0.15/hammad/genai/__init__.py +45 -0
  148. hammad_python-0.0.15/hammad/genai/embedding_models/__init__.py +41 -0
  149. hammad_python-0.0.15/hammad/genai/embedding_models/embedding_model.py +193 -0
  150. hammad_python-0.0.15/hammad/genai/embedding_models/embedding_model_name.py +77 -0
  151. hammad_python-0.0.15/hammad/genai/embedding_models/embedding_model_request.py +65 -0
  152. hammad_python-0.0.15/hammad/genai/embedding_models/embedding_model_response.py +69 -0
  153. hammad_python-0.0.15/hammad/genai/embedding_models/run.py +161 -0
  154. hammad_python-0.0.15/hammad/genai/language_models/__init__.py +35 -0
  155. hammad_python-0.0.15/hammad/genai/language_models/_streaming.py +368 -0
  156. hammad_python-0.0.15/hammad/genai/language_models/_types.py +276 -0
  157. hammad_python-0.0.15/hammad/genai/language_models/_utils/__init__.py +31 -0
  158. hammad_python-0.0.15/hammad/genai/language_models/_utils/_completions.py +131 -0
  159. hammad_python-0.0.15/hammad/genai/language_models/_utils/_messages.py +89 -0
  160. hammad_python-0.0.15/hammad/genai/language_models/_utils/_requests.py +180 -0
  161. hammad_python-0.0.15/hammad/genai/language_models/_utils/_structured_outputs.py +122 -0
  162. hammad_python-0.0.15/hammad/genai/language_models/language_model.py +596 -0
  163. hammad_python-0.0.15/hammad/genai/language_models/language_model_request.py +122 -0
  164. hammad_python-0.0.15/hammad/genai/language_models/language_model_response.py +220 -0
  165. hammad_python-0.0.15/hammad/genai/language_models/language_model_response_chunk.py +53 -0
  166. hammad_python-0.0.15/hammad/genai/language_models/run.py +498 -0
  167. hammad_python-0.0.15/hammad/logging/__init__.py +35 -0
  168. hammad_python-0.0.15/hammad/logging/decorators.py +834 -0
  169. hammad_python-0.0.15/hammad/logging/logger.py +954 -0
  170. hammad_python-0.0.15/hammad/mcp/__init__.py +50 -0
  171. hammad_python-0.0.15/hammad/mcp/client/__init__.py +36 -0
  172. hammad_python-0.0.15/hammad/mcp/client/client.py +624 -0
  173. hammad_python-0.0.15/hammad/mcp/client/client_service.py +400 -0
  174. hammad_python-0.0.15/hammad/mcp/client/settings.py +178 -0
  175. hammad_python-0.0.15/hammad/mcp/servers/__init__.py +25 -0
  176. hammad_python-0.0.15/hammad/mcp/servers/launcher.py +1161 -0
  177. hammad_python-0.0.15/hammad/runtime/__init__.py +32 -0
  178. hammad_python-0.0.15/hammad/runtime/decorators.py +142 -0
  179. hammad_python-0.0.15/hammad/runtime/run.py +299 -0
  180. hammad_python-0.0.15/hammad/service/__init__.py +49 -0
  181. hammad_python-0.0.15/hammad/service/create.py +527 -0
  182. hammad_python-0.0.15/hammad/service/decorators.py +285 -0
  183. hammad_python-0.0.15/hammad/typing/__init__.py +435 -0
  184. hammad_python-0.0.15/hammad/web/__init__.py +43 -0
  185. hammad_python-0.0.15/hammad/web/http/__init__.py +1 -0
  186. hammad_python-0.0.15/hammad/web/http/client.py +944 -0
  187. hammad_python-0.0.15/hammad/web/models.py +277 -0
  188. hammad_python-0.0.15/hammad/web/openapi/__init__.py +1 -0
  189. hammad_python-0.0.15/hammad/web/openapi/client.py +740 -0
  190. hammad_python-0.0.15/hammad/web/search/__init__.py +1 -0
  191. hammad_python-0.0.15/hammad/web/search/client.py +1035 -0
  192. hammad_python-0.0.15/hammad/web/utils.py +472 -0
  193. {hammad_python-0.0.13 → hammad_python-0.0.15}/mkdocs.yml +7 -0
  194. {hammad_python-0.0.13 → hammad_python-0.0.15}/pyproject.toml +47 -42
  195. {hammad_python-0.0.13 → hammad_python-0.0.15}/uv.lock +78 -630
  196. hammad_python-0.0.13/PKG-INFO +0 -38
  197. hammad_python-0.0.13/README.md +0 -2
  198. hammad_python-0.0.13/hammad/__init__.py +0 -180
  199. hammad_python-0.0.13/hammad/_core/__init__.py +0 -1
  200. hammad_python-0.0.13/hammad/_core/_utils/__init__.py +0 -4
  201. hammad_python-0.0.13/hammad/ai/__init__.py +0 -59
  202. hammad_python-0.0.13/hammad/cache/__init__.py +0 -48
  203. hammad_python-0.0.13/hammad/multithreading/__init__.py +0 -304
  204. hammad_python-0.0.13/hammad/types/__init__.py +0 -11
  205. hammad_python-0.0.13/hammad/yaml/converters.py +0 -19
  206. hammad_python-0.0.13/tests/configuration/test_configuration.py +0 -0
  207. {hammad_python-0.0.13 → hammad_python-0.0.15}/.python-version +0 -0
  208. {hammad_python-0.0.13 → hammad_python-0.0.15}/LICENSE +0 -0
  209. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/hammad/ai/_utils.py +0 -0
  210. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/hammad/ai/embeddings/client/__init__.py +0 -0
  211. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/hammad/ai/embeddings/client/base_embeddings_client.py +0 -0
  212. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/hammad/ai/embeddings/create.py +0 -0
  213. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/hammad/cache/base_cache.py +0 -0
  214. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/hammad/cache/cache.py +0 -0
  215. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/hammad/cache/decorators.py +0 -0
  216. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/hammad/cache/file_cache.py +0 -0
  217. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/hammad/cache/ttl_cache.py +0 -0
  218. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/hammad/cli/styles/settings.py +0 -0
  219. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/hammad/cli/styles/types.py +0 -0
  220. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/hammad/cli/styles/utils.py +0 -0
  221. {hammad_python-0.0.13/hammad → hammad_python-0.0.15/deprecated/hammad/data/models}/base/fields.py +0 -0
  222. {hammad_python-0.0.13/hammad → hammad_python-0.0.15/deprecated/hammad/data/models}/base/model.py +0 -0
  223. {hammad_python-0.0.13/hammad → hammad_python-0.0.15/deprecated/hammad/data/models}/base/utils.py +0 -0
  224. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/hammad/logging/decorators.py +0 -0
  225. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/hammad/py.typed +0 -0
  226. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/hammad/typing/__init__.py +0 -0
  227. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/hammad/web/http/__init__.py +0 -0
  228. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/hammad/web/models.py +0 -0
  229. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/hammad/web/openapi/client.py +0 -0
  230. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/hammad/web/search/__init__.py +0 -0
  231. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/hammad/web/search/client.py +0 -0
  232. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/hammad/web/utils.py +0 -0
  233. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/tests/ai/completions/test_ai_completions_types.py +0 -0
  234. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/tests/cli/test_cli_plugins_animate.py +0 -0
  235. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/tests/cli/test_cli_plugins_input.py +0 -0
  236. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/tests/cli/test_cli_plugins_print.py +0 -0
  237. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/tests/cli/test_cli_styles_utils.py +0 -0
  238. {hammad_python-0.0.13/tests/data → hammad_python-0.0.15/deprecated/tests/data/collections}/test_data_collections_vector_collection.py +0 -0
  239. /hammad_python-0.0.13/hammad/web/openapi/__init__.py → /hammad_python-0.0.15/deprecated/tests/data/configuration/test_data_configuration.py +0 -0
  240. {hammad_python-0.0.13/tests/data → hammad_python-0.0.15/deprecated/tests/data/databases}/test_data_databases_database.py +0 -0
  241. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/tests/logging/test_logging_decorators.py +0 -0
  242. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/tests/logging/test_logging_logger.py +0 -0
  243. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/tests/typing/test_typing_utils.py +0 -0
  244. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/tests/web/test_web_toolkits_http_toolkit.py +0 -0
  245. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/tests/web/test_web_toolkits_openapi_toolkit.py +0 -0
  246. {hammad_python-0.0.13 → hammad_python-0.0.15/deprecated}/tests/web/test_web_utils.py +0 -0
@@ -28,7 +28,6 @@ dist/
28
28
  downloads/
29
29
  eggs/
30
30
  .eggs/
31
- lib/
32
31
  lib64/
33
32
  parts/
34
33
  sdist/
@@ -0,0 +1,184 @@
1
+ Metadata-Version: 2.4
2
+ Name: hammad-python
3
+ Version: 0.0.15
4
+ Author-email: Hammad Saeed <hammadaidev@gmail.com>
5
+ License: MIT License
6
+
7
+ Copyright (c) 2025 Hammad Saeed
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ of this software and associated documentation files (the "Software"), to deal
11
+ in the Software without restriction, including without limitation the rights
12
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ copies of the Software, and to permit persons to whom the Software is
14
+ furnished to do so, subject to the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be included in all
17
+ copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ SOFTWARE.
26
+ License-File: LICENSE
27
+ Requires-Python: >=3.11
28
+ Requires-Dist: ddgs>=9.0.0
29
+ Requires-Dist: httpx>=0.28.1
30
+ Requires-Dist: msgspec>=0.19.0
31
+ Requires-Dist: pydantic>=2.11.7
32
+ Requires-Dist: rich>=14.0.0
33
+ Requires-Dist: selectolax>=0.3.31
34
+ Requires-Dist: sqlalchemy>=2.0.41
35
+ Requires-Dist: tantivy>=0.24.0
36
+ Requires-Dist: tenacity>=9.1.2
37
+ Requires-Dist: typing-inspect>=0.9.0
38
+ Provides-Extra: ai
39
+ Requires-Dist: instructor>=1.9.0; extra == 'ai'
40
+ Requires-Dist: litellm>=1.73.6; extra == 'ai'
41
+ Requires-Dist: qdrant-client>=1.14.3; extra == 'ai'
42
+ Provides-Extra: mcp
43
+ Requires-Dist: mcp>=1.10.1; extra == 'mcp'
44
+ Provides-Extra: serve
45
+ Requires-Dist: fastapi>=0.115.6; extra == 'serve'
46
+ Requires-Dist: uvicorn>=0.34.0; extra == 'serve'
47
+ Description-Content-Type: text/markdown
48
+
49
+ ## hammad-python
50
+
51
+ > __Happily Accelerated Micro-Modules (_for_) Application Development__
52
+
53
+ ## Introduction
54
+
55
+ The `hammad-python` library, is a mix of a love letter and collection of mixed resources for
56
+ developing Python applications. This library is meant to be used for rapid prototyping and
57
+ development, and is focused on providing styled placeholder tools for common patterns, tasks
58
+ and workflows.
59
+
60
+ The package is currently built into the following structures:
61
+
62
+ - `hammad-python` : Contains most core functionality and resources.
63
+ - `hammad-python[ai]` : Contains easy to use resources for Generative AI related tasks such as
64
+ generating completions with language models, or creating embeddings.
65
+ - `hammad-python[serve]` : Contains FastAPI / Uvicorn based resources for serving and running applications.
66
+
67
+ ## Installation
68
+
69
+ You can install the package using `pip` or `uv`:
70
+
71
+ ```bash
72
+ pip install hammad-python
73
+
74
+ # or install the `ai` extension
75
+ # pip install 'hammad-python[ai]'
76
+
77
+ # or install the `serve` extension
78
+ # pip install 'hammad-python[serve]'
79
+ ```
80
+
81
+ ```bash
82
+ uv pip install hammad-python
83
+
84
+ # or install the `ai` extension
85
+ # uv pip install 'hammad-python[ai]'
86
+
87
+ # or install the `serve` extension
88
+ # uv pip install 'hammad-python[serve]'
89
+ ```
90
+
91
+ ## Basic Usage
92
+
93
+ ### Data Structures, Databases and Other Data Related Resources
94
+
95
+ #### Collections
96
+
97
+ Using `hammad.data.collections` is a simple way to create searchable collections of
98
+ data using both `bm25` and `vector` based search.
99
+
100
+ ```python
101
+ from hammad.data.collections import create_collection
102
+
103
+ # Create either a `vector` or `searchable` collection
104
+ col = create_collection(type = "searchable")
105
+
106
+ # add anything to the collection
107
+ col.add("This is some text")
108
+ col.add(5)
109
+ col.add({'text' : "this is a dictionary"})
110
+
111
+ # search the collection
112
+ print(col.query("text"))
113
+ ```
114
+
115
+ #### Databases
116
+
117
+ Any collection can be either used as a standalone database, or can be added as one
118
+ of the collections within a database. Databases provide a unified interface for handling
119
+ both `Searchable` and `Vector` based collections.
120
+
121
+ ```python
122
+ from hammad.data.collections import create_collection
123
+ from hammad.data.databases import Database
124
+
125
+ # Create either a `vector` or `searchable` collection
126
+ col = create_collection(type = "searchable")
127
+
128
+ col.add("This is some text")
129
+
130
+ # Databases can either be created on memory or using a path
131
+ db = Database(location = "memory")
132
+
133
+ db.add_collection(col)
134
+
135
+ # search globally or within a single collection
136
+ print(db.query("text"))
137
+ ```
138
+
139
+ ### Styling / Introspection Resources
140
+
141
+ The `hammad-python` package contains a variety of components that can be used
142
+ to easily style, or run introspection (logging) on your code.
143
+
144
+ ```python
145
+ from hammad.cli import print, input, animate
146
+
147
+ # Use extended `rich` styling easily
148
+ print("Hello, World", bg_settings = {"title" : "This is a title"})
149
+
150
+ # Easily collect various forms of input in a single function
151
+ class User(BaseModel):
152
+ name : str
153
+ age : int
154
+
155
+ # TIP:
156
+ # you can style this the same way with `print`
157
+ user = input("Enter some information about yourself: ", schema = User)
158
+
159
+ # easily run a collection of prebuilt animations
160
+ animate("This is a rainbow!", type = "rainbow", duration = 2, refresh_rate = 20)
161
+ ```
162
+
163
+ Using the various `hammad.logging` resources, you can both create custom & styled
164
+ loggers, as well as easily inspect various aspects of your code during runtime.
165
+
166
+ ```python
167
+ from hammad.logging import Logger
168
+
169
+ # create standard / file based loggers easily
170
+ logger = Logger("hammad", level = "info", rich = Trues)
171
+
172
+ file_logger = Logger("hammad-file", level = "info", file = "hammad.log")
173
+
174
+ # log to the console
175
+ logger.info("This is an info message")
176
+
177
+ # Use the various `trace_` methods to run various introspection tasks
178
+ from hammad.logging import (
179
+ trace,
180
+ trace_cls,
181
+ trace_function,
182
+ trace_http
183
+ )
184
+ ```
@@ -0,0 +1,136 @@
1
+ ## hammad-python
2
+
3
+ > __Happily Accelerated Micro-Modules (_for_) Application Development__
4
+
5
+ ## Introduction
6
+
7
+ The `hammad-python` library, is a mix of a love letter and collection of mixed resources for
8
+ developing Python applications. This library is meant to be used for rapid prototyping and
9
+ development, and is focused on providing styled placeholder tools for common patterns, tasks
10
+ and workflows.
11
+
12
+ The package is currently built into the following structures:
13
+
14
+ - `hammad-python` : Contains most core functionality and resources.
15
+ - `hammad-python[ai]` : Contains easy to use resources for Generative AI related tasks such as
16
+ generating completions with language models, or creating embeddings.
17
+ - `hammad-python[serve]` : Contains FastAPI / Uvicorn based resources for serving and running applications.
18
+
19
+ ## Installation
20
+
21
+ You can install the package using `pip` or `uv`:
22
+
23
+ ```bash
24
+ pip install hammad-python
25
+
26
+ # or install the `ai` extension
27
+ # pip install 'hammad-python[ai]'
28
+
29
+ # or install the `serve` extension
30
+ # pip install 'hammad-python[serve]'
31
+ ```
32
+
33
+ ```bash
34
+ uv pip install hammad-python
35
+
36
+ # or install the `ai` extension
37
+ # uv pip install 'hammad-python[ai]'
38
+
39
+ # or install the `serve` extension
40
+ # uv pip install 'hammad-python[serve]'
41
+ ```
42
+
43
+ ## Basic Usage
44
+
45
+ ### Data Structures, Databases and Other Data Related Resources
46
+
47
+ #### Collections
48
+
49
+ Using `hammad.data.collections` is a simple way to create searchable collections of
50
+ data using both `bm25` and `vector` based search.
51
+
52
+ ```python
53
+ from hammad.data.collections import create_collection
54
+
55
+ # Create either a `vector` or `searchable` collection
56
+ col = create_collection(type = "searchable")
57
+
58
+ # add anything to the collection
59
+ col.add("This is some text")
60
+ col.add(5)
61
+ col.add({'text' : "this is a dictionary"})
62
+
63
+ # search the collection
64
+ print(col.query("text"))
65
+ ```
66
+
67
+ #### Databases
68
+
69
+ Any collection can be either used as a standalone database, or can be added as one
70
+ of the collections within a database. Databases provide a unified interface for handling
71
+ both `Searchable` and `Vector` based collections.
72
+
73
+ ```python
74
+ from hammad.data.collections import create_collection
75
+ from hammad.data.databases import Database
76
+
77
+ # Create either a `vector` or `searchable` collection
78
+ col = create_collection(type = "searchable")
79
+
80
+ col.add("This is some text")
81
+
82
+ # Databases can either be created on memory or using a path
83
+ db = Database(location = "memory")
84
+
85
+ db.add_collection(col)
86
+
87
+ # search globally or within a single collection
88
+ print(db.query("text"))
89
+ ```
90
+
91
+ ### Styling / Introspection Resources
92
+
93
+ The `hammad-python` package contains a variety of components that can be used
94
+ to easily style, or run introspection (logging) on your code.
95
+
96
+ ```python
97
+ from hammad.cli import print, input, animate
98
+
99
+ # Use extended `rich` styling easily
100
+ print("Hello, World", bg_settings = {"title" : "This is a title"})
101
+
102
+ # Easily collect various forms of input in a single function
103
+ class User(BaseModel):
104
+ name : str
105
+ age : int
106
+
107
+ # TIP:
108
+ # you can style this the same way with `print`
109
+ user = input("Enter some information about yourself: ", schema = User)
110
+
111
+ # easily run a collection of prebuilt animations
112
+ animate("This is a rainbow!", type = "rainbow", duration = 2, refresh_rate = 20)
113
+ ```
114
+
115
+ Using the various `hammad.logging` resources, you can both create custom & styled
116
+ loggers, as well as easily inspect various aspects of your code during runtime.
117
+
118
+ ```python
119
+ from hammad.logging import Logger
120
+
121
+ # create standard / file based loggers easily
122
+ logger = Logger("hammad", level = "info", rich = Trues)
123
+
124
+ file_logger = Logger("hammad-file", level = "info", file = "hammad.log")
125
+
126
+ # log to the console
127
+ logger.info("This is an info message")
128
+
129
+ # Use the various `trace_` methods to run various introspection tasks
130
+ from hammad.logging import (
131
+ trace,
132
+ trace_cls,
133
+ trace_function,
134
+ trace_http
135
+ )
136
+ ```
@@ -0,0 +1 @@
1
+ """hammad-python"""
@@ -0,0 +1 @@
1
+ """hammad.ai"""
@@ -4,7 +4,7 @@ Contains types and model like objects for working with language model
4
4
  completions."""
5
5
 
6
6
  from typing import TYPE_CHECKING
7
- from ..._core._utils._import_utils import _auto_create_getattr_loader
7
+ from ...performance.imports import create_getattr_importer
8
8
 
9
9
  if TYPE_CHECKING:
10
10
  from .client import CompletionsClient
@@ -17,6 +17,7 @@ if TYPE_CHECKING:
17
17
  CompletionsModelName,
18
18
  CompletionsOutputType,
19
19
  )
20
+ from .settings import CompletionsSettings, CompletionsModelSettings
20
21
  from .create import create_completion, async_create_completion
21
22
 
22
23
 
@@ -37,7 +38,7 @@ __all__ = (
37
38
  )
38
39
 
39
40
 
40
- __getattr__ = _auto_create_getattr_loader(__all__)
41
+ __getattr__ = create_getattr_importer(__all__)
41
42
 
42
43
 
43
44
  def __dir__() -> list[str]:
@@ -22,9 +22,8 @@ except ImportError:
22
22
  "`pip install 'hammad-python[ai]'"
23
23
  )
24
24
 
25
- from ...pydantic.converters import convert_to_pydantic_model
25
+ from ...data.models.pydantic.converters import convert_to_pydantic_model
26
26
  from .._utils import get_litellm, get_instructor
27
- from ...base.model import Model
28
27
  from ...typing import is_pydantic_basemodel
29
28
  from .utils import (
30
29
  format_tool_calls,
@@ -32,117 +31,23 @@ from .utils import (
32
31
  convert_response_to_completion,
33
32
  create_async_completion_stream,
34
33
  create_completion_stream,
34
+ InstructorStreamWrapper,
35
+ AsyncInstructorStreamWrapper,
36
+ )
37
+ from .settings import (
38
+ CompletionsSettings,
39
+ OpenAIWebSearchOptions,
40
+ AnthropicThinkingParam,
35
41
  )
36
42
  from .types import (
43
+ CompletionsInstructorModeParam,
37
44
  CompletionsInputParam,
38
45
  CompletionsOutputType,
39
46
  Completion,
40
- CompletionChunk,
41
- CompletionStream,
42
- AsyncCompletionStream,
43
47
  )
44
48
 
45
49
 
46
- class OpenAIWebSearchUserLocationApproximate(TypedDict):
47
- city: str
48
- country: str
49
- region: str
50
- timezone: str
51
-
52
-
53
- class OpenAIWebSearchUserLocation(TypedDict):
54
- approximate: OpenAIWebSearchUserLocationApproximate
55
- type: Literal["approximate"]
56
-
57
-
58
- class OpenAIWebSearchOptions(TypedDict, total=False):
59
- search_context_size: Optional[Literal["low", "medium", "high"]]
60
- user_location: Optional[OpenAIWebSearchUserLocation]
61
-
62
-
63
- class AnthropicThinkingParam(TypedDict, total=False):
64
- type: Literal["enabled"]
65
- budget_tokens: int
66
-
67
-
68
- InstructorModeParam = Literal[
69
- "function_call",
70
- "parallel_tool_call",
71
- "tool_call",
72
- "tools_strict",
73
- "json_mode",
74
- "json_o1",
75
- "markdown_json_mode",
76
- "json_schema_mode",
77
- "anthropic_tools",
78
- "anthropic_reasoning_tools",
79
- "anthropic_json",
80
- "mistral_tools",
81
- "mistral_structured_outputs",
82
- "vertexai_tools",
83
- "vertexai_json",
84
- "vertexai_parallel_tools",
85
- "gemini_json",
86
- "gemini_tools",
87
- "genai_tools",
88
- "genai_structured_outputs",
89
- "cohere_tools",
90
- "cohere_json_object",
91
- "cerebras_tools",
92
- "cerebras_json",
93
- "fireworks_tools",
94
- "fireworks_json",
95
- "writer_tools",
96
- "bedrock_tools",
97
- "bedrock_json",
98
- "perplexity_json",
99
- "openrouter_structured_outputs",
100
- ]
101
- """Instructor prompt/parsing mode for structured outputs."""
102
-
103
-
104
- class CompletionsSettings(TypedDict):
105
- """Accepted settings for the `litellm` completion function."""
106
-
107
- model: str
108
- messages: List
109
- timeout: Optional[Union[float, str, Timeout]]
110
- temperature: Optional[float]
111
- top_p: Optional[float]
112
- n: Optional[int]
113
- stream: Optional[bool]
114
- stream_options: Optional[Dict[str, Any]]
115
- stop: Optional[str]
116
- max_completion_tokens: Optional[int]
117
- max_tokens: Optional[int]
118
- modalities: Optional[List[ChatCompletionModality]]
119
- prediction: Optional[ChatCompletionPredictionContentParam]
120
- audio: Optional[ChatCompletionAudioParam]
121
- presence_penalty: Optional[float]
122
- frequency_penalty: Optional[float]
123
- logit_bias: Optional[Dict[str, float]]
124
- user: Optional[str]
125
- reasoning_effort: Optional[Literal["low", "medium", "high"]]
126
- # NOTE: response_format is not used within the `completions` resource
127
- # in place of `instructor` and the `type` parameter
128
- seed: Optional[int]
129
- tools: Optional[List]
130
- tool_choice: Optional[Union[str, Dict[str, Any]]]
131
- logprobs: Optional[bool]
132
- top_logprobs: Optional[int]
133
- parallel_tool_calls: Optional[bool]
134
- web_search_options: Optional[OpenAIWebSearchOptions]
135
- deployment_id: Optional[str]
136
- extra_headers: Optional[Dict[str, str]]
137
- base_url: Optional[str]
138
- functions: Optional[List]
139
- function_call: Optional[str]
140
- # set api_base, api_version, api_key
141
- api_version: Optional[str]
142
- api_key: Optional[str]
143
- model_list: Optional[list]
144
- # Optional liteLLM function params
145
- thinking: Optional[AnthropicThinkingParam]
50
+ __all__ = "CompletionsClient"
146
51
 
147
52
 
148
53
  class CompletionsError(Exception):
@@ -372,7 +277,9 @@ class CompletionsClient(Generic[CompletionsOutputType]):
372
277
  instructions: Optional[str] = None,
373
278
  model: str = "openai/gpt-4o-mini",
374
279
  type: CompletionsOutputType = str,
375
- instructor_mode: InstructorModeParam = "tool_call",
280
+ response_field_name: str = "content",
281
+ response_field_instruction: str = "A response in the correct type as requested by the user, or relevant content.",
282
+ instructor_mode: CompletionsInstructorModeParam = "tool_call",
376
283
  max_retries: int = 3,
377
284
  strict: bool = True,
378
285
  *,
@@ -515,22 +422,30 @@ class CompletionsClient(Generic[CompletionsOutputType]):
515
422
  response_model = convert_to_pydantic_model(
516
423
  target=type,
517
424
  name="Response",
518
- field_name="value",
519
- description="A single field response in the correct type.",
425
+ field_name=response_field_name,
426
+ description=response_field_instruction,
520
427
  )
521
428
  else:
522
429
  response_model = type
523
430
 
524
431
  if stream:
525
- stream = await client.chat.completions.create_partial(
432
+ # Create wrapper to capture raw content via hooks
433
+ wrapper = AsyncInstructorStreamWrapper(
434
+ client=client,
526
435
  response_model=response_model,
527
- max_retries=max_retries,
528
- strict=strict,
529
- **{k: v for k, v in params.items() if v is not None},
436
+ params={
437
+ "max_retries": max_retries,
438
+ "strict": strict,
439
+ **{k: v for k, v in params.items() if v is not None},
440
+ },
441
+ output_type=type,
442
+ model=model,
443
+ )
444
+ return create_async_completion_stream(
445
+ wrapper, output_type=type, model=model
530
446
  )
531
- return create_async_completion_stream(stream, output_type=type, model=model)
532
447
  else:
533
- response = await client.chat.completions.create(
448
+ response, completion = await client.chat.completions.create_with_completion(
534
449
  response_model=response_model,
535
450
  max_retries=max_retries,
536
451
  strict=strict,
@@ -538,13 +453,29 @@ class CompletionsClient(Generic[CompletionsOutputType]):
538
453
  )
539
454
 
540
455
  # Extract the actual value if using converted pydantic model
541
- if not is_pydantic_basemodel(type) and hasattr(response, "value"):
542
- actual_output = response.value
456
+ if not is_pydantic_basemodel(type) and hasattr(
457
+ response, response_field_name
458
+ ):
459
+ actual_output = getattr(response, response_field_name)
543
460
  else:
544
461
  actual_output = response
545
462
 
463
+ # Extract content and tool calls from the completion
464
+ content = None
465
+ tool_calls = None
466
+ if hasattr(completion, "choices") and completion.choices:
467
+ choice = completion.choices[0]
468
+ if hasattr(choice, "message"):
469
+ message = choice.message
470
+ content = getattr(message, "content", None)
471
+ tool_calls = getattr(message, "tool_calls", None)
472
+
546
473
  return Completion(
547
- output=actual_output, model=model, content=None, completion=None
474
+ output=actual_output,
475
+ model=model,
476
+ content=content,
477
+ tool_calls=tool_calls,
478
+ completion=completion,
548
479
  )
549
480
 
550
481
  @staticmethod
@@ -553,7 +484,9 @@ class CompletionsClient(Generic[CompletionsOutputType]):
553
484
  instructions: Optional[str] = None,
554
485
  model: str = "openai/gpt-4o-mini",
555
486
  type: CompletionsOutputType = str,
556
- instructor_mode: InstructorModeParam = "tool_call",
487
+ response_field_name: str = "content",
488
+ response_field_instruction: str = "A response in the correct type as requested by the user, or relevant content.",
489
+ instructor_mode: CompletionsInstructorModeParam = "tool_call",
557
490
  max_retries: int = 3,
558
491
  strict: bool = True,
559
492
  *,
@@ -696,22 +629,28 @@ class CompletionsClient(Generic[CompletionsOutputType]):
696
629
  response_model = convert_to_pydantic_model(
697
630
  target=type,
698
631
  name="Response",
699
- field_name="value",
700
- description="A single field response in the correct type.",
632
+ field_name=response_field_name,
633
+ description=response_field_instruction,
701
634
  )
702
635
  else:
703
636
  response_model = type
704
637
 
705
638
  if stream:
706
- stream = client.chat.completions.create_partial(
639
+ # Create wrapper to capture raw content via hooks
640
+ wrapper = InstructorStreamWrapper(
641
+ client=client,
707
642
  response_model=response_model,
708
- max_retries=max_retries,
709
- strict=strict,
710
- **{k: v for k, v in params.items() if v is not None},
643
+ params={
644
+ "max_retries": max_retries,
645
+ "strict": strict,
646
+ **{k: v for k, v in params.items() if v is not None},
647
+ },
648
+ output_type=type,
649
+ model=model,
711
650
  )
712
- return create_completion_stream(stream, output_type=type, model=model)
651
+ return create_completion_stream(wrapper, output_type=type, model=model)
713
652
  else:
714
- response = client.chat.completions.create(
653
+ response, completion = client.chat.completions.create_with_completion(
715
654
  response_model=response_model,
716
655
  max_retries=max_retries,
717
656
  strict=strict,
@@ -719,11 +658,27 @@ class CompletionsClient(Generic[CompletionsOutputType]):
719
658
  )
720
659
 
721
660
  # Extract the actual value if using converted pydantic model
722
- if not is_pydantic_basemodel(type) and hasattr(response, "value"):
723
- actual_output = response.value
661
+ if not is_pydantic_basemodel(type) and hasattr(
662
+ response, response_field_name
663
+ ):
664
+ actual_output = getattr(response, response_field_name)
724
665
  else:
725
666
  actual_output = response
726
667
 
668
+ # Extract content and tool calls from the completion
669
+ content = None
670
+ tool_calls = None
671
+ if hasattr(completion, "choices") and completion.choices:
672
+ choice = completion.choices[0]
673
+ if hasattr(choice, "message"):
674
+ message = choice.message
675
+ content = getattr(message, "content", None)
676
+ tool_calls = getattr(message, "tool_calls", None)
677
+
727
678
  return Completion(
728
- output=actual_output, model=model, content=None, completion=None
679
+ output=actual_output,
680
+ model=model,
681
+ content=content,
682
+ tool_calls=tool_calls,
683
+ completion=completion,
729
684
  )