proscenium 0.0.6__tar.gz → 0.0.8__tar.gz

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.
Files changed (36) hide show
  1. {proscenium-0.0.6 → proscenium-0.0.8}/PKG-INFO +1 -1
  2. proscenium-0.0.8/proscenium/bin/__init__.py +42 -0
  3. proscenium-0.0.8/proscenium/bin/bot.py +60 -0
  4. {proscenium-0.0.6 → proscenium-0.0.8}/proscenium/interfaces/slack.py +73 -1
  5. proscenium-0.0.8/proscenium/util/__init__.py +26 -0
  6. {proscenium-0.0.6 → proscenium-0.0.8}/pyproject.toml +1 -1
  7. proscenium-0.0.6/proscenium/bin/bot.py +0 -142
  8. {proscenium-0.0.6 → proscenium-0.0.8}/LICENSE +0 -0
  9. {proscenium-0.0.6 → proscenium-0.0.8}/README.md +0 -0
  10. {proscenium-0.0.6 → proscenium-0.0.8}/proscenium/__init__.py +0 -0
  11. {proscenium-0.0.6 → proscenium-0.0.8}/proscenium/admin/__init__.py +0 -0
  12. {proscenium-0.0.6 → proscenium-0.0.8}/proscenium/core/__init__.py +0 -0
  13. {proscenium-0.0.6 → proscenium-0.0.8}/proscenium/interfaces/__init__.py +0 -0
  14. {proscenium-0.0.6 → proscenium-0.0.8}/proscenium/patterns/__init__.py +0 -0
  15. {proscenium-0.0.6 → proscenium-0.0.8}/proscenium/patterns/chunk_space.py +0 -0
  16. {proscenium-0.0.6 → proscenium-0.0.8}/proscenium/patterns/document_enricher.py +0 -0
  17. {proscenium-0.0.6 → proscenium-0.0.8}/proscenium/patterns/entity_resolver.py +0 -0
  18. {proscenium-0.0.6 → proscenium-0.0.8}/proscenium/patterns/graph_rag.py +0 -0
  19. {proscenium-0.0.6 → proscenium-0.0.8}/proscenium/patterns/knowledge_graph.py +0 -0
  20. {proscenium-0.0.6 → proscenium-0.0.8}/proscenium/patterns/rag.py +0 -0
  21. {proscenium-0.0.6 → proscenium-0.0.8}/proscenium/patterns/tools.py +0 -0
  22. {proscenium-0.0.6 → proscenium-0.0.8}/proscenium/verbs/__init__.py +0 -0
  23. {proscenium-0.0.6 → proscenium-0.0.8}/proscenium/verbs/chunk.py +0 -0
  24. {proscenium-0.0.6 → proscenium-0.0.8}/proscenium/verbs/complete.py +0 -0
  25. {proscenium-0.0.6 → proscenium-0.0.8}/proscenium/verbs/display/__init__.py +0 -0
  26. {proscenium-0.0.6 → proscenium-0.0.8}/proscenium/verbs/display/chat.py +0 -0
  27. {proscenium-0.0.6 → proscenium-0.0.8}/proscenium/verbs/display/milvus.py +0 -0
  28. {proscenium-0.0.6 → proscenium-0.0.8}/proscenium/verbs/display/neo4j.py +0 -0
  29. {proscenium-0.0.6 → proscenium-0.0.8}/proscenium/verbs/display/tools.py +0 -0
  30. {proscenium-0.0.6 → proscenium-0.0.8}/proscenium/verbs/display.py +0 -0
  31. {proscenium-0.0.6 → proscenium-0.0.8}/proscenium/verbs/extract.py +0 -0
  32. {proscenium-0.0.6 → proscenium-0.0.8}/proscenium/verbs/invoke.py +0 -0
  33. {proscenium-0.0.6 → proscenium-0.0.8}/proscenium/verbs/read.py +0 -0
  34. {proscenium-0.0.6 → proscenium-0.0.8}/proscenium/verbs/remember.py +0 -0
  35. {proscenium-0.0.6 → proscenium-0.0.8}/proscenium/verbs/vector_database.py +0 -0
  36. {proscenium-0.0.6 → proscenium-0.0.8}/proscenium/verbs/write.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: proscenium
