diff --git a/helpers/tools.ts b/helpers/tools.ts index 0d758f23..87540580 100644 --- a/helpers/tools.ts +++ b/helpers/tools.ts @@ -72,7 +72,7 @@ export const supportedTools: Tool[] = [ name: TOOL_SYSTEM_PROMPT_ENV_VAR, description: "System prompt for DuckDuckGo search tool.", value: `You are a DuckDuckGo search agent. -You can use the duckduckgo search tool to get information from the web to answer user questions. +You can use the duckduckgo search tool to get information or images from the web to answer user questions. For better results, you can specify the region parameter to get results from a specific region but it's optional.`, }, ], diff --git a/templates/components/engines/python/agent/tools/artifact.py b/templates/components/engines/python/agent/tools/document_generator.py similarity index 90% rename from templates/components/engines/python/agent/tools/artifact.py rename to templates/components/engines/python/agent/tools/document_generator.py index 2a9bb638..212542ee 100644 --- a/templates/components/engines/python/agent/tools/artifact.py +++ b/templates/components/engines/python/agent/tools/document_generator.py @@ -9,7 +9,7 @@ OUTPUT_DIR = "output/tools" -class ArtifactType(Enum): +class DocumentType(Enum): PDF = "pdf" HTML = "html" @@ -98,7 +98,7 @@ class ArtifactType(Enum): """ -class ArtifactGenerator: +class DocumentGenerator: @classmethod def _generate_html_content(cls, original_content: str) -> str: """ @@ -159,36 +159,36 @@ def _generate_html(cls, html_content: str) -> str: ) @classmethod - def generate_artifact( - cls, original_content: str, artifact_type: str, file_name: str + def generate_document( + cls, original_content: str, document_type: str, file_name: str ) -> str: """ To generate artifact as PDF or HTML file. Parameters: original_content: str (markdown style) - artifact_type: str (pdf or html) specify the type of the file format based on the use case + document_type: str (pdf or html) specify the type of the file format based on the use case file_name: str (name of the artifact file) must be a valid file name, no extensions needed Returns: str (URL to the artifact file): A file URL ready to serve. """ try: - artifact_type = ArtifactType(artifact_type.lower()) + document_type = DocumentType(document_type.lower()) except ValueError: raise ValueError( - f"Invalid artifact type: {artifact_type}. Must be 'pdf' or 'html'." + f"Invalid document type: {document_type}. Must be 'pdf' or 'html'." ) # Always generate html content first html_content = cls._generate_html_content(original_content) # Based on the type of artifact, generate the corresponding file - if artifact_type == ArtifactType.PDF: + if document_type == DocumentType.PDF: content = cls._generate_pdf(html_content) file_extension = "pdf" - elif artifact_type == ArtifactType.HTML: + elif document_type == DocumentType.HTML: content = BytesIO(cls._generate_html(html_content).encode("utf-8")) file_extension = "html" else: - raise ValueError(f"Unexpected artifact type: {artifact_type}") + raise ValueError(f"Unexpected document type: {document_type}") file_name = cls._validate_file_name(file_name) file_path = os.path.join(OUTPUT_DIR, f"{file_name}.{file_extension}") @@ -226,4 +226,4 @@ def _validate_file_name(file_name: str) -> str: def get_tools(**kwargs): - return [FunctionTool.from_defaults(ArtifactGenerator.generate_artifact)] + return [FunctionTool.from_defaults(DocumentGenerator.generate_document)]