repo stringlengths 7 90 | file_url stringlengths 81 315 | file_path stringlengths 4 228 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 14:38:15 2026-01-05 02:33:18 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/metagpt/exp_pool/scorers/simple.py | metagpt/exp_pool/scorers/simple.py | """Simple scorer."""
import json
from pydantic import Field
from metagpt.exp_pool.schema import Score
from metagpt.exp_pool.scorers.base import BaseScorer
from metagpt.llm import LLM
from metagpt.provider.base_llm import BaseLLM
from metagpt.utils.common import CodeParser
SIMPLE_SCORER_TEMPLATE = """
Role: You are ... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/metagpt/exp_pool/scorers/__init__.py | metagpt/exp_pool/scorers/__init__.py | """Scorers init."""
from metagpt.exp_pool.scorers.base import BaseScorer
from metagpt.exp_pool.scorers.simple import SimpleScorer
__all__ = ["BaseScorer", "SimpleScorer"]
| python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/metagpt/exp_pool/scorers/base.py | metagpt/exp_pool/scorers/base.py | """Base scorer."""
from abc import ABC, abstractmethod
from pydantic import BaseModel, ConfigDict
from metagpt.exp_pool.schema import Score
class BaseScorer(BaseModel, ABC):
model_config = ConfigDict(arbitrary_types_allowed=True)
@abstractmethod
async def evaluate(self, req: str, resp: str) -> Score:
... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/metagpt/exp_pool/context_builders/role_zero.py | metagpt/exp_pool/context_builders/role_zero.py | """RoleZero context builder."""
import copy
from typing import Any
from metagpt.const import EXPERIENCE_MASK
from metagpt.exp_pool.context_builders.base import BaseContextBuilder
class RoleZeroContextBuilder(BaseContextBuilder):
async def build(self, req: Any) -> list[dict]:
"""Builds the role zero cont... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/metagpt/exp_pool/context_builders/simple.py | metagpt/exp_pool/context_builders/simple.py | """Simple context builder."""
from typing import Any
from metagpt.exp_pool.context_builders.base import BaseContextBuilder
SIMPLE_CONTEXT_TEMPLATE = """
## Context
### Experiences
-----
{exps}
-----
## User Requirement
{req}
## Instruction
Consider **Experiences** to generate a better answer.
"""
class SimpleC... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/metagpt/exp_pool/context_builders/__init__.py | metagpt/exp_pool/context_builders/__init__.py | """Context builders init."""
from metagpt.exp_pool.context_builders.base import BaseContextBuilder
from metagpt.exp_pool.context_builders.simple import SimpleContextBuilder
from metagpt.exp_pool.context_builders.role_zero import RoleZeroContextBuilder
__all__ = ["BaseContextBuilder", "SimpleContextBuilder", "RoleZero... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/metagpt/exp_pool/context_builders/base.py | metagpt/exp_pool/context_builders/base.py | """Base context builder."""
from abc import ABC, abstractmethod
from typing import Any
from pydantic import BaseModel, ConfigDict
from metagpt.exp_pool.schema import Experience
EXP_TEMPLATE = """Given the request: {req}, We can get the response: {resp}, which scored: {score}."""
class BaseContextBuilder(BaseModel... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/metagpt/exp_pool/context_builders/action_node.py | metagpt/exp_pool/context_builders/action_node.py | """Action Node context builder."""
from typing import Any
from metagpt.exp_pool.context_builders.base import BaseContextBuilder
ACTION_NODE_CONTEXT_TEMPLATE = """
{req}
### Experiences
-----
{exps}
-----
## Instruction
Consider **Experiences** to generate a better answer.
"""
class ActionNodeContextBuilder(BaseC... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/metagpt/strategy/task_type.py | metagpt/strategy/task_type.py | from enum import Enum
from pydantic import BaseModel
from metagpt.prompts.task_type import (
DATA_PREPROCESS_PROMPT,
EDA_PROMPT,
FEATURE_ENGINEERING_PROMPT,
IMAGE2WEBPAGE_PROMPT,
MODEL_EVALUATE_PROMPT,
MODEL_TRAIN_PROMPT,
WEB_SCRAPING_PROMPT,
)
class TaskTypeDef(BaseModel):
name: str... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/metagpt/strategy/search_space.py | metagpt/strategy/search_space.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2024/1/30 17:15
@Author : alexanderwu
@File : search_space.py
"""
class SearchSpace:
"""SearchSpace: 用于定义一个搜索空间,搜索空间中的节点是 ActionNode 类。"""
def __init__(self):
self.search_space = {}
def add_node(self, node):
self.search_spa... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/metagpt/strategy/tot.py | metagpt/strategy/tot.py | # -*- coding: utf-8 -*-
# @Date : 12/23/2023 4:51 PM
# @Author : stellahong (stellahong@fuzhi.ai)
# @Desc :
from __future__ import annotations
import asyncio
from typing import Any, List, Optional
from pydantic import BaseModel, ConfigDict, Field
from metagpt.llm import LLM
from metagpt.logs import logger
fro... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/metagpt/strategy/tot_schema.py | metagpt/strategy/tot_schema.py | # -*- coding: utf-8 -*-
# @Date : 12/25/2023 9:14 PM
# @Author : stellahong (stellahong@fuzhi.ai)
# @Desc :
from enum import Enum
from pydantic import BaseModel, Field
from metagpt.strategy.base import BaseEvaluator, BaseParser
class MethodSelect(Enum):
SAMPLE = "sample"
GREEDY = "greedy"
class Str... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/metagpt/strategy/experience_retriever.py | metagpt/strategy/experience_retriever.py | from typing import Literal
from pydantic import BaseModel
class ExpRetriever(BaseModel):
"""interface for experience retriever"""
def retrieve(self, context: str = "") -> str:
raise NotImplementedError
class DummyExpRetriever(ExpRetriever):
"""A dummy experience retriever that returns empty st... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | true |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/metagpt/strategy/thinking_command.py | metagpt/strategy/thinking_command.py | from __future__ import annotations
from enum import Enum
from pydantic import BaseModel
from metagpt.environment.mgx.mgx_env import MGXEnv
from metagpt.memory import Memory
from metagpt.roles import Role
from metagpt.schema import Message
class CommandDef(BaseModel):
name: str
signature: str = ""
desc:... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/metagpt/strategy/solver.py | metagpt/strategy/solver.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2024/1/30 17:13
@Author : alexanderwu
@File : solver.py
"""
from abc import abstractmethod
from metagpt.actions.action_graph import ActionGraph
from metagpt.provider.base_llm import BaseLLM
from metagpt.strategy.search_space import SearchSpace
class Ba... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/metagpt/strategy/__init__.py | metagpt/strategy/__init__.py | # -*- coding: utf-8 -*-
# @Date : 12/23/2023 4:51 PM
# @Author : stellahong (stellahong@fuzhi.ai)
# @Desc :
| python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/metagpt/strategy/planner.py | metagpt/strategy/planner.py | from __future__ import annotations
import json
from typing import List
from pydantic import BaseModel, Field
from metagpt.actions.di.ask_review import AskReview, ReviewConst
from metagpt.actions.di.write_plan import (
WritePlan,
precheck_update_plan_from_rsp,
update_plan_from_rsp,
)
from metagpt.logs imp... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/metagpt/strategy/base.py | metagpt/strategy/base.py | # -*- coding: utf-8 -*-
# @Date : 12/25/2023 9:16 PM
# @Author : stellahong (stellahong@fuzhi.ai)
# @Desc :
from abc import ABC
from typing import List
from anytree import Node, RenderTree
from pydantic import BaseModel
class BaseParser(BaseModel, ABC):
def __call__(self, *args, **kwargs):
raise N... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/metagpt/learn/text_to_speech.py | metagpt/learn/text_to_speech.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2023/8/17
@Author : mashenquan
@File : text_to_speech.py
@Desc : Text-to-Speech skill, which provides text-to-speech functionality
"""
from typing import Optional
from metagpt.config2 import Config
from metagpt.const import BASE64_FORMAT
from metagpt.... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/metagpt/learn/skill_loader.py | metagpt/learn/skill_loader.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2023/8/18
@Author : mashenquan
@File : skill_loader.py
@Desc : Skill YAML Configuration Loader.
"""
from pathlib import Path
from typing import Dict, List, Optional
import yaml
from pydantic import BaseModel, Field
from metagpt.context import Context... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/metagpt/learn/text_to_embedding.py | metagpt/learn/text_to_embedding.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2023/8/18
@Author : mashenquan
@File : text_to_embedding.py
@Desc : Text-to-Embedding skill, which provides text-to-embedding functionality.
"""
from typing import Optional
from metagpt.config2 import Config
from metagpt.tools.openai_text_to_embedding... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/metagpt/learn/text_to_image.py | metagpt/learn/text_to_image.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2023/8/18
@Author : mashenquan
@File : text_to_image.py
@Desc : Text-to-Image skill, which provides text-to-image functionality.
"""
import base64
from typing import Optional
from metagpt.config2 import Config
from metagpt.const import BASE64_FORMAT
f... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/metagpt/learn/google_search.py | metagpt/learn/google_search.py | from metagpt.tools.search_engine import SearchEngine
async def google_search(query: str, max_results: int = 6, **kwargs):
"""Perform a web search and retrieve search results.
:param query: The search query.
:param max_results: The number of search results to retrieve
:return: The web search results i... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
FoundationAgents/MetaGPT | https://github.com/FoundationAgents/MetaGPT/blob/fc6e8433747be02826dec818627ed5cec0950e77/metagpt/learn/__init__.py | metagpt/learn/__init__.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2023/4/30 20:57
@Author : alexanderwu
@File : __init__.py
"""
from metagpt.learn.text_to_image import text_to_image
from metagpt.learn.text_to_speech import text_to_speech
from metagpt.learn.google_search import google_search
__all__ = ["text_to_image",... | python | MIT | fc6e8433747be02826dec818627ed5cec0950e77 | 2026-01-04T14:38:37.890126Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/setup.py | setup.py | from setuptools import setup, find_packages
import os
from pathlib import Path
import shutil
# Note: Most configuration is now in pyproject.toml
# This setup.py is kept for backwards compatibility
# Create the .crawl4ai folder in the user's home directory if it doesn't exist
# If the folder already exists, remove the... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/test_webhook_implementation.py | test_webhook_implementation.py | """
Simple test script to validate webhook implementation without running full server.
This script tests:
1. Webhook module imports and syntax
2. WebhookDeliveryService initialization
3. Payload construction logic
4. Configuration parsing
"""
import sys
import os
import json
from datetime import datetime, timezone
#... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/test_llm_webhook_feature.py | test_llm_webhook_feature.py | #!/usr/bin/env python3
"""
Test script to validate webhook implementation for /llm/job endpoint.
This tests that the /llm/job endpoint now supports webhooks
following the same pattern as /crawl/job.
"""
import sys
import os
# Add deploy/docker to path
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'deplo... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/deploy/docker/schemas.py | deploy/docker/schemas.py | from typing import List, Optional, Dict
from enum import Enum
from pydantic import BaseModel, Field, HttpUrl
from utils import FilterType
class CrawlRequest(BaseModel):
urls: List[str] = Field(min_length=1, max_length=100)
browser_config: Optional[Dict] = Field(default_factory=dict)
crawler_config: Option... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/deploy/docker/api.py | deploy/docker/api.py | import os
import json
import asyncio
from typing import List, Tuple, Dict
from functools import partial
from uuid import uuid4
from datetime import datetime, timezone
from base64 import b64encode
import logging
from typing import Optional, AsyncGenerator
from urllib.parse import unquote
from fastapi import HTTPExcepti... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/deploy/docker/monitor_routes.py | deploy/docker/monitor_routes.py | # monitor_routes.py - Monitor API endpoints
from fastapi import APIRouter, HTTPException, WebSocket, WebSocketDisconnect
from pydantic import BaseModel
from typing import Optional
from monitor import get_monitor
import logging
import asyncio
import json
logger = logging.getLogger(__name__)
router = APIRouter(prefix="/... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/deploy/docker/hook_manager.py | deploy/docker/hook_manager.py | """
Hook Manager for User-Provided Hook Functions
Handles validation, compilation, and safe execution of user-provided hook code
"""
import ast
import asyncio
import traceback
from typing import Dict, Callable, Optional, Tuple, List, Any
import logging
logger = logging.getLogger(__name__)
class UserHookManager:
... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/deploy/docker/crawler_pool.py | deploy/docker/crawler_pool.py | # crawler_pool.py - Smart browser pool with tiered management
import asyncio, json, hashlib, time
from contextlib import suppress
from typing import Dict, Optional
from crawl4ai import AsyncWebCrawler, BrowserConfig
from utils import load_config, get_container_memory_percent
import logging
logger = logging.getLogger(_... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/deploy/docker/utils.py | deploy/docker/utils.py | import dns.resolver
import logging
import yaml
import os
from datetime import datetime
from enum import Enum
from pathlib import Path
from fastapi import Request
from typing import Dict, Optional
class TaskStatus(str, Enum):
PROCESSING = "processing"
FAILED = "failed"
COMPLETED = "completed"
class FilterT... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/deploy/docker/mcp_bridge.py | deploy/docker/mcp_bridge.py | # deploy/docker/mcp_bridge.py
from __future__ import annotations
import inspect, json, re, anyio
from contextlib import suppress
from typing import Any, Callable, Dict, List, Tuple
import httpx
from fastapi import FastAPI, WebSocket, WebSocketDisconnect, HTTPException
from fastapi.responses import JSONResponse
from f... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/deploy/docker/webhook.py | deploy/docker/webhook.py | """
Webhook delivery service for Crawl4AI.
This module provides webhook notification functionality with exponential backoff retry logic.
"""
import asyncio
import httpx
import logging
from typing import Dict, Optional
from datetime import datetime, timezone
logger = logging.getLogger(__name__)
class WebhookDelivery... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/deploy/docker/test-websocket.py | deploy/docker/test-websocket.py | #!/usr/bin/env python3
"""
Quick WebSocket test - Connect to monitor WebSocket and print updates
"""
import asyncio
import websockets
import json
async def test_websocket():
uri = "ws://localhost:11235/monitor/ws"
print(f"Connecting to {uri}...")
try:
async with websockets.connect(uri) as websocke... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/deploy/docker/server.py | deploy/docker/server.py | # ───────────────────────── server.py ─────────────────────────
"""
Crawl4AI FastAPI entry‑point
• Browser pool + global page cap
• Rate‑limiting, security, metrics
• /crawl, /crawl/stream, /md, /llm endpoints
"""
# ── stdlib & 3rd‑party imports ───────────────────────────────
from crawler_pool import get_crawler, clo... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/deploy/docker/monitor.py | deploy/docker/monitor.py | # monitor.py - Real-time monitoring stats with Redis persistence
import time
import json
import asyncio
from typing import Dict, List, Optional
from datetime import datetime, timezone
from collections import deque
from redis import asyncio as aioredis
from utils import get_container_memory_percent
import psutil
import ... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/deploy/docker/job.py | deploy/docker/job.py | """
Job endpoints (enqueue + poll) for long-running LLM extraction and raw crawl.
Relies on the existing Redis task helpers in api.py
"""
from typing import Dict, Optional, Callable
from fastapi import APIRouter, BackgroundTasks, Depends, Request
from pydantic import BaseModel, HttpUrl
from api import (
handle_l... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/deploy/docker/auth.py | deploy/docker/auth.py | import os
from datetime import datetime, timedelta, timezone
from typing import Dict, Optional
from jwt import JWT, jwk_from_dict
from jwt.utils import get_int_from_datetime
from fastapi import Depends, HTTPException
from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials
from pydantic import EmailStr
fro... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/deploy/docker/tests/test_6_multi_endpoint.py | deploy/docker/tests/test_6_multi_endpoint.py | #!/usr/bin/env python3
"""
Test 6: Multi-Endpoint Testing
- Tests multiple endpoints together: /html, /screenshot, /pdf, /crawl
- Validates each endpoint works correctly
- Monitors success rates per endpoint
"""
import asyncio
import time
import docker
import httpx
from threading import Thread, Event
# Config
IMAGE = ... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/deploy/docker/tests/test_4_concurrent.py | deploy/docker/tests/test_4_concurrent.py | #!/usr/bin/env python3
"""
Test 4: Concurrent Load Testing
- Tests pool under concurrent load
- Escalates: 10 → 50 → 100 concurrent requests
- Validates latency distribution (P50, P95, P99)
- Monitors memory stability
"""
import asyncio
import time
import docker
import httpx
from threading import Thread, Event
from col... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/deploy/docker/tests/test_7_cleanup.py | deploy/docker/tests/test_7_cleanup.py | #!/usr/bin/env python3
"""
Test 7: Cleanup Verification (Janitor)
- Creates load spike then goes idle
- Verifies memory returns to near baseline
- Tests janitor cleanup of idle browsers
- Monitors memory recovery time
"""
import asyncio
import time
import docker
import httpx
from threading import Thread, Event
# Confi... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/deploy/docker/tests/demo_monitor_dashboard.py | deploy/docker/tests/demo_monitor_dashboard.py | #!/usr/bin/env python3
"""
Monitor Dashboard Demo Script
Generates varied activity to showcase all monitoring features for video recording.
"""
import httpx
import asyncio
import time
from datetime import datetime
BASE_URL = "http://localhost:11235"
async def demo_dashboard():
print("🎬 Monitor Dashboard Demo - S... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/deploy/docker/tests/test_1_basic.py | deploy/docker/tests/test_1_basic.py | #!/usr/bin/env python3
"""
Test 1: Basic Container Health + Single Endpoint
- Starts container
- Hits /health endpoint 10 times
- Reports success rate and basic latency
"""
import asyncio
import time
import docker
import httpx
# Config
IMAGE = "crawl4ai-local:latest"
CONTAINER_NAME = "crawl4ai-test"
PORT = 11235
REQUE... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/deploy/docker/tests/test_3_pool.py | deploy/docker/tests/test_3_pool.py | #!/usr/bin/env python3
"""
Test 3: Pool Validation - Permanent Browser Reuse
- Tests /html endpoint (should use permanent browser)
- Monitors container logs for pool hit markers
- Validates browser reuse rate
- Checks memory after browser creation
"""
import asyncio
import time
import docker
import httpx
from threading... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/deploy/docker/tests/test_5_pool_stress.py | deploy/docker/tests/test_5_pool_stress.py | #!/usr/bin/env python3
"""
Test 5: Pool Stress - Mixed Configs
- Tests hot/cold pool with different browser configs
- Uses different viewports to create config variants
- Validates cold → hot promotion after 3 uses
- Monitors pool tier distribution
"""
import asyncio
import time
import docker
import httpx
from threadin... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/deploy/docker/tests/test_2_memory.py | deploy/docker/tests/test_2_memory.py | #!/usr/bin/env python3
"""
Test 2: Docker Stats Monitoring
- Extends Test 1 with real-time container stats
- Monitors memory % and CPU during requests
- Reports baseline, peak, and final memory
"""
import asyncio
import time
import docker
import httpx
from threading import Thread, Event
# Config
IMAGE = "crawl4ai-loca... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/deploy/docker/tests/test_monitor_demo.py | deploy/docker/tests/test_monitor_demo.py | #!/usr/bin/env python3
"""Quick test to generate monitor dashboard activity"""
import httpx
import asyncio
async def test_dashboard():
async with httpx.AsyncClient(timeout=30.0) as client:
print("📊 Generating dashboard activity...")
# Test 1: Simple crawl
print("\n1️⃣ Running simple crawl... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/test_config_selection.py | tests/test_config_selection.py | """
Test config selection logic in dispatchers
"""
import asyncio
import sys
from pathlib import Path
from unittest.mock import AsyncMock, MagicMock
# Add parent directory to path for imports
sys.path.insert(0, str(Path(__file__).parent.parent))
from crawl4ai.async_configs import CrawlerRunConfig, MatchMode
from craw... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/docker_example.py | tests/docker_example.py | import requests
import json
import time
import sys
import base64
import os
from typing import Dict, Any
class Crawl4AiTester:
def __init__(self, base_url: str = "http://localhost:11235"):
self.base_url = base_url
def submit_and_wait(
self, request_data: Dict[str, Any], timeout: int = 300
... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/test_cli_docs.py | tests/test_cli_docs.py | import asyncio
from crawl4ai.docs_manager import DocsManager
from click.testing import CliRunner
from crawl4ai.cli import cli
def test_cli():
"""Test all CLI commands"""
runner = CliRunner()
print("\n1. Testing docs update...")
# Use sync version for testing
docs_manager = DocsManager()
loop ... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/test_multi_config.py | tests/test_multi_config.py | """
Test example for multiple crawler configs feature
"""
import asyncio
import sys
from pathlib import Path
# Add parent directory to path for imports
sys.path.insert(0, str(Path(__file__).parent.parent))
from crawl4ai import AsyncWebCrawler, CrawlerRunConfig, MatchMode, CacheMode
async def test_multi_config():
... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/test_memory_macos.py | tests/test_memory_macos.py | #!/usr/bin/env python3
"""Test script to verify macOS memory calculation accuracy."""
import psutil
import platform
import time
from crawl4ai.utils import get_true_memory_usage_percent, get_memory_stats, get_true_available_memory_gb
def test_memory_calculation():
"""Test and compare memory calculations."""
p... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/test_docker.py | tests/test_docker.py | import requests
import json
import time
import sys
import base64
import os
from typing import Dict, Any
class Crawl4AiTester:
def __init__(self, base_url: str = "http://localhost:11235"):
self.base_url = base_url
def submit_and_wait(
self, request_data: Dict[str, Any], timeout: int = 300
... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/test_docker_api_with_llm_provider.py | tests/test_docker_api_with_llm_provider.py | #!/usr/bin/env python3
"""Test script to verify Docker API with LLM provider configuration."""
import requests
import json
import time
BASE_URL = "http://localhost:11235"
def test_health():
"""Test health endpoint."""
print("1. Testing health endpoint...")
response = requests.get(f"{BASE_URL}/health")
... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/test_preserve_https_for_internal_links.py | tests/test_preserve_https_for_internal_links.py | #!/usr/bin/env python3
"""
Final test and demo for HTTPS preservation feature (Issue #1410)
This demonstrates how the preserve_https_for_internal_links flag
prevents HTTPS downgrade when servers redirect to HTTP.
"""
import sys
import os
from urllib.parse import urljoin, urlparse
def demonstrate_issue():
"""Show... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/test_config_matching_only.py | tests/test_config_matching_only.py | """
Test only the config matching logic without running crawler
"""
import sys
from pathlib import Path
# Add parent directory to path for imports
sys.path.insert(0, str(Path(__file__).parent.parent))
from crawl4ai.async_configs import CrawlerRunConfig, MatchMode
def test_all_matching_scenarios():
print("Testing... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/test_arun_many.py | tests/test_arun_many.py | """
Test example for multiple crawler configs feature
"""
import asyncio
import sys
from pathlib import Path
# Add parent directory to path for imports
sys.path.insert(0, str(Path(__file__).parent.parent))
from crawl4ai import AsyncWebCrawler, CrawlerRunConfig, CacheMode
from crawl4ai.processors.pdf import PDFContent... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/test_pyopenssl_update.py | tests/test_pyopenssl_update.py | """
Test script to verify pyOpenSSL update doesn't break crawl4ai functionality.
This test verifies:
1. pyOpenSSL and cryptography versions are correct and secure
2. Basic crawling functionality still works
3. HTTPS/SSL connections work properly
4. Stealth mode integration works (uses playwright-stealth internally)
I... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/test_pyopenssl_security_fix.py | tests/test_pyopenssl_security_fix.py | """
Lightweight test to verify pyOpenSSL security fix (Issue #1545).
This test verifies the security requirements are met:
1. pyOpenSSL >= 25.3.0 is installed
2. cryptography >= 45.0.7 is installed (above vulnerable range)
3. SSL/TLS functionality works correctly
This test can run without full crawl4ai dependencies i... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/test_main.py | tests/test_main.py | import asyncio
import aiohttp
import json
import time
import os
from typing import Dict, Any
class NBCNewsAPITest:
def __init__(self, base_url: str = "http://localhost:8000"):
self.base_url = base_url
self.session = None
async def __aenter__(self):
self.session = aiohttp.ClientSession... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/test_virtual_scroll.py | tests/test_virtual_scroll.py | """
Test virtual scroll implementation according to the design:
- Create a page with virtual scroll that replaces content
- Verify all 1000 items are captured
"""
import asyncio
import os
from crawl4ai import AsyncWebCrawler, CrawlerRunConfig, VirtualScrollConfig, CacheMode, BrowserConfig
async def test_virtual_scrol... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/test_llm_simple_url.py | tests/test_llm_simple_url.py | #!/usr/bin/env python3
"""
Test LLMTableExtraction with controlled HTML
"""
import os
import sys
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import asyncio
from crawl4ai import (
AsyncWebCrawler,
CrawlerRunConfig,
LLMConfig,
LLMTableExtraction,
DefaultTableExtraction,
CacheM... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/check_dependencies.py | tests/check_dependencies.py | #!/usr/bin/env python3
"""
Dependency checker for Crawl4AI
Analyzes imports in the codebase and shows which files use them
"""
import ast
import os
import sys
from pathlib import Path
from typing import Set, Dict, List, Tuple
from collections import defaultdict
import re
import toml
# Standard library modules to igno... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/test_web_crawler.py | tests/test_web_crawler.py | import unittest, os
from crawl4ai import LLMConfig
from crawl4ai.web_crawler import WebCrawler
from crawl4ai.chunking_strategy import (
RegexChunking,
FixedLengthWordChunking,
SlidingWindowChunking,
)
from crawl4ai import (
CosineStrategy,
LLMExtractionStrategy,
TopicExtractionStrategy,
NoEx... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/__init__.py | tests/__init__.py | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false | |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/test_llm_extraction_parallel_issue_1055.py | tests/test_llm_extraction_parallel_issue_1055.py | """
Final verification test for Issue #1055 fix
This test demonstrates that LLM extraction now runs in parallel
when using arun_many with multiple URLs.
"""
import os
import sys
import time
import asyncio
grandparent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(grandparent_dir)
... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/test_link_extractor.py | tests/test_link_extractor.py | #!/usr/bin/env python3
"""
Test script for Link Extractor functionality
"""
from crawl4ai.models import Link
from crawl4ai import AsyncWebCrawler, CrawlerRunConfig
from crawl4ai import LinkPreviewConfig
import asyncio
import sys
import os
# Add the crawl4ai directory to the path
sys.path.insert(0, os.path.join(os.pat... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/test_llmtxt.py | tests/test_llmtxt.py | from crawl4ai.llmtxt import AsyncLLMTextManager # Changed to AsyncLLMTextManager
from crawl4ai.async_logger import AsyncLogger
from pathlib import Path
import asyncio
async def main():
current_file = Path(__file__).resolve()
# base_dir = current_file.parent.parent / "local/_docs/llm.txt/test_docs"
base_d... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/test_scraping_strategy.py | tests/test_scraping_strategy.py | import nest_asyncio
nest_asyncio.apply()
import asyncio
from crawl4ai import (
AsyncWebCrawler,
CrawlerRunConfig,
LXMLWebScrapingStrategy,
CacheMode,
)
async def main():
config = CrawlerRunConfig(
cache_mode=CacheMode.BYPASS,
scraping_strategy=LXMLWebScrapingStrategy(), # Faster... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/test_normalize_url.py | tests/test_normalize_url.py | import unittest
from crawl4ai.utils import normalize_url
class TestNormalizeUrl(unittest.TestCase):
def test_basic_relative_path(self):
self.assertEqual(normalize_url("path/to/page.html", "http://example.com/base/"), "http://example.com/base/path/to/page.html")
def test_base_url_with_trailing_slash(s... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/profiler/test_keyboard_handle.py | tests/profiler/test_keyboard_handle.py | import sys
import pytest
import asyncio
from unittest.mock import patch, MagicMock
from crawl4ai.browser_profiler import BrowserProfiler
@pytest.mark.asyncio
@pytest.mark.skipif(sys.platform != "win32", reason="Windows-specific msvcrt test")
async def test_keyboard_input_handling():
# Mock sequence of keystrokes: ... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/profiler/test_create_profile.py | tests/profiler/test_create_profile.py | from crawl4ai import BrowserProfiler
import asyncio
if __name__ == "__main__":
# Example usage
profiler = BrowserProfiler()
# Create a new profile
import os
from pathlib import Path
home_dir = Path.home()
profile_path = asyncio.run(profiler.create_profile( str(home_dir / ".crawl4ai/pr... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/proxy/test_proxy_deprecation.py | tests/proxy/test_proxy_deprecation.py | import warnings
import pytest
from crawl4ai.async_configs import BrowserConfig, ProxyConfig
def test_browser_config_proxy_string_emits_deprecation_and_autoconverts():
warnings.simplefilter("always", DeprecationWarning)
proxy_str = "23.95.150.145:6114:username:password"
with warnings.catch_warnings(reco... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/proxy/test_proxy_config.py | tests/proxy/test_proxy_config.py | """
Comprehensive test suite for ProxyConfig in different forms:
1. String form (ip:port:username:password)
2. Dict form (dictionary with keys)
3. Object form (ProxyConfig instance)
4. Environment variable form (from env vars)
Tests cover all possible scenarios and edge cases using pytest.
"""
import asyncio
import o... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/docker/test_docker.py | tests/docker/test_docker.py | import requests
import time
import httpx
import asyncio
from typing import Dict, Any
from crawl4ai import (
BrowserConfig, CrawlerRunConfig, DefaultMarkdownGenerator,
PruningContentFilter, JsonCssExtractionStrategy, LLMContentFilter, CacheMode
)
from crawl4ai import LLMConfig
from crawl4ai.docker_client import ... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/docker/test_hooks_client.py | tests/docker/test_hooks_client.py | #!/usr/bin/env python3
"""
Test client for demonstrating user-provided hooks in Crawl4AI Docker API
"""
import requests
import json
from typing import Dict, Any
API_BASE_URL = "http://localhost:11234" # Adjust if needed
def test_hooks_info():
"""Get information about available hooks"""
print("=" * 70)
... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/docker/test_server_requests.py | tests/docker/test_server_requests.py | import pytest
import pytest_asyncio
import httpx
import json
import asyncio
import os
from typing import List, Dict, Any, AsyncGenerator
from dotenv import load_dotenv
load_dotenv()
# Optional: Import crawl4ai classes directly for reference/easier payload creation aid
# You don't strictly NEED these imports for the ... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | true |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/docker/test_hooks_comprehensive.py | tests/docker/test_hooks_comprehensive.py | #!/usr/bin/env python3
"""
Comprehensive test demonstrating all hook types from hooks_example.py
adapted for the Docker API with real URLs
"""
import requests
import json
import time
from typing import Dict, Any
API_BASE_URL = "http://localhost:11234"
def test_all_hooks_demo():
"""Demonstrate all 8 hook types w... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/docker/simple_api_test.py | tests/docker/simple_api_test.py | #!/usr/bin/env python3
"""
Simple API Test for Crawl4AI Docker Server v0.7.0
Uses only built-in Python modules to test all endpoints.
"""
import urllib.request
import urllib.parse
import json
import time
import sys
from typing import Dict, List, Optional
# Configuration
BASE_URL = "http://localhost:11234" # Change t... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/docker/test_server.py | tests/docker/test_server.py | import asyncio
import json
from typing import Optional
from urllib.parse import quote
async def test_endpoint(
endpoint: str,
url: str,
params: Optional[dict] = None,
expected_status: int = 200
) -> None:
"""Test an endpoint and print results"""
import aiohttp
params = params or {}
... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/docker/test_config_object.py | tests/docker/test_config_object.py | import json
from crawl4ai import (
CrawlerRunConfig,
DefaultMarkdownGenerator,
RegexChunking,
JsonCssExtractionStrategy,
BM25ContentFilter,
CacheMode
)
from crawl4ai.deep_crawling import BFSDeepCrawlStrategy
from crawl4ai.deep_crawling.filters import FastFilterChain
from crawl4ai.deep_crawling.f... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/docker/test_filter_deep_crawl.py | tests/docker/test_filter_deep_crawl.py | """
Test the complete fix for both the filter serialization and JSON serialization issues.
"""
import os
import traceback
from typing import Any
import asyncio
import httpx
from crawl4ai import BrowserConfig, CacheMode, CrawlerRunConfig
from crawl4ai.deep_crawling import (
BFSDeepCrawlStrategy,
ContentRelevan... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/docker/test_hooks_utility.py | tests/docker/test_hooks_utility.py | """
Test script demonstrating the hooks_to_string utility and Docker client integration.
"""
import asyncio
from crawl4ai import Crawl4aiDockerClient, hooks_to_string
# Define hook functions as regular Python functions
async def auth_hook(page, context, **kwargs):
"""Add authentication cookies."""
await conte... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/docker/test_llm_params.py | tests/docker/test_llm_params.py | #!/usr/bin/env python3
"""
Test script for LLM temperature and base_url parameters in Crawl4AI Docker API.
This demonstrates the new hierarchical configuration system:
1. Request-level parameters (highest priority)
2. Provider-specific environment variables
3. Global environment variables
4. System defaults (lowest pri... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/docker/test_server_token.py | tests/docker/test_server_token.py | import asyncio
import json
from typing import Optional
from urllib.parse import quote
async def get_token(session, email: str = "test@example.com") -> str:
"""Fetch a JWT token from the /token endpoint."""
url = "http://localhost:8000/token"
payload = {"email": email}
print(f"\nFetching token from {url... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/docker/test_dockerclient.py | tests/docker/test_dockerclient.py | import asyncio
from crawl4ai.docker_client import Crawl4aiDockerClient
from crawl4ai import (
BrowserConfig,
CrawlerRunConfig
)
async def main():
async with Crawl4aiDockerClient(base_url="http://localhost:8000", verbose=True) as client:
await client.authenticate("test@example.com")
... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/docker/test_rest_api_deep_crawl.py | tests/docker/test_rest_api_deep_crawl.py | # ==== File: test_rest_api_deep_crawl.py ====
import pytest
import pytest_asyncio
import httpx
import json
import asyncio
import os
from typing import List, Dict, Any, AsyncGenerator
from dotenv import load_dotenv
load_dotenv() # Load environment variables from .env file if present
# --- Test Configuration ---
BASE_... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/docker/test_serialization.py | tests/docker/test_serialization.py | import inspect
from typing import Any, Dict
from enum import Enum
from crawl4ai import LLMConfig
def to_serializable_dict(obj: Any) -> Dict:
"""
Recursively convert an object to a serializable dictionary using {type, params} structure
for complex objects.
"""
if obj is None:
return None
... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/async_assistant/test_extract_pipeline_v2.py | tests/async_assistant/test_extract_pipeline_v2.py | """
Test implementation v2: Combined classification and preparation in one LLM call.
More efficient approach that reduces token usage and LLM calls.
"""
import asyncio
import json
import os
from typing import List, Dict, Any, Optional, Union
from lxml import html as lxml_html
import re
from crawl4ai import AsyncWebCr... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/async_assistant/test_extract_pipeline.py | tests/async_assistant/test_extract_pipeline.py | """
Test implementation of AI Assistant extract pipeline using only Crawl4AI capabilities.
This follows the exact flow discussed: query enhancement, classification, HTML skimming,
parent extraction, schema generation, and extraction.
"""
import asyncio
import json
import os
from typing import List, Dict, Any, Optional... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/adaptive/test_embedding_strategy.py | tests/adaptive/test_embedding_strategy.py | """
Test and demo script for Embedding-based Adaptive Crawler
This script demonstrates the embedding-based adaptive crawling
with semantic space coverage and gap-driven expansion.
"""
import asyncio
import os
from pathlib import Path
import time
from rich.console import Console
from rich import print as rprint
import... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/adaptive/test_adaptive_crawler.py | tests/adaptive/test_adaptive_crawler.py | """
Test and demo script for Adaptive Crawler
This script demonstrates the progressive crawling functionality
with various configurations and use cases.
"""
import asyncio
import json
from pathlib import Path
import time
from typing import Dict, List
from rich.console import Console
from rich.table import Table
from ... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/adaptive/compare_performance.py | tests/adaptive/compare_performance.py | """
Compare performance before and after optimizations
"""
def read_baseline():
"""Read baseline performance metrics"""
with open('performance_baseline.txt', 'r') as f:
content = f.read()
# Extract key metrics
metrics = {}
lines = content.split('\n')
for i, line in enumerate(lines)... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/adaptive/test_confidence_debug.py | tests/adaptive/test_confidence_debug.py | """
Test script for debugging confidence calculation in adaptive crawler
Focus: Testing why confidence decreases when crawling relevant URLs
"""
import asyncio
import sys
from pathlib import Path
from typing import List, Dict
import math
# Add parent directory to path for imports
sys.path.append(str(Path(__file__).pa... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/adaptive/test_llm_embedding.py | tests/adaptive/test_llm_embedding.py | import asyncio
import os
from crawl4ai import AsyncWebCrawler, AdaptiveCrawler, AdaptiveConfig, LLMConfig
async def test_configuration(name: str, config: AdaptiveConfig, url: str, query: str):
"""Test a specific configuration"""
print(f"\n{'='*60}")
print(f"Configuration: {name}")
print(f"{'='*60}")
... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/adaptive/test_embedding_performance.py | tests/adaptive/test_embedding_performance.py | """
Performance test for Embedding Strategy optimizations
Measures time and memory usage before and after optimizations
"""
import asyncio
import time
import tracemalloc
import numpy as np
from pathlib import Path
import sys
import os
# Add parent directory to path for imports
sys.path.append(str(Path(__file__).paren... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/memory/benchmark_report.py | tests/memory/benchmark_report.py | #!/usr/bin/env python3
"""
Benchmark reporting tool for Crawl4AI stress tests.
Generates visual reports and comparisons between test runs.
"""
import os
import json
import glob
import argparse
import sys
from datetime import datetime
from pathlib import Path
from rich.console import Console
from rich.table import Tabl... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | true |
unclecode/crawl4ai | https://github.com/unclecode/crawl4ai/blob/c85f56b085a1d5b62779774d48887345e566869b/tests/memory/test_crawler_monitor.py | tests/memory/test_crawler_monitor.py | """
Test script for the CrawlerMonitor component.
This script simulates a crawler with multiple tasks to demonstrate the real-time monitoring capabilities.
"""
import time
import uuid
import random
import threading
import sys
import os
# Add the parent directory to the path to import crawl4ai
sys.path.append(os.path.... | python | Apache-2.0 | c85f56b085a1d5b62779774d48887345e566869b | 2026-01-04T14:38:51.943025Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.