repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
ChatDev | utils/env_loader.py | .py | """Environment loading utilities for root-level vars interpolation."""
import os
from pathlib import Path
from typing import Dict
_DOTENV_LOADED = False
def load_dotenv_file(dotenv_path: Path | None = None) -> None:
"""Populate ``os.environ`` with key/value pairs from a .env file once per process."""
globa... | 37 | 1,075 |
ChatDev | utils/log_manager.py | .py | """Log manager compatibility shim.
LogManager now wraps WorkflowLogger for backward compatibility.
All timing helpers live inside WorkflowLogger; prefer using it directly.
"""
import time
from contextlib import contextmanager
from typing import Any, Dict, List
from entity.enums import CallStage, LogLevel
from utils.... | 216 | 8,985 |
ChatDev | utils/human_prompt.py | .py | """Human-in-the-loop prompt service with pluggable channels."""
import threading
from dataclasses import dataclass, field
from typing import Any, Callable, Dict, List, Optional, Protocol
from entity.messages import MessageBlock, MessageBlockType, MessageContent
from utils.log_manager import LogManager
@dataclass
cl... | 165 | 5,208 |
ChatDev | utils/function_manager.py | .py | """Unified function management."""
import importlib.util
import inspect
import os
from pathlib import Path
from typing import Any, Callable, Dict, Optional
_MODULE_PREFIX = "_dynamic_functions"
_FUNCTION_CALLING_ENV = "MAC_FUNCTIONS_DIR"
_EDGE_FUNCTION_ENV = "MAC_EDGE_FUNCTIONS_DIR"
_EDGE_PROCESSOR_FUNCTION_ENV = "MAC... | 135 | 5,372 |
ChatDev | utils/error_handler.py | .py | """Error handling utilities for the DevAll workflow system."""
from fastapi import Request
from fastapi.responses import JSONResponse
from fastapi.encoders import jsonable_encoder
import traceback
from utils.structured_logger import get_server_logger
from utils.exceptions import MACException, ValidationError, Securit... | 147 | 5,376 |
ChatDev | utils/io_utils.py | .py | from typing import Any, Dict
import yaml
def read_yaml(path) -> Dict[str, Any]:
with open(path, mode="r", encoding="utf-8") as f:
return yaml.load(f, Loader=yaml.FullLoader) | 6 | 186 |
ChatDev | utils/function_catalog.py | .py | """Utility helpers for introspecting function-calling tools."""
import inspect
from collections import abc
from dataclasses import dataclass
from enum import Enum
from pathlib import Path
from typing import Annotated, Any, Dict, List, Literal, Mapping, Sequence, Tuple, Union, get_args, get_origin
from utils.function_... | 354 | 11,757 |
ChatDev | utils/workspace_scanner.py | .py | """Utilities for scanning nested code_workspace directories."""
from dataclasses import dataclass
from pathlib import Path
from typing import Iterator, List, Optional
@dataclass
class WorkspaceEntry:
"""Metadata about a workspace file or directory."""
path: str # relative path from workspace root
type:... | 72 | 2,150 |
ChatDev | utils/task_input.py | .py | """Helpers for building initial task inputs with optional attachments."""
import mimetypes
from pathlib import Path
from typing import List, Sequence, Union
from entity.messages import Message, MessageBlock, MessageBlockType, MessageRole
from utils.attachments import AttachmentStore
class TaskInputBuilder:
"""B... | 62 | 2,106 |
ChatDev | utils/structured_logger.py | .py | """Structured logging utilities for the DevAll workflow system."""
import json
import logging
import sys
import traceback
import datetime
from enum import Enum
from pathlib import Path
import os
from entity.enums import LogLevel
from utils.exceptions import MACException
class LogType(str, Enum):
"""Types of str... | 187 | 7,761 |
ChatDev | utils/attachments.py | .py | """Attachment storage and serialization helpers."""
import base64
import hashlib
import json
import mimetypes
import shutil
import uuid
from dataclasses import dataclass, field
from pathlib import Path
from typing import Any, Dict, Optional
from entity.messages import AttachmentRef, MessageBlock, MessageBlockType
DE... | 350 | 12,183 |
ChatDev | utils/schema_exporter.py | .py | """Schema exporter for dynamic configuration metadata."""
import hashlib
import json
from dataclasses import dataclass
from typing import Any, Dict, Iterable, List, Mapping, Sequence, Type
from entity.configs import BaseConfig
from entity.configs.graph import DesignConfig
SCHEMA_VERSION = "0.1.0"
class SchemaResol... | 140 | 4,783 |
ChatDev | runtime/__init__.py | .py | from runtime.sdk import WorkflowMetaInfo, WorkflowRunResult, run_workflow
__all__ = ["WorkflowMetaInfo", "WorkflowRunResult", "run_workflow"]
| 4 | 143 |
ChatDev | runtime/sdk.py | .py | """SDK helpers for executing workflows from Python code."""
from dataclasses import dataclass
from datetime import datetime
from pathlib import Path
from typing import Any, Dict, Optional, Sequence, Union
from check.check import load_config
from entity.enums import LogLevel
from entity.graph_config import GraphConfig... | 134 | 4,528 |
ChatDev | runtime/bootstrap/schema.py | .py | """Ensure schema registry is populated with runtime-provided registrations."""
from importlib import import_module
from typing import Iterable
_BOOTSTRAPPED = False
def _modules_to_import() -> Iterable[str]:
return (
"runtime.node.builtin_nodes",
"runtime.node.agent.memory.builtin_stores",
... | 29 | 772 |
ChatDev | runtime/node/__init__.py | .py | """Node package."""
__all__: list[str] = []
| 4 | 45 |
ChatDev | runtime/node/registry.py | .py | """Registry helpers for pluggable workflow node types."""
from dataclasses import dataclass, field
from typing import Any, Callable, Dict, Type
from schema_registry import register_node_schema
from utils.registry import Registry, RegistryEntry, RegistryError
node_registry = Registry("node_type")
_BUILTINS_LOADED = ... | 82 | 2,500 |
ChatDev | runtime/node/builtin_nodes.py | .py | """Register built-in workflow node types."""
from entity.configs.node.agent import AgentConfig
from entity.configs.node.human import HumanConfig
from entity.configs.node.subgraph import (
SubgraphConfig,
SubgraphFileConfig,
SubgraphInlineConfig,
register_subgraph_source,
)
from entity.configs.node.pass... | 114 | 3,904 |
ChatDev | runtime/node/splitter.py | .py | """Split strategies for dynamic node execution.
Provides different methods to split input messages into execution units.
"""
import json
import re
from abc import ABC, abstractmethod
from typing import List, Any, Optional
from entity.configs.dynamic_base import SplitConfig, RegexSplitConfig, JsonPathSplitConfig
from... | 289 | 9,578 |
ChatDev | runtime/node/executor/loop_counter_executor.py | .py | """Loop counter guard node executor."""
from typing import List, Dict, Any
from entity.configs import Node
from entity.configs.node.loop_counter import LoopCounterConfig
from entity.messages import Message, MessageRole
from runtime.node.executor.base import NodeExecutor
class LoopCounterNodeExecutor(NodeExecutor):
... | 56 | 1,824 |
ChatDev | runtime/node/executor/__init__.py | .py | """Node executor module.
Implements different execution strategies for each node type.
"""
from runtime.node.executor.base import NodeExecutor, ExecutionContext
from runtime.node.executor.agent_executor import AgentNodeExecutor
from runtime.node.executor.human_executor import HumanNodeExecutor
from runtime.node.execu... | 22 | 706 |
ChatDev | runtime/node/executor/human_executor.py | .py | """Executor for Human nodes.
Runs the human-in-the-loop interaction nodes.
"""
from typing import List
from entity.configs import Node
from entity.configs.node.human import HumanConfig
from entity.messages import Message, MessageRole
from runtime.node.executor.base import NodeExecutor
class HumanNodeExecutor(NodeE... | 57 | 1,782 |
ChatDev | runtime/node/executor/agent_executor.py | .py | """Agent node executor.
Responsible for running agent nodes, including
- memory retrieval
- thinking workflows
- agent invocation
- tool calling
"""
import asyncio
import base64
import json
import traceback
from typing import Any, Callable, Dict, List, Optional, Sequence
from entity.configs import Node
from entity.c... | 1,337 | 52,823 |
ChatDev | runtime/node/executor/loop_timer_executor.py | .py | """Loop timer guard node executor."""
import time
from typing import List, Dict, Any
from entity.configs import Node
from entity.configs.node.loop_timer import LoopTimerConfig
from entity.messages import Message, MessageRole
from runtime.node.executor.base import NodeExecutor
class LoopTimerNodeExecutor(NodeExecuto... | 149 | 5,446 |
ChatDev | runtime/node/executor/factory.py | .py | """Factory helpers for node executors.
Create and manage executors for different node types.
"""
from typing import Dict
from runtime.node.executor.base import NodeExecutor, ExecutionContext
from runtime.node.registry import iter_node_registrations
class NodeExecutorFactory:
"""Factory class that instantiates ... | 58 | 1,950 |
ChatDev | runtime/node/executor/python_executor.py | .py | """Executor for Python code runner nodes."""
import os
import re
import subprocess
import textwrap
from dataclasses import dataclass
from pathlib import Path
from typing import List
from entity.configs import Node
from entity.configs.node.python_runner import PythonRunnerConfig
from entity.messages import Message, Me... | 203 | 6,930 |
ChatDev | runtime/node/executor/base.py | .py | """Abstract base classes for node executors.
Defines the interfaces that every node executor must implement.
"""
from abc import ABC, abstractmethod
from dataclasses import dataclass, field
from typing import Any, Dict, Optional, List
from entity.configs import Node
from entity.messages import Message, MessageConten... | 147 | 5,341 |
ChatDev | runtime/node/executor/passthrough_executor.py | .py | """Passthrough node executor."""
from typing import List
from entity.configs import Node
from entity.configs.node.passthrough import PassthroughConfig
from entity.messages import Message, MessageRole
from runtime.node.executor.base import NodeExecutor
class PassthroughNodeExecutor(NodeExecutor):
"""Forward inpu... | 37 | 1,418 |
ChatDev | runtime/node/executor/subgraph_executor.py | .py | """Executor for subgraph nodes.
Runs nested graph nodes inside the parent workflow.
"""
from typing import List
import copy
from entity.configs import Node
from entity.configs.node.subgraph import SubgraphConfig
from runtime.node.executor.base import NodeExecutor
from entity.messages import Message, MessageRole
cl... | 104 | 3,475 |
ChatDev | runtime/node/executor/literal_executor.py | .py | """Literal node executor."""
from typing import List
from entity.configs import Node
from entity.configs.node.literal import LiteralNodeConfig
from entity.messages import Message
from runtime.node.executor.base import NodeExecutor
class LiteralNodeExecutor(NodeExecutor):
"""Emit the configured literal message w... | 30 | 898 |
ChatDev | runtime/node/agent/thinking/builtin_thinking.py | .py | """Register built-in thinking modes."""
from entity.configs.node.thinking import ReflectionThinkingConfig, ThinkingConfig
from runtime.node.agent.thinking.thinking_manager import ThinkingManagerBase
from runtime.node.agent.thinking.self_reflection import SelfReflectionThinkingManager
from runtime.node.agent.thinking.r... | 27 | 1,014 |
ChatDev | runtime/node/agent/thinking/__init__.py | .py | from .thinking_manager import ThinkingManagerBase, ThinkingPayload
from .builtin_thinking import ThinkingManagerFactory
__all__ = [
"ThinkingManagerBase",
"ThinkingPayload",
"ThinkingManagerFactory",
]
| 9 | 215 |
ChatDev | runtime/node/agent/thinking/registry.py | .py | """Registry for thinking managers."""
from dataclasses import dataclass
from importlib import import_module
from typing import Any, Dict, Type
from schema_registry import register_thinking_schema
from utils.registry import Registry, RegistryEntry, RegistryError
from runtime.node.agent.thinking.thinking_manager import... | 64 | 1,991 |
ChatDev | runtime/node/agent/thinking/thinking_manager.py | .py | from abc import abstractmethod, ABC
from dataclasses import dataclass, field
from typing import Any, Callable, Dict, List
from entity.configs import ThinkingConfig
from entity.messages import Message, MessageRole, MessageBlock
AgentInvoker = Callable[[List[Message]], Message]
@dataclass
class ThinkingPayload:
"... | 107 | 3,542 |
ChatDev | runtime/node/agent/thinking/self_reflection.py | .py | from entity.configs import ReflectionThinkingConfig
from entity.messages import Message, MessageRole
from runtime.node.agent.thinking.thinking_manager import (
ThinkingManagerBase,
AgentInvoker,
ThinkingPayload,
)
class SelfReflectionThinkingManager(ThinkingManagerBase):
"""
A simple implementatio... | 54 | 1,968 |
ChatDev | runtime/node/agent/tool/tool_manager.py | .py | """Tool management for function calling and MCP."""
import asyncio
import base64
import binascii
from dataclasses import dataclass
import inspect
import logging
import mimetypes
import os
import threading
from pathlib import Path
from typing import Any, Dict, List, Mapping, Sequence
from fastmcp import Client
from fa... | 559 | 21,122 |
ChatDev | runtime/node/agent/tool/__init__.py | .py | from .tool_manager import ToolManager
__all__ = [
"ToolManager"
]
| 6 | 71 |
ChatDev | runtime/node/agent/skills/manager.py | .py | """Agent Skills discovery and loading helpers."""
from dataclasses import dataclass
from html import escape
from pathlib import Path
from typing import Callable, Dict, Iterable, List, Mapping, Sequence
import yaml
from entity.tool_spec import ToolSpec
REPO_ROOT = Path(__file__).resolve().parents[4]
DEFAULT_SKILLS_... | 310 | 11,987 |
ChatDev | runtime/node/agent/skills/__init__.py | .py | from .manager import AgentSkillManager, SkillMetadata, SkillValidationError, parse_skill_file
__all__ = [
"AgentSkillManager",
"SkillMetadata",
"SkillValidationError",
"parse_skill_file",
]
| 9 | 207 |
ChatDev | runtime/node/agent/memory/simple_memory.py | .py | import hashlib
import json
import logging
import os
import re
import time
from typing import List
from entity.configs import MemoryStoreConfig
from entity.configs.node.memory import SimpleMemoryConfig
from runtime.node.agent.memory.memory_base import (
MemoryBase,
MemoryContentSnapshot,
MemoryItem,
Mem... | 295 | 11,467 |
ChatDev | runtime/node/agent/memory/mem0_memory.py | .py | """Mem0 managed memory store implementation."""
import logging
import re
import time
import uuid
from typing import Any, Dict, List
from entity.configs import MemoryStoreConfig
from entity.configs.node.memory import Mem0MemoryConfig
from runtime.node.agent.memory.memory_base import (
MemoryBase,
MemoryContent... | 220 | 7,379 |
ChatDev | runtime/node/agent/memory/__init__.py | .py | from .memory_base import MemoryBase, MemoryManager
from .builtin_stores import MemoryFactory
__all__ = [
"MemoryBase",
"MemoryManager",
"MemoryFactory",
]
| 9 | 168 |
ChatDev | runtime/node/agent/memory/registry.py | .py | """Registry for memory store implementations."""
from dataclasses import dataclass
from importlib import import_module
from typing import Any, Callable, Dict, Type
from schema_registry import register_memory_store_schema
from utils.registry import Registry, RegistryEntry, RegistryError
from entity.configs import Memo... | 65 | 2,122 |
ChatDev | runtime/node/agent/memory/memory_base.py | .py | """Base memory abstractions with multimodal snapshots."""
from dataclasses import dataclass, field
from typing import Any, Dict, List, Optional
import time
from entity.configs import MemoryAttachmentConfig, MemoryStoreConfig
from entity.configs.node.memory import FileMemoryConfig, SimpleMemoryConfig
from entity.enums... | 305 | 10,948 |
ChatDev | runtime/node/agent/memory/builtin_stores.py | .py | """Register built-in memory stores."""
from entity.configs.node.memory import (
BlackboardMemoryConfig,
FileMemoryConfig,
Mem0MemoryConfig,
SimpleMemoryConfig,
MemoryStoreConfig,
)
from runtime.node.agent.memory.blackboard_memory import BlackboardMemory
from runtime.node.agent.memory.file_memory im... | 56 | 1,683 |
ChatDev | runtime/node/agent/memory/blackboard_memory.py | .py | """Lightweight append-only Blackboard memory implementation."""
import json
import os
import time
import uuid
from typing import List
from entity.configs import MemoryStoreConfig
from entity.configs.node.memory import BlackboardMemoryConfig
from runtime.node.agent.memory.memory_base import (
MemoryBase,
Memor... | 100 | 3,277 |
ChatDev | runtime/node/agent/memory/embedding.py | .py | from abc import ABC, abstractmethod
import re
import logging
from typing import List, Optional
import openai
from tenacity import (
retry,
stop_after_attempt,
wait_random_exponential,
)
from entity.configs import EmbeddingConfig
logger = logging.getLogger(__name__)
class EmbeddingBase(ABC):
def __i... | 195 | 7,247 |
ChatDev | runtime/node/agent/memory/file_memory.py | .py | """
FileMemory: Memory system for vectorizing and retrieving file contents
"""
import json
import os
import hashlib
import logging
from pathlib import Path
from typing import List, Dict, Any
import time
import faiss
import numpy as np
from runtime.node.agent.memory.memory_base import (
MemoryBase,
MemoryConte... | 486 | 16,272 |
ChatDev | runtime/node/agent/providers/gemini_provider.py | .py | """Gemini provider implementation."""
import base64
import binascii
import json
import os
import uuid
from typing import Any, Dict, List, Optional, Sequence, Tuple
from google import genai
from google.genai import types as genai_types
from google.genai.types import GenerateContentResponse
from entity.messages import... | 834 | 32,374 |
ChatDev | runtime/node/agent/providers/__init__.py | .py | from .base import ModelProvider, ProviderRegistry
from .response import ModelResponse
__all__ = [
"ModelProvider",
"ProviderRegistry",
"ModelResponse",
] | 8 | 166 |
ChatDev | runtime/node/agent/providers/builtin_providers.py | .py | """Register built-in agent providers."""
from runtime.node.agent.providers.base import ProviderRegistry
from runtime.node.agent.providers.openai_provider import OpenAIProvider
ProviderRegistry.register(
"openai",
OpenAIProvider,
label="OpenAI",
summary="OpenAI models via the official OpenAI SDK (resp... | 28 | 745 |
ChatDev | runtime/node/agent/providers/openai_provider.py | .py | """OpenAI provider implementation."""
import base64
import hashlib
import re
import binascii
import os
from typing import Any, Dict, List, Optional, Union
from urllib.parse import unquote_to_bytes
import openai
from openai import OpenAI
from entity.messages import (
AttachmentRef,
FunctionCallOutputEvent,
... | 810 | 32,297 |
ChatDev | runtime/node/agent/providers/base.py | .py | """Abstract base classes for agent providers."""
from abc import ABC, abstractmethod
from typing import Any, Dict, List, Optional
from entity.configs import AgentConfig
from entity.messages import Message
from schema_registry import register_model_provider_schema
from entity.tool_spec import ToolSpec
from runtime.node... | 117 | 3,498 |
ChatDev | runtime/node/agent/providers/response.py | .py | """Normalized provider response dataclasses."""
from dataclasses import dataclass
from typing import Any
from entity.messages import Message
@dataclass
class ModelResponse:
"""Represents a provider response with normalized message payload."""
message: Message
raw_response: Any | None = None
def ha... | 40 | 1,280 |
ChatDev | runtime/edge/processors/function_processor.py | .py | """Payload processor that delegates to Python functions."""
from typing import Any, Callable, Mapping
from entity.messages import Message
from utils.log_manager import LogManager
from utils.structured_logger import get_server_logger
from .base import EdgePayloadProcessor, ProcessorFactoryContext
from entity.configs.e... | 77 | 2,801 |
ChatDev | runtime/edge/processors/builtin_types.py | .py | """Register built-in edge payload processors."""
from entity.configs.edge.edge_processor import (
RegexEdgeProcessorConfig,
FunctionEdgeProcessorConfig,
)
from .registry import register_edge_processor
from .regex_processor import RegexEdgePayloadProcessor
from .function_processor import FunctionEdgePayloadProc... | 24 | 766 |
ChatDev | runtime/edge/processors/__init__.py | .py | """Public helpers for edge payload processors."""
from .base import EdgePayloadProcessor, ProcessorFactoryContext
from .registry import build_edge_processor
__all__ = [
"EdgePayloadProcessor",
"ProcessorFactoryContext",
"build_edge_processor",
]
| 11 | 260 |
ChatDev | runtime/edge/processors/registry.py | .py | """Registry helpers for edge payload processors."""
from dataclasses import dataclass
from importlib import import_module
from typing import Any, Dict, Type
from schema_registry import register_edge_processor_schema
from utils.registry import Registry, RegistryEntry, RegistryError
from entity.configs.edge.edge_proces... | 82 | 2,732 |
ChatDev | runtime/edge/processors/regex_processor.py | .py | """Regex-based payload processor."""
import re
from typing import List
from entity.messages import Message
from utils.log_manager import LogManager
from .base import EdgePayloadProcessor, ProcessorFactoryContext
from entity.configs.edge.edge_processor import RegexEdgeProcessorConfig
from runtime.node.executor import ... | 93 | 3,035 |
ChatDev | runtime/edge/processors/base.py | .py | """Base classes for payload processors applied on edges."""
from abc import ABC, abstractmethod
from dataclasses import dataclass
from typing import Any, Generic, TypeVar
from entity.messages import Message
from runtime.node.executor import ExecutionContext
from utils.log_manager import LogManager
from utils.function... | 51 | 1,390 |
ChatDev | runtime/edge/conditions/builtin_types.py | .py | """Register built-in edge condition manager implementations."""
from entity.configs.edge.edge_condition import (
FunctionEdgeConditionConfig,
KeywordEdgeConditionConfig,
)
from runtime.edge.conditions.registry import register_edge_condition
from runtime.edge.conditions.function_manager import FunctionEdgeCondit... | 22 | 850 |
ChatDev | runtime/edge/conditions/__init__.py | .py | """Edge condition registry utilities."""
from .base import EdgeConditionManager, ConditionFactoryContext
from .registry import build_edge_condition_manager
__all__ = [
"ConditionFactoryContext",
"EdgeConditionManager",
"build_edge_condition_manager",
]
| 11 | 267 |
ChatDev | runtime/edge/conditions/registry.py | .py | """Registry helpers for pluggable edge condition managers."""
from dataclasses import dataclass
from importlib import import_module
from typing import Any, Dict, Type
from schema_registry import register_edge_condition_schema
from utils.registry import Registry, RegistryEntry, RegistryError
from entity.configs.edge.e... | 93 | 3,188 |
ChatDev | runtime/edge/conditions/function_manager.py | .py | """FunctionEdgeManager centralizes function-based edge conditions."""
from typing import Callable, Optional
from entity.configs.edge.edge_condition import FunctionEdgeConditionConfig
from utils.structured_logger import get_server_logger
from .base import ConditionFactoryContext
from .base import EdgeConditionManager
... | 68 | 2,418 |
ChatDev | runtime/edge/conditions/keyword_manager.py | .py | """KeywordEdgeManager implements declarative keyword conditions."""
import re
from entity.configs.edge.edge_condition import KeywordEdgeConditionConfig
from .base import ConditionFactoryContext
from .base import EdgeConditionManager
from ...node.executor import ExecutionContext
class KeywordEdgeConditionManager(Edg... | 67 | 2,668 |
ChatDev | runtime/edge/conditions/base.py | .py | """EdgeConditionManager abstraction that unifies edge condition compilation."""
from abc import ABC, abstractmethod
from dataclasses import dataclass
from typing import Any, Callable, Generic, TypeVar
from entity.messages import Message, MessageRole
from runtime.node.executor import ExecutionContext
from utils.log_ma... | 234 | 8,475 |
ChatDev | schema_registry/__init__.py | .py | """Public helpers for entity schema registries."""
from .registry import (
SchemaLookupError,
SchemaRegistrationError,
NodeSchemaSpec,
EdgeConditionSchemaSpec,
EdgeProcessorSchemaSpec,
MemoryStoreSchemaSpec,
ThinkingSchemaSpec,
ModelProviderSchemaSpec,
register_node_schema,
regi... | 60 | 1,657 |
ChatDev | schema_registry/registry.py | .py | """Schema registries for entity-layer configuration classes."""
from dataclasses import dataclass, field
from typing import Any, Dict, Mapping, MutableMapping, Type
from entity.configs.base import BaseConfig
class SchemaLookupError(RuntimeError):
"""Raised when a requested schema spec is not registered."""
cla... | 291 | 9,116 |
spaCy | setup.py | .py | #!/usr/bin/env python
from setuptools import Extension, setup, find_packages
import sys
import numpy
from setuptools.command.build_ext import build_ext
from sysconfig import get_path
from pathlib import Path
import shutil
from Cython.Build import cythonize
from Cython.Compiler import Options
import os
import subprocess... | 222 | 6,963 |
spaCy | website/setup/jinja_to_js.py | .py | # Forked from: https://github.com/jonbretman/jinja-to-js
# With additional functionality: in/not in, replace, pprint, round, + for lists,
# rendering empty dicts
# This script is mostly used to generate the JavaScript function for the
# training quickstart widget.
import contextlib
import json
import re
import os
from ... | 1,273 | 47,269 |
spaCy | spacy/scorer.py | .py | from collections import defaultdict
from typing import (
TYPE_CHECKING,
Any,
Callable,
Dict,
Iterable,
List,
Optional,
Set,
Tuple,
)
import numpy as np
from .errors import Errors
from .morphology import Morphology
from .tokens import Doc, Span, Token
from .training import Example
f... | 1,168 | 45,768 |
spaCy | spacy/errors.py | .py | import warnings
from .compat import Literal
class ErrorsWithCodes(type):
def __getattribute__(self, code):
msg = super().__getattribute__(code)
if code.startswith("__"): # python system attributes like __class__
return msg
else:
return "[{code}] {msg}".format(code... | 1,018 | 68,134 |
spaCy | spacy/pipe_analysis.py | .py | from typing import TYPE_CHECKING, Dict, ItemsView, Iterable, List, Set, Union
from wasabi import msg
from .errors import Errors
from .tokens import Doc, Span, Token
from .util import dot_to_dict
if TYPE_CHECKING:
# This lets us add type hints for mypy etc. without causing circular imports
from .language impo... | 139 | 6,230 |
spaCy | spacy/glossary.py | .py | import warnings
from .errors import Warnings
def explain(term):
"""Get a description for a given POS tag, dependency label or entity type.
term (str): The term to explain.
RETURNS (str): The explanation, or `None` if not found in the glossary.
EXAMPLE:
>>> spacy.explain(u'NORP')
>>>... | 361 | 13,186 |
spaCy | spacy/language.py | .py | import functools
import inspect
import itertools
import multiprocessing as mp
import random
import traceback
import warnings
from contextlib import ExitStack, contextmanager
from copy import deepcopy
from dataclasses import dataclass
from itertools import chain, cycle
from pathlib import Path
from timeit import default... | 2,467 | 106,983 |
spaCy | spacy/util.py | .py | import functools
import importlib
import importlib.util
import inspect
import itertools
import logging
import os
import re
import shlex
import shutil
import socket
import stat
import subprocess
import sys
import tempfile
import warnings
from collections import defaultdict
from contextlib import contextmanager
from path... | 1,897 | 68,475 |
spaCy | spacy/__main__.py | .py | if __name__ == "__main__":
from spacy.cli import setup_cli
setup_cli()
| 5 | 80 |
spaCy | spacy/__init__.py | .py | import sys
from pathlib import Path
from typing import Any, Dict, Iterable, Union
# set library-specific custom warning handling before doing anything else
from .errors import setup_default_warnings
setup_default_warnings() # noqa: E402
# These are imported as part of the API
from thinc.api import Config, prefer_gp... | 103 | 3,562 |
spaCy | spacy/ty.py | .py | from typing import (
TYPE_CHECKING,
Any,
Callable,
Dict,
Iterable,
List,
Optional,
Sequence,
)
from thinc.api import Model, Optimizer
from .compat import Protocol, runtime_checkable
if TYPE_CHECKING:
from .language import Language
from .training import Example
@runtime_check... | 60 | 1,299 |
spaCy | spacy/lookups.py | .py | from collections import OrderedDict
from pathlib import Path
from typing import Any, Dict, List, Optional, Union
import srsly
from preshed.bloom import BloomFilter
from .errors import Errors
from .strings import get_string_id
from .util import SimpleFrozenDict, ensure_path, load_language_data, registry
UNSET = objec... | 315 | 10,854 |
spaCy | spacy/schemas.py | .py | import inspect
from collections import defaultdict
from enum import Enum
from typing import (
TYPE_CHECKING,
Any,
Callable,
Dict,
Iterable,
List,
Optional,
Tuple,
Type,
TypeVar,
Union,
)
from pydantic import (
BaseModel,
ConfigDict,
Field,
StrictBool,
Str... | 501 | 21,122 |
spaCy | spacy/compat.py | .py | """Helpers for Python and platform compatibility."""
import sys
from thinc.util import copy_array
try:
import cPickle as pickle
except ImportError:
import pickle # type: ignore[no-redef]
try:
import copy_reg
except ImportError:
import copyreg as copy_reg # type: ignore[no-redef]
try:
from cup... | 53 | 1,363 |
spaCy | spacy/registrations.py | .py | """Centralized registry population for spaCy config
This module centralizes registry decorations to prevent circular import issues
with Cython annotation changes from __future__ import annotations. Functions
remain in their original locations, but decoration is moved here.
Component definitions and registrations are ... | 247 | 11,372 |
spaCy | spacy/about.py | .py | # fmt: off
__title__ = "spacy"
__version__ = "3.8.15"
__download_url__ = "https://github.com/explosion/spacy-models/releases/download"
__compatibility__ = "https://raw.githubusercontent.com/explosion/spacy-models/master/compatibility.json"
| 6 | 240 |
spaCy | spacy/lang/norm_exceptions.py | .py | # These exceptions are used to add NORM values based on a token's ORTH value.
# Individual languages can also add their own exceptions and overwrite them -
# for example, British vs. American spelling in English.
# Norms are only set if no alternative is provided in the tokenizer exceptions.
# Note that this does not ... | 60 | 1,425 |
spaCy | spacy/lang/punctuation.py | .py | from .char_classes import (
ALPHA,
ALPHA_LOWER,
ALPHA_UPPER,
COMBINING_DIACRITICS,
CONCAT_QUOTES,
CURRENCY,
HYPHENS,
LIST_CURRENCY,
LIST_ELLIPSES,
LIST_ICONS,
LIST_PUNCT,
LIST_QUOTES,
PUNCT,
UNITS,
)
TOKENIZER_PREFIXES = (
["§", "%", "=", "—", "–", r"\+(?![0-... | 79 | 2,202 |
spaCy | spacy/lang/char_classes.py | .py | split_chars = lambda char: list(char.strip().split(" "))
merge_chars = lambda char: char.strip().replace(" ", "|")
group_chars = lambda char: char.strip().replace(" ", "")
_ethiopic = r"\u1200-\u137F"
_bengali = r"\u0980-\u09FF"
_hebrew = r"\u0591-\u05F4\uFB1D-\uFB4F"
_hindi = r"\u0900-\u097F"
_kannada = r"\u0C80-... | 334 | 14,678 |
spaCy | spacy/lang/lex_attrs.py | .py | import re
import unicodedata
from typing import Set
from .. import attrs
from .tokenizer_exceptions import URL_MATCH
_like_email = re.compile(r"([a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+)").match
_tlds = set(
"com|org|edu|gov|net|mil|aero|asia|biz|cat|coop|info|int|jobs|mobi|museum|"
"name|pro|tel|travel... | 214 | 5,943 |
spaCy | spacy/lang/tokenizer_exceptions.py | .py | import re
from ..symbols import NORM, ORTH
from .char_classes import ALPHA_LOWER
# URL validation regex courtesy of: https://mathiasbynens.be/demo/url-regex
# and https://gist.github.com/dperini/729294 (Diego Perini, MIT License)
# A few mods to this regex to account for use cases represented in test_urls
URL_PATTERN... | 258 | 3,461 |
spaCy | spacy/lang/it/punctuation.py | .py | from ..char_classes import (
ALPHA,
ALPHA_LOWER,
ALPHA_UPPER,
CONCAT_QUOTES,
HYPHENS,
LIST_ELLIPSES,
LIST_ICONS,
)
from ..punctuation import TOKENIZER_PREFIXES as BASE_TOKENIZER_PREFIXES
ELISION = "'’"
_prefixes = [r"'[0-9][0-9]", r"[0-9]+°"] + BASE_TOKENIZER_PREFIXES
_infixes = (
L... | 35 | 853 |
spaCy | spacy/lang/it/__init__.py | .py | from typing import Callable, Optional
from thinc.api import Model
from ...language import BaseDefaults, Language
from .lemmatizer import ItalianLemmatizer
from .punctuation import TOKENIZER_INFIXES, TOKENIZER_PREFIXES
from .stop_words import STOP_WORDS
from .syntax_iterators import SYNTAX_ITERATORS
from .tokenizer_ex... | 51 | 1,230 |
spaCy | spacy/lang/it/stop_words.py | .py | STOP_WORDS = set(
"""
a abbastanza abbia abbiamo abbiano abbiate accidenti ad adesso affinche agl
agli ahime ahimè ai al alcuna alcuni alcuno all alla alle allo allora altri
altrimenti altro altrove altrui anche ancora anni anno ansa anticipo assai
attesa attraverso avanti avemmo avendo avente aver avere averlo ave... | 84 | 4,114 |
spaCy | spacy/lang/it/syntax_iterators.py | .py | from typing import Iterator, Tuple, Union
from ...errors import Errors
from ...symbols import NOUN, PRON, PROPN
from ...tokens import Doc, Span
def noun_chunks(doclike: Union[Doc, Span]) -> Iterator[Tuple[int, int, int]]:
"""
Detect base noun phrases from a dependency parse. Works on both Doc and Span.
"... | 87 | 3,137 |
spaCy | spacy/lang/it/examples.py | .py | """
Example sentences to test spaCy and its language models.
>>> from spacy.lang.it.examples import sentences
>>> docs = nlp.pipe(sentences)
"""
sentences = [
"Apple vuole comprare una startup del Regno Unito per un miliardo di dollari",
"Le automobili a guida autonoma spostano la responsabilità assicurativa ... | 14 | 470 |
spaCy | spacy/lang/it/lemmatizer.py | .py | from typing import Dict, List, Tuple
from ...pipeline import Lemmatizer
from ...tokens import Token
class ItalianLemmatizer(Lemmatizer):
"""This lemmatizer was adapted from the Polish one (version of April 2021).
It implements lookup lemmatization based on the morphological lexicon
morph-it (Baroni and Z... | 133 | 4,615 |
spaCy | spacy/lang/it/tokenizer_exceptions.py | .py | from ...symbols import ORTH
from ...util import update_exc
from ..tokenizer_exceptions import BASE_EXCEPTIONS
_exc = {
"all'art.": [{ORTH: "all'"}, {ORTH: "art."}],
"dall'art.": [{ORTH: "dall'"}, {ORTH: "art."}],
"dell'art.": [{ORTH: "dell'"}, {ORTH: "art."}],
"L'art.": [{ORTH: "L'"}, {ORTH: "art."}],
... | 65 | 1,160 |
spaCy | spacy/lang/lg/punctuation.py | .py | from ..char_classes import (
ALPHA,
ALPHA_LOWER,
ALPHA_UPPER,
CONCAT_QUOTES,
HYPHENS,
LIST_ELLIPSES,
LIST_ICONS,
)
_infixes = (
LIST_ELLIPSES
+ LIST_ICONS
+ [
r"(?<=[0-9])[+\-\*^](?=[0-9-])",
r"(?<=[{al}{q}])\.(?=[{au}{q}])".format(
al=ALPHA_LOWER, au... | 27 | 576 |
spaCy | spacy/lang/lg/__init__.py | .py | from ...language import BaseDefaults, Language
from .lex_attrs import LEX_ATTRS
from .punctuation import TOKENIZER_INFIXES
from .stop_words import STOP_WORDS
class LugandaDefaults(BaseDefaults):
lex_attr_getters = LEX_ATTRS
infixes = TOKENIZER_INFIXES
stop_words = STOP_WORDS
class Luganda(Language):
... | 19 | 388 |
spaCy | spacy/lang/lg/stop_words.py | .py | STOP_WORDS = set(
"""
abadde abalala abamu abangi abava ajja ali alina ani anti ateekeddwa atewamu
atya awamu aweebwa ayinza ba baali babadde babalina bajja
bajjanewankubade bali balina bandi bangi bano bateekeddwa baweebwa bayina bebombi beera bibye
bimu bingi bino bo bokka bonna buli bulijjo bulungi bwabwe bwaffe... | 20 | 1,361 |
spaCy | spacy/lang/lg/lex_attrs.py | .py | from ...attrs import LIKE_NUM
_num_words = [
"nnooti", # Zero
"zeero", # zero
"emu", # one
"bbiri", # two
"ssatu", # three
"nnya", # four
"ttaano", # five
"mukaaga", # six
"musanvu", # seven
"munaana", # eight
"mwenda", # nine
"kkumi", # ten
"kkumi n'emu"... | 96 | 2,680 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.