forked from openai/openai-agents-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
133 lines (108 loc) · 4.62 KB
/
__init__.py
File metadata and controls
133 lines (108 loc) · 4.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
"""Session memory backends living in the extensions namespace.
This package contains optional, production-grade session implementations that
introduce extra third-party dependencies (database drivers, ORMs, etc.). They
conform to the :class:`agents.memory.session.Session` protocol so they can be
used as a drop-in replacement for :class:`agents.memory.session.SQLiteSession`.
"""
from __future__ import annotations
from typing import TYPE_CHECKING, Any
if TYPE_CHECKING:
from .advanced_sqlite_session import AdvancedSQLiteSession
from .async_sqlite_session import AsyncSQLiteSession
from .dapr_session import (
DAPR_CONSISTENCY_EVENTUAL,
DAPR_CONSISTENCY_STRONG,
DaprSession,
)
from .encrypt_session import EncryptedSession
from .mongodb_session import MongoDBSession
from .redis_session import RedisSession
from .sqlalchemy_session import SQLAlchemySession
__all__: list[str] = [
"AdvancedSQLiteSession",
"AsyncSQLiteSession",
"DAPR_CONSISTENCY_EVENTUAL",
"DAPR_CONSISTENCY_STRONG",
"DaprSession",
"EncryptedSession",
"MongoDBSession",
"RedisSession",
"SQLAlchemySession",
]
def __getattr__(name: str) -> Any:
if name == "EncryptedSession":
try:
from .encrypt_session import EncryptedSession # noqa: F401
return EncryptedSession
except ModuleNotFoundError as e:
raise ImportError(
"EncryptedSession requires the 'cryptography' extra. "
"Install it with: pip install openai-agents[encrypt]"
) from e
if name == "RedisSession":
try:
from .redis_session import RedisSession # noqa: F401
return RedisSession
except ModuleNotFoundError as e:
raise ImportError(
"RedisSession requires the 'redis' extra. "
"Install it with: pip install openai-agents[redis]"
) from e
if name == "SQLAlchemySession":
try:
from .sqlalchemy_session import SQLAlchemySession # noqa: F401
return SQLAlchemySession
except ModuleNotFoundError as e:
raise ImportError(
"SQLAlchemySession requires the 'sqlalchemy' extra. "
"Install it with: pip install openai-agents[sqlalchemy]"
) from e
if name == "AdvancedSQLiteSession":
try:
from .advanced_sqlite_session import AdvancedSQLiteSession # noqa: F401
return AdvancedSQLiteSession
except ModuleNotFoundError as e:
raise ImportError(f"Failed to import AdvancedSQLiteSession: {e}") from e
if name == "AsyncSQLiteSession":
try:
from .async_sqlite_session import AsyncSQLiteSession # noqa: F401
return AsyncSQLiteSession
except ModuleNotFoundError as e:
raise ImportError(f"Failed to import AsyncSQLiteSession: {e}") from e
if name == "DaprSession":
try:
from .dapr_session import DaprSession # noqa: F401
return DaprSession
except ModuleNotFoundError as e:
raise ImportError(
"DaprSession requires the 'dapr' extra. "
"Install it with: pip install openai-agents[dapr]"
) from e
if name == "DAPR_CONSISTENCY_EVENTUAL":
try:
from .dapr_session import DAPR_CONSISTENCY_EVENTUAL # noqa: F401
return DAPR_CONSISTENCY_EVENTUAL
except ModuleNotFoundError as e:
raise ImportError(
"DAPR_CONSISTENCY_EVENTUAL requires the 'dapr' extra. "
"Install it with: pip install openai-agents[dapr]"
) from e
if name == "DAPR_CONSISTENCY_STRONG":
try:
from .dapr_session import DAPR_CONSISTENCY_STRONG # noqa: F401
return DAPR_CONSISTENCY_STRONG
except ModuleNotFoundError as e:
raise ImportError(
"DAPR_CONSISTENCY_STRONG requires the 'dapr' extra. "
"Install it with: pip install openai-agents[dapr]"
) from e
if name == "MongoDBSession":
try:
from .mongodb_session import MongoDBSession # noqa: F401
return MongoDBSession
except ModuleNotFoundError as e:
raise ImportError(
"MongoDBSession requires the 'mongodb' extra. "
"Install it with: pip install openai-agents[mongodb]"
) from e
raise AttributeError(f"module {__name__} has no attribute {name}")