fetchgraph 0.1.2__tar.gz → 0.2.0__tar.gz
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.
- fetchgraph-0.2.0/MANIFEST.in +4 -0
- {fetchgraph-0.1.2/src/fetchgraph.egg-info → fetchgraph-0.2.0}/PKG-INFO +18 -11
- {fetchgraph-0.1.2 → fetchgraph-0.2.0}/README.md +8 -9
- {fetchgraph-0.1.2 → fetchgraph-0.2.0}/pyproject.toml +11 -2
- {fetchgraph-0.1.2 → fetchgraph-0.2.0}/src/fetchgraph/__init__.py +23 -25
- fetchgraph-0.2.0/src/fetchgraph/core/__init__.py +52 -0
- fetchgraph-0.1.2/src/fetchgraph/core.py → fetchgraph-0.2.0/src/fetchgraph/core/context.py +9 -2
- {fetchgraph-0.1.2/src/fetchgraph → fetchgraph-0.2.0/src/fetchgraph/core}/protocols.py +15 -2
- {fetchgraph-0.1.2/src/fetchgraph → fetchgraph-0.2.0/src/fetchgraph/core}/utils.py +2 -0
- {fetchgraph-0.1.2 → fetchgraph-0.2.0}/src/fetchgraph/parsing/json_parser.py +1 -1
- {fetchgraph-0.1.2 → fetchgraph-0.2.0}/src/fetchgraph/parsing/plan_parser.py +2 -2
- fetchgraph-0.2.0/src/fetchgraph/providers/__init__.py +1 -0
- fetchgraph-0.2.0/src/fetchgraph/relational/__init__.py +81 -0
- fetchgraph-0.2.0/src/fetchgraph/relational/dsl/__init__.py +1 -0
- fetchgraph-0.2.0/src/fetchgraph/relational/dsl/ast.py +0 -0
- fetchgraph-0.2.0/src/fetchgraph/relational/dsl/compile.py +0 -0
- fetchgraph-0.2.0/src/fetchgraph/relational/dsl/diagnostics.py +0 -0
- fetchgraph-0.2.0/src/fetchgraph/relational/dsl/normalize.py +0 -0
- fetchgraph-0.2.0/src/fetchgraph/relational/dsl/parser.py +0 -0
- fetchgraph-0.1.2/src/fetchgraph/relational_models.py → fetchgraph-0.2.0/src/fetchgraph/relational/models.py +1 -0
- fetchgraph-0.2.0/src/fetchgraph/relational/providers/__init__.py +13 -0
- fetchgraph-0.1.2/src/fetchgraph/relational_base.py → fetchgraph-0.2.0/src/fetchgraph/relational/providers/base.py +7 -6
- fetchgraph-0.1.2/src/fetchgraph/relational_composite.py → fetchgraph-0.2.0/src/fetchgraph/relational/providers/composite_provider.py +8 -6
- fetchgraph-0.1.2/src/fetchgraph/relational_pandas.py → fetchgraph-0.2.0/src/fetchgraph/relational/providers/pandas_provider.py +36 -18
- fetchgraph-0.2.0/src/fetchgraph/relational/providers/sql/__init__.py +1 -0
- fetchgraph-0.2.0/src/fetchgraph/relational/providers/sql/builder.py +0 -0
- fetchgraph-0.2.0/src/fetchgraph/relational/providers/sql/dialects.py +0 -0
- fetchgraph-0.1.2/src/fetchgraph/relational_sql.py → fetchgraph-0.2.0/src/fetchgraph/relational/providers/sql_provider.py +5 -6
- fetchgraph-0.1.2/src/fetchgraph/relational_schema.py → fetchgraph-0.2.0/src/fetchgraph/relational/schema.py +8 -8
- fetchgraph-0.2.0/src/fetchgraph/relational/semantic/__init__.py +23 -0
- fetchgraph-0.1.2/src/fetchgraph/semantic_backend.py → fetchgraph-0.2.0/src/fetchgraph/relational/semantic/backend.py +2 -2
- fetchgraph-0.2.0/src/fetchgraph/utils/__init__.py +3 -0
- fetchgraph-0.2.0/src/fetchgraph/utils/log_context.py +26 -0
- {fetchgraph-0.1.2 → fetchgraph-0.2.0/src/fetchgraph.egg-info}/PKG-INFO +18 -11
- fetchgraph-0.2.0/src/fetchgraph.egg-info/SOURCES.txt +53 -0
- fetchgraph-0.2.0/src/fetchgraph.egg-info/requires.txt +17 -0
- {fetchgraph-0.1.2 → fetchgraph-0.2.0}/tests/test_relational_base.py +1 -1
- {fetchgraph-0.1.2 → fetchgraph-0.2.0}/tests/test_relational_composite.py +8 -6
- {fetchgraph-0.1.2 → fetchgraph-0.2.0}/tests/test_relational_composite_cross_provider.py +11 -8
- {fetchgraph-0.1.2 → fetchgraph-0.2.0}/tests/test_relational_pandas.py +2 -2
- {fetchgraph-0.1.2 → fetchgraph-0.2.0}/tests/test_relational_sql.py +3 -2
- {fetchgraph-0.1.2 → fetchgraph-0.2.0}/tests/test_semantic_backend_csv.py +1 -1
- {fetchgraph-0.1.2 → fetchgraph-0.2.0}/tests/test_semantic_backend_pgvector.py +1 -1
- {fetchgraph-0.1.2 → fetchgraph-0.2.0}/tests/test_streaming_cross_joins.py +5 -5
- fetchgraph-0.1.2/src/fetchgraph/relational_provider.py +0 -34
- fetchgraph-0.1.2/src/fetchgraph.egg-info/SOURCES.txt +0 -37
- fetchgraph-0.1.2/src/fetchgraph.egg-info/requires.txt +0 -8
- {fetchgraph-0.1.2 → fetchgraph-0.2.0}/LICENSE +0 -0
- {fetchgraph-0.1.2 → fetchgraph-0.2.0}/setup.cfg +0 -0
- {fetchgraph-0.1.2/src/fetchgraph → fetchgraph-0.2.0/src/fetchgraph/core}/models.py +0 -0
- {fetchgraph-0.1.2 → fetchgraph-0.2.0}/src/fetchgraph/parsing/__init__.py +1 -1
- {fetchgraph-0.1.2 → fetchgraph-0.2.0}/src/fetchgraph/parsing/exceptions.py +0 -0
- {fetchgraph-0.1.2 → fetchgraph-0.2.0}/src/fetchgraph/parsing/extract_json.py +0 -0
- {fetchgraph-0.1.2 → fetchgraph-0.2.0}/src/fetchgraph/prompts/plan_generic.md +0 -0
- {fetchgraph-0.1.2 → fetchgraph-0.2.0}/src/fetchgraph/prompts/synth_generic.md +0 -0
- /fetchgraph-0.1.2/src/fetchgraph/json_types.py → /fetchgraph-0.2.0/src/fetchgraph/relational/types.py +0 -0
- {fetchgraph-0.1.2 → fetchgraph-0.2.0}/src/fetchgraph.egg-info/dependency_links.txt +0 -0
- {fetchgraph-0.1.2 → fetchgraph-0.2.0}/src/fetchgraph.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fetchgraph
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: Graph-like planning → context fetching → synthesis agent (library-style).
|
|
5
5
|
Author: Alexander Onischenko
|
|
6
6
|
License-Expression: MIT
|
|
@@ -9,7 +9,7 @@ Project-URL: Repository, https://github.com/AlexanderOnischenko/fetchgraph
|
|
|
9
9
|
Project-URL: Documentation, https://github.com/AlexanderOnischenko/fetchgraph#readme
|
|
10
10
|
Project-URL: Issues, https://github.com/AlexanderOnischenko/fetchgraph/issues
|
|
11
11
|
Keywords: agents,context,langgraph,planning,llm
|
|
12
|
-
Requires-Python: >=3.
|
|
12
|
+
Requires-Python: >=3.11
|
|
13
13
|
Description-Content-Type: text/markdown
|
|
14
14
|
License-File: LICENSE
|
|
15
15
|
Requires-Dist: pydantic>=2.6
|
|
@@ -17,8 +17,16 @@ Requires-Dist: pandas>=2.0
|
|
|
17
17
|
Provides-Extra: dev
|
|
18
18
|
Requires-Dist: pytest>=9.0; extra == "dev"
|
|
19
19
|
Requires-Dist: pre-commit; extra == "dev"
|
|
20
|
+
Requires-Dist: pydantic-settings>=2.2; extra == "dev"
|
|
21
|
+
Requires-Dist: python-dotenv>=1.0; extra == "dev"
|
|
22
|
+
Requires-Dist: ruff; extra == "dev"
|
|
23
|
+
Requires-Dist: pyright; extra == "dev"
|
|
20
24
|
Requires-Dist: build; extra == "dev"
|
|
21
25
|
Requires-Dist: twine; extra == "dev"
|
|
26
|
+
Provides-Extra: demo
|
|
27
|
+
Requires-Dist: pydantic-settings>=2.12; extra == "demo"
|
|
28
|
+
Requires-Dist: python-dotenv>=1.0; extra == "demo"
|
|
29
|
+
Requires-Dist: openai; extra == "demo"
|
|
22
30
|
Dynamic: license-file
|
|
23
31
|
|
|
24
32
|
# fetchgraph
|
|
@@ -59,7 +67,7 @@ pip install fetchgraph
|
|
|
59
67
|
### Selectors are JSON-only
|
|
60
68
|
|
|
61
69
|
Providers receive a `selectors` argument that **must be JSON-serializable**. The
|
|
62
|
-
shared alias `SelectorsDict` (
|
|
70
|
+
shared alias `SelectorsDict` (exported from `fetchgraph.relational.types`) represents
|
|
63
71
|
`Dict[str, JSONValue]` and is used across protocols and models. The planner/LLM
|
|
64
72
|
produces this structure, so do not place runtime-only Python objects (e.g.
|
|
65
73
|
connections, DataFrames) into `selectors`; pass such hints through `**kwargs`
|
|
@@ -125,8 +133,8 @@ print(agent.run("FeatureX"))
|
|
|
125
133
|
Example for a relational provider that requires an `"op"` selector:
|
|
126
134
|
|
|
127
135
|
```python
|
|
128
|
-
from fetchgraph
|
|
129
|
-
from fetchgraph.
|
|
136
|
+
from fetchgraph import ProviderInfo
|
|
137
|
+
from fetchgraph.relational import SelectorsDict
|
|
130
138
|
|
|
131
139
|
class RelationalDataProvider:
|
|
132
140
|
name = "relational"
|
|
@@ -160,7 +168,7 @@ fetch_spec = ContextFetchSpec(provider="relational", selectors={"op": "schema"})
|
|
|
160
168
|
|
|
161
169
|
## CSV semantic backend for Pandas providers
|
|
162
170
|
|
|
163
|
-
`fetchgraph.
|
|
171
|
+
`fetchgraph.relational.semantic.backend` ships a lightweight TF-IDF backend that turns a CSV
|
|
164
172
|
file into semantic embeddings and reuses them across runs. The flow is:
|
|
165
173
|
|
|
166
174
|
1. Build embeddings from a CSV once using `CsvEmbeddingBuilder` and persist them
|
|
@@ -174,14 +182,13 @@ Example setup:
|
|
|
174
182
|
|
|
175
183
|
```python
|
|
176
184
|
from pathlib import Path
|
|
177
|
-
from fetchgraph.
|
|
185
|
+
from fetchgraph.relational.semantic import (
|
|
178
186
|
EmbeddingModel,
|
|
179
187
|
CsvEmbeddingBuilder,
|
|
180
188
|
CsvSemanticBackend,
|
|
181
189
|
CsvSemanticSource,
|
|
182
190
|
)
|
|
183
|
-
from fetchgraph.
|
|
184
|
-
from fetchgraph.relational_pandas import PandasRelationalDataProvider
|
|
191
|
+
from fetchgraph.relational import ColumnDescriptor, EntityDescriptor, PandasRelationalDataProvider
|
|
185
192
|
|
|
186
193
|
csv_path = Path("products.csv")
|
|
187
194
|
embedding_path = Path("products_embeddings.json")
|
|
@@ -215,7 +222,7 @@ You can plug in an embedding model (for example, an OpenAI client) to build and
|
|
|
215
222
|
query dense embeddings instead of the default TF-IDF vectors:
|
|
216
223
|
|
|
217
224
|
```python
|
|
218
|
-
from fetchgraph.
|
|
225
|
+
from fetchgraph.relational.semantic import (
|
|
219
226
|
EmbeddingModel,
|
|
220
227
|
CsvSemanticSource,
|
|
221
228
|
CsvEmbeddingBuilder,
|
|
@@ -271,7 +278,7 @@ you can supply your existing vector stores directly:
|
|
|
271
278
|
|
|
272
279
|
```python
|
|
273
280
|
from langchain_community.vectorstores.pgvector import PGVector
|
|
274
|
-
from fetchgraph.
|
|
281
|
+
from fetchgraph.relational.semantic import PgVectorSemanticBackend, PgVectorSemanticSource
|
|
275
282
|
|
|
276
283
|
vector_store = PGVector.from_existing_index(
|
|
277
284
|
collection_name="product_vectors", connection_string="postgresql+psycopg://..."
|
|
@@ -36,7 +36,7 @@ pip install fetchgraph
|
|
|
36
36
|
### Selectors are JSON-only
|
|
37
37
|
|
|
38
38
|
Providers receive a `selectors` argument that **must be JSON-serializable**. The
|
|
39
|
-
shared alias `SelectorsDict` (
|
|
39
|
+
shared alias `SelectorsDict` (exported from `fetchgraph.relational.types`) represents
|
|
40
40
|
`Dict[str, JSONValue]` and is used across protocols and models. The planner/LLM
|
|
41
41
|
produces this structure, so do not place runtime-only Python objects (e.g.
|
|
42
42
|
connections, DataFrames) into `selectors`; pass such hints through `**kwargs`
|
|
@@ -102,8 +102,8 @@ print(agent.run("FeatureX"))
|
|
|
102
102
|
Example for a relational provider that requires an `"op"` selector:
|
|
103
103
|
|
|
104
104
|
```python
|
|
105
|
-
from fetchgraph
|
|
106
|
-
from fetchgraph.
|
|
105
|
+
from fetchgraph import ProviderInfo
|
|
106
|
+
from fetchgraph.relational import SelectorsDict
|
|
107
107
|
|
|
108
108
|
class RelationalDataProvider:
|
|
109
109
|
name = "relational"
|
|
@@ -137,7 +137,7 @@ fetch_spec = ContextFetchSpec(provider="relational", selectors={"op": "schema"})
|
|
|
137
137
|
|
|
138
138
|
## CSV semantic backend for Pandas providers
|
|
139
139
|
|
|
140
|
-
`fetchgraph.
|
|
140
|
+
`fetchgraph.relational.semantic.backend` ships a lightweight TF-IDF backend that turns a CSV
|
|
141
141
|
file into semantic embeddings and reuses them across runs. The flow is:
|
|
142
142
|
|
|
143
143
|
1. Build embeddings from a CSV once using `CsvEmbeddingBuilder` and persist them
|
|
@@ -151,14 +151,13 @@ Example setup:
|
|
|
151
151
|
|
|
152
152
|
```python
|
|
153
153
|
from pathlib import Path
|
|
154
|
-
from fetchgraph.
|
|
154
|
+
from fetchgraph.relational.semantic import (
|
|
155
155
|
EmbeddingModel,
|
|
156
156
|
CsvEmbeddingBuilder,
|
|
157
157
|
CsvSemanticBackend,
|
|
158
158
|
CsvSemanticSource,
|
|
159
159
|
)
|
|
160
|
-
from fetchgraph.
|
|
161
|
-
from fetchgraph.relational_pandas import PandasRelationalDataProvider
|
|
160
|
+
from fetchgraph.relational import ColumnDescriptor, EntityDescriptor, PandasRelationalDataProvider
|
|
162
161
|
|
|
163
162
|
csv_path = Path("products.csv")
|
|
164
163
|
embedding_path = Path("products_embeddings.json")
|
|
@@ -192,7 +191,7 @@ You can plug in an embedding model (for example, an OpenAI client) to build and
|
|
|
192
191
|
query dense embeddings instead of the default TF-IDF vectors:
|
|
193
192
|
|
|
194
193
|
```python
|
|
195
|
-
from fetchgraph.
|
|
194
|
+
from fetchgraph.relational.semantic import (
|
|
196
195
|
EmbeddingModel,
|
|
197
196
|
CsvSemanticSource,
|
|
198
197
|
CsvEmbeddingBuilder,
|
|
@@ -248,7 +247,7 @@ you can supply your existing vector stores directly:
|
|
|
248
247
|
|
|
249
248
|
```python
|
|
250
249
|
from langchain_community.vectorstores.pgvector import PGVector
|
|
251
|
-
from fetchgraph.
|
|
250
|
+
from fetchgraph.relational.semantic import PgVectorSemanticBackend, PgVectorSemanticSource
|
|
252
251
|
|
|
253
252
|
vector_store = PGVector.from_existing_index(
|
|
254
253
|
collection_name="product_vectors", connection_string="postgresql+psycopg://..."
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "fetchgraph"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.2.0"
|
|
4
4
|
description = "Graph-like planning → context fetching → synthesis agent (library-style)."
|
|
5
5
|
readme = "README.md"
|
|
6
|
-
requires-python = ">=3.
|
|
6
|
+
requires-python = ">=3.11"
|
|
7
7
|
license = "MIT"
|
|
8
8
|
authors = [{name = "Alexander Onischenko"}]
|
|
9
9
|
keywords = ["agents", "context", "langgraph", "planning", "llm"]
|
|
@@ -29,9 +29,18 @@ build-backend = "setuptools.build_meta"
|
|
|
29
29
|
dev = [
|
|
30
30
|
"pytest>=9.0",
|
|
31
31
|
"pre-commit",
|
|
32
|
+
"pydantic-settings>=2.2",
|
|
33
|
+
"python-dotenv>=1.0",
|
|
34
|
+
"ruff",
|
|
35
|
+
"pyright",
|
|
32
36
|
"build",
|
|
33
37
|
"twine"
|
|
34
38
|
]
|
|
39
|
+
demo = [
|
|
40
|
+
"pydantic-settings>=2.12",
|
|
41
|
+
"python-dotenv>=1.0",
|
|
42
|
+
"openai"
|
|
43
|
+
]
|
|
35
44
|
|
|
36
45
|
[project.urls]
|
|
37
46
|
Homepage = "https://github.com/AlexanderOnischenko/fetchgraph"
|
|
@@ -12,32 +12,28 @@ import logging
|
|
|
12
12
|
logger = logging.getLogger(__name__)
|
|
13
13
|
logger.addHandler(logging.NullHandler())
|
|
14
14
|
|
|
15
|
-
from .core import (
|
|
16
|
-
ContextPacker,
|
|
15
|
+
from .core import ( # noqa: E402
|
|
17
16
|
BaseGraphAgent,
|
|
18
|
-
create_generic_agent,
|
|
19
|
-
make_llm_plan_generic,
|
|
20
|
-
make_llm_synth_generic,
|
|
21
|
-
)
|
|
22
|
-
from .models import (
|
|
23
|
-
RawLLMOutput,
|
|
24
|
-
ProviderInfo,
|
|
25
|
-
TaskProfile,
|
|
26
|
-
ContextFetchSpec,
|
|
27
17
|
BaselineSpec,
|
|
18
|
+
ContextFetchSpec,
|
|
28
19
|
ContextItem,
|
|
29
|
-
|
|
30
|
-
Plan,
|
|
31
|
-
)
|
|
32
|
-
from .protocols import (
|
|
20
|
+
ContextPacker,
|
|
33
21
|
ContextProvider,
|
|
34
|
-
|
|
22
|
+
LLMInvoke,
|
|
23
|
+
Plan,
|
|
24
|
+
ProviderInfo,
|
|
25
|
+
RawLLMOutput,
|
|
26
|
+
RefetchDecision,
|
|
27
|
+
Saver,
|
|
35
28
|
SupportsDescribe,
|
|
29
|
+
SupportsFilter,
|
|
30
|
+
TaskProfile,
|
|
36
31
|
Verifier,
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
create_generic_agent,
|
|
33
|
+
make_llm_plan_generic,
|
|
34
|
+
make_llm_synth_generic,
|
|
39
35
|
)
|
|
40
|
-
from .
|
|
36
|
+
from .relational import ( # noqa: E402
|
|
41
37
|
AggregationResult,
|
|
42
38
|
AggregationSpec,
|
|
43
39
|
ColumnDescriptor,
|
|
@@ -46,25 +42,26 @@ from .relational_provider import (
|
|
|
46
42
|
GroupBySpec,
|
|
47
43
|
LogicalFilter,
|
|
48
44
|
PandasRelationalDataProvider,
|
|
49
|
-
SqlRelationalDataProvider,
|
|
50
45
|
RelatedEntityData,
|
|
51
|
-
RelationDescriptor,
|
|
52
|
-
RelationJoin,
|
|
53
46
|
RelationalDataProvider,
|
|
54
47
|
RelationalQuery,
|
|
55
48
|
RelationalRequest,
|
|
56
49
|
RelationalResponse,
|
|
50
|
+
RelationDescriptor,
|
|
51
|
+
RelationJoin,
|
|
57
52
|
RowResult,
|
|
58
53
|
SchemaRequest,
|
|
59
54
|
SchemaResult,
|
|
60
55
|
SelectExpr,
|
|
56
|
+
SelectorsDict,
|
|
61
57
|
SemanticBackend,
|
|
62
58
|
SemanticClause,
|
|
63
59
|
SemanticMatch,
|
|
64
60
|
SemanticOnlyRequest,
|
|
65
61
|
SemanticOnlyResult,
|
|
62
|
+
SqlRelationalDataProvider,
|
|
66
63
|
)
|
|
67
|
-
from .
|
|
64
|
+
from .relational.semantic import ( # noqa: E402
|
|
68
65
|
CsvEmbeddingBuilder,
|
|
69
66
|
CsvSemanticBackend,
|
|
70
67
|
CsvSemanticSource,
|
|
@@ -73,7 +70,7 @@ from .semantic_backend import (
|
|
|
73
70
|
VectorStoreLike,
|
|
74
71
|
)
|
|
75
72
|
|
|
76
|
-
__all__ =
|
|
73
|
+
__all__ = (
|
|
77
74
|
"RawLLMOutput",
|
|
78
75
|
"ProviderInfo",
|
|
79
76
|
"TaskProfile",
|
|
@@ -93,6 +90,7 @@ __all__ = [
|
|
|
93
90
|
"create_generic_agent",
|
|
94
91
|
"make_llm_plan_generic",
|
|
95
92
|
"make_llm_synth_generic",
|
|
93
|
+
"SelectorsDict",
|
|
96
94
|
"AggregationResult",
|
|
97
95
|
"AggregationSpec",
|
|
98
96
|
"ColumnDescriptor",
|
|
@@ -124,4 +122,4 @@ __all__ = [
|
|
|
124
122
|
"PgVectorSemanticSource",
|
|
125
123
|
"VectorStoreLike",
|
|
126
124
|
"PandasRelationalDataProvider",
|
|
127
|
-
|
|
125
|
+
)
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"""Core (non-relational) components for fetchgraph."""
|
|
2
|
+
|
|
3
|
+
from .context import (
|
|
4
|
+
BaseGraphAgent,
|
|
5
|
+
ContextPacker,
|
|
6
|
+
create_generic_agent,
|
|
7
|
+
make_llm_plan_generic,
|
|
8
|
+
make_llm_synth_generic,
|
|
9
|
+
)
|
|
10
|
+
from .models import (
|
|
11
|
+
BaselineSpec,
|
|
12
|
+
ContextFetchSpec,
|
|
13
|
+
ContextItem,
|
|
14
|
+
Plan,
|
|
15
|
+
ProviderInfo,
|
|
16
|
+
RawLLMOutput,
|
|
17
|
+
RefetchDecision,
|
|
18
|
+
TaskProfile,
|
|
19
|
+
)
|
|
20
|
+
from .protocols import (
|
|
21
|
+
ContextProvider,
|
|
22
|
+
LLMInvoke,
|
|
23
|
+
Saver,
|
|
24
|
+
SupportsDescribe,
|
|
25
|
+
SupportsFilter,
|
|
26
|
+
Verifier,
|
|
27
|
+
)
|
|
28
|
+
from .utils import load_pkg_text, render_prompt
|
|
29
|
+
|
|
30
|
+
__all__ = [
|
|
31
|
+
"ContextPacker",
|
|
32
|
+
"BaseGraphAgent",
|
|
33
|
+
"create_generic_agent",
|
|
34
|
+
"make_llm_plan_generic",
|
|
35
|
+
"make_llm_synth_generic",
|
|
36
|
+
"RawLLMOutput",
|
|
37
|
+
"ProviderInfo",
|
|
38
|
+
"TaskProfile",
|
|
39
|
+
"ContextFetchSpec",
|
|
40
|
+
"BaselineSpec",
|
|
41
|
+
"ContextItem",
|
|
42
|
+
"RefetchDecision",
|
|
43
|
+
"Plan",
|
|
44
|
+
"ContextProvider",
|
|
45
|
+
"SupportsFilter",
|
|
46
|
+
"SupportsDescribe",
|
|
47
|
+
"Verifier",
|
|
48
|
+
"Saver",
|
|
49
|
+
"LLMInvoke",
|
|
50
|
+
"load_pkg_text",
|
|
51
|
+
"render_prompt",
|
|
52
|
+
]
|
|
@@ -3,8 +3,9 @@ from __future__ import annotations
|
|
|
3
3
|
import json
|
|
4
4
|
import logging
|
|
5
5
|
import time
|
|
6
|
-
from typing import Any, Dict, List, Optional
|
|
6
|
+
from typing import Any, Callable, Dict, List, Optional
|
|
7
7
|
|
|
8
|
+
from ..parsing.plan_parser import PlanParser
|
|
8
9
|
from .models import (
|
|
9
10
|
BaselineSpec,
|
|
10
11
|
ContextFetchSpec,
|
|
@@ -16,7 +17,6 @@ from .models import (
|
|
|
16
17
|
RefetchDecision,
|
|
17
18
|
TaskProfile,
|
|
18
19
|
)
|
|
19
|
-
from .parsing.plan_parser import PlanParser
|
|
20
20
|
from .protocols import (
|
|
21
21
|
ContextProvider,
|
|
22
22
|
LLMInvoke,
|
|
@@ -449,6 +449,13 @@ class BaseGraphAgent:
|
|
|
449
449
|
plan.required_context,
|
|
450
450
|
len(plan.context_plan or []),
|
|
451
451
|
)
|
|
452
|
+
logger.debug(
|
|
453
|
+
"Plan built for feature_name=%r (providers=%s, steps=%d)",
|
|
454
|
+
feature_name,
|
|
455
|
+
plan.required_context,
|
|
456
|
+
len(plan.context_plan or []),
|
|
457
|
+
)
|
|
458
|
+
logger.debug("Plan JSON for feature_name=%r: %s", feature_name, plan.model_dump_json())
|
|
452
459
|
logger.debug(
|
|
453
460
|
"Raw plan text for feature_name=%r (chars=%d)",
|
|
454
461
|
feature_name,
|
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
from typing import
|
|
3
|
+
from typing import (
|
|
4
|
+
TYPE_CHECKING,
|
|
5
|
+
Any,
|
|
6
|
+
Dict,
|
|
7
|
+
List,
|
|
8
|
+
Optional,
|
|
9
|
+
Protocol,
|
|
10
|
+
overload,
|
|
11
|
+
runtime_checkable,
|
|
12
|
+
)
|
|
4
13
|
|
|
5
14
|
from .models import ProviderInfo, RawLLMOutput
|
|
6
|
-
|
|
15
|
+
|
|
16
|
+
if TYPE_CHECKING:
|
|
17
|
+
from ..relational.types import SelectorsDict
|
|
18
|
+
else:
|
|
19
|
+
SelectorsDict = Dict[str, Any]
|
|
7
20
|
|
|
8
21
|
|
|
9
22
|
class LLMInvoke(Protocol):
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
|
+
|
|
2
3
|
from importlib import resources
|
|
3
4
|
|
|
5
|
+
|
|
4
6
|
def load_pkg_text(rel_path: str) -> str:
|
|
5
7
|
"""Read a text resource from package (e.g., 'prompts/plan_generic.md')."""
|
|
6
8
|
with resources.files("fetchgraph").joinpath(rel_path).open("r", encoding="utf-8") as f:
|
|
@@ -2,9 +2,9 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from typing import Any, Dict, List
|
|
4
4
|
|
|
5
|
-
from ..models import
|
|
6
|
-
from .json_parser import JsonParser
|
|
5
|
+
from ..core.models import ContextFetchSpec, Plan, RawLLMOutput
|
|
7
6
|
from .exceptions import OutputParserException
|
|
7
|
+
from .json_parser import JsonParser
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
class PlanParser(JsonParser[Plan]):
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Non-relational providers live here."""
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"""Relational providers and helpers."""
|
|
2
|
+
|
|
3
|
+
from .models import (
|
|
4
|
+
AggregationResult,
|
|
5
|
+
AggregationSpec,
|
|
6
|
+
ColumnDescriptor,
|
|
7
|
+
ComparisonFilter,
|
|
8
|
+
ComparisonOp,
|
|
9
|
+
EntityDescriptor,
|
|
10
|
+
FilterClause,
|
|
11
|
+
GroupBySpec,
|
|
12
|
+
LogicalFilter,
|
|
13
|
+
RelatedEntityData,
|
|
14
|
+
RelationalQuery,
|
|
15
|
+
RelationalRequest,
|
|
16
|
+
RelationalResponse,
|
|
17
|
+
RelationDescriptor,
|
|
18
|
+
RelationJoin,
|
|
19
|
+
RowResult,
|
|
20
|
+
SchemaRequest,
|
|
21
|
+
SchemaResult,
|
|
22
|
+
SelectExpr,
|
|
23
|
+
SemanticClause,
|
|
24
|
+
SemanticMatch,
|
|
25
|
+
SemanticOnlyRequest,
|
|
26
|
+
SemanticOnlyResult,
|
|
27
|
+
)
|
|
28
|
+
from .providers import (
|
|
29
|
+
CompositeRelationalProvider,
|
|
30
|
+
PandasRelationalDataProvider,
|
|
31
|
+
RelationalDataProvider,
|
|
32
|
+
SqlRelationalDataProvider,
|
|
33
|
+
)
|
|
34
|
+
from .semantic import (
|
|
35
|
+
CsvEmbeddingBuilder,
|
|
36
|
+
CsvSemanticBackend,
|
|
37
|
+
CsvSemanticSource,
|
|
38
|
+
PgVectorSemanticBackend,
|
|
39
|
+
PgVectorSemanticSource,
|
|
40
|
+
SemanticBackend,
|
|
41
|
+
VectorStoreLike,
|
|
42
|
+
)
|
|
43
|
+
from .types import SelectorsDict
|
|
44
|
+
|
|
45
|
+
__all__ = (
|
|
46
|
+
"AggregationResult",
|
|
47
|
+
"AggregationSpec",
|
|
48
|
+
"ColumnDescriptor",
|
|
49
|
+
"ComparisonFilter",
|
|
50
|
+
"ComparisonOp",
|
|
51
|
+
"EntityDescriptor",
|
|
52
|
+
"FilterClause",
|
|
53
|
+
"GroupBySpec",
|
|
54
|
+
"LogicalFilter",
|
|
55
|
+
"RelatedEntityData",
|
|
56
|
+
"RelationDescriptor",
|
|
57
|
+
"RelationJoin",
|
|
58
|
+
"RelationalQuery",
|
|
59
|
+
"RelationalRequest",
|
|
60
|
+
"RelationalResponse",
|
|
61
|
+
"RowResult",
|
|
62
|
+
"SchemaRequest",
|
|
63
|
+
"SchemaResult",
|
|
64
|
+
"SelectExpr",
|
|
65
|
+
"SelectorsDict",
|
|
66
|
+
"SemanticClause",
|
|
67
|
+
"SemanticMatch",
|
|
68
|
+
"SemanticOnlyRequest",
|
|
69
|
+
"SemanticOnlyResult",
|
|
70
|
+
"RelationalDataProvider",
|
|
71
|
+
"SqlRelationalDataProvider",
|
|
72
|
+
"CompositeRelationalProvider",
|
|
73
|
+
"SemanticBackend",
|
|
74
|
+
"CsvSemanticBackend",
|
|
75
|
+
"CsvSemanticSource",
|
|
76
|
+
"CsvEmbeddingBuilder",
|
|
77
|
+
"PgVectorSemanticBackend",
|
|
78
|
+
"PgVectorSemanticSource",
|
|
79
|
+
"VectorStoreLike",
|
|
80
|
+
"PandasRelationalDataProvider",
|
|
81
|
+
)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Relational DSL components (parsing, AST, compilation)."""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""Relational data providers."""
|
|
2
|
+
|
|
3
|
+
from .base import RelationalDataProvider
|
|
4
|
+
from .composite_provider import CompositeRelationalProvider
|
|
5
|
+
from .pandas_provider import PandasRelationalDataProvider
|
|
6
|
+
from .sql_provider import SqlRelationalDataProvider
|
|
7
|
+
|
|
8
|
+
__all__ = (
|
|
9
|
+
"RelationalDataProvider",
|
|
10
|
+
"CompositeRelationalProvider",
|
|
11
|
+
"SqlRelationalDataProvider",
|
|
12
|
+
"PandasRelationalDataProvider",
|
|
13
|
+
)
|
|
@@ -2,22 +2,23 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
"""Base relational provider abstraction."""
|
|
4
4
|
|
|
5
|
-
from typing import Any, List, Optional
|
|
6
5
|
import json
|
|
7
6
|
import re
|
|
7
|
+
from typing import Any, List, Optional
|
|
8
8
|
|
|
9
|
-
from .
|
|
10
|
-
from .
|
|
11
|
-
from
|
|
9
|
+
from ...core.models import ProviderInfo
|
|
10
|
+
from ...core.protocols import ContextProvider, SupportsDescribe
|
|
11
|
+
from ..models import (
|
|
12
|
+
EntityDescriptor,
|
|
12
13
|
QueryResult,
|
|
13
14
|
RelationalQuery,
|
|
15
|
+
RelationDescriptor,
|
|
14
16
|
SchemaRequest,
|
|
15
17
|
SchemaResult,
|
|
16
18
|
SemanticOnlyRequest,
|
|
17
19
|
SemanticOnlyResult,
|
|
18
|
-
EntityDescriptor,
|
|
19
|
-
RelationDescriptor,
|
|
20
20
|
)
|
|
21
|
+
from ..types import SelectorsDict
|
|
21
22
|
|
|
22
23
|
|
|
23
24
|
class RelationalDataProvider(ContextProvider, SupportsDescribe):
|
|
@@ -4,9 +4,7 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
from typing import Any, Dict, List, Optional, Set, Tuple
|
|
6
6
|
|
|
7
|
-
from
|
|
8
|
-
from .relational_base import RelationalDataProvider
|
|
9
|
-
from .relational_models import (
|
|
7
|
+
from ..models import (
|
|
10
8
|
AggregationResult,
|
|
11
9
|
AggregationSpec,
|
|
12
10
|
ComparisonFilter,
|
|
@@ -15,12 +13,14 @@ from .relational_models import (
|
|
|
15
13
|
GroupBySpec,
|
|
16
14
|
LogicalFilter,
|
|
17
15
|
QueryResult,
|
|
18
|
-
RelationDescriptor,
|
|
19
16
|
RelationalQuery,
|
|
17
|
+
RelationDescriptor,
|
|
20
18
|
RowResult,
|
|
21
19
|
SemanticOnlyRequest,
|
|
22
20
|
SemanticOnlyResult,
|
|
23
21
|
)
|
|
22
|
+
from ..types import SelectorsDict
|
|
23
|
+
from .base import RelationalDataProvider
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
class CompositeRelationalProvider(RelationalDataProvider):
|
|
@@ -259,12 +259,14 @@ class CompositeRelationalProvider(RelationalDataProvider):
|
|
|
259
259
|
left_rows, req, cross_relation, root_provider_name, feature_name, **kwargs
|
|
260
260
|
)
|
|
261
261
|
|
|
262
|
+
batch_start_len = len(all_rows)
|
|
262
263
|
for row in joined_rows:
|
|
263
|
-
if remaining is not None and len(all_rows) >=
|
|
264
|
+
if remaining is not None and len(all_rows) >= remaining:
|
|
264
265
|
break
|
|
265
266
|
all_rows.append(row)
|
|
266
267
|
if remaining is not None:
|
|
267
|
-
|
|
268
|
+
added = len(all_rows) - batch_start_len
|
|
269
|
+
remaining = remaining - added
|
|
268
270
|
if remaining <= 0:
|
|
269
271
|
break
|
|
270
272
|
# NOTE: offset and limit are applied to the root-entity rows prior to
|