File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
samples/agentic-strands/app Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change 57
57
color : # 888 ;
58
58
font-style : italic;
59
59
}
60
+ pre {
61
+ font-family : Arial, sans-serif;
62
+ white-space : pre-wrap;
63
+ }
60
64
</ style >
61
65
</ head >
62
66
< body >
@@ -88,7 +92,10 @@ <h1>Library Assistant AI</h1>
88
92
if ( isUser ) {
89
93
messageDiv . textContent = text ;
90
94
} else {
91
- messageDiv . innerHTML = text ;
95
+ // Use a pre element to preserve new line formatting in agent messages
96
+ const pre = document . createElement ( 'pre' ) ;
97
+ pre . textContent = text ;
98
+ messageDiv . appendChild ( pre ) ;
92
99
}
93
100
chatContainer . appendChild ( messageDiv ) ;
94
101
chatContainer . scrollTop = chatContainer . scrollHeight ;
@@ -123,7 +130,7 @@ <h1>Library Assistant AI</h1>
123
130
// Remove loading indicator
124
131
chatContainer . removeChild ( loadingDiv ) ;
125
132
126
- const agentResponse = data . response . replace ( / \n / g , '<br>' ) ;
133
+ const agentResponse = data . response ;
127
134
// Display the agent's response
128
135
addMessage ( agentResponse , false ) ;
129
136
You can’t perform that action at this time.
0 commit comments