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: Artifact Parsing and Rendering Bug Fix for Gemini 2.0 Flash #5633

Merged
merged 8 commits into from
Feb 5, 2025

Conversation

yaleh
Copy link
Contributor

@yaleh yaleh commented Jan 30, 2025

๐Ÿ’ป ๅ˜ๆ›ด็ฑปๅž‹ | Change Type

  • โœจ feat
  • ๐Ÿ› fix
  • โ™ป๏ธ refactor
  • ๐Ÿ’„ style
  • ๐Ÿ‘ท build
  • โšก๏ธ perf
  • ๐Ÿ“ docs
  • ๐Ÿ”จ chore

๐Ÿ”€ ๅ˜ๆ›ด่ฏดๆ˜Ž | Description of Change

This merge request includes several feature enhancements related to LobeArtifact processing, specifically focusing on code block extraction and removal. The changes include:

  • Improved artifact code block extraction in selectors.
  • Added artifact processing and selector tests.
  • Improved LobeArtifact code block processing regex.
  • Enhanced LobeArtifact code block removal tests.
  • Improved LobeArtifact processing with advanced code block removal.
  • Enhanced LobeArtifact processing and rehype plugin.

These changes collectively improve the robustness and accuracy of LobeArtifact processing, particularly in handling code blocks within the content.

๐Ÿ“ ่กฅๅ……ไฟกๆฏ | Additional Information

This merge request enhances the processing of LobeArtifact tags by improving the extraction and removal of code blocks. It can now handle cases where:

  • Code blocks are present inside LobeArtifact tags, including HTML code blocks.
  • Code blocks wrap around LobeArtifact and LobeThinking tags.
  • There are no line breaks between LobeThinking and LobeArtifact tags.

yale added 6 commits January 27, 2025 23:48
- Add test cases for artifact processing with adjacent lobeThinking tags
- Modify utils to insert empty line between lobeThinking and lobeArtifact
- Implement rehype plugin for transforming LobeArtifact tags in markdown
- Add comprehensive test cases for artifact processing with various code block scenarios
- Enhance utils to handle fenced code blocks within and around lobeArtifact tags
- Support removing code blocks for HTML and other artifact types
- Add comprehensive test cases for processWithArtifact function
- Cover scenarios with HTML and tool_code code blocks
- Test handling of code blocks with content before and after
- Verify processing of artifacts with and without surrounding code blocks
- Enhance regex in processWithArtifact to handle more complex code block scenarios
- Support better extraction of content before, within, and after code blocks
- Improve handling of artifacts with surrounding text and multiple tags
- Enhance `processWithArtifact` with debug logging and improved code block handling
- Add comprehensive test cases for artifact-related selectors in chat store
- Implement tests for message content, artifact code extraction, and tag closure detection
- Add support for removing markdown code block wrapping in artifact content
- Update `artifactCode` selector to handle HTML and other code block scenarios
- Enhance test coverage for artifact code extraction with markdown-wrapped content
Copy link

vercel bot commented Jan 30, 2025

Someone is attempting to deploy a commit to the LobeHub Team on Vercel.

A member of the Team first needs to authorize it.

@dosubot dosubot bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Jan 30, 2025
@lobehubbot
Copy link
Member

๐Ÿ‘ @yaleh

Thank you for raising your pull request and contributing to our Community
Please make sure you have followed our contributing guidelines. We will review it as soon as possible.
If you encounter any problems, please feel free to connect with us.
้žๅธธๆ„Ÿ่ฐขๆ‚จๆๅ‡บๆ‹‰ๅ–่ฏทๆฑ‚ๅนถไธบๆˆ‘ไปฌ็š„็คพๅŒบๅšๅ‡บ่ดก็Œฎ๏ผŒ่ฏท็กฎไฟๆ‚จๅทฒ็ป้ตๅพชไบ†ๆˆ‘ไปฌ็š„่ดก็ŒฎๆŒ‡ๅ—๏ผŒๆˆ‘ไปฌไผšๅฐฝๅฟซๅฎกๆŸฅๅฎƒใ€‚
ๅฆ‚ๆžœๆ‚จ้‡ๅˆฐไปปไฝ•้—ฎ้ข˜๏ผŒ่ฏท้šๆ—ถไธŽๆˆ‘ไปฌ่”็ณปใ€‚

@dosubot dosubot bot added the ๐Ÿ› Bug Something isn't working | ็ผบ้™ท label Jan 30, 2025
- Clean up unnecessary console.log statements in artifact processing utility
- Improve code readability and performance by removing debug logging
- Maintain existing logic for artifact tag and code block processing
Copy link

vercel bot commented Feb 3, 2025

The latest updates on your projects. Learn more about Vercel for Git โ†—๏ธŽ

Name Status Preview Comments Updated (UTC)
lobe-chat-preview ๐Ÿ›‘ Canceled (Inspect) Feb 3, 2025 8:46am

@arvinxx arvinxx changed the title ๐Ÿ› Artifact Parsing and Rendering Bug Fix for Gemini 2.0 Flash ๐Ÿ› fix: Artifact Parsing and Rendering Bug Fix for Gemini 2.0 Flash Feb 5, 2025
@arvinxx arvinxx merged commit 7d782b1 into lobehub:main Feb 5, 2025
4 of 5 checks passed
@lobehubbot
Copy link
Member

โค๏ธ Great PR @yaleh โค๏ธ

The growth of project is inseparable from user feedback and contribution, thanks for your contribution! If you are interesting with the lobehub developer community, please join our discord and then dm @arvinxx or @canisminor1990. They will invite you to our private developer channel. We are talking about the lobe-chat development or sharing ai newsletter around the world.
้กน็›ฎ็š„ๆˆ้•ฟ็ฆปไธๅผ€็”จๆˆทๅ้ฆˆๅ’Œ่ดก็Œฎ๏ผŒๆ„Ÿ่ฐขๆ‚จ็š„่ดก็Œฎ! ๅฆ‚ๆžœๆ‚จๅฏน LobeHub ๅผ€ๅ‘่€…็คพๅŒบๆ„Ÿๅ…ด่ถฃ๏ผŒ่ฏทๅŠ ๅ…ฅๆˆ‘ไปฌ็š„ discord๏ผŒ็„ถๅŽ็งไฟก @arvinxx ๆˆ– @canisminor1990ใ€‚ไป–ไปฌไผš้‚€่ฏทๆ‚จๅŠ ๅ…ฅๆˆ‘ไปฌ็š„็งๅฏ†ๅผ€ๅ‘่€…้ข‘้“ใ€‚ๆˆ‘ไปฌๅฐ†ไผš่ฎจ่ฎบๅ…ณไบŽ Lobe Chat ็š„ๅผ€ๅ‘๏ผŒๅˆ†ไบซๅ’Œ่ฎจ่ฎบๅ…จ็ƒ่Œƒๅ›ดๅ†…็š„ AI ๆถˆๆฏใ€‚

github-actions bot pushed a commit that referenced this pull request Feb 5, 2025
### [Version 1.51.3](v1.51.2...v1.51.3)
<sup>Released on **2025-02-05**</sup>

#### โ™ป Code Refactoring

- **misc**: Refactor Wenxin with LobeOpenAICompatibleFactory.

#### ๐Ÿ› Bug Fixes

- **misc**: Artifact Parsing and Rendering Bug Fix for Gemini 2.0 Flash.

#### ๐Ÿ’„ Styles

- **misc**: Add Cache, Metadata, FeatureFlag Viewer to DevPanel.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### Code refactoring

* **misc**: Refactor Wenxin with LobeOpenAICompatibleFactory, closes [#5729](#5729) ([a90a75e](a90a75e))

#### What's fixed

* **misc**: Artifact Parsing and Rendering Bug Fix for Gemini 2.0 Flash, closes [#5633](#5633) ([7d782b1](7d782b1))

#### Styles

* **misc**: Add Cache, Metadata, FeatureFlag Viewer to DevPanel, closes [#5764](#5764) ([db4e9c7](db4e9c7))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>
@lobehubbot
Copy link
Member

๐ŸŽ‰ This PR is included in version 1.51.3 ๐ŸŽ‰

The release is available on:

Your semantic-release bot ๐Ÿ“ฆ๐Ÿš€

github-actions bot pushed a commit to bentwnghk/lobe-chat that referenced this pull request Feb 6, 2025
### [Version&nbsp;1.93.2](v1.93.1...v1.93.2)
<sup>Released on **2025-02-06**</sup>

#### โ™ป Code Refactoring

- **misc**: Refactor Wenxin with LobeOpenAICompatibleFactory.

#### ๐Ÿ› Bug Fixes

- **misc**: Artifact Parsing and Rendering Bug Fix for Gemini 2.0 Flash.

#### ๐Ÿ’„ Styles

- **misc**: Add Cache, Metadata, FeatureFlag Viewer to DevPanel, update model list, add reasoning tag.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### Code refactoring

* **misc**: Refactor Wenxin with LobeOpenAICompatibleFactory, closes [lobehub#5729](https://github.com/bentwnghk/lobe-chat/issues/5729) ([a90a75e](a90a75e))

#### What's fixed

* **misc**: Artifact Parsing and Rendering Bug Fix for Gemini 2.0 Flash, closes [lobehub#5633](https://github.com/bentwnghk/lobe-chat/issues/5633) ([7d782b1](7d782b1))

#### Styles

* **misc**: Add Cache, Metadata, FeatureFlag Viewer to DevPanel, closes [lobehub#5764](https://github.com/bentwnghk/lobe-chat/issues/5764) ([db4e9c7](db4e9c7))
* **misc**: Update model list, add reasoning tag, closes [lobehub#5696](https://github.com/bentwnghk/lobe-chat/issues/5696) ([dedd784](dedd784))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
๐Ÿ› Bug Something isn't working | ็ผบ้™ท released size:XL This PR changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants