perf(core): Optimize DAG engine, orchestrator loop, and simulations
This commit is contained in:
+18
-13
@@ -4,10 +4,11 @@ from typing import Any, Callable
|
||||
from src import ai_client
|
||||
|
||||
class UserSimAgent:
|
||||
def __init__(self, hook_client: Any, model: str = "gemini-2.5-flash-lite", enable_delays: bool = True) -> None:
|
||||
def __init__(self, hook_client: Any, model: str = "gemini-2.5-flash-lite", enable_delays: bool = True, batch_typing: bool = False) -> None:
|
||||
self.hook_client = hook_client
|
||||
self.model = model
|
||||
self.enable_delays = enable_delays
|
||||
self.batch_typing = batch_typing
|
||||
self.system_prompt = (
|
||||
"You are a software engineer testing an AI coding assistant called 'Manual Slop'. "
|
||||
"You want to build a small Python project and verify the assistant's capabilities. "
|
||||
@@ -30,18 +31,22 @@ class UserSimAgent:
|
||||
delay = random.uniform(min_delay, max_delay)
|
||||
time.sleep(delay)
|
||||
|
||||
def simulate_typing(self, text: str, jitter_range: tuple[float, float] = (0.01, 0.05)) -> None:
|
||||
if self.enable_delays:
|
||||
# Simulate typing by sleeping after chunks or characters to balance speed and realism
|
||||
if len(text) > 200:
|
||||
for i in range(0, len(text), 10):
|
||||
time.sleep(random.uniform(jitter_range[0] * 3, jitter_range[1] * 3))
|
||||
elif len(text) > 50:
|
||||
for i in range(0, len(text), 3):
|
||||
time.sleep(random.uniform(jitter_range[0] * 1.5, jitter_range[1] * 1.5))
|
||||
else:
|
||||
for char in text:
|
||||
time.sleep(random.uniform(jitter_range[0], jitter_range[1]))
|
||||
def simulate_typing(self, text: str, jitter_range: tuple[float, float] = (0.01, 0.05), batch_typing: bool = False) -> None:
|
||||
if not self.enable_delays:
|
||||
return
|
||||
if batch_typing or self.batch_typing:
|
||||
time.sleep(0.01)
|
||||
return
|
||||
# Simulate typing by sleeping after chunks or characters to balance speed and realism
|
||||
if len(text) > 200:
|
||||
for i in range(0, len(text), 10):
|
||||
time.sleep(random.uniform(jitter_range[0] * 3, jitter_range[1] * 3))
|
||||
elif len(text) > 50:
|
||||
for i in range(0, len(text), 3):
|
||||
time.sleep(random.uniform(jitter_range[0] * 1.5, jitter_range[1] * 1.5))
|
||||
else:
|
||||
for char in text:
|
||||
time.sleep(random.uniform(jitter_range[0], jitter_range[1]))
|
||||
|
||||
def generate_response(self, conversation_history: list[dict]) -> str:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user