agentloop-profiler 0.4.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of agentloop-profiler might be problematic. Click here for more details.

Files changed (50) hide show
  1. agentloop/__init__.py +68 -0
  2. agentloop/audit.py +34 -0
  3. agentloop/autoinstrument.py +102 -0
  4. agentloop/ci.py +135 -0
  5. agentloop/cli.py +876 -0
  6. agentloop/client.py +170 -0
  7. agentloop/config.py +50 -0
  8. agentloop/costs.py +15 -0
  9. agentloop/decorators.py +160 -0
  10. agentloop/demo.py +283 -0
  11. agentloop/doctor.py +344 -0
  12. agentloop/events.py +49 -0
  13. agentloop/exporters.py +60 -0
  14. agentloop/findings.py +215 -0
  15. agentloop/graph.py +312 -0
  16. agentloop/integrations/__init__.py +1 -0
  17. agentloop/integrations/crewai.py +144 -0
  18. agentloop/integrations/langgraph.py +140 -0
  19. agentloop/integrations/openai.py +369 -0
  20. agentloop/integrations/openai_agents.py +212 -0
  21. agentloop/integrations/sdk.py +82 -0
  22. agentloop/integrations/vercel_ai.py +83 -0
  23. agentloop/issues.py +88 -0
  24. agentloop/markdown.py +102 -0
  25. agentloop/metrics.py +123 -0
  26. agentloop/optimizer.py +323 -0
  27. agentloop/otel.py +302 -0
  28. agentloop/otel_ids.py +81 -0
  29. agentloop/patches.py +583 -0
  30. agentloop/plan_export.py +72 -0
  31. agentloop/quality.py +222 -0
  32. agentloop/replay.py +424 -0
  33. agentloop/runtime.py +244 -0
  34. agentloop/savings.py +135 -0
  35. agentloop/server.py +292 -0
  36. agentloop/store.py +840 -0
  37. agentloop/timing.py +124 -0
  38. agentloop/tracer.py +356 -0
  39. agentloop/value.py +243 -0
  40. agentloop/version.py +3 -0
  41. agentloop_profiler-0.4.0.dist-info/METADATA +598 -0
  42. agentloop_profiler-0.4.0.dist-info/RECORD +50 -0
  43. agentloop_profiler-0.4.0.dist-info/WHEEL +5 -0
  44. agentloop_profiler-0.4.0.dist-info/entry_points.txt +2 -0
  45. agentloop_profiler-0.4.0.dist-info/licenses/LICENSE +201 -0
  46. agentloop_profiler-0.4.0.dist-info/licenses/THIRD_PARTY_LICENSES.md +54 -0
  47. agentloop_profiler-0.4.0.dist-info/top_level.txt +2 -0
  48. dashboard/__init__.py +1 -0
  49. dashboard/app.py +698 -0
  50. dashboard/value_view.py +101 -0
@@ -0,0 +1,101 @@
1
+ from __future__ import annotations
2
+
3
+ import json
4
+ from typing import Any
5
+
6
+
7
+ def money(value: float, decimals: int = 2) -> str:
8
+ return f"${float(value):,.{decimals}f}"
9
+
10
+
11
+ def seconds(ms: float) -> str:
12
+ return f"{float(ms) / 1000:,.2f}s"
13
+
14
+
15
+ def _streamlit() -> Any:
16
+ try:
17
+ import streamlit as st
18
+ except ModuleNotFoundError as exc:
19
+ raise ModuleNotFoundError(
20
+ "Install dashboard support with: uv sync --locked --extra dashboard"
21
+ ) from exc
22
+ return st
23
+
24
+
25
+ def assumption_inputs(prefix: str = "") -> tuple[int, float, float]:
26
+ st = _streamlit()
27
+ c1, c2, c3 = st.columns(3)
28
+ runs_per_month = c1.number_input(
29
+ "Runs per month",
30
+ min_value=0,
31
+ value=5000,
32
+ step=500,
33
+ key=f"{prefix}runs_per_month",
34
+ )
35
+ engineer_hourly_rate_usd = c2.number_input(
36
+ "Engineer hourly rate",
37
+ min_value=0.0,
38
+ value=150.0,
39
+ step=25.0,
40
+ key=f"{prefix}engineer_hourly_rate_usd",
41
+ )
42
+ incident_cost_usd = c3.number_input(
43
+ "Reliability event cost",
44
+ min_value=0.0,
45
+ value=500.0,
46
+ step=100.0,
47
+ key=f"{prefix}incident_cost_usd",
48
+ )
49
+ return int(runs_per_month), float(engineer_hourly_rate_usd), float(incident_cost_usd)
50
+
51
+
52
+ def render_value_report(value: dict, *, show_download: bool = True) -> None:
53
+ st = _streamlit()
54
+ monthly = value["monthly_value"]
55
+ per_run = value["per_run"]
56
+ pricing = value.get("pricing", {})
57
+ reliability = value["reliability"]
58
+
59
+ st.subheader("Operational value")
60
+ c1, c2, c3, c4 = st.columns(4)
61
+ c1.metric("Monthly value", money(monthly["total_value_usd"]))
62
+ c2.metric("Cost savings / month", money(monthly["direct_model_cost_savings_usd"]))
63
+ c3.metric("Engineering hours saved", monthly["engineering_hours_saved"])
64
+ c4.metric("Latency hours saved", monthly["latency_hours_saved"])
65
+
66
+ c5, c6, c7, c8 = st.columns(4)
67
+ c5.metric("Latency saved / run", seconds(per_run["latency_savings_ms"]))
68
+ c6.metric("Cost saved / run", money(per_run["cost_savings_usd"], decimals=6))
69
+ c7.metric("Reliability risk", f"{reliability['risk_score']}/100")
70
+ c8.metric("High confidence fixes", reliability["high_confidence_fixes"])
71
+
72
+ st.subheader("Pricing scenario")
73
+ p1, p2, p3, p4 = st.columns(4)
74
+ p1.metric("Modeled tier", pricing.get("suggested_plan", "n/a"))
75
+ p2.metric("Modeled price", money(pricing.get("suggested_monthly_price_usd", 0), decimals=0))
76
+ ratio = pricing.get("value_to_price_ratio")
77
+ p3.metric("Value / price", "n/a" if ratio is None else f"{ratio}x")
78
+ p4.metric("Monthly value", money(pricing.get("estimated_monthly_value_usd", 0)))
79
+
80
+ st.info(pricing.get("rationale", "No pricing rationale available."))
81
+
82
+ notes = pricing.get("scenario_notes", [])
83
+ if notes:
84
+ st.markdown("#### Scenario includes")
85
+ st.write("\n".join(f"- {note}" for note in notes))
86
+
87
+ st.subheader("Value summary")
88
+ st.write(value["value_summary"])
89
+
90
+ risks = reliability.get("top_risks", [])
91
+ if risks:
92
+ st.subheader("Top reliability risks")
93
+ st.write("\n".join(f"- {risk}" for risk in risks))
94
+
95
+ if show_download:
96
+ st.download_button(
97
+ "Download value report JSON",
98
+ data=json.dumps(value, indent=2),
99
+ file_name="agentloop_value_report.json",
100
+ mime="application/json",
101
+ )