ragbits-chat 1.4.0.dev202601310254__py3-none-any.whl → 1.4.0.dev202602030301__py3-none-any.whl

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.
ragbits/chat/api.py CHANGED
@@ -3,6 +3,7 @@ import importlib
3
3
  import json
4
4
  import logging
5
5
  import re
6
+ import tempfile
6
7
  import time
7
8
  from collections.abc import AsyncGenerator
8
9
  from contextlib import asynccontextmanager, suppress
@@ -944,9 +945,68 @@ class RagbitsAPI:
944
945
  def run(self, host: str = "127.0.0.1", port: int = 8000) -> None:
945
946
  """
946
947
  Used for starting the API
948
+
949
+ Args:
950
+ host: Host to bind the API server to
951
+ port: Port to bind the API server to
947
952
  """
948
953
  uvicorn.run(self.app, host=host, port=port)
949
954
 
955
+ @staticmethod
956
+ def run_with_reload(
957
+ host: str,
958
+ port: int,
959
+ chat_interface: str | None = None,
960
+ cors_origins: list[str] | None = None,
961
+ ui_build_dir: str | None = None,
962
+ debug_mode: bool = False,
963
+ auth_backend: str | None = None,
964
+ theme_path: str | None = None,
965
+ ) -> None:
966
+ """
967
+ Run the API server with auto-reload enabled for development.
968
+
969
+ This method creates a temporary Python file with the API configuration
970
+ that uvicorn can import and reload when code changes are detected.
971
+
972
+ Args:
973
+ host: Host to bind the API server to
974
+ port: Port to bind the API server to
975
+ chat_interface: Path to chat interface module
976
+ cors_origins: List of allowed CORS origins
977
+ ui_build_dir: Path to custom UI build directory
978
+ debug_mode: Enable debug mode
979
+ auth_backend: Path to authentication backend module
980
+ theme_path: Path to theme configuration file
981
+ """
982
+ temp_file_path: Path | None = None
983
+ try:
984
+ with tempfile.NamedTemporaryFile(
985
+ mode="w", suffix=".py", delete=False, dir=".", prefix="_ragbits_app_"
986
+ ) as temp_file:
987
+ temp_file_path = Path(temp_file.name)
988
+ temp_file.write(
989
+ f"""# Auto-generated file for ragbits reload mode - DO NOT EDIT
990
+ from ragbits.chat.api import RagbitsAPI
991
+
992
+ api = RagbitsAPI(
993
+ chat_interface={repr(chat_interface)},
994
+ cors_origins={repr(cors_origins)},
995
+ ui_build_dir={repr(ui_build_dir)},
996
+ debug_mode={repr(debug_mode)},
997
+ auth_backend={repr(auth_backend)},
998
+ theme_path={repr(theme_path)},
999
+ )
1000
+ app = api.app
1001
+ """
1002
+ )
1003
+
1004
+ module_name = temp_file_path.stem
1005
+ uvicorn.run(f"{module_name}:app", host=host, port=port, reload=True)
1006
+ finally:
1007
+ if temp_file_path:
1008
+ temp_file_path.unlink(missing_ok=True)
1009
+
950
1010
  @staticmethod
951
1011
  def _convert_heroui_json_to_css(json_content: str) -> str:
952
1012
  """Convert HeroUI JSON theme configuration to CSS variables."""
ragbits/chat/cli.py CHANGED
@@ -37,16 +37,29 @@ def run(
37
37
  "--theme",
38
38
  help="Path to a HeroUI theme JSON file from heroui.com/themes",
39
39
  ),
40
+ reload: bool = typer.Option(False, "--reload", help="Enable auto-reload on code changes for debugging"),
40
41
  ) -> None:
41
42
  """
42
43
  Run API service with UI demo
43
44
  """
44
- api = RagbitsAPI(
45
- chat_interface=chat_interface,
46
- cors_origins=cors_origins,
47
- ui_build_dir=ui_build_dir,
48
- debug_mode=debug_mode,
49
- auth_backend=auth,
50
- theme_path=theme,
51
- )
52
- api.run(host=host, port=port)
45
+ if reload:
46
+ RagbitsAPI.run_with_reload(
47
+ host=host,
48
+ port=port,
49
+ chat_interface=chat_interface,
50
+ cors_origins=cors_origins,
51
+ ui_build_dir=ui_build_dir,
52
+ debug_mode=debug_mode,
53
+ auth_backend=auth,
54
+ theme_path=theme,
55
+ )
56
+ else:
57
+ api = RagbitsAPI(
58
+ chat_interface=chat_interface,
59
+ cors_origins=cors_origins,
60
+ ui_build_dir=ui_build_dir,
61
+ debug_mode=debug_mode,
62
+ auth_backend=auth,
63
+ theme_path=theme,
64
+ )
65
+ api.run(host=host, port=port)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ragbits-chat
3
- Version: 1.4.0.dev202601310254
3
+ Version: 1.4.0.dev202602030301
4
4
  Summary: Building blocks for rapid development of GenAI applications
5
5
  Project-URL: Homepage, https://github.com/deepsense-ai/ragbits
6
6
  Project-URL: Bug Reports, https://github.com/deepsense-ai/ragbits/issues
@@ -26,7 +26,7 @@ Requires-Dist: bcrypt>=4.2.0
26
26
  Requires-Dist: fastapi<1.0.0,>=0.115.0
27
27
  Requires-Dist: httpx<1.0.0,>=0.28.1
28
28
  Requires-Dist: python-jose[cryptography]>=3.5.0
29
- Requires-Dist: ragbits-core==1.4.0.dev202601310254
29
+ Requires-Dist: ragbits-core==1.4.0.dev202602030301
30
30
  Requires-Dist: uvicorn<1.0.0,>=0.31.0
31
31
  Provides-Extra: sql
32
32
  Requires-Dist: sqlalchemy<3.0.0,>=2.0.39; extra == 'sql'
@@ -1,7 +1,7 @@
1
1
  ragbits/chat/__init__.py,sha256=mlByYmz2jY7BE90VFya-hJ0R9MHyxbRP6XhP8n3KuQk,1978
2
2
  ragbits/chat/_utils.py,sha256=jEgSO1juCzVYKmHXtYnSfkKlxaVU0UZavmYDq4d6DIs,1197
3
- ragbits/chat/api.py,sha256=A1BezQif9ePGfbmqsWrxyjwZnIGcav7L74tFM0_Tkk8,44427
4
- ragbits/chat/cli.py,sha256=lBQx21Ne-SZpmGnFfFYbkjE7jRroSgny2D-6OoOTuTM,1665
3
+ ragbits/chat/api.py,sha256=QtgLlWYpIhXNOpunJmEtI_TLEo6crFR_NoEJ2QC_AK8,46540
4
+ ragbits/chat/cli.py,sha256=I8XJc1yx4RZMJrSl2iFP8am0UN08kEdZN-_btW8BQnE,2144
5
5
  ragbits/chat/config.py,sha256=47EJgMnumXjZ8QtE7l1fzSrGAW2uoTRiOwXaXF9eOww,753
6
6
  ragbits/chat/metrics.py,sha256=7MzmBr6r8FNNwNCVPjTCKgb1aWiGIsYuXDCj704Hq9E,6305
7
7
  ragbits/chat/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -55,6 +55,6 @@ ragbits/chat/ui-build/assets/index-W9apL6ID.js,sha256=3cjW7kZQz1GbaUAkDHUUJBRvMN
55
55
  ragbits/chat/ui-build/assets/useInitializeUserStore-Be1mCLhv.js,sha256=rsWNxkdvQyUbdnqSw0SGgI71L47HvHeOgcZJrICw3OQ,229
56
56
  ragbits/chat/ui-build/assets/useMenuTriggerState-DRPPkuuB.js,sha256=K6ZcYir4QnojvtPryl8aGUvkLEUesST8iWr4IPMmqlI,21616
57
57
  ragbits/chat/ui-build/assets/useSelectableItem-BHUz-f5B.js,sha256=UErqaZ8HFcnJHP82SMq2V7Me7uT4t1sM0GABWXBA8tw,4813
58
- ragbits_chat-1.4.0.dev202601310254.dist-info/METADATA,sha256=jySVOpLTbEjQ-561SfW-pfhyald0AzNiJs6kgGEGG3c,1968
59
- ragbits_chat-1.4.0.dev202601310254.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
60
- ragbits_chat-1.4.0.dev202601310254.dist-info/RECORD,,
58
+ ragbits_chat-1.4.0.dev202602030301.dist-info/METADATA,sha256=7Ypk4r11GK5iUbb57GSh6e3SSUCbpXd5dqrW1dPWkXI,1968
59
+ ragbits_chat-1.4.0.dev202602030301.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
60
+ ragbits_chat-1.4.0.dev202602030301.dist-info/RECORD,,