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 5757 color : # 888 ;
5858 font-style : italic;
5959 }
60+ pre {
61+ font-family : Arial, sans-serif;
62+ white-space : pre-wrap;
63+ }
6064 </ style >
6165</ head >
6266< body >
@@ -88,7 +92,10 @@ <h1>Library Assistant AI</h1>
8892 if ( isUser ) {
8993 messageDiv . textContent = text ;
9094 } 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 ) ;
9299 }
93100 chatContainer . appendChild ( messageDiv ) ;
94101 chatContainer . scrollTop = chatContainer . scrollHeight ;
@@ -123,7 +130,7 @@ <h1>Library Assistant AI</h1>
123130 // Remove loading indicator
124131 chatContainer . removeChild ( loadingDiv ) ;
125132
126- const agentResponse = data . response . replace ( / \n / g , '<br>' ) ;
133+ const agentResponse = data . response ;
127134 // Display the agent's response
128135 addMessage ( agentResponse , false ) ;
129136
You can’t perform that action at this time.
0 commit comments