piglets 0.1.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.
piglets-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,29 @@
1
+ Metadata-Version: 2.4
2
+ Name: piglets
3
+ Version: 0.1.0
4
+ Summary: A modular text-to-SQL toolkit.
5
+ Requires-Python: >=3.10
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: langchain>=1.0
8
+ Provides-Extra: openai
9
+ Requires-Dist: langchain-openai>=1.0; extra == "openai"
10
+
11
+ # 🐷 piglets
12
+
13
+ A modular, pre-1.0 library of text-to-SQL planning tools.
14
+
15
+ ## Status
16
+
17
+ `piglets` is currently an **alpha-stage** package. The API is expected to evolve before `1.0`.
18
+
19
+ ## Current scope
20
+
21
+ ### Planning
22
+
23
+ The first included primitive is a `LogicalPlanner` that turns a natural-language analytics question into an ordered list of abstract logical steps.
24
+
25
+ This keeps planning at the business-logic level before later schema grounding or SQL generation.
26
+
27
+ ### Pruning
28
+
29
+ Pruning components are planned but not included yet.
@@ -0,0 +1,19 @@
1
+ # 🐷 piglets
2
+
3
+ A modular, pre-1.0 library of text-to-SQL planning tools.
4
+
5
+ ## Status
6
+
7
+ `piglets` is currently an **alpha-stage** package. The API is expected to evolve before `1.0`.
8
+
9
+ ## Current scope
10
+
11
+ ### Planning
12
+
13
+ The first included primitive is a `LogicalPlanner` that turns a natural-language analytics question into an ordered list of abstract logical steps.
14
+
15
+ This keeps planning at the business-logic level before later schema grounding or SQL generation.
16
+
17
+ ### Pruning
18
+
19
+ Pruning components are planned but not included yet.
@@ -0,0 +1,34 @@
1
+ [project]
2
+ name = "piglets"
3
+ version = "0.1.0"
4
+ description = "A modular text-to-SQL toolkit."
5
+ readme = "README.md"
6
+ requires-python = ">=3.10"
7
+ dependencies = [
8
+ "langchain>=1.0",
9
+ ]
10
+
11
+ [project.optional-dependencies]
12
+ openai = [
13
+ "langchain-openai>=1.0",
14
+ ]
15
+
16
+ [dependency-groups]
17
+ dev = [
18
+ "build>=1.4.3",
19
+ "twine>=6.2.0",
20
+ ]
21
+ test = [
22
+ "pytest>=8.0",
23
+ "langchain-openai>=1.0"
24
+ ]
25
+
26
+ [tool.setuptools]
27
+ package-dir = {"" = "src"}
28
+
29
+ [tool.setuptools.packages.find]
30
+ where = ["src"]
31
+
32
+ [tool.pytest.ini_options]
33
+ testpaths = ["tests"]
34
+ addopts = ["-ra"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,7 @@
1
+ from .planning import LogicalPlanner as LogicalPlanner
2
+ from .types import LogicalPlan as LogicalPlan
3
+
4
+ __all__ = [
5
+ "LogicalPlan",
6
+ "LogicalPlanner",
7
+ ]
@@ -0,0 +1,5 @@
1
+ from .logical_planning import LogicalPlanner as LogicalPlanner
2
+
3
+ __all__ = [
4
+ "LogicalPlanner"
5
+ ]
@@ -0,0 +1,5 @@
1
+ from .logical_planner import LogicalPlanner as LogicalPlanner
2
+
3
+ __all__ = [
4
+ "LogicalPlanner"
5
+ ]
@@ -0,0 +1,17 @@
1
+ from pathlib import Path
2
+ from langchain.chat_models import init_chat_model
3
+
4
+ from piglets.types import LogicalPlan
5
+ from piglets.utils import read_markdown_file
6
+
7
+ class LogicalPlanner():
8
+ def __init__(self, model_name: str):
9
+ file_path = Path(__file__).with_suffix(".md").resolve()
10
+ self.system_instruction = read_markdown_file(file_path=file_path)
11
+
12
+ llm = init_chat_model(model_name)
13
+ llm = llm.with_structured_output(LogicalPlan)
14
+ self.llm = llm
15
+
16
+ def plan(self, natural_language_query: str) -> LogicalPlan:
17
+ return self.llm.invoke(f"{self.system_instruction} \nUser question: {natural_language_query}")
@@ -0,0 +1,5 @@
1
+ from .plans import LogicalPlan as LogicalPlan
2
+
3
+ __all__ = [
4
+ "LogicalPlan"
5
+ ]
@@ -0,0 +1,5 @@
1
+ from typing import TypedDict
2
+
3
+ class LogicalPlan(TypedDict):
4
+ """A logical plan for how to answer a natural language query."""
5
+ logical_steps: list[str]
@@ -0,0 +1,5 @@
1
+ from .mardown_handling import read_markdown_file as read_markdown_file
2
+
3
+ __all__ = [
4
+ "read_markdown_file"
5
+ ]
@@ -0,0 +1,4 @@
1
+ from pathlib import Path
2
+
3
+ def read_markdown_file(file_path: Path) -> str:
4
+ return file_path.read_text(encoding="utf-8")
@@ -0,0 +1,29 @@
1
+ Metadata-Version: 2.4
2
+ Name: piglets
3
+ Version: 0.1.0
4
+ Summary: A modular text-to-SQL toolkit.
5
+ Requires-Python: >=3.10
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: langchain>=1.0
8
+ Provides-Extra: openai
9
+ Requires-Dist: langchain-openai>=1.0; extra == "openai"
10
+
11
+ # 🐷 piglets
12
+
13
+ A modular, pre-1.0 library of text-to-SQL planning tools.
14
+
15
+ ## Status
16
+
17
+ `piglets` is currently an **alpha-stage** package. The API is expected to evolve before `1.0`.
18
+
19
+ ## Current scope
20
+
21
+ ### Planning
22
+
23
+ The first included primitive is a `LogicalPlanner` that turns a natural-language analytics question into an ordered list of abstract logical steps.
24
+
25
+ This keeps planning at the business-logic level before later schema grounding or SQL generation.
26
+
27
+ ### Pruning
28
+
29
+ Pruning components are planned but not included yet.
@@ -0,0 +1,15 @@
1
+ README.md
2
+ pyproject.toml
3
+ src/piglets/__init__.py
4
+ src/piglets.egg-info/PKG-INFO
5
+ src/piglets.egg-info/SOURCES.txt
6
+ src/piglets.egg-info/dependency_links.txt
7
+ src/piglets.egg-info/requires.txt
8
+ src/piglets.egg-info/top_level.txt
9
+ src/piglets/planning/__init__.py
10
+ src/piglets/planning/logical_planning/__init__.py
11
+ src/piglets/planning/logical_planning/logical_planner.py
12
+ src/piglets/types/__init__.py
13
+ src/piglets/types/plans.py
14
+ src/piglets/utils/__init__.py
15
+ src/piglets/utils/mardown_handling.py
@@ -0,0 +1,4 @@
1
+ langchain>=1.0
2
+
3
+ [openai]
4
+ langchain-openai>=1.0
@@ -0,0 +1 @@
1
+ piglets