Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions chatlas/_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
from ._typing_extensions import TypedDict

if TYPE_CHECKING:
from htmltools import Tagified

from ._tools import Tool, ToolBuiltIn


Expand Down Expand Up @@ -316,7 +318,7 @@ def _format_arg(value: object) -> str:
def _repr_html_(self) -> str:
return str(self.tagify())

def tagify(self):
def tagify(self) -> Tagified:
"Returns an HTML string suitable for passing to htmltools/shiny's `Chat()` component."
try:
from htmltools import HTML, TagList, head_content, tags
Expand All @@ -331,7 +333,7 @@ def tagify(self):
return TagList(
HTML(html),
head_content(tags.style(TOOL_CSS)),
)
).tagify()


class ContentToolResult(Content):
Expand Down Expand Up @@ -523,7 +525,7 @@ def _to_json(value: Any) -> object:
def _repr_html_(self):
return str(self.tagify())

def tagify(self):
def tagify(self) -> Tagified:
"A method for rendering this object via htmltools/shiny."
try:
from htmltools import HTML, html_escape
Expand Down Expand Up @@ -694,7 +696,7 @@ def __str__(self):
def _repr_html_(self):
return str(self.tagify())

def tagify(self):
def tagify(self) -> Tagified:
try:
from htmltools import HTML
except ImportError:
Expand Down
10 changes: 9 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ dev = [
"matplotlib",
"Pillow",
"shiny",
"htmltools",
"htmltools>=0.7.0;python_version>='3.10'",
"shinychat",
"narwhals",
"pandas",
Expand Down Expand Up @@ -208,3 +208,11 @@ skip-magic-trailing-comma = false
line-ending = "auto"
docstring-code-format = true
docstring-code-line-length = "dynamic"


# TODO(htmltools-105): remove this source override before merging.
# Pins htmltools to the PR branch that adds the `Tagified` alias
# (posit-dev/py-htmltools#106). Flip back to the released htmltools
# once it ships.
[tool.uv.sources]
htmltools = { git = "https://github.com/posit-dev/py-htmltools.git", branch = "main" }
Loading