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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
<!DOCTYPE html>
|
3 |
+
<html lang="en">
|
4 |
+
<head>
|
5 |
+
<meta charset="UTF-8">
|
6 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
7 |
+
<title>Report Generator</title>
|
8 |
+
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
9 |
+
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
|
10 |
+
<style>
|
11 |
+
/* Main styles */
|
12 |
+
body {
|
13 |
+
margin: 0;
|
14 |
+
padding: 0;
|
15 |
+
text-rendering: optimizeLegibility;
|
16 |
+
-webkit-font-smoothing: antialiased;
|
17 |
+
color: rgba(0,0,0,0.8);
|
18 |
+
position: relative;
|
19 |
+
min-height: 100vh;
|
20 |
+
font-family: source-serif-pro, Georgia, Cambria, "Times New Roman", Times, serif;
|
21 |
+
font-size: 20px;
|
22 |
+
line-height: 1.58;
|
23 |
+
color: rgba(0, 0, 0, 0.8);
|
24 |
+
background-color: #fff;
|
25 |
+
margin: 0;
|
26 |
+
padding: 0;
|
27 |
+
}
|
28 |
+
|
29 |
+
|
30 |
+
|
31 |
+
.container {
|
32 |
+
max-width: 800px;
|
33 |
+
margin: 0 auto;
|
34 |
+
padding: 0 20px;
|
35 |
+
}
|
36 |
+
/* Typography */
|
37 |
+
h1, h2, h3, h4, h5, h6 {
|
38 |
+
font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif;
|
39 |
+
font-weight: 700;
|
40 |
+
color: rgba(0, 0, 0, 0.84);
|
41 |
+
letter-spacing: -0.022em;
|
42 |
+
line-height: 1.2;
|
43 |
+
}
|
44 |
+
|
45 |
+
h1 {
|
46 |
+
font-size: 40px;
|
47 |
+
margin-bottom: 0.5em;
|
48 |
+
}
|
49 |
+
|
50 |
+
h2 {
|
51 |
+
font-size: 32px;
|
52 |
+
margin-top: 1.5em;
|
53 |
+
margin-bottom: 0.5em;
|
54 |
+
}
|
55 |
+
|
56 |
+
h3 {
|
57 |
+
font-size: 26px;
|
58 |
+
margin-top: 1.5em;
|
59 |
+
margin-bottom: 0.5em;
|
60 |
+
}
|
61 |
+
p {
|
62 |
+
margin-bottom: 32px;
|
63 |
+
}
|
64 |
+
/* Links */
|
65 |
+
a {
|
66 |
+
color: #1a8917;
|
67 |
+
text-decoration: none;
|
68 |
+
}
|
69 |
+
a:hover {
|
70 |
+
text-decoration: underline;
|
71 |
+
}
|
72 |
+
/* Input container */
|
73 |
+
#input-container {
|
74 |
+
margin-bottom: 40px;
|
75 |
+
background-color: #f9f9f9;
|
76 |
+
padding: 32px;
|
77 |
+
border-radius: 5px;
|
78 |
+
}
|
79 |
+
textarea {
|
80 |
+
width: 100%;
|
81 |
+
padding: 12px;
|
82 |
+
margin-bottom: 20px;
|
83 |
+
border: 1px solid rgba(0, 0, 0, 0.15);
|
84 |
+
border-radius: 4px;
|
85 |
+
font-size: 18px;
|
86 |
+
resize: vertical;
|
87 |
+
box-sizing: border-box;
|
88 |
+
font-family: inherit;
|
89 |
+
}
|
90 |
+
button {
|
91 |
+
padding: 12px 24px;
|
92 |
+
background-color: #1a8917;
|
93 |
+
color: white;
|
94 |
+
border: none;
|
95 |
+
border-radius: 4px;
|
96 |
+
cursor: pointer;
|
97 |
+
font-size: 18px;
|
98 |
+
transition: background-color 0.3s;
|
99 |
+
}
|
100 |
+
button:hover {
|
101 |
+
background-color: #0f6b0f;
|
102 |
+
}
|
103 |
+
/* Output container */
|
104 |
+
#output-container {
|
105 |
+
display: flex;
|
106 |
+
flex-direction: column;
|
107 |
+
gap: 40px;
|
108 |
+
}
|
109 |
+
#report-container, #sources-container {
|
110 |
+
background-color: #fff;
|
111 |
+
padding: 32px;
|
112 |
+
border-radius: 5px;
|
113 |
+
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
|
114 |
+
overflow-wrap: break-word;
|
115 |
+
word-wrap: break-word;
|
116 |
+
word-break: break-word;
|
117 |
+
}
|
118 |
+
/* Sources */
|
119 |
+
.source-item {
|
120 |
+
margin-bottom: 32px;
|
121 |
+
padding: 24px;
|
122 |
+
background-color: #f9f9f9;
|
123 |
+
border: 1px solid #e0e0e0;
|
124 |
+
border-radius: 5px;
|
125 |
+
position: relative;
|
126 |
+
cursor: pointer;
|
127 |
+
transition: box-shadow 0.3s;
|
128 |
+
}
|
129 |
+
.source-item:hover {
|
130 |
+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
131 |
+
}
|
132 |
+
.source-url {
|
133 |
+
color: #1a8917;
|
134 |
+
text-decoration: none;
|
135 |
+
word-break: break-all;
|
136 |
+
font-weight: bold;
|
137 |
+
display: block;
|
138 |
+
margin-bottom: 16px;
|
139 |
+
font-size: 18px;
|
140 |
+
}
|
141 |
+
.source-content {
|
142 |
+
margin-top: 16px;
|
143 |
+
position: relative;
|
144 |
+
overflow: hidden;
|
145 |
+
}
|
146 |
+
.source-snippet {
|
147 |
+
max-height: 150px;
|
148 |
+
overflow: hidden;
|
149 |
+
}
|
150 |
+
.source-full {
|
151 |
+
display: none;
|
152 |
+
}
|
153 |
+
.expand-indicator {
|
154 |
+
position: absolute;
|
155 |
+
bottom: 0;
|
156 |
+
left: 0;
|
157 |
+
right: 0;
|
158 |
+
height: 40px;
|
159 |
+
background: linear-gradient(to bottom, rgba(249,249,249,0), rgba(249,249,249,1));
|
160 |
+
display: flex;
|
161 |
+
align-items: center;
|
162 |
+
justify-content: center;
|
163 |
+
}
|
164 |
+
.expand-indicator::after {
|
165 |
+
content: '▼';
|
166 |
+
font-size: 14px;
|
167 |
+
color: #666;
|
168 |
+
}
|
169 |
+
.expanded .expand-indicator::after {
|
170 |
+
content: '▲';
|
171 |
+
}
|
172 |
+
/* Responsive adjustments */
|
173 |
+
@media (max-width: 768px) {
|
174 |
+
.container {
|
175 |
+
padding: 0 16px;
|
176 |
+
}
|
177 |
+
h1 {
|
178 |
+
font-size: 32px;
|
179 |
+
}
|
180 |
+
h2 {
|
181 |
+
font-size: 24px;
|
182 |
+
}
|
183 |
+
#input-container, #report-container, #sources-container {
|
184 |
+
padding: 24px;
|
185 |
+
}
|
186 |
+
}
|
187 |
+
</style>
|
188 |
+
</head>
|
189 |
+
<body>
|
190 |
+
<div class="container">
|
191 |
+
<div id="input-container">
|
192 |
+
<h1>Report Generator</h1>
|
193 |
+
<textarea id="description" rows="4" placeholder="Enter description">nvidia stock performance</textarea>
|
194 |
+
<button onclick="generateReport()">Generate Report</button>
|
195 |
+
</div>
|
196 |
+
<div id="output-container">
|
197 |
+
<div id="report-container"></div>
|
198 |
+
<div id="sources-container"></div>
|
199 |
+
</div>
|
200 |
+
</div>
|
201 |
+
<script>
|
202 |
+
async function generateReport() {
|
203 |
+
const description = document.getElementById('description').value;
|
204 |
+
const reportContainer = document.getElementById('report-container');
|
205 |
+
const sourcesContainer = document.getElementById('sources-container');
|
206 |
+
reportContainer.innerHTML = 'Generating report...';
|
207 |
+
sourcesContainer.innerHTML = '';
|
208 |
+
|
209 |
+
try {
|
210 |
+
const response = await fetch('https://pvanand-search-generate-prod.hf.space/generate_report', {
|
211 |
+
method: 'POST',
|
212 |
+
headers: {
|
213 |
+
'Content-Type': 'application/json',
|
214 |
+
'Accept': 'text/plain'
|
215 |
+
},
|
216 |
+
body: JSON.stringify({
|
217 |
+
description: description,
|
218 |
+
user_id: "",
|
219 |
+
user_name: "multi-agent-research",
|
220 |
+
internet: true,
|
221 |
+
output_format: "report_table",
|
222 |
+
data_format: "Structured data",
|
223 |
+
generate_charts: true,
|
224 |
+
output_as_md: true
|
225 |
+
})
|
226 |
+
});
|
227 |
+
|
228 |
+
if (!response.ok) {
|
229 |
+
throw new Error(`HTTP error! status: ${response.status}`);
|
230 |
+
}
|
231 |
+
|
232 |
+
const reader = response.body.getReader();
|
233 |
+
const decoder = new TextDecoder();
|
234 |
+
let markdown = '';
|
235 |
+
let metadata = '';
|
236 |
+
let isReadingMetadata = false;
|
237 |
+
|
238 |
+
while (true) {
|
239 |
+
const { value, done } = await reader.read();
|
240 |
+
if (done) break;
|
241 |
+
|
242 |
+
const chunk = decoder.decode(value, { stream: true });
|
243 |
+
|
244 |
+
if (chunk.includes('<report-metadata>')) {
|
245 |
+
isReadingMetadata = true;
|
246 |
+
metadata = '';
|
247 |
+
}
|
248 |
+
|
249 |
+
if (isReadingMetadata) {
|
250 |
+
metadata += chunk;
|
251 |
+
if (chunk.includes('</report-metadata>')) {
|
252 |
+
isReadingMetadata = false;
|
253 |
+
processMetadata(metadata);
|
254 |
+
}
|
255 |
+
} else {
|
256 |
+
markdown += chunk;
|
257 |
+
renderMarkdown(markdown);
|
258 |
+
}
|
259 |
+
}
|
260 |
+
} catch (error) {
|
261 |
+
reportContainer.innerHTML = `Error generating report: ${error.message}`;
|
262 |
+
}
|
263 |
+
}
|
264 |
+
|
265 |
+
function renderMarkdown(markdown) {
|
266 |
+
const reportContainer = document.getElementById('report-container');
|
267 |
+
const reportContent = markdown.match(/<report>([\s\S]*)<\/report>/);
|
268 |
+
|
269 |
+
if (reportContent) {
|
270 |
+
reportContainer.innerHTML = marked.parse(reportContent[1]);
|
271 |
+
} else {
|
272 |
+
reportContainer.innerHTML = marked.parse(markdown);
|
273 |
+
}
|
274 |
+
|
275 |
+
const scripts = reportContainer.getElementsByTagName('script');
|
276 |
+
Array.from(scripts).forEach(script => {
|
277 |
+
const newScript = document.createElement('script');
|
278 |
+
newScript.textContent = script.textContent;
|
279 |
+
script.parentNode.replaceChild(newScript, script);
|
280 |
+
});
|
281 |
+
|
282 |
+
// Make Plotly charts responsive
|
283 |
+
const plots = reportContainer.querySelectorAll('.js-plotly-plot');
|
284 |
+
plots.forEach(plot => {
|
285 |
+
Plotly.Plots.resize(plot);
|
286 |
+
});
|
287 |
+
}
|
288 |
+
|
289 |
+
function processMetadata(metadata) {
|
290 |
+
const sourcesContainer = document.getElementById('sources-container');
|
291 |
+
const metadataMatch = metadata.match(/all-text-with-urls: (.+)/);
|
292 |
+
|
293 |
+
if (metadataMatch) {
|
294 |
+
const metadataObj = JSON.parse(metadataMatch[1]);
|
295 |
+
|
296 |
+
sourcesContainer.innerHTML = '<h2>Sources</h2>';
|
297 |
+
metadataObj.forEach(([content, url]) => {
|
298 |
+
if (content.trim() !== "") {
|
299 |
+
const sourceItem = document.createElement('div');
|
300 |
+
sourceItem.className = 'source-item';
|
301 |
+
const snippet = content.length > 400 ? content.substring(0, 400) + '...' : content;
|
302 |
+
sourceItem.innerHTML = `
|
303 |
+
<a href="${url}" target="_blank" class="source-url">${url}</a>
|
304 |
+
<div class="source-content">
|
305 |
+
<div class="source-snippet">${marked.parse(snippet)}</div>
|
306 |
+
<div class="source-full">${marked.parse(content)}</div>
|
307 |
+
<div class="expand-indicator"></div>
|
308 |
+
</div>
|
309 |
+
`;
|
310 |
+
sourcesContainer.appendChild(sourceItem);
|
311 |
+
|
312 |
+
const sourceUrl = sourceItem.querySelector('.source-url');
|
313 |
+
const sourceContent = sourceItem.querySelector('.source-content');
|
314 |
+
const snippetDiv = sourceItem.querySelector('.source-snippet');
|
315 |
+
const fullDiv = sourceItem.querySelector('.source-full');
|
316 |
+
|
317 |
+
sourceContent.addEventListener('click', function(e) {
|
318 |
+
if (!sourceItem.classList.contains('expanded')) {
|
319 |
+
sourceItem.classList.add('expanded');
|
320 |
+
snippetDiv.style.display = 'none';
|
321 |
+
fullDiv.style.display = 'block';
|
322 |
+
} else if (e.clientY > sourceContent.getBoundingClientRect().bottom - 30) {
|
323 |
+
sourceItem.classList.remove('expanded');
|
324 |
+
snippetDiv.style.display = 'block';
|
325 |
+
fullDiv.style.display = 'none';
|
326 |
+
}
|
327 |
+
});
|
328 |
+
|
329 |
+
sourceUrl.addEventListener('click', function(e) {
|
330 |
+
e.stopPropagation();
|
331 |
+
});
|
332 |
+
}
|
333 |
+
});
|
334 |
+
} else {
|
335 |
+
sourcesContainer.innerHTML = '<h2>Sources</h2><p>No source information available.</p>';
|
336 |
+
}
|
337 |
+
}
|
338 |
+
|
339 |
+
// Make Plotly charts responsive on window resize
|
340 |
+
window.addEventListener('resize', function() {
|
341 |
+
const plots = document.querySelectorAll('.js-plotly-plot');
|
342 |
+
plots.forEach(plot => {
|
343 |
+
Plotly.Plots.resize(plot);
|
344 |
+
});
|
345 |
+
});
|
346 |
+
</script>
|
347 |
+
</body>
|
348 |
+
</html>
|