bear-utils 0.8.16__tar.gz → 0.8.17__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 (118) hide show
  1. {bear_utils-0.8.16 → bear_utils-0.8.17}/.bumpversion.cfg +1 -1
  2. {bear_utils-0.8.16 → bear_utils-0.8.17}/PKG-INFO +2 -2
  3. {bear_utils-0.8.16 → bear_utils-0.8.17}/README.md +1 -1
  4. {bear_utils-0.8.16 → bear_utils-0.8.17}/pyproject.toml +1 -1
  5. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/extras/responses/function_response.py +51 -48
  6. {bear_utils-0.8.16 → bear_utils-0.8.17}/.gitignore +0 -0
  7. {bear_utils-0.8.16 → bear_utils-0.8.17}/.python-version +0 -0
  8. {bear_utils-0.8.16 → bear_utils-0.8.17}/AGENTS.md +0 -0
  9. {bear_utils-0.8.16 → bear_utils-0.8.17}/config/coverage.ini +0 -0
  10. {bear_utils-0.8.16 → bear_utils-0.8.17}/config/default.toml +0 -0
  11. {bear_utils-0.8.16 → bear_utils-0.8.17}/config/git-changelog.toml +0 -0
  12. {bear_utils-0.8.16 → bear_utils-0.8.17}/config/pytest.ini +0 -0
  13. {bear_utils-0.8.16 → bear_utils-0.8.17}/config/ruff.toml +0 -0
  14. {bear_utils-0.8.16 → bear_utils-0.8.17}/config/vscode/launch.json +0 -0
  15. {bear_utils-0.8.16 → bear_utils-0.8.17}/config/vscode/settings.json +0 -0
  16. {bear_utils-0.8.16 → bear_utils-0.8.17}/config/vscode/tasks.json +0 -0
  17. {bear_utils-0.8.16 → bear_utils-0.8.17}/directory_structure.txt +0 -0
  18. {bear_utils-0.8.16 → bear_utils-0.8.17}/directory_structure.xml +0 -0
  19. {bear_utils-0.8.16 → bear_utils-0.8.17}/maskfile.md +0 -0
  20. {bear_utils-0.8.16 → bear_utils-0.8.17}/noxfile.py +0 -0
  21. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/__init__.py +0 -0
  22. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/__main__.py +0 -0
  23. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/_internal/__init__.py +0 -0
  24. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/_internal/cli.py +0 -0
  25. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/_internal/debug.py +0 -0
  26. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/ai/__init__.py +0 -0
  27. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/ai/ai_helpers/__init__.py +0 -0
  28. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/ai/ai_helpers/_common.py +0 -0
  29. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/ai/ai_helpers/_config.py +0 -0
  30. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/ai/ai_helpers/_parsers.py +0 -0
  31. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/ai/ai_helpers/_types.py +0 -0
  32. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/cache/__init__.py +0 -0
  33. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/cli/__init__.py +0 -0
  34. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/cli/commands.py +0 -0
  35. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/cli/prompt_helpers.py +0 -0
  36. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/cli/shell/__init__.py +0 -0
  37. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/cli/shell/_base_command.py +0 -0
  38. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/cli/shell/_base_shell.py +0 -0
  39. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/cli/shell/_common.py +0 -0
  40. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/config/__init__.py +0 -0
  41. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/config/config_manager.py +0 -0
  42. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/config/dir_manager.py +0 -0
  43. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/config/settings_manager.py +0 -0
  44. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/constants/__init__.py +0 -0
  45. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/constants/_exceptions.py +0 -0
  46. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/constants/_lazy_typing.py +0 -0
  47. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/constants/date_related.py +0 -0
  48. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/constants/server.py +0 -0
  49. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/constants/time_related.py +0 -0
  50. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/database/__init__.py +0 -0
  51. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/database/_db_manager.py +0 -0
  52. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/events/__init__.py +0 -0
  53. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/events/events_class.py +0 -0
  54. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/events/events_module.py +0 -0
  55. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/extras/__init__.py +0 -0
  56. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/extras/_async_helpers.py +0 -0
  57. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/extras/_tools.py +0 -0
  58. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/extras/platform_utils.py +0 -0
  59. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/extras/responses/__init__.py +0 -0
  60. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/extras/wrappers/__init__.py +0 -0
  61. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/extras/wrappers/add_methods.py +0 -0
  62. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/files/__init__.py +0 -0
  63. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/files/file_handlers/__init__.py +0 -0
  64. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/files/file_handlers/_base_file_handler.py +0 -0
  65. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/files/file_handlers/file_handler_factory.py +0 -0
  66. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/files/file_handlers/json_file_handler.py +0 -0
  67. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/files/file_handlers/log_file_handler.py +0 -0
  68. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/files/file_handlers/toml_file_handler.py +0 -0
  69. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/files/file_handlers/txt_file_handler.py +0 -0
  70. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/files/file_handlers/yaml_file_handler.py +0 -0
  71. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/files/ignore_parser.py +0 -0
  72. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/graphics/__init__.py +0 -0
  73. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/graphics/bear_gradient.py +0 -0
  74. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/graphics/image_helpers.py +0 -0
  75. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/gui/__init__.py +0 -0
  76. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/gui/gui_tools/__init__.py +0 -0
  77. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/gui/gui_tools/_settings.py +0 -0
  78. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/gui/gui_tools/_types.py +0 -0
  79. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/gui/gui_tools/qt_app.py +0 -0
  80. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/gui/gui_tools/qt_color_picker.py +0 -0
  81. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/gui/gui_tools/qt_file_handler.py +0 -0
  82. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/gui/gui_tools/qt_input_dialog.py +0 -0
  83. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/logger_manager/__init__.py +0 -0
  84. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/logger_manager/_common.py +0 -0
  85. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/logger_manager/_console_junk.py +0 -0
  86. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/logger_manager/_log_level.py +0 -0
  87. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/logger_manager/_styles.py +0 -0
  88. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/logger_manager/logger_protocol.py +0 -0
  89. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/logger_manager/loggers/__init__.py +0 -0
  90. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/logger_manager/loggers/_level_sin.py +0 -0
  91. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/logger_manager/loggers/base_logger.py +0 -0
  92. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/logger_manager/loggers/base_logger.pyi +0 -0
  93. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/logger_manager/loggers/basic_logger/__init__.py +0 -0
  94. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/logger_manager/loggers/basic_logger/logger.py +0 -0
  95. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/logger_manager/loggers/basic_logger/logger.pyi +0 -0
  96. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/logger_manager/loggers/buffer_logger.py +0 -0
  97. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/logger_manager/loggers/console_logger.py +0 -0
  98. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/logger_manager/loggers/console_logger.pyi +0 -0
  99. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/logger_manager/loggers/fastapi_logger.py +0 -0
  100. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/logger_manager/loggers/file_logger.py +0 -0
  101. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/logger_manager/loggers/simple_logger.py +0 -0
  102. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/logger_manager/loggers/sub_logger.py +0 -0
  103. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/logger_manager/loggers/sub_logger.pyi +0 -0
  104. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/monitoring/__init__.py +0 -0
  105. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/monitoring/_common.py +0 -0
  106. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/monitoring/host_monitor.py +0 -0
  107. {bear_utils-0.8.16 → bear_utils-0.8.17}/src/bear_utils/time/__init__.py +0 -0
  108. {bear_utils-0.8.16 → bear_utils-0.8.17}/tests/__init__.py +0 -0
  109. {bear_utils-0.8.16 → bear_utils-0.8.17}/tests/test_add_ord_suffix.py +0 -0
  110. {bear_utils-0.8.16 → bear_utils-0.8.17}/tests/test_clipboard.py +0 -0
  111. {bear_utils-0.8.16 → bear_utils-0.8.17}/tests/test_database_manager.py +0 -0
  112. {bear_utils-0.8.16 → bear_utils-0.8.17}/tests/test_default_shell.py +0 -0
  113. {bear_utils-0.8.16 → bear_utils-0.8.17}/tests/test_function_response.py +0 -0
  114. {bear_utils-0.8.16 → bear_utils-0.8.17}/tests/test_gradient.py +0 -0
  115. {bear_utils-0.8.16 → bear_utils-0.8.17}/tests/test_logger.py +0 -0
  116. {bear_utils-0.8.16 → bear_utils-0.8.17}/tests/test_platform_utils.py +0 -0
  117. {bear_utils-0.8.16 → bear_utils-0.8.17}/tests/test_prompt_helpers.py +0 -0
  118. {bear_utils-0.8.16 → bear_utils-0.8.17}/uv.lock +0 -0
