mirror of
https://github.com/langgenius/dify.git
synced 2026-01-08 07:14:14 +00:00
transform document
This commit is contained in:
@@ -48,7 +48,6 @@ class WebsiteCrawlStatusApi(Resource):
|
||||
parser.add_argument(
|
||||
"provider", type=str, choices=["firecrawl", "watercrawl", "jinareader"], required=True, location="args"
|
||||
)
|
||||
parser.add_argument("credential_id", type=str, required=True, nullable=True, location="args")
|
||||
args = parser.parse_args()
|
||||
|
||||
# Create typed request and validate
|
||||
|
||||
@@ -98,20 +98,16 @@ class WebsiteCrawlStatusApiRequest:
|
||||
|
||||
provider: str
|
||||
job_id: str
|
||||
credential_id: Optional[str] = None
|
||||
|
||||
@classmethod
|
||||
def from_args(cls, args: dict, job_id: str) -> "WebsiteCrawlStatusApiRequest":
|
||||
"""Create from Flask-RESTful parsed arguments."""
|
||||
provider = args.get("provider")
|
||||
credential_id = args.get("credential_id")
|
||||
|
||||
if not provider:
|
||||
raise ValueError("Provider is required")
|
||||
if not job_id:
|
||||
raise ValueError("Job ID is required")
|
||||
|
||||
return cls(provider=provider, job_id=job_id, credential_id=credential_id)
|
||||
return cls(provider=provider, job_id=job_id)
|
||||
|
||||
|
||||
class WebsiteService:
|
||||
@@ -134,7 +130,12 @@ class WebsiteService:
|
||||
provider=provider,
|
||||
plugin_id=plugin_id,
|
||||
)
|
||||
return credential.get("api_key"), credential
|
||||
if provider == "firecrawl":
|
||||
return credential.get("firecrawl_api_key"), credential
|
||||
elif provider in {"watercrawl", "jinareader"}:
|
||||
return credential.get("api_key"), credential
|
||||
else:
|
||||
raise ValueError("Invalid provider")
|
||||
|
||||
@classmethod
|
||||
def _get_decrypted_api_key(cls, tenant_id: str, config: dict) -> str:
|
||||
@@ -221,7 +222,7 @@ class WebsiteService:
|
||||
headers={"Accept": "application/json", "Authorization": f"Bearer {api_key}"},
|
||||
)
|
||||
if response.json().get("code") != 200:
|
||||
raise ValueError("Failed to crawl")
|
||||
raise ValueError(f"Failed to crawl:")
|
||||
return {"status": "active", "data": response.json().get("data")}
|
||||
else:
|
||||
response = requests.post(
|
||||
|
||||
Reference in New Issue
Block a user