File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change 11from __future__ import annotations
22
33import asyncio
4+ from typing import TYPE_CHECKING
45
56import numpy as np
67import sounddevice as sd
1314
1415from agents .voice import StreamedAudioInput , VoicePipeline
1516
16- # Use absolute or relative import based on context
17- if __name__ == "__main__" :
18- # When running as script, use absolute import
19- from my_workflow import MyWorkflow # type: ignore
20- else :
21- # When imported as module, use relative import
17+ # Import MyWorkflow class - handle both module and package use cases
18+ if TYPE_CHECKING :
19+ # For type checking, use the relative import
2220 from .my_workflow import MyWorkflow
21+ else :
22+ # At runtime, try both import styles
23+ try :
24+ # Try relative import first (when used as a package)
25+ from .my_workflow import MyWorkflow
26+ except ImportError :
27+ # Fall back to direct import (when run as a script)
28+ from my_workflow import MyWorkflow
2329
2430CHUNK_LENGTH_S = 0.05 # 100ms
2531SAMPLE_RATE = 24000
You can’t perform that action at this time.
0 commit comments