@@ -1,5 +1,5 @@
1
1
  [bumpversion]
2
- current_version = 0.8.16
2
+ current_version = 0.8.17
3
3
 
4
4
  [bumpversion:file:pyproject.toml]
5
5
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bear-utils
3
- Version: 0.8.16
3
+ Version: 0.8.17
4
4
  Summary: Various utilities for Bear programmers, including a rich logging utility, a disk cache, and a SQLite database wrapper amongst other things.
5
5
  Author-email: chaz <bright.lid5647@fastmail.com>
6
6
  Requires-Python: >=3.12
@@ -22,7 +22,7 @@ Requires-Dist: toml>=0.10.2
22
22
  Requires-Dist: uvicorn>=0.35.0
23
23
  Description-Content-Type: text/markdown
24
24
 
25
- # Bear Utils v# Bear Utils v0.8.16
25
+ # Bear Utils v# Bear Utils v0.8.17
26
26
 
27
27
  Personal set of tools and utilities for Python projects, focusing on modularity and ease of use. This library includes components for caching, database management, logging, time handling, file operations, CLI prompts, image processing, clipboard interaction, gradient utilities, event systems, and async helpers.
28
28
 
@@ -1,4 +1,4 @@
1
- # Bear Utils v# Bear Utils v0.8.16
1
+ # Bear Utils v# Bear Utils v0.8.17
2
2
 
