Disable markdown as it causes crash for some responses

pull/5846/head
hunteraraujo 2023-10-20 08:07:27 -07:00
parent 2187f66149
commit 82434a248c
2 changed files with 6 additions and 6 deletions

View File

@ -28,14 +28,13 @@ class _AgentMessageTileState extends State<AgentMessageTile> {
int artifactsCount = widget.chat.artifacts.length;
bool containsMarkdown(String text) {
// Regular expression to detect Markdown patterns including code blocks.
// Regular expression to detect Markdown patterns like headers, bold, links, etc.
final RegExp markdownPattern = RegExp(
r'(?:\*\*|__).*?(?:\*\*|__)|' + // Bold
r'(?:\*|_).*?(?:\*|_)|' + // Italic
r'\[.*?\]\(.*?\)|' + // Links
r'!\[.*?\]\(.*?\)|' + // Images
r'#{1,6}.*|' + // Headers
r'`.*?`', // Inline Code Blocks
r'#{1,6}.*', // Headers
multiLine: true,
caseSensitive: false,
);
@ -81,9 +80,10 @@ class _AgentMessageTileState extends State<AgentMessageTile> {
Expanded(
child: Container(
padding: const EdgeInsets.fromLTRB(0, 10, 20, 10),
child: hasMarkdown
child: false
? Markdown(data: widget.chat.message)
: Text(widget.chat.message, maxLines: null),
: SelectableText(widget.chat.message,
maxLines: null),
),
),
ElevatedButton(

View File

@ -54,7 +54,7 @@ class UserMessageTile extends StatelessWidget {
// Padding for the text content
padding: const EdgeInsets.fromLTRB(0, 10, 20, 10),
// Displaying the user message with no max line limit
child: Text(
child: SelectableText(
message,
maxLines: null,
),