Refactor generator completion checks for consistency.
Replaced `.is_complete()` method calls with direct `.complete` attribute access to streamline the code. Removed the redundant `is_complete()` method from `deepresearch.py` to reduce unnecessary indirection. This simplifies the logic and improves readability.
This commit is contained in:
parent
b16305e369
commit
79be94afd2
2 changed files with 2 additions and 5 deletions
|
@ -42,7 +42,7 @@ async def get_report_endpoint(request: ReportRequest):
|
||||||
generator.generate_report()
|
generator.generate_report()
|
||||||
yield "Report generation completed successfully!\n"
|
yield "Report generation completed successfully!\n"
|
||||||
index = 0
|
index = 0
|
||||||
while not generator.is_complete():
|
while not generator.complete:
|
||||||
# If there are more logs to send, yield them
|
# If there are more logs to send, yield them
|
||||||
if index < len(custom_logs_handler.logs):
|
if index < len(custom_logs_handler.logs):
|
||||||
log_entry = custom_logs_handler.logs[index]
|
log_entry = custom_logs_handler.logs[index]
|
||||||
|
@ -52,7 +52,7 @@ async def get_report_endpoint(request: ReportRequest):
|
||||||
# Wait briefly to avoid aggressive looping
|
# Wait briefly to avoid aggressive looping
|
||||||
await asyncio.sleep(0.1)
|
await asyncio.sleep(0.1)
|
||||||
# Stop if processing is complete and no more logs remain
|
# Stop if processing is complete and no more logs remain
|
||||||
if generator.researcher.is_complete():
|
if generator.researcher.complete:
|
||||||
break
|
break
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
@ -28,9 +28,6 @@ class ReportGenerator:
|
||||||
def init(self) -> CustomLogsHandler:
|
def init(self) -> CustomLogsHandler:
|
||||||
return self.custom_logs_handler
|
return self.custom_logs_handler
|
||||||
|
|
||||||
def is_complete(self):
|
|
||||||
return self.complete
|
|
||||||
|
|
||||||
async def generate_report(self) -> None:
|
async def generate_report(self) -> None:
|
||||||
"""
|
"""
|
||||||
Conducts research and generates the report along with additional information.
|
Conducts research and generates the report along with additional information.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue