shinychat 0.2.3__tar.gz → 0.2.4__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 (32) hide show
  1. {shinychat-0.2.3 → shinychat-0.2.4}/PKG-INFO +1 -1
  2. {shinychat-0.2.3 → shinychat-0.2.4}/pkg-py/src/shinychat/__version.py +2 -2
  3. {shinychat-0.2.3 → shinychat-0.2.4}/pkg-py/src/shinychat/_chat.py +6 -11
  4. {shinychat-0.2.3 → shinychat-0.2.4}/pkg-py/src/shinychat/_chat_types.py +5 -16
  5. {shinychat-0.2.3 → shinychat-0.2.4}/.gitignore +0 -0
  6. {shinychat-0.2.3 → shinychat-0.2.4}/LICENSE +0 -0
  7. {shinychat-0.2.3 → shinychat-0.2.4}/pkg-py/README.md +0 -0
  8. {shinychat-0.2.3 → shinychat-0.2.4}/pkg-py/src/shinychat/__init__.py +0 -0
  9. {shinychat-0.2.3 → shinychat-0.2.4}/pkg-py/src/shinychat/_chat_bookmark.py +0 -0
  10. {shinychat-0.2.3 → shinychat-0.2.4}/pkg-py/src/shinychat/_chat_normalize.py +0 -0
  11. {shinychat-0.2.3 → shinychat-0.2.4}/pkg-py/src/shinychat/_chat_normalize_chatlas.py +0 -0
  12. {shinychat-0.2.3 → shinychat-0.2.4}/pkg-py/src/shinychat/_chat_provider_types.py +0 -0
  13. {shinychat-0.2.3 → shinychat-0.2.4}/pkg-py/src/shinychat/_chat_tokenizer.py +0 -0
  14. {shinychat-0.2.3 → shinychat-0.2.4}/pkg-py/src/shinychat/_html_deps_py_shiny.py +0 -0
  15. {shinychat-0.2.3 → shinychat-0.2.4}/pkg-py/src/shinychat/_markdown_stream.py +0 -0
  16. {shinychat-0.2.3 → shinychat-0.2.4}/pkg-py/src/shinychat/_typing_extensions.py +0 -0
  17. {shinychat-0.2.3 → shinychat-0.2.4}/pkg-py/src/shinychat/_utils.py +0 -0
  18. {shinychat-0.2.3 → shinychat-0.2.4}/pkg-py/src/shinychat/express/__init__.py +0 -0
  19. {shinychat-0.2.3 → shinychat-0.2.4}/pkg-py/src/shinychat/playwright/__init__.py +0 -0
  20. {shinychat-0.2.3 → shinychat-0.2.4}/pkg-py/src/shinychat/playwright/_chat.py +0 -0
  21. {shinychat-0.2.3 → shinychat-0.2.4}/pkg-py/src/shinychat/py.typed +0 -0
  22. {shinychat-0.2.3 → shinychat-0.2.4}/pkg-py/src/shinychat/types/__init__.py +0 -0
  23. {shinychat-0.2.3 → shinychat-0.2.4}/pkg-py/src/shinychat/www/GIT_VERSION +0 -0
  24. {shinychat-0.2.3 → shinychat-0.2.4}/pkg-py/src/shinychat/www/chat/chat.css +0 -0
  25. {shinychat-0.2.3 → shinychat-0.2.4}/pkg-py/src/shinychat/www/chat/chat.css.map +0 -0
  26. {shinychat-0.2.3 → shinychat-0.2.4}/pkg-py/src/shinychat/www/chat/chat.js +0 -0
  27. {shinychat-0.2.3 → shinychat-0.2.4}/pkg-py/src/shinychat/www/chat/chat.js.map +0 -0
  28. {shinychat-0.2.3 → shinychat-0.2.4}/pkg-py/src/shinychat/www/markdown-stream/markdown-stream.css +0 -0
  29. {shinychat-0.2.3 → shinychat-0.2.4}/pkg-py/src/shinychat/www/markdown-stream/markdown-stream.css.map +0 -0
  30. {shinychat-0.2.3 → shinychat-0.2.4}/pkg-py/src/shinychat/www/markdown-stream/markdown-stream.js +0 -0
  31. {shinychat-0.2.3 → shinychat-0.2.4}/pkg-py/src/shinychat/www/markdown-stream/markdown-stream.js.map +0 -0
  32. {shinychat-0.2.3 → shinychat-0.2.4}/pyproject.toml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: shinychat
3
- Version: 0.2.3
3
+ Version: 0.2.4
4
4
  Summary: An AI Chat interface for Shiny apps.
5
5
  Project-URL: Homepage, https://posit-dev.github.io/shinychat/
6
6
  Project-URL: Documentation, https://posit-dev.github.io/shinychat/py/
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
28
28
  commit_id: COMMIT_ID
29
29
  __commit_id__: COMMIT_ID
30
30
 
31
- __version__ = version = '0.2.3'
32
- __version_tuple__ = version_tuple = (0, 2, 3)
31
+ __version__ = version = '0.2.4'
32
+ __version_tuple__ = version_tuple = (0, 2, 4)
33
33
 
34
34
  __commit_id__ = commit_id = None
@@ -20,15 +20,7 @@ from typing import (
20
20
  )
21
21
  from weakref import WeakValueDictionary
22
22
 
23
- from htmltools import (
24
- HTML,
25
- HTMLDependency,
26
- Tag,
27
- TagAttrValue,
28
- TagChild,
29
- TagList,
30
- css,
31
- )
23
+ from htmltools import HTML, Tag, TagAttrValue, TagChild, TagList, css
32
24
  from shiny import reactive
33
25
  from shiny._deprecated import warn_deprecated
34
26
  from shiny.bookmark import BookmarkState, RestoreState
@@ -1001,9 +993,12 @@ class Chat:
1001
993
  if icon is not None:
1002
994
  msg["icon"] = str(icon)
1003
995
 
996
+ # Register deps with the session and get the dictionary format
997
+ # for client-side rendering
1004
998
  deps = message.html_deps
1005
999
  if deps:
1006
- msg["html_deps"] = deps
1000
+ processed = self._session._process_ui(TagList(*deps))
1001
+ msg["html_deps"] = processed["deps"]
1007
1002
 
1008
1003
  # print(msg)
1009
1004
 
@@ -1766,7 +1761,7 @@ def chat_ui(
1766
1761
  message_tags.append(
1767
1762
  Tag(
1768
1763
  "shiny-chat-message",
1769
- *[HTMLDependency(**d) for d in msg.html_deps],
1764
+ *msg.html_deps,
1770
1765
  content=msg.content,
1771
1766
  icon=icon_attr,
1772
1767
  data_role=msg.role,
@@ -3,8 +3,7 @@ from __future__ import annotations
3
3
  from dataclasses import dataclass
4
4
  from typing import Literal, TypedDict
5
5
 
6
- from htmltools import HTML, Tag, TagChild, Tagifiable, TagList
7
- from shiny.session import get_current_session
6
+ from htmltools import HTML, HTMLDependency, TagChild, TagList
8
7
 
9
8
  from ._typing_extensions import NotRequired
10
9
 
@@ -26,28 +25,18 @@ class ChatMessage:
26
25
  ):
27
26
  self.role: Role = role
28
27
 
29
- is_html = isinstance(content, (Tag, TagList, HTML, Tagifiable))
30
-
31
28
  # content _can_ be a TagChild, but it's most likely just a string (of
32
29
  # markdown), so only process it if it's not a string.
33
30
  deps = []
34
31
  if not isinstance(content, str):
35
- session = get_current_session()
36
- if session and not session.is_stub_session():
37
- res = session._process_ui(content)
38
- deps = res["deps"]
39
- else:
40
- res = TagList(content).render()
41
- deps = [d.as_dict() for d in res["dependencies"]]
42
- content = res["html"]
43
-
44
- if is_html:
32
+ ui = TagList(content).render()
33
+ content, deps = ui["html"], ui["dependencies"]
45
34
  # Code blocks with `{=html}` infostrings are rendered as-is by a
46
35
  # custom rendering method in markdown-stream.ts
47
36
  content = f"\n\n````````{{=html}}\n{content}\n````````\n\n"
48
37
 
49
38
  self.content = content
50
- self.html_deps = deps
39
+ self.html_deps: list[HTMLDependency] = deps
51
40
 
52
41
 
53
42
  # A message once transformed have been applied
@@ -58,7 +47,7 @@ class TransformedMessage:
58
47
  role: Role
59
48
  transform_key: Literal["content_client", "content_server"]
60
49
  pre_transform_key: Literal["content_client", "content_server"]
61
- html_deps: list[dict[str, str]] | None = None
50
+ html_deps: list[HTMLDependency] | None = None
62
51
 
63
52
  @classmethod
64
53
  def from_chat_message(cls, message: ChatMessage) -> "TransformedMessage":
File without changes
File without changes
File without changes
File without changes