MCPcopy
hub / github.com/stitionai/devika / wrapper

Function wrapper

src/services/utils.py:10–25  ·  view source on GitHub ↗
(*args, **kwargs)

Source from the content-addressed store, hash-verified

8
9def retry_wrapper(func):
10 def wrapper(*args, **kwargs):
11 max_tries = 5
12 tries = 0
13 while tries < max_tries:
14 result = func(*args, **kwargs)
15 if result:
16 return result
17 print("Invalid response from the model, I'm trying again...")
18 emit_agent("info", {"type": "warning", "message": "Invalid response from the model, trying again..."})
19 tries += 1
20 time.sleep(2)
21 print("Maximum 5 attempts reached. try other models")
22 emit_agent("info", {"type": "error", "message": "Maximum attempts reached. model keeps failing."})
23 sys.exit(1)
24
25 return False
26 return wrapper
27
28

Callers

nothing calls this directly

Calls 1

emit_agentFunction · 0.90

Tested by

no test coverage detected