npcpy 1.0.26__py3-none-any.whl → 1.2.32__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.
- npcpy/__init__.py +0 -7
- npcpy/data/audio.py +16 -99
- npcpy/data/image.py +43 -42
- npcpy/data/load.py +83 -124
- npcpy/data/text.py +28 -28
- npcpy/data/video.py +8 -32
- npcpy/data/web.py +51 -23
- npcpy/ft/diff.py +110 -0
- npcpy/ft/ge.py +115 -0
- npcpy/ft/memory_trainer.py +171 -0
- npcpy/ft/model_ensembler.py +357 -0
- npcpy/ft/rl.py +360 -0
- npcpy/ft/sft.py +248 -0
- npcpy/ft/usft.py +128 -0
- npcpy/gen/audio_gen.py +24 -0
- npcpy/gen/embeddings.py +13 -13
- npcpy/gen/image_gen.py +262 -117
- npcpy/gen/response.py +615 -415
- npcpy/gen/video_gen.py +53 -7
- npcpy/llm_funcs.py +1869 -437
- npcpy/main.py +1 -1
- npcpy/memory/command_history.py +844 -510
- npcpy/memory/kg_vis.py +833 -0
- npcpy/memory/knowledge_graph.py +892 -1845
- npcpy/memory/memory_processor.py +81 -0
- npcpy/memory/search.py +188 -90
- npcpy/mix/debate.py +192 -3
- npcpy/npc_compiler.py +1672 -801
- npcpy/npc_sysenv.py +593 -1266
- npcpy/serve.py +3120 -0
- npcpy/sql/ai_function_tools.py +257 -0
- npcpy/sql/database_ai_adapters.py +186 -0
- npcpy/sql/database_ai_functions.py +163 -0
- npcpy/sql/model_runner.py +19 -19
- npcpy/sql/npcsql.py +706 -507
- npcpy/sql/sql_model_compiler.py +156 -0
- npcpy/tools.py +183 -0
- npcpy/work/plan.py +13 -279
- npcpy/work/trigger.py +3 -3
- npcpy-1.2.32.dist-info/METADATA +803 -0
- npcpy-1.2.32.dist-info/RECORD +54 -0
- npcpy/data/dataframes.py +0 -171
- npcpy/memory/deep_research.py +0 -125
- npcpy/memory/sleep.py +0 -557
- npcpy/modes/_state.py +0 -78
- npcpy/modes/alicanto.py +0 -1075
- npcpy/modes/guac.py +0 -785
- npcpy/modes/mcp_npcsh.py +0 -822
- npcpy/modes/npc.py +0 -213
- npcpy/modes/npcsh.py +0 -1158
- npcpy/modes/plonk.py +0 -409
- npcpy/modes/pti.py +0 -234
- npcpy/modes/serve.py +0 -1637
- npcpy/modes/spool.py +0 -312
- npcpy/modes/wander.py +0 -549
- npcpy/modes/yap.py +0 -572
- npcpy/npc_team/alicanto.npc +0 -2
- npcpy/npc_team/alicanto.png +0 -0
- npcpy/npc_team/assembly_lines/test_pipeline.py +0 -181
- npcpy/npc_team/corca.npc +0 -13
- npcpy/npc_team/foreman.npc +0 -7
- npcpy/npc_team/frederic.npc +0 -6
- npcpy/npc_team/frederic4.png +0 -0
- npcpy/npc_team/guac.png +0 -0
- npcpy/npc_team/jinxs/automator.jinx +0 -18
- npcpy/npc_team/jinxs/bash_executer.jinx +0 -31
- npcpy/npc_team/jinxs/calculator.jinx +0 -11
- npcpy/npc_team/jinxs/edit_file.jinx +0 -96
- npcpy/npc_team/jinxs/file_chat.jinx +0 -14
- npcpy/npc_team/jinxs/gui_controller.jinx +0 -28
- npcpy/npc_team/jinxs/image_generation.jinx +0 -29
- npcpy/npc_team/jinxs/internet_search.jinx +0 -30
- npcpy/npc_team/jinxs/local_search.jinx +0 -152
- npcpy/npc_team/jinxs/npcsh_executor.jinx +0 -31
- npcpy/npc_team/jinxs/python_executor.jinx +0 -8
- npcpy/npc_team/jinxs/screen_cap.jinx +0 -25
- npcpy/npc_team/jinxs/sql_executor.jinx +0 -33
- npcpy/npc_team/kadiefa.npc +0 -3
- npcpy/npc_team/kadiefa.png +0 -0
- npcpy/npc_team/npcsh.ctx +0 -9
- npcpy/npc_team/npcsh_sibiji.png +0 -0
- npcpy/npc_team/plonk.npc +0 -2
- npcpy/npc_team/plonk.png +0 -0
- npcpy/npc_team/plonkjr.npc +0 -2
- npcpy/npc_team/plonkjr.png +0 -0
- npcpy/npc_team/sibiji.npc +0 -5
- npcpy/npc_team/sibiji.png +0 -0
- npcpy/npc_team/spool.png +0 -0
- npcpy/npc_team/templates/analytics/celona.npc +0 -0
- npcpy/npc_team/templates/hr_support/raone.npc +0 -0
- npcpy/npc_team/templates/humanities/eriane.npc +0 -4
- npcpy/npc_team/templates/it_support/lineru.npc +0 -0
- npcpy/npc_team/templates/marketing/slean.npc +0 -4
- npcpy/npc_team/templates/philosophy/maurawa.npc +0 -0
- npcpy/npc_team/templates/sales/turnic.npc +0 -4
- npcpy/npc_team/templates/software/welxor.npc +0 -0
- npcpy/npc_team/yap.png +0 -0
- npcpy/routes.py +0 -958
- npcpy/work/mcp_helpers.py +0 -357
- npcpy/work/mcp_server.py +0 -194
- npcpy-1.0.26.data/data/npcpy/npc_team/alicanto.npc +0 -2
- npcpy-1.0.26.data/data/npcpy/npc_team/alicanto.png +0 -0
- npcpy-1.0.26.data/data/npcpy/npc_team/automator.jinx +0 -18
- npcpy-1.0.26.data/data/npcpy/npc_team/bash_executer.jinx +0 -31
- npcpy-1.0.26.data/data/npcpy/npc_team/calculator.jinx +0 -11
- npcpy-1.0.26.data/data/npcpy/npc_team/celona.npc +0 -0
- npcpy-1.0.26.data/data/npcpy/npc_team/corca.npc +0 -13
- npcpy-1.0.26.data/data/npcpy/npc_team/edit_file.jinx +0 -96
- npcpy-1.0.26.data/data/npcpy/npc_team/eriane.npc +0 -4
- npcpy-1.0.26.data/data/npcpy/npc_team/file_chat.jinx +0 -14
- npcpy-1.0.26.data/data/npcpy/npc_team/foreman.npc +0 -7
- npcpy-1.0.26.data/data/npcpy/npc_team/frederic.npc +0 -6
- npcpy-1.0.26.data/data/npcpy/npc_team/frederic4.png +0 -0
- npcpy-1.0.26.data/data/npcpy/npc_team/guac.png +0 -0
- npcpy-1.0.26.data/data/npcpy/npc_team/gui_controller.jinx +0 -28
- npcpy-1.0.26.data/data/npcpy/npc_team/image_generation.jinx +0 -29
- npcpy-1.0.26.data/data/npcpy/npc_team/internet_search.jinx +0 -30
- npcpy-1.0.26.data/data/npcpy/npc_team/kadiefa.npc +0 -3
- npcpy-1.0.26.data/data/npcpy/npc_team/kadiefa.png +0 -0
- npcpy-1.0.26.data/data/npcpy/npc_team/lineru.npc +0 -0
- npcpy-1.0.26.data/data/npcpy/npc_team/local_search.jinx +0 -152
- npcpy-1.0.26.data/data/npcpy/npc_team/maurawa.npc +0 -0
- npcpy-1.0.26.data/data/npcpy/npc_team/npcsh.ctx +0 -9
- npcpy-1.0.26.data/data/npcpy/npc_team/npcsh_executor.jinx +0 -31
- npcpy-1.0.26.data/data/npcpy/npc_team/npcsh_sibiji.png +0 -0
- npcpy-1.0.26.data/data/npcpy/npc_team/plonk.npc +0 -2
- npcpy-1.0.26.data/data/npcpy/npc_team/plonk.png +0 -0
- npcpy-1.0.26.data/data/npcpy/npc_team/plonkjr.npc +0 -2
- npcpy-1.0.26.data/data/npcpy/npc_team/plonkjr.png +0 -0
- npcpy-1.0.26.data/data/npcpy/npc_team/python_executor.jinx +0 -8
- npcpy-1.0.26.data/data/npcpy/npc_team/raone.npc +0 -0
- npcpy-1.0.26.data/data/npcpy/npc_team/screen_cap.jinx +0 -25
- npcpy-1.0.26.data/data/npcpy/npc_team/sibiji.npc +0 -5
- npcpy-1.0.26.data/data/npcpy/npc_team/sibiji.png +0 -0
- npcpy-1.0.26.data/data/npcpy/npc_team/slean.npc +0 -4
- npcpy-1.0.26.data/data/npcpy/npc_team/spool.png +0 -0
- npcpy-1.0.26.data/data/npcpy/npc_team/sql_executor.jinx +0 -33
- npcpy-1.0.26.data/data/npcpy/npc_team/test_pipeline.py +0 -181
- npcpy-1.0.26.data/data/npcpy/npc_team/turnic.npc +0 -4
- npcpy-1.0.26.data/data/npcpy/npc_team/welxor.npc +0 -0
- npcpy-1.0.26.data/data/npcpy/npc_team/yap.png +0 -0
- npcpy-1.0.26.dist-info/METADATA +0 -827
- npcpy-1.0.26.dist-info/RECORD +0 -139
- npcpy-1.0.26.dist-info/entry_points.txt +0 -11
- /npcpy/{modes → ft}/__init__.py +0 -0
- {npcpy-1.0.26.dist-info → npcpy-1.2.32.dist-info}/WHEEL +0 -0
- {npcpy-1.0.26.dist-info → npcpy-1.2.32.dist-info}/licenses/LICENSE +0 -0
- {npcpy-1.0.26.dist-info → npcpy-1.2.32.dist-info}/top_level.txt +0 -0
npcpy/sql/model_runner.py
CHANGED
|
@@ -35,7 +35,7 @@ class NPCModelRunner:
|
|
|
35
35
|
)
|
|
36
36
|
|
|
37
37
|
def _load_sample_data(self):
|
|
38
|
-
|
|
38
|
+
|
|
39
39
|
return pd.DataFrame(
|
|
40
40
|
{
|
|
41
41
|
"customer_id": range(1, 4),
|
|
@@ -50,32 +50,32 @@ class NPCModelRunner:
|
|
|
50
50
|
|
|
51
51
|
def run_model(self, model_name: str, model_sql: str, sample_data=None):
|
|
52
52
|
try:
|
|
53
|
-
|
|
53
|
+
|
|
54
54
|
if sample_data is None:
|
|
55
55
|
raw_data = self._load_sample_data()
|
|
56
56
|
else:
|
|
57
57
|
raw_data = sample_data
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
|
|
60
60
|
self.model_registry["raw_customer_feedback"] = raw_data
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
|
|
63
63
|
if "{{ ref(" in model_sql:
|
|
64
|
-
|
|
64
|
+
|
|
65
65
|
for dep in self._extract_dependencies(model_sql):
|
|
66
66
|
if dep not in self.model_registry:
|
|
67
67
|
raise ValueError(f"Dependent model {dep} not found")
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
|
|
70
70
|
model_sql = self._resolve_refs(model_sql)
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
|
|
73
73
|
result_df = self._execute_model(model_sql)
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
|
|
76
76
|
self.model_registry[model_name] = result_df
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
|
|
79
79
|
self._log_model_run(model_name, result_df)
|
|
80
80
|
|
|
81
81
|
return result_df
|
|
@@ -85,8 +85,8 @@ class NPCModelRunner:
|
|
|
85
85
|
raise e
|
|
86
86
|
|
|
87
87
|
def _execute_model(self, model_sql: str) -> pd.DataFrame:
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
|
|
89
|
+
|
|
90
90
|
|
|
91
91
|
if "synthesize(" in model_sql:
|
|
92
92
|
raw_data = self.model_registry["raw_customer_feedback"]
|
|
@@ -109,7 +109,7 @@ class NPCModelRunner:
|
|
|
109
109
|
context=self._load_vars()["business_context"],
|
|
110
110
|
)
|
|
111
111
|
|
|
112
|
-
return pd.DataFrame()
|
|
112
|
+
return pd.DataFrame()
|
|
113
113
|
|
|
114
114
|
def _log_model_run(self, model_name: str, result_df, status="success", error=None):
|
|
115
115
|
with sqlite3.connect(self.history_db) as conn:
|
|
@@ -139,14 +139,14 @@ class NPCModelRunner:
|
|
|
139
139
|
return yaml.safe_load(f).get("vars", {})
|
|
140
140
|
|
|
141
141
|
def _extract_dependencies(self, model_sql: str) -> List[str]:
|
|
142
|
-
|
|
142
|
+
|
|
143
143
|
import re
|
|
144
144
|
|
|
145
145
|
refs = re.findall(r'{{\s*ref\([\'"](.+?)[\'"]\)\s*}}', model_sql)
|
|
146
146
|
return refs
|
|
147
147
|
|
|
148
148
|
def _resolve_refs(self, model_sql: str) -> str:
|
|
149
|
-
|
|
149
|
+
|
|
150
150
|
import re
|
|
151
151
|
|
|
152
152
|
def replace_ref(match):
|
|
@@ -158,25 +158,25 @@ class NPCModelRunner:
|
|
|
158
158
|
return re.sub(r'{{\s*ref\([\'"](.+?)[\'"]\)\s*}}', replace_ref, model_sql)
|
|
159
159
|
|
|
160
160
|
|
|
161
|
-
|
|
161
|
+
|
|
162
162
|
def main():
|
|
163
|
-
|
|
163
|
+
|
|
164
164
|
|
|
165
165
|
runner = NPCModelRunner(npc_compiler)
|
|
166
166
|
|
|
167
|
-
|
|
167
|
+
|
|
168
168
|
with open("models/customer_feedback.sql", "r") as f:
|
|
169
169
|
feedback_model = runner.run_model("customer_feedback", f.read())
|
|
170
170
|
print("First model results:")
|
|
171
171
|
print(feedback_model.head())
|
|
172
172
|
|
|
173
|
-
|
|
173
|
+
|
|
174
174
|
with open("models/customer_insights.sql", "r") as f:
|
|
175
175
|
insights_model = runner.run_model("customer_insights", f.read())
|
|
176
176
|
print("\nSecond model results:")
|
|
177
177
|
print(insights_model.head())
|
|
178
178
|
|
|
179
|
-
|
|
179
|
+
|
|
180
180
|
with sqlite3.connect(runner.history_db) as conn:
|
|
181
181
|
history = pd.read_sql(
|
|
182
182
|
"SELECT * FROM model_runs ORDER BY run_timestamp DESC", conn
|