docugraph 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- docugraph/__init__.py +24 -0
- docugraph/_version.py +28 -0
- docugraph/agents/__init__.py +27 -0
- docugraph/agents/coding_agent.py +532 -0
- docugraph/agents/tools/__init__.py +62 -0
- docugraph/agents/tools/graph_query.py +203 -0
- docugraph/agents/tools/memory_ops.py +305 -0
- docugraph/agents/tools/search_code.py +305 -0
- docugraph/agents/tools/search_docs.py +148 -0
- docugraph/core/__init__.py +34 -0
- docugraph/core/config.py +183 -0
- docugraph/core/embeddings.py +394 -0
- docugraph/core/llm.py +892 -0
- docugraph/core/models.py +145 -0
- docugraph/ingestion/__init__.py +64 -0
- docugraph/ingestion/api_docs.py +646 -0
- docugraph/ingestion/chunker.py +382 -0
- docugraph/ingestion/crawler.py +305 -0
- docugraph/ingestion/git_indexer.py +556 -0
- docugraph/ingestion/local_files.py +516 -0
- docugraph/interfaces/__init__.py +1 -0
- docugraph/interfaces/cli.py +983 -0
- docugraph/interfaces/mcp_server.py +918 -0
- docugraph/retrieval/__init__.py +54 -0
- docugraph/retrieval/context_builder.py +522 -0
- docugraph/retrieval/hybrid_search.py +534 -0
- docugraph/retrieval/reranker.py +532 -0
- docugraph/storage/__init__.py +14 -0
- docugraph/storage/graph_store.py +602 -0
- docugraph/storage/memory_store.py +529 -0
- docugraph/storage/vector_store.py +367 -0
- docugraph-0.1.0.dist-info/METADATA +354 -0
- docugraph-0.1.0.dist-info/RECORD +37 -0
- docugraph-0.1.0.dist-info/WHEEL +4 -0
- docugraph-0.1.0.dist-info/entry_points.txt +3 -0
- docugraph-0.1.0.dist-info/licenses/LICENSE +201 -0
- docugraph-0.1.0.dist-info/licenses/NOTICE +10 -0
docugraph/core/models.py
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"""Core data models for DocuGraph AI."""
|
|
2
|
+
|
|
3
|
+
from datetime import UTC, datetime
|
|
4
|
+
from enum import StrEnum
|
|
5
|
+
from typing import Any
|
|
6
|
+
from uuid import uuid4
|
|
7
|
+
|
|
8
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def generate_id() -> str:
|
|
12
|
+
"""Generate a unique ID."""
|
|
13
|
+
return str(uuid4())
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class ContentType(StrEnum):
|
|
17
|
+
"""Type of document content."""
|
|
18
|
+
|
|
19
|
+
MARKDOWN = "markdown"
|
|
20
|
+
CODE = "code"
|
|
21
|
+
API_SPEC = "api_spec"
|
|
22
|
+
TEXT = "text"
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class EntityType(StrEnum):
|
|
26
|
+
"""Type of knowledge graph entity."""
|
|
27
|
+
|
|
28
|
+
FUNCTION = "function"
|
|
29
|
+
CLASS = "class"
|
|
30
|
+
MODULE = "module"
|
|
31
|
+
PACKAGE = "package"
|
|
32
|
+
ENDPOINT = "endpoint"
|
|
33
|
+
PARAMETER = "parameter"
|
|
34
|
+
CONCEPT = "concept"
|
|
35
|
+
PATTERN = "pattern"
|
|
36
|
+
DOCUMENTATION = "documentation"
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class RelationshipType(StrEnum):
|
|
40
|
+
"""Type of relationship between entities."""
|
|
41
|
+
|
|
42
|
+
CALLS = "CALLS"
|
|
43
|
+
IMPORTS = "IMPORTS"
|
|
44
|
+
INHERITS = "INHERITS"
|
|
45
|
+
IMPLEMENTS = "IMPLEMENTS"
|
|
46
|
+
DEPENDS_ON = "DEPENDS_ON"
|
|
47
|
+
USED_BY = "USED_BY"
|
|
48
|
+
DESCRIBES = "DESCRIBES"
|
|
49
|
+
EXAMPLE_OF = "EXAMPLE_OF"
|
|
50
|
+
RELATED_TO = "RELATED_TO"
|
|
51
|
+
SUPERSEDES = "SUPERSEDES"
|
|
52
|
+
DEPRECATES = "DEPRECATES"
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class Document(BaseModel):
|
|
56
|
+
"""A crawled or indexed document."""
|
|
57
|
+
|
|
58
|
+
id: str = Field(default_factory=generate_id)
|
|
59
|
+
source_url: str | None = None
|
|
60
|
+
source_path: str | None = None
|
|
61
|
+
title: str | None = None
|
|
62
|
+
content: str
|
|
63
|
+
content_type: ContentType = ContentType.MARKDOWN
|
|
64
|
+
metadata: dict[str, Any] = Field(default_factory=dict)
|
|
65
|
+
created_at: datetime = Field(default_factory=lambda: datetime.now(UTC))
|
|
66
|
+
updated_at: datetime = Field(default_factory=lambda: datetime.now(UTC))
|
|
67
|
+
|
|
68
|
+
def __hash__(self) -> int:
|
|
69
|
+
return hash(self.id)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
class Chunk(BaseModel):
|
|
73
|
+
"""A chunk of a document for vector storage."""
|
|
74
|
+
|
|
75
|
+
id: str = Field(default_factory=generate_id)
|
|
76
|
+
document_id: str
|
|
77
|
+
content: str
|
|
78
|
+
embedding: list[float] | None = None
|
|
79
|
+
start_char: int = 0
|
|
80
|
+
end_char: int = 0
|
|
81
|
+
metadata: dict[str, Any] = Field(default_factory=dict)
|
|
82
|
+
created_at: datetime = Field(default_factory=lambda: datetime.now(UTC))
|
|
83
|
+
|
|
84
|
+
def __hash__(self) -> int:
|
|
85
|
+
return hash(self.id)
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
class Entity(BaseModel):
|
|
89
|
+
"""A knowledge graph entity (node)."""
|
|
90
|
+
|
|
91
|
+
id: str = Field(default_factory=generate_id)
|
|
92
|
+
name: str
|
|
93
|
+
entity_type: EntityType
|
|
94
|
+
description: str | None = None
|
|
95
|
+
source_chunks: list[str] = Field(default_factory=list)
|
|
96
|
+
properties: dict[str, Any] = Field(default_factory=dict)
|
|
97
|
+
created_at: datetime = Field(default_factory=lambda: datetime.now(UTC))
|
|
98
|
+
valid_from: datetime = Field(default_factory=lambda: datetime.now(UTC))
|
|
99
|
+
valid_to: datetime | None = None
|
|
100
|
+
|
|
101
|
+
def __hash__(self) -> int:
|
|
102
|
+
return hash(self.id)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
class Relationship(BaseModel):
|
|
106
|
+
"""A knowledge graph relationship (edge)."""
|
|
107
|
+
|
|
108
|
+
id: str = Field(default_factory=generate_id)
|
|
109
|
+
source_id: str
|
|
110
|
+
target_id: str
|
|
111
|
+
relationship_type: RelationshipType
|
|
112
|
+
properties: dict[str, Any] = Field(default_factory=dict)
|
|
113
|
+
weight: float = 1.0
|
|
114
|
+
created_at: datetime = Field(default_factory=lambda: datetime.now(UTC))
|
|
115
|
+
|
|
116
|
+
def __hash__(self) -> int:
|
|
117
|
+
return hash(self.id)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
class MemoryEntry(BaseModel):
|
|
121
|
+
"""An entry in the agent's memory store."""
|
|
122
|
+
|
|
123
|
+
id: str = Field(default_factory=generate_id)
|
|
124
|
+
repository: str
|
|
125
|
+
branch: str = "main"
|
|
126
|
+
key: str
|
|
127
|
+
value: Any
|
|
128
|
+
context: dict[str, Any] = Field(default_factory=dict)
|
|
129
|
+
created_at: datetime = Field(default_factory=lambda: datetime.now(UTC))
|
|
130
|
+
accessed_at: datetime = Field(default_factory=lambda: datetime.now(UTC))
|
|
131
|
+
|
|
132
|
+
def __hash__(self) -> int:
|
|
133
|
+
return hash(self.id)
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
class SearchResult(BaseModel):
|
|
137
|
+
"""A search result with relevance score."""
|
|
138
|
+
|
|
139
|
+
# Class-based `Config` is deprecated in Pydantic v2 and warns on import.
|
|
140
|
+
model_config = ConfigDict(arbitrary_types_allowed=True)
|
|
141
|
+
|
|
142
|
+
chunk: Chunk
|
|
143
|
+
score: float
|
|
144
|
+
source_document: Document | None = None
|
|
145
|
+
highlights: list[str] = Field(default_factory=list)
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"""Ingestion pipeline: crawling, file processing, and chunking."""
|
|
2
|
+
|
|
3
|
+
from docugraph.ingestion.api_docs import (
|
|
4
|
+
APIDocConfig,
|
|
5
|
+
APIDocParser,
|
|
6
|
+
APIDocType,
|
|
7
|
+
APIEndpoint,
|
|
8
|
+
APIParameter,
|
|
9
|
+
APISchema,
|
|
10
|
+
GraphQLType,
|
|
11
|
+
ParsedAPISpec,
|
|
12
|
+
get_api_doc_parser,
|
|
13
|
+
)
|
|
14
|
+
from docugraph.ingestion.chunker import (
|
|
15
|
+
Chunker,
|
|
16
|
+
ChunkerConfig,
|
|
17
|
+
ChunkingStrategy,
|
|
18
|
+
get_chunker,
|
|
19
|
+
)
|
|
20
|
+
from docugraph.ingestion.crawler import DocCrawler
|
|
21
|
+
from docugraph.ingestion.git_indexer import (
|
|
22
|
+
GitIndexer,
|
|
23
|
+
GitIndexerConfig,
|
|
24
|
+
RepoInfo,
|
|
25
|
+
get_git_indexer,
|
|
26
|
+
)
|
|
27
|
+
from docugraph.ingestion.local_files import (
|
|
28
|
+
FileType,
|
|
29
|
+
IndexedFile,
|
|
30
|
+
LocalFileConfig,
|
|
31
|
+
LocalFileIndexer,
|
|
32
|
+
get_local_file_indexer,
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
__all__ = [
|
|
36
|
+
# Crawler
|
|
37
|
+
"DocCrawler",
|
|
38
|
+
# Chunker
|
|
39
|
+
"Chunker",
|
|
40
|
+
"ChunkerConfig",
|
|
41
|
+
"ChunkingStrategy",
|
|
42
|
+
"get_chunker",
|
|
43
|
+
# Local Files
|
|
44
|
+
"FileType",
|
|
45
|
+
"IndexedFile",
|
|
46
|
+
"LocalFileConfig",
|
|
47
|
+
"LocalFileIndexer",
|
|
48
|
+
"get_local_file_indexer",
|
|
49
|
+
# Git Indexer
|
|
50
|
+
"GitIndexer",
|
|
51
|
+
"GitIndexerConfig",
|
|
52
|
+
"RepoInfo",
|
|
53
|
+
"get_git_indexer",
|
|
54
|
+
# API Docs
|
|
55
|
+
"APIDocType",
|
|
56
|
+
"APIParameter",
|
|
57
|
+
"APIEndpoint",
|
|
58
|
+
"APISchema",
|
|
59
|
+
"GraphQLType",
|
|
60
|
+
"ParsedAPISpec",
|
|
61
|
+
"APIDocConfig",
|
|
62
|
+
"APIDocParser",
|
|
63
|
+
"get_api_doc_parser",
|
|
64
|
+
]
|