Skip to content

Commit b1f6f0a

Browse files
committed
chore: remove dead handle_artifacts method
1 parent 7f1703c commit b1f6f0a

1 file changed

Lines changed: 0 additions & 80 deletions

File tree

swarms/structs/agent.py

Lines changed: 0 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
)
5353
from swarms.utils.get_reasoning_efforts import get_reasoning_efforts
5454
from swarms.utils.workspace_utils import get_workspace_dir
55-
from swarms.artifacts.main_artifact import Artifact
5655
from swarms.prompts.agent_system_prompts import AGENT_SYSTEM_PROMPT_3
5756
from swarms.prompts.autonomous_agent_prompt import (
5857
get_autonomous_agent_prompt,
@@ -289,8 +288,6 @@ class Agent:
289288
run_async_concurrent: Run the agent asynchronously and concurrently
290289
run_async_concurrent: Run the agent asynchronously and concurrently
291290
construct_dynamic_prompt: Construct the dynamic prompt
292-
handle_artifacts: Handle artifacts
293-
294291
295292
Examples:
296293
>>> from swarms import Agent
@@ -4369,83 +4366,6 @@ def run_batched(
43694366
for task, imgs in zip(tasks, imgs)
43704367
]
43714368

4372-
def handle_artifacts(
4373-
self, text: str, file_output_path: str, file_extension: str
4374-
) -> None:
4375-
"""
4376-
Handle creating and saving artifacts with error handling.
4377-
Artifacts are saved in the agent-specific workspace directory if the path is relative.
4378-
4379-
Args:
4380-
text (str): The content to save as an artifact.
4381-
file_output_path (str): The path where the artifact should be saved. If relative,
4382-
will be saved in the agent-specific workspace directory.
4383-
file_extension (str): The file extension for the artifact (e.g., '.md', '.txt', '.pdf').
4384-
"""
4385-
try:
4386-
# Ensure file_extension starts with a dot
4387-
if not file_extension.startswith("."):
4388-
file_extension = "." + file_extension
4389-
4390-
# Get agent-specific workspace directory
4391-
agent_workspace = self._get_agent_workspace_dir()
4392-
4393-
# If file_output_path doesn't have an extension, treat it as a directory
4394-
# and create a default filename based on timestamp
4395-
if not os.path.splitext(file_output_path)[1]:
4396-
timestamp = time.strftime("%Y%m%d_%H%M%S")
4397-
filename = f"artifact_{timestamp}{file_extension}"
4398-
# If path is relative, use agent workspace; otherwise use as-is
4399-
if os.path.isabs(file_output_path):
4400-
full_path = os.path.join(
4401-
file_output_path, filename
4402-
)
4403-
else:
4404-
full_path = os.path.join(
4405-
agent_workspace, file_output_path, filename
4406-
)
4407-
else:
4408-
# If path is absolute, use as-is; otherwise use agent workspace
4409-
if os.path.isabs(file_output_path):
4410-
full_path = file_output_path
4411-
else:
4412-
full_path = os.path.join(
4413-
agent_workspace, file_output_path
4414-
)
4415-
4416-
# Create the directory if it doesn't exist
4417-
os.makedirs(os.path.dirname(full_path), exist_ok=True)
4418-
4419-
logger.info(f"Creating artifact for file: {full_path}")
4420-
artifact = Artifact(
4421-
file_path=full_path,
4422-
file_type=file_extension,
4423-
contents=text,
4424-
edit_count=0,
4425-
)
4426-
4427-
logger.info(
4428-
f"Saving artifact with extension: {file_extension}"
4429-
)
4430-
artifact.save_as(file_extension)
4431-
logger.success(
4432-
f"Successfully saved artifact to {full_path}"
4433-
)
4434-
4435-
except ValueError as e:
4436-
logger.error(
4437-
f"Invalid input values for artifact: {str(e)}"
4438-
)
4439-
raise
4440-
except IOError as e:
4441-
logger.error(f"Error saving artifact to file: {str(e)}")
4442-
raise
4443-
except Exception as e:
4444-
logger.error(
4445-
f"Unexpected error handling artifact: {str(e)}"
4446-
)
4447-
raise
4448-
44494369
def showcase_config(self):
44504370

44514371
# Convert all values in config_dict to concise string representations

0 commit comments

Comments
 (0)