Skip to content

Commit 6f74065

Browse files
committed
feat: OAuth client implementation for Python chatbot
1 parent 90e478c commit 6f74065

File tree

3 files changed

+600
-2
lines changed

3 files changed

+600
-2
lines changed

examples/chatbots/python/main.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
LambdaFunctionUrlClient,
1515
LambdaFunctionUrlConfig,
1616
)
17+
from server_clients.interactive_oauth import (
18+
InteractiveOAuthClient,
19+
InteractiveOAuthConfig,
20+
)
1721

1822
# Configure logging
1923
logging.basicConfig(
@@ -77,14 +81,20 @@ async def main() -> None:
7781
"""Initialize and run the chat session."""
7882
config = Configuration()
7983
server_config = config.load_config("servers_config.json")
84+
85+
# Initialize stdio servers
8086
servers = [
8187
StdioServer(name, srv_config)
82-
for name, srv_config in server_config["stdioServers"].items()
88+
for name, srv_config in server_config.get("stdioServers", {}).items()
8389
]
90+
91+
# Initialize lambda function servers
8492
servers.extend(
8593
[
8694
LambdaFunctionClient(name, srv_config)
87-
for name, srv_config in server_config["lambdaFunctionServers"].items()
95+
for name, srv_config in server_config.get(
96+
"lambdaFunctionServers", {}
97+
).items()
8898
]
8999
)
90100

@@ -98,6 +108,14 @@ async def main() -> None:
98108
]
99109
)
100110

111+
# Initialize interactive OAuth servers
112+
servers.extend(
113+
[
114+
InteractiveOAuthClient(name, InteractiveOAuthConfig(**srv_config))
115+
for name, srv_config in server_config.get("oAuthServers", {}).items()
116+
]
117+
)
118+
101119
llm_client = LLMClient(config.bedrock_client, config.model_id)
102120
chat_session = ChatSession(servers, llm_client)
103121
await chat_session.start()

0 commit comments

Comments
 (0)