-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
AttributedString
content in ChatEntity
#10
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #10 +/- ##
==========================================
- Coverage 83.84% 83.50% -0.33%
==========================================
Files 11 11
Lines 495 503 +8
==========================================
+ Hits 415 420 +5
- Misses 80 83 +3
Continue to review full report in Codecov by Sentry.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the improvements! I only had a few minor comments that should be easily addressable before merging the PR. Thank you @philippzagar!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review @PSchmiedmayer! 🚀
I reverted back to String
-based content, after I initially drafted the content as an AttributedString
.
The reason for that is the following: An AttributedString
can be initialized with Markdown text which is then parsed to an internal representation within the AttributedString
. However, this representation doesn't enable us to actually get the Markdown text back from the AttributedString
, as all Markdown-specific syntax will be gone by then. This is a major dealbreaker for SpeziLLM
, in which we need to get the existing AttributedString
content, get the raw String
out of it, concatenate the new output piece to the raw String
, and then parse it as an AttributedString
Markdown text again.
Of course, one could store both the raw String
(containing Markdown) as well as the parsed AttributedString
. However, this is overly complex and requires to keep both of these data points in sync. Therefore, I opted for the easier route by just offering a computed property that parses the raw stored String
to an AttributedString
.
@philippzagar Nice; I like the approach. Makes the internal logic a bit cleaner 🎉 |
@PSchmiedmayer The downside is that one cannot initialize with |
In addition, this PR tackles issues with scrolling to the latest rendered text piece within a message bubble as well as multiline text alingment |
AttributedString
content inChatEntity
♻️ Current situation & Problem
At the moment, SpeziChat is not able to store and display Markdown-based content, which is typically returned from LLM providers like OpenAI.
⚙️ Release Notes
ChatEntity
can now be accessed as a computed property that is anAttributedString
, providing the ability to render Markdown-formatted text in theMessageView
.📚 Documentation
In-line DocC comments written and adjusted
✅ Testing
--
📝 Code of Conduct & Contributing Guidelines
By submitting creating this pull request, you agree to follow our Code of Conduct and Contributing Guidelines: