(self)
| 462 | self.messages.info(message) |
| 463 | |
| 464 | def do_web(self): |
| 465 | st.markdown("Add the text content of a web page to the chat") |
| 466 | |
| 467 | if not self.web_content_empty: |
| 468 | self.web_content_empty = st.empty() |
| 469 | |
| 470 | if self.prompt_pending(): |
| 471 | self.web_content_empty.empty() |
| 472 | self.state.web_content_num += 1 |
| 473 | |
| 474 | with self.web_content_empty: |
| 475 | self.web_content = st.text_input( |
| 476 | "URL", |
| 477 | placeholder="https://...", |
| 478 | key=f"web_content_{self.state.web_content_num}", |
| 479 | ) |
| 480 | |
| 481 | if not self.web_content: |
| 482 | return |
| 483 | |
| 484 | url = self.web_content |
| 485 | |
| 486 | if not self.state.scraper: |
| 487 | self.scraper = Scraper(print_error=self.info, playwright_available=has_playwright()) |
| 488 | |
| 489 | content = self.scraper.scrape(url) or "" |
| 490 | if content.strip(): |
| 491 | content = f"{url}\n\n" + content |
| 492 | self.prompt = content |
| 493 | self.prompt_as = "text" |
| 494 | else: |
| 495 | self.info(f"No web content found for `{url}`.") |
| 496 | self.web_content = None |
| 497 | |
| 498 | def do_undo(self, commit_hash): |
| 499 | self.last_undo_empty.empty() |
no test coverage detected