Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: support for multiple artifacts to support newer llm #1426

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

thecodacus
Copy link
Collaborator

Refactor Artifact Component to Use Unique Artifact IDs

Overview

This PR refactors the artifact handling system to use dedicated artifact IDs instead of message IDs as artifact identifiers. This change improves the architecture by allowing multiple artifacts to be associated with a single message, providing a more flexible and robust artifact management system.

Key Changes

1. Artifact Component Props

  • Changed Artifact component to primarily use artifactId instead of messageId
  • Updated component interface to include both IDs while maintaining backward compatibility

2. Artifact Identification System

  • Implemented a counter-based unique artifact ID generation system (${messageId}-${counter})
  • Modified artifact references throughout the codebase to use the new ID system
  • Updated stores and parser to properly handle the new artifact identification approach

Technical Details

Artifact Component

Key technical implementation details:

  • Modified component props to accept and prioritize artifactId
  • Updated store references to look up artifacts by their unique identifier
  • Ensured backward compatibility by maintaining messageId in the component interface

Message Parser Changes

  • Added artifact counter to the message state to generate unique IDs
  • Modified artifact open/close handlers to use the new ID system
  • Added validation for artifact IDs similar to message IDs
  • Updated element factory to include both message and artifact IDs

Testing

  • Verified artifact rendering works correctly with the new ID system
  • Ensured multiple artifacts within a single message display properly
  • Validated store operations function with the new ID references

Migration Impact

  • Breaking changes: None for external API consumers
  • Minor changes to internal implementations that directly access artifact IDs
  • Fully backward compatible with existing message-to-artifact mappings

@thecodacus thecodacus requested a review from leex279 March 2, 2025 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Ready
Development

Successfully merging this pull request may close these issues.

1 participant