3
3
  Personal set of tools and utilities for Python projects, focusing on modularity and ease of use. This library includes components for caching, database management, logging, time handling, file operations, CLI prompts, image processing, clipboard interaction, gradient utilities, event systems, and async helpers.
4
4
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "bear-utils"
3
- version = "0.8.16"
3
+ version = "0.8.17"
4
4
  description = "Various utilities for Bear programmers, including a rich logging utility, a disk cache, and a SQLite database wrapper amongst other things."
5
5
  authors = [{ name = "chaz", email = "bright.lid5647@fastmail.com" }]
6
6
  readme = "README.md"
@@ -2,6 +2,7 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
+ import asyncio
5
6
  from collections.abc import Callable
6
7
  import json
7
8
  from subprocess import CompletedProcess
@@ -10,9 +11,10 @@ from typing import Any, Literal, Self, overload
10
11
 
11
12
  from pydantic import BaseModel, Field, field_validator
12
13
 
14
+ from bear_utils.extras._async_helpers import is_async_function
13
15
  from bear_utils.logger_manager import (
14
- AsyncLoggerProtocol, # noqa: TC001
15
- LoggerProtocol, # noqa: TC001
16
+ AsyncLoggerProtocol,
17
+ LoggerProtocol,
16
18
  )
17
19
 
18
20
  SUCCESS: list[str] = ["name", "success"]
@@ -202,43 +204,47 @@ class FunctionResponse(BaseModel):
202
204
  self.add(content=content, error=error, returncode=returncode or 1, **kwargs)
203
205
  return self
204
206
 
