Skip to main content

ArtifactToolkit

A toolkit for creating and managing artifacts like HTML, SVG, charts, and diagrams. This toolkit enables agents to generate visual content that can be previewed in the CAMEL web application, similar to Claude’s artifact system. Supported artifact types:
  • HTML documents
  • SVG graphics
  • Mermaid flowcharts and diagrams
  • Code snippets (with syntax highlighting)
  • Markdown documents
  • LaTeX math expressions

_generate_artifact_id

Generate a unique artifact ID with microsecond precision.

create_html_artifact

Create an HTML artifact that can be rendered in the web interface. Parameters:
  • content (str): The HTML content to be displayed.
  • title (str, optional): Title for the artifact. Defaults to “HTML Artifact”. (default: "HTML Artifact")
  • include_css (bool, optional): Whether to include basic CSS styling. Defaults to True. (default: True)
  • css_styles (str, optional): Additional CSS styles to include.
Returns: Dict[str, Any]: A dictionary containing the artifact data with metadata.

_wrap_html_content

Wrap content in a complete HTML document with optional styling.

_create_html_document

Create a complete HTML document with consistent structure.

_get_base_styles

Get base CSS styles used across all artifacts.

create_svg_artifact

Create an SVG artifact for vector graphics. Parameters:
  • svg_content (str): The SVG content (can be just the inner elements or complete SVG).
  • title (str, optional): Title for the artifact. Defaults to “SVG Graphic”. (default: "SVG Graphic")
  • width (int, optional): Width of the SVG. If not provided, uses SVG’s viewBox or defaults.
  • height (int, optional): Height of the SVG. If not provided, uses SVG’s viewBox or defaults.
Returns: Dict[str, Any]: A dictionary containing the SVG artifact data.

create_mermaid_flowchart

Create a Mermaid flowchart artifact. Parameters:
  • flowchart_definition (str): The Mermaid flowchart definition.
  • title (str, optional): Title for the flowchart. Defaults to “Flowchart”. (default: "Flowchart")
  • direction (str, optional): Flow direction (TD, LR, BT, RL). Defaults to “TD”. (default: "TD")
Returns: Dict[str, Any]: A dictionary containing the Mermaid flowchart data.

create_code_artifact

Create a code artifact with syntax highlighting. Parameters:
  • code (str): The source code content.
  • language (str, optional): Programming language for syntax highlighting. Defaults to “python”. (default: "python")
  • title (str, optional): Title for the code artifact. Defaults to “Code Snippet”. (default: "Code Snippet")
  • show_line_numbers (bool, optional): Whether to show line numbers. Defaults to True. (default: True)
  • theme (str, optional): Syntax highlighting theme. Defaults to “github”. (default: "github")
Returns: Dict[str, Any]: A dictionary containing the code artifact data.

create_markdown_artifact

Create a Markdown document artifact with rendering. Parameters:
  • markdown_content (str): The Markdown content.
  • title (str, optional): Title for the document. Defaults to “Document”. (default: "Document")
  • include_toc (bool, optional): Whether to include a table of contents. Defaults to False. (default: False)
  • theme (str, optional): Styling theme for the document. Defaults to “github”. (default: "github")
Returns: Dict[str, Any]: A dictionary containing the Markdown artifact data.

create_latex_math

Create a LaTeX mathematical expression artifact. Parameters:
  • latex_expression (str): The LaTeX mathematical expression.
  • title (str, optional): Title for the math artifact. Defaults to “Mathematical Expression”. (default: "Mathematical Expression")
  • display_mode (str, optional): Display mode - “block” for centered equations, “inline” for text-style. Defaults to “block”. (default: "block")
  • show_source (bool, optional): Whether to show the LaTeX source code. Defaults to False. (default: False)
Returns: Dict[str, Any]: A dictionary containing the LaTeX math artifact data.

get_artifact_info

Get formatted information about an artifact. Parameters:
  • artifact (Dict[str, Any]): The artifact dictionary.
Returns: str: Formatted information about the artifact.

get_tools

Returns: List[FunctionTool]: A list of FunctionTool objects representing the functions in the toolkit.