Spaces:
Running
Running
Joseph Pollack
commited on
ruff format check solution
Browse files- examples/rate_limiting_demo.py +1 -1
- src/agents/long_writer.py +2 -2
- src/agents/writer.py +1 -1
- src/utils/models.py +1 -4
- tests/unit/tools/test_pubmed.py +1 -1
examples/rate_limiting_demo.py
CHANGED
|
@@ -22,7 +22,7 @@ async def test_basic_limiter():
|
|
| 22 |
for i in range(6):
|
| 23 |
await limiter.acquire()
|
| 24 |
elapsed = time.monotonic() - start
|
| 25 |
-
print(f" Request {i+1} at {elapsed:.2f}s")
|
| 26 |
|
| 27 |
total = time.monotonic() - start
|
| 28 |
print(f" Total time for 6 requests: {total:.2f}s (expected ~2s)")
|
|
|
|
| 22 |
for i in range(6):
|
| 23 |
await limiter.acquire()
|
| 24 |
elapsed = time.monotonic() - start
|
| 25 |
+
print(f" Request {i + 1} at {elapsed:.2f}s")
|
| 26 |
|
| 27 |
total = time.monotonic() - start
|
| 28 |
print(f" Total time for 6 requests: {total:.2f}s (expected ~2s)")
|
src/agents/long_writer.py
CHANGED
|
@@ -35,7 +35,7 @@ class LongWriterOutput(BaseModel):
|
|
| 35 |
# System prompt for the long writer agent
|
| 36 |
SYSTEM_PROMPT = f"""
|
| 37 |
You are an expert report writer tasked with iteratively writing each section of a report.
|
| 38 |
-
Today's date is {datetime.now().strftime(
|
| 39 |
You will be provided with:
|
| 40 |
1. The original research query
|
| 41 |
2. A final draft of the report containing the table of contents and all sections written up until this point (in the first iteration there will be no sections written yet)
|
|
@@ -274,7 +274,7 @@ class LongWriterAgent:
|
|
| 274 |
f"# {report_title}\n\n## Table of Contents\n\n"
|
| 275 |
+ "\n".join(
|
| 276 |
[
|
| 277 |
-
f"{i+1}. {section.section_title}"
|
| 278 |
for i, section in enumerate(report_draft.sections)
|
| 279 |
]
|
| 280 |
)
|
|
|
|
| 35 |
# System prompt for the long writer agent
|
| 36 |
SYSTEM_PROMPT = f"""
|
| 37 |
You are an expert report writer tasked with iteratively writing each section of a report.
|
| 38 |
+
Today's date is {datetime.now().strftime("%Y-%m-%d")}.
|
| 39 |
You will be provided with:
|
| 40 |
1. The original research query
|
| 41 |
2. A final draft of the report containing the table of contents and all sections written up until this point (in the first iteration there will be no sections written yet)
|
|
|
|
| 274 |
f"# {report_title}\n\n## Table of Contents\n\n"
|
| 275 |
+ "\n".join(
|
| 276 |
[
|
| 277 |
+
f"{i + 1}. {section.section_title}"
|
| 278 |
for i, section in enumerate(report_draft.sections)
|
| 279 |
]
|
| 280 |
)
|
src/agents/writer.py
CHANGED
|
@@ -18,7 +18,7 @@ logger = structlog.get_logger()
|
|
| 18 |
# System prompt for the writer agent
|
| 19 |
SYSTEM_PROMPT = f"""
|
| 20 |
You are a senior researcher tasked with comprehensively answering a research query.
|
| 21 |
-
Today's date is {datetime.now().strftime(
|
| 22 |
You will be provided with the original query along with research findings put together by a research assistant.
|
| 23 |
Your objective is to generate the final response in markdown format.
|
| 24 |
The response should be as lengthy and detailed as possible with the information provided, focusing on answering the original query.
|
|
|
|
| 18 |
# System prompt for the writer agent
|
| 19 |
SYSTEM_PROMPT = f"""
|
| 20 |
You are a senior researcher tasked with comprehensively answering a research query.
|
| 21 |
+
Today's date is {datetime.now().strftime("%Y-%m-%d")}.
|
| 22 |
You will be provided with the original query along with research findings put together by a research assistant.
|
| 23 |
Your objective is to generate the final response in markdown format.
|
| 24 |
The response should be as lengthy and detailed as possible with the information provided, focusing on answering the original query.
|
src/utils/models.py
CHANGED
|
@@ -417,10 +417,7 @@ class Conversation(BaseModel):
|
|
| 417 |
def get_task_string(self, iteration_num: int) -> str:
|
| 418 |
"""Get the task for the specified iteration."""
|
| 419 |
if iteration_num < len(self.history) and self.history[iteration_num].gap:
|
| 420 |
-
return
|
| 421 |
-
f"<task>\nAddress this knowledge gap: "
|
| 422 |
-
f"{self.history[iteration_num].gap}\n</task>"
|
| 423 |
-
)
|
| 424 |
return ""
|
| 425 |
|
| 426 |
def get_action_string(self, iteration_num: int) -> str:
|
|
|
|
| 417 |
def get_task_string(self, iteration_num: int) -> str:
|
| 418 |
"""Get the task for the specified iteration."""
|
| 419 |
if iteration_num < len(self.history) and self.history[iteration_num].gap:
|
| 420 |
+
return f"<task>\nAddress this knowledge gap: {self.history[iteration_num].gap}\n</task>"
|
|
|
|
|
|
|
|
|
|
| 421 |
return ""
|
| 422 |
|
| 423 |
def get_action_string(self, iteration_num: int) -> str:
|
tests/unit/tools/test_pubmed.py
CHANGED
|
@@ -163,7 +163,7 @@ class TestPubMedTool:
|
|
| 163 |
# Make first 3 requests - should all succeed without sleep (within rate limit)
|
| 164 |
with patch("asyncio.sleep") as mock_sleep_first:
|
| 165 |
for i in range(3):
|
| 166 |
-
await tool.search(f"test query {i+1}")
|
| 167 |
# First 3 requests should not sleep (within 3/second limit)
|
| 168 |
assert mock_sleep_first.call_count == 0
|
| 169 |
|
|
|
|
| 163 |
# Make first 3 requests - should all succeed without sleep (within rate limit)
|
| 164 |
with patch("asyncio.sleep") as mock_sleep_first:
|
| 165 |
for i in range(3):
|
| 166 |
+
await tool.search(f"test query {i + 1}")
|
| 167 |
# First 3 requests should not sleep (within 3/second limit)
|
| 168 |
assert mock_sleep_first.call_count == 0
|
| 169 |
|