# frozen_string_literal: true
module DiscourseAi
module AiBot
module Tools
class CreateArtifact < Tool
def self.name
"create_artifact"
end
def self.js_dependency_tip
<<~TIP
If you need to include a JavaScript library, you may include assets from:
- unpkg.com
- cdnjs.com
- jsdelivr.com
- ajax.googleapis.com
To include them ensure they are the last tag in your HTML body.
Example:
TIP
end
def self.js_script_tag_tip
<<~TIP
if you need a custom script tag, you can use the following format:
If you only need a regular script tag, you can use the following format:
// your script here
TIP
end
def self.signature
{
name: "create_artifact",
description:
"Creates a web artifact with HTML, CSS, and JavaScript that can be displayed in an iframe",
parameters: [
{
name: "name",
description: "A name for the artifact (max 255 chars)",
type: "string",
required: true,
},
{
name: "html_body",
description:
"The HTML content for the BODY tag (do not include the BODY tag). #{js_dependency_tip}",
type: "string",
required: true,
},
{ name: "css", description: "Optional CSS styles for the artifact", type: "string" },
{
name: "js",
description:
"Optional
JavaScript code for the artifact, this will be the last