piglets 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.
- piglets/__init__.py +7 -0
- piglets/planning/__init__.py +5 -0
- piglets/planning/logical_planning/__init__.py +5 -0
- piglets/planning/logical_planning/logical_planner.py +17 -0
- piglets/types/__init__.py +5 -0
- piglets/types/plans.py +5 -0
- piglets/utils/__init__.py +5 -0
- piglets/utils/mardown_handling.py +4 -0
- piglets-0.1.0.dist-info/METADATA +29 -0
- piglets-0.1.0.dist-info/RECORD +12 -0
- piglets-0.1.0.dist-info/WHEEL +5 -0
- piglets-0.1.0.dist-info/top_level.txt +1 -0
piglets/__init__.py
ADDED
|
@@ -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}")
|
piglets/types/plans.py
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,12 @@
|
|
|
1
|
+
piglets/__init__.py,sha256=PNNFVoGd4R6yNvSV-2TdS2cei2QXprgswqL9vl0X5O4,156
|
|
2
|
+
piglets/planning/__init__.py,sha256=nTwVulVR7jQ7I5TTGdtDxfFodC46WdGYFVEIbJY3-uo,98
|
|
3
|
+
piglets/planning/logical_planning/__init__.py,sha256=KLKNsvhraKn3tscwMmJUHZtOnlfIz6LflR6jm3OMYAg,97
|
|
4
|
+
piglets/planning/logical_planning/logical_planner.py,sha256=rRolhxVDsgH285BDLEP4rncRVFDzIc_a0KpUrXXYOC0,650
|
|
5
|
+
piglets/types/__init__.py,sha256=vb57W3R4JjAg5T4a3XBzzuSyFSnpJjg64U3pv5q4ydk,78
|
|
6
|
+
piglets/types/plans.py,sha256=gJ8DN9WJrdwWrZnynj4LbD63TorieiN7btBuHiyOtAw,157
|
|
7
|
+
piglets/utils/__init__.py,sha256=ApkNLewpgD17MEm88OaaKRpOxPFYSoMJFc6bKy-y_y8,110
|
|
8
|
+
piglets/utils/mardown_handling.py,sha256=Omwh9jJshutRaj2WCCjgpdmHNjwLSrpH7Je3exnnGiE,123
|
|
9
|
+
piglets-0.1.0.dist-info/METADATA,sha256=B6GbPsXbHXXIdMzC-af4S_njJr4EXpdjKI9zZldz0HU,792
|
|
10
|
+
piglets-0.1.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
11
|
+
piglets-0.1.0.dist-info/top_level.txt,sha256=9jlI4jWtCYTI5JQRBreB3QgYSdULNisQGqhjyA24M0A,8
|
|
12
|
+
piglets-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
piglets
|