3
- Version: 0.0.6
3
+ Version: 0.0.8
4
4
  Summary: Frame AI Agents
5
5
  License: ASFv2
6
6
  Author: Adam Pingel
@@ -0,0 +1,42 @@
1
+ from typing import Callable, Optional
2
+
3
+ import logging
4
+ import importlib
5
+ import yaml
6
+ from pathlib import Path
7
+ from rich.console import Console
8
+ from proscenium.core import Production
9
+
10
+ logging.getLogger(__name__).addHandler(logging.NullHandler())
11
+
12
+
13
+ def load_config(config_file_name: Path) -> dict:
14
+
15
+ if not config_file_name.exists():
16
+ raise FileNotFoundError(
17
+ f"Configuration file {config_file_name} not found. "
18
+ "Please provide a valid configuration file."
19
+ )
20
+
21
+ with open(config_file_name, "r", encoding="utf-8") as f:
22
+ config = yaml.safe_load(f)
23
+ return config
24
+
25
+
26
+ def production_from_config(
27
+ config_file_name: Path,
28
+ get_secret: Callable[[str, str], str],
29
+ sub_console: Optional[Console] = None,
30
+ ) -> tuple[Production, dict]:
31
+
32
+ config = load_config(config_file_name)
33
+
34
+ production_config = config.get("production", {})
35
+
36
+ production_module_name = production_config.get("module", None)
37
+
38
+ production_module = importlib.import_module(production_module_name, package=None)
39
+
40
+ production = production_module.make_production(config, get_secret, sub_console)
41
+
42
+ return production, config
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env python3
2
+
3
+ import os
4
+ import sys
5
+ import logging
6
+ import typer
7
+ from pathlib import Path
8
+ from rich.console import Console
9
+
10
+ from proscenium.verbs.display import header
11
+ from proscenium.bin import production_from_config
12
+ from proscenium.interfaces.slack import slack_main
13
+
14
+ logging.basicConfig(
15
+ stream=sys.stdout,
16
+ format="%(asctime)s %(levelname)-8s %(name)s: %(message)s",
17
+ level=logging.WARNING,
18
+ )
19
+
20
+ app = typer.Typer(help="Proscenium Bot")
21
+
22
+ log = logging.getLogger(__name__)
23
+
24
+ default_config_path = Path("demo/demo.yml")
25
+
26
+
27
+ @app.command(help="""Start the Proscenium Bot.""")
28
+ def start(
29
+ config_file: Path = typer.Option(
30
+ default_config_path,
31
+ help="The name of the Proscenium YAML configuration file.",
32
+ ),
33
+ verbose: bool = False,
34
+ ):
35
+
36
+ console = Console()
37
+ sub_console = None
38
+
39
+ if verbose:
40
+ log.setLevel(logging.INFO)
41
+ logging.getLogger("proscenium").setLevel(logging.INFO)
42
+ logging.getLogger("demo").setLevel(logging.INFO)
43
+ sub_console = console
44
+
45
+ console.print(header())
46
+
47
+ production, config = production_from_config(
48
+ config_file, os.environ.get, sub_console
49
+ )
50
+
51
+ console.print("Preparing props...")
52
+ production.prepare_props()
53
+ console.print("Props are up-to-date.")
54
+
55
+ slack_main(production, config, console)
56
+
57
+
58
+ if __name__ == "__main__":
59
+
60
+ app()
@@ -1,6 +1,6 @@
1
1
  from typing import Callable
2
-
3
2
  from typing import Generator
3
+
4
4
  import time
5
5
  import logging
6
6
  import os
@@ -15,6 +15,7 @@ from slack_sdk.socket_mode.listeners import SocketModeRequestListener
15
15
 
16
16
  from proscenium.core import Production
17
17
  from proscenium.core import Character
18
+ from proscenium.admin import Admin
18
19
 
19
20
  log = logging.getLogger(__name__)
20
21
 
