From 1dbf774d55dcfc27c70e2f9e209c7ab61b80d824 Mon Sep 17 00:00:00 2001 From: ThomasTaroni Date: Fri, 25 Apr 2025 18:46:48 +0200 Subject: [PATCH] Refactor async methods to adjust return types. Changed `send_json` to return `None` instead of yielding and updated log retrieval to use `yield` in place of `return`. These modifications align function behavior with intended asynchronous use cases and improve consistency. --- src/phoenix_technologies/gptresearch/deepresearch.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/phoenix_technologies/gptresearch/deepresearch.py b/src/phoenix_technologies/gptresearch/deepresearch.py index 3724c99..f10497e 100644 --- a/src/phoenix_technologies/gptresearch/deepresearch.py +++ b/src/phoenix_technologies/gptresearch/deepresearch.py @@ -9,11 +9,10 @@ class CustomLogsHandler: logs = [] self.logs = logs # Initialize logs to store data - async def send_json(self, data: Dict[str, Any]) -> AsyncGenerator[str, Any]: + async def send_json(self, data: Dict[str, Any]) -> None: """Send JSON data and log it.""" self.logs.append(data) # Append data to logs print(f"My custom Log: {data}") - yield f"My custom Log: {data}" class ReportGenerator: def __init__(self, query: str, report_type: str): @@ -64,6 +63,6 @@ class ReportGenerator: if self._log_index < len(self.logs): log = self.logs[self._log_index] self._log_index += 1 - return log # Return the next log + yield log # Return the next log else: raise StopAsyncIteration # Stop when logs are exhausted