Kevin Hu
commited on
Commit
·
4006c52
1
Parent(s):
6cc09f7
For security. (#3642)
Browse files### What problem does this PR solve?
### Type of change
- [x] Performance Improvement
agent/component/crawler.py
CHANGED
|
@@ -17,6 +17,7 @@ from abc import ABC
|
|
| 17 |
import asyncio
|
| 18 |
from crawl4ai import AsyncWebCrawler
|
| 19 |
from agent.component.base import ComponentBase, ComponentParamBase
|
|
|
|
| 20 |
|
| 21 |
|
| 22 |
class CrawlerParam(ComponentParamBase):
|
|
@@ -39,7 +40,7 @@ class Crawler(ComponentBase, ABC):
|
|
| 39 |
def _run(self, history, **kwargs):
|
| 40 |
ans = self.get_input()
|
| 41 |
ans = " - ".join(ans["content"]) if "content" in ans else ""
|
| 42 |
-
if not ans:
|
| 43 |
return Crawler.be_output("")
|
| 44 |
try:
|
| 45 |
result = asyncio.run(self.get_web(ans))
|
|
|
|
| 17 |
import asyncio
|
| 18 |
from crawl4ai import AsyncWebCrawler
|
| 19 |
from agent.component.base import ComponentBase, ComponentParamBase
|
| 20 |
+
from api.utils.web_utils import is_valid_url
|
| 21 |
|
| 22 |
|
| 23 |
class CrawlerParam(ComponentParamBase):
|
|
|
|
| 40 |
def _run(self, history, **kwargs):
|
| 41 |
ans = self.get_input()
|
| 42 |
ans = " - ".join(ans["content"]) if "content" in ans else ""
|
| 43 |
+
if not is_valid_url(ans):
|
| 44 |
return Crawler.be_output("")
|
| 45 |
try:
|
| 46 |
result = asyncio.run(self.get_web(ans))
|