@@ -277,3 +278,74 @@ def shutdown(
277
278
  production.curtain()
278
279
 
279
280
  console.print("Handlers stopped.")
281
+
282
+
283
+ def slack_main(
284
+ production: Production,
285
+ config: dict,
286
+ console: Console,
287
+ ) -> None:
288
+
289
+ slack_app_token, slack_bot_token = get_slack_auth()
290
+
291
+ socket_mode_client = connect(slack_app_token, slack_bot_token)
292
+
293
+ user_id = bot_user_id(socket_mode_client, console)
294
+ console.print()
295
+
296
+ channels_by_id, channel_name_to_id = channel_maps(socket_mode_client)
297
+ console.print(channel_table(channels_by_id))
298
+ console.print()
299
+
300
+ slack_admin_channel = config.get("slack", {}).get("admin_channel", None)
301
+
302
+ if slack_admin_channel is None:
303
+ raise ValueError(
304
+ "slack.admin_channel is not set. "
305
+ "Please set it to the channel name of the Proscenium admin channel."
306
+ )
307
+ slack_admin_channel_id = channel_name_to_id.get(slack_admin_channel, None)
308
+ if slack_admin_channel_id is None:
309
+ raise ValueError(
310
+ f"Admin channel {slack_admin_channel} not found in subscribed channels."
311
+ )
312
+
313
+ admin = Admin(slack_admin_channel_id)
314
+ log.info(
315
+ "Admin handler started %s %s.", slack_admin_channel, slack_admin_channel_id
316
+ )
317
+
318
+ log.info("Places, please!")
319
+ channel_id_to_character = production.places(channel_name_to_id)
320
+ channel_id_to_character[slack_admin_channel_id] = admin
321
+
322
+ console.print(places_table(channel_id_to_character, channels_by_id))
323
+ console.print()
324
+
325
+ slack_listener = make_slack_listener(
326
+ user_id,
327
+ slack_admin_channel_id,
328
+ channels_by_id,
329
+ channel_id_to_character,
330
+ console,
331
+ )
332
+
333
+ send_curtain_up(socket_mode_client, production, slack_admin_channel_id)
334
+
335
+ console.print("Starting the show. Listening for events...")
336
+ listen(
337
+ socket_mode_client,
338
+ slack_listener,
339
+ user_id,
340
+ console,
341
+ )
342
+
343
+ send_curtain_down(socket_mode_client, slack_admin_channel_id)
344
+
345
+ shutdown(
346
+ socket_mode_client,
347
+ slack_listener,
348
+ user_id,
349
+ production,
350
+ console,
351
+ )
@@ -0,0 +1,26 @@
1
+ import logging
2
+ import os
3
+
4
+ logging.getLogger(__name__).addHandler(logging.NullHandler())
5
+
6
+ log = logging.getLogger(__name__)
7
+
8
+
9
+ def get_secret(key: str, default: str = None) -> str:
10
+ try:
11
+ from google.colab import userdata
12
+
13
+ try:
14
+ value = userdata.get(key)
15
+ os.environ[key] = value
16
+ log.info(
17
+ f"In colab. Read {key} from colab userdata and set os.environ value"
18
+ )
19
+ return value
20
+ except userdata.SecretNotFoundError:
21
+ return default
22
+ except ImportError:
23
+ if key in os.environ:
24
+ return os.environ.get(key, default)
25
+ else:
26
+ return default
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "proscenium"
3
- version = "0.0.6"
3
+ version = "0.0.8"
4
4
  description = "Frame AI Agents"
5
5
  authors = ["Adam Pingel <oss@pingel.org>"]
6
6
  license = "ASFv2"
@@ -1,142 +0,0 @@
1
- #!/usr/bin/env python3
2
-
3
- import os
4
- import sys
5
- import logging
6
- import typer
7
- import importlib
8
- from rich.console import Console
9
-
10
- from proscenium.admin import Admin
11
-
12
- from proscenium.interfaces.slack import (
13
- get_slack_auth,
14
- channel_table,
15
- bot_user_id,
16
- places_table,
17
- channel_maps,
18
- make_slack_listener,
19
- connect,
20
- send_curtain_up,
21
- listen,
22
- send_curtain_down,
23
- shutdown,
24
- )
25
-
26
- from proscenium.verbs.display import header
27
-
28
- logging.basicConfig(
29
- stream=sys.stdout,
30
- format="%(asctime)s %(levelname)-8s %(name)s: %(message)s",
31
- level=logging.WARNING,
32
- )
33
-
34
- logging.basicConfig(
35
- stream=sys.stdout,
36
- format="%(asctime)s %(levelname)-8s %(name)s: %(message)s",
37
- level=logging.WARNING,
38
- )
39
-
40
- app = typer.Typer(help="Proscenium Bot")
41
-
42
- log = logging.getLogger(__name__)
43
-
44
-
45
- @app.command(help="""Start the Proscenium Bot.""")
46
- def start(
47
- verbose: bool = False,
48
- production_module_name: str = typer.Option(
49
- "demo.production",
50
- "-p",
51
- "--production",
52
- help="The name of the python module in PYTHONPATH in which the variable production of type proscenium.core.Production is defined.",
53
- ),
54
- force_rebuild: bool = False,
55
- ):
56
-
57
- console = Console()
58
- sub_console = None
59
-
60
- if verbose:
61
- log.setLevel(logging.INFO)
62
- logging.getLogger("proscenium").setLevel(logging.INFO)
63
- logging.getLogger("demo").setLevel(logging.INFO)
64
- sub_console = console
65
-
66
- console.print(header())
67
-
68
- production_module = importlib.import_module(production_module_name, package=None)
69
-
70
- slack_admin_channel_id = os.environ.get("SLACK_ADMIN_CHANNEL_ID")
71
- # Note that the checking of the existence of the admin channel id is delayed
72
- # until after the subscribed channels are shown.
73
-
74
- production = production_module.make_production(slack_admin_channel_id, sub_console)
75
-
76
- console.print("Preparing props...")
77
- production.prepare_props()
78
- console.print("Props are up-to-date.")
79
-
80
- slack_app_token, slack_bot_token = get_slack_auth()
81
-
82
- socket_mode_client = connect(slack_app_token, slack_bot_token)
83
-
84
- user_id = bot_user_id(socket_mode_client, console)
85
- console.print()
86
-
87
- channels_by_id, channel_name_to_id = channel_maps(socket_mode_client)
88
- console.print(channel_table(channels_by_id))
89
- console.print()
90
-
91
- if slack_admin_channel_id is None:
92
- raise ValueError(
93
- "SLACK_ADMIN_CHANNEL_ID environment variable not set. "
94
- "Please set it to the channel ID of the Proscenium admin channel."
95
- )
96
- if slack_admin_channel_id not in channels_by_id:
97
- raise ValueError(
98
- f"Admin channel {slack_admin_channel_id} not found in subscribed channels."
99
- )
100
-
101
- admin = Admin(slack_admin_channel_id)
102
- log.info("Admin handler started.")
103
-
104
- log.info("Places, please!")
105
- channel_id_to_character = production.places(channel_name_to_id)
106
- channel_id_to_character[slack_admin_channel_id] = admin
107
-
108
- console.print(places_table(channel_id_to_character, channels_by_id))
109
- console.print()
110
-
111
- slack_listener = make_slack_listener(
112
- user_id,
113
- slack_admin_channel_id,
114
- channels_by_id,
115
- channel_id_to_character,
116
- console,
117
- )
118
-
119
- send_curtain_up(socket_mode_client, production, slack_admin_channel_id)
120
-
121
- console.print("Starting the show. Listening for events...")
122
- listen(
123
- socket_mode_client,
124
- slack_listener,
125
- user_id,
126
- console,
127
- )
128
-
129
- send_curtain_down(socket_mode_client, slack_admin_channel_id)
130
-
131
- shutdown(
132
- socket_mode_client,
133
- slack_listener,
134
- user_id,
135
- production,
136
- console,
137
- )
138
-
139
-
140
- if __name__ == "__main__":
141
-
142
- app()
File without changes
File without changes