205
- def _add_item(self, item: str, target_list: list[str]) -> None:
207
+ async def _add_item(self, item: str, target_list: list[str]) -> None:
206
208
  """Append an item to the target list if not empty."""
207
209
  if item != "":
208
210
  target_list.append(item)
209
211
 
210
- def _add_to_list(self, items: str | list[str], target_list: list[str], name: str | None = None) -> None:
212
+ async def _add_to_list(self, items: str | list[str], target_list: list[str], name: str | None = None) -> None:
211
213
  """Append items to the target list with optional name prefix."""
212
214
  try:
213
215
  if isinstance(items, list):
214
216
  for item in items:
215
- self._add_item(f"{name}: {item}" if name else item, target_list)
217
+ await self._add_item(f"{name}: {item}" if name else item, target_list)
216
218
  elif isinstance(items, str):
217
- self._add_item(f"{name}: {items}" if name else items, target_list)
219
+ await self._add_item(f"{name}: {items}" if name else items, target_list)
218
220
  except Exception as e:
219
221
  raise ValueError(f"Failed to add items: {e!s}") from e
220
222
 
221
- def _add_content(self, content: str | list[str], name: str | None = None) -> None:
223
+ async def _add_content(self, content: str | list[str], name: str | None = None) -> None:
222
224
  """Append content to the existing content."""
223
- self._add_to_list(content, self.content, name)
225
+ await self._add_to_list(content, self.content, name)
224
226
 
225
- def _add_error(self, error: str | list[str], name: str | None = None) -> None:
227
+ async def _add_error(self, error: str | list[str], name: str | None = None) -> None:
226
228
  """Append error to the existing error."""
227
- self._add_to_list(error, self.error, name)
229
+ await self._add_to_list(error, self.error, name)
228
230
 
229
- def _handle_function_response(self, func_response: FunctionResponse) -> None:
231
+ async def _handle_function_response(self, func_response: FunctionResponse) -> None:
230
232
  """Handle a FunctionResponse object and update the current response."""
231
233
  if func_response.extra:
232
234
  self.extra.update(func_response.extra)
233
- self._add_error(error=func_response.error, name=func_response.name)
234
- self._add_content(content=func_response.content, name=func_response.name)
235
+ await self._add_error(error=func_response.error, name=func_response.name)
236
+ await self._add_content(content=func_response.content, name=func_response.name)
235
237
 
236
- def _handle_completed_process(self, result: CompletedProcess[str]) -> None:
238
+ async def _handle_completed_process(self, result: CompletedProcess[str]) -> None:
237
239
  """Handle a CompletedProcess object and update the FunctionResponse."""
238
- self._add_content(content=result.stdout.strip() if result.stdout else "")
239
- self._add_error(error=result.stderr.strip() if result.stderr else "")
240
+ await self._add_content(content=result.stdout.strip() if result.stdout else "")
241
+ await self._add_error(error=result.stderr.strip() if result.stderr else "")
240
242
  self.returncode = result.returncode
241
243
 
244
+ @staticmethod
245
+ async def _run_coroutines(coroutines: list[asyncio._CoroutineLike]) -> None:
246
+ await asyncio.gather(*coroutines)
247
+
242
248
  def add(
243
249
  self,
244
250
  content: list[str] | str | FunctionResponse | CompletedProcess | None = None,
@@ -247,62 +253,56 @@ class FunctionResponse(BaseModel):
247
253
  log_output: bool = False,
248
254
  extra: dict[str, Any] | None = None,
249
255
  ) -> Self:
250
- """Append additional content to the existing content.
251
-
252
- Args:
253
- content (list[str] | str | FunctionResponse | CompletedProcess): The content to add.
254
- error (str | list[str] | None): The error message(s) to add.
255
- returncode (int | None): The return code of the function call.
256
- log_output (bool): Whether to log the output using the logger.
257
- **kwargs: Additional metadata to include in the response.
258
-
259
- Returns:
260
- Self: The updated FunctionResponse instance.
261
- """
256
+ """Append additional content to the existing content."""
257
+ coroutines: list[asyncio._CoroutineLike] = []
262
258
  try:
