File tree Expand file tree Collapse file tree 3 files changed +1934
-3932
lines changed
examples/other_examples/openai_realtime_webrtc Expand file tree Collapse file tree 3 files changed +1934
-3932
lines changed Original file line number Diff line number Diff line change 1111from uuid import uuid4
1212
1313from dotenv import load_dotenv
14+ import pyinstrument
1415
1516from vision_agents .plugins import openai , getstream
1617from vision_agents .core .agents import Agent
2324
2425
2526async def start_agent () -> None :
27+ profiler = pyinstrument .Profiler ()
28+ profiler .start ()
2629 # Set the call ID here to be used in the logging
2730 call_id = str (uuid4 ())
2831
@@ -72,6 +75,10 @@ async def start_agent() -> None:
7275
7376 await agent .finish () # run till the call ends
7477
78+ profiler .stop ()
79+ with open ('profiled.html' , 'w' ) as f :
80+ f .write (profiler .output_html ())
81+
7582
7683if __name__ == "__main__" :
7784 asyncio .run (start_agent ())
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ dependencies = [
1010 " asyncio" ,
1111 " aiortc" ,
1212 " openai" ,
13+ " pyinstrument>=5.1.1" ,
1314]
1415
1516[tool .uv .sources ]
You can’t perform that action at this time.
0 commit comments