mirror of
https://github.com/agentscope-ai/ReMe.git
synced 2026-09-17 23:51:19 +00:00
- Integrate AnthropicChatModel with new AnthropicAsLLM component - Add component formatters for OpenAI and Anthropic chat models - Implement token counter component with estimated token counting - Create base client component for ReMe service communication - Refactor BaseComponent to remove app_context parameter from _start/_close - Update embedding model base class to remove retry logic and use npz cache - Add job component for sequential step execution with BaseJob - Implement step component base class for LLM workflow execution - Enhance application context with proper type annotations - Update component initialization to pass app_context automatically - Remove asyncio dependency from embedding model cache operations
41 lines
1.1 KiB
Python
41 lines
1.1 KiB
Python
"""Abstract base class for file parsers."""
|
|
|
|
from abc import abstractmethod
|
|
|
|
from ..base_component import BaseComponent
|
|
from ...enumeration import ComponentEnum
|
|
from ...schema import FileChunk, FileMetadata
|
|
|
|
|
|
class BaseFileParser(BaseComponent):
|
|
"""Abstract base class for file format parsers.
|
|
|
|
Each parser declares which file suffixes it handles and implements
|
|
the parse method to produce FileMetadata and FileChunks.
|
|
"""
|
|
|
|
component_type = ComponentEnum.FILE_PARSER
|
|
|
|
suffixes: list[str] = []
|
|
|
|
def __init__(self, chunk_tokens: int = 400, chunk_overlap: int = 80, **kwargs):
|
|
super().__init__(**kwargs)
|
|
self.chunk_tokens = chunk_tokens
|
|
self.chunk_overlap = chunk_overlap
|
|
|
|
async def _start(self):
|
|
pass
|
|
|
|
async def _close(self):
|
|
pass
|
|
|
|
@abstractmethod
|
|
async def parse(self, path: str) -> tuple[FileMetadata, list[FileChunk]]:
|
|
"""Parse a file into metadata and chunks.
|
|
|
|
Args:
|
|
path: Absolute path to the file.
|
|
|
|
Returns:
|
|
Tuple of (FileMetadata, list of FileChunks).
|
|
"""
|