263
259
  match content:
264
260
  case FunctionResponse():
265
- self._handle_function_response(func_response=content)
261
+ coroutines.append(self._handle_function_response(func_response=content))
266
262
  self.number_of_tasks += 1
267
263
  case CompletedProcess():
268
- self._handle_completed_process(result=content)
264
+ coroutines.append(self._handle_completed_process(result=content))
269
265
  self.number_of_tasks += 1
270
266
  case str() | list() if content:
271
- self._add_content(content=content)
267
+ coroutines.append(self._add_content(content=content))
272
268
  self.number_of_tasks += 1
273
- case None:
274
- content = None
275
- case _:
276
- content = None
277
- self._add_error(error=error) if isinstance(error, (str | list)) else None
278
- self.returncode = returncode if returncode is not None else self.returncode
279
- self.extra.update(extra) if isinstance(extra, dict) else None
280
- if log_output and self.logger is not None and (content is not None or error is not None):
281
- self._log_handling(content=content, error=error, logger=self.logger)
269
+ if isinstance(error, (str | list)):
270
+ coroutines.append(self._add_error(error=error))
271
+ if returncode is not None:
272
+ self.returncode = returncode
273
+ if isinstance(extra, dict):
274
+ self.extra.update(extra)
275
+ if log_output and self.logger and (content or error):
276
+ coroutines.append(self._log_handling(content=content, error=error, logger=self.logger))
277
+ if coroutines:
278
+ asyncio.run(self._run_coroutines(coroutines))
282
279
  except Exception as e:
283
280
  raise ValueError(f"Failed to add content: {e!s}") from e
284
281
  return self
285
282
 
286
- def _log_handling(
283
+ async def _log_handling(
287
284
  self,
288
285
  content: list[str] | str | FunctionResponse | CompletedProcess | None,
289
286
  error: str | list[str] | None,
290
- logger: LoggerProtocol,
287
+ logger: LoggerProtocol | AsyncLoggerProtocol,
291
288
  ) -> None:
292
289
  """Log the content and error messages if they exist."""
293
290
 
294
- def _log_messages(messages: str | list[str], log_func: Callable) -> None:
291
+ async def _log_messages(messages: str | list[str], log_func: Callable) -> None:
295
292
  if isinstance(messages, str):
296
293
  messages = [messages]
297
294
  if isinstance(messages, list):
298
295
  for msg in messages:
299
- log_func(f"{self.name}: {msg}" if self.name else msg)
296
+ if is_async_function(log_func):
297
+ await log_func(f"{self.name}: {msg}" if self.name else msg)
298
+ else:
299
+ log_func(f"{self.name}: {msg}" if self.name else msg)
300
300
 
301
301
  if content and isinstance(content, (str | list)):
302
- _log_messages(content, logger.info)
302
+ await _log_messages(content, logger.info)
303
303
 
304
304
  if error and isinstance(error, (str | list)):
305
- _log_messages(error, logger.error)
305
+ await _log_messages(error, logger.error)
306
306
 
307
307
  @overload
308
308
  def done(self, to_dict: Literal[True], suppress: list[str] | None = None) -> dict[str, Any]: ...
@@ -365,8 +365,11 @@ if __name__ == "__main__":
365
365
  # Example usage
366
366
  from rich import inspect
367
367
 
368
- response = FunctionResponse(name="example_function", returncode=0, content=["Task completed successfully."])
369
- response.task_id = 124
368
+ from bear_utils.logger_manager import SimpleLogger
369
+
370
+ response = FunctionResponse(name="example_function", logger=SimpleLogger())
371
+
372
+ response.add(content="This is a test content.", error="This is an error message.", log_output=True)
370
373
 
371
374
  inspect(response)
372
375
  print(response)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes