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/modes/npc.py
DELETED
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
import argparse
|
|
2
|
-
import sys
|
|
3
|
-
import os
|
|
4
|
-
import sqlite3
|
|
5
|
-
import traceback
|
|
6
|
-
from typing import Optional
|
|
7
|
-
|
|
8
|
-
from npcpy.npc_sysenv import (
|
|
9
|
-
NPCSH_CHAT_MODEL, NPCSH_CHAT_PROVIDER,
|
|
10
|
-
NPCSH_API_URL, NPCSH_DB_PATH, NPCSH_STREAM_OUTPUT,
|
|
11
|
-
print_and_process_stream_with_markdown,
|
|
12
|
-
render_markdown,
|
|
13
|
-
)
|
|
14
|
-
from npcpy.npc_compiler import NPC, Team
|
|
15
|
-
from npcpy.routes import router
|
|
16
|
-
from npcpy.llm_funcs import check_llm_command
|
|
17
|
-
|
|
18
|
-
def load_npc_by_name(npc_name: str = "sibiji", db_path: str = NPCSH_DB_PATH) -> Optional[NPC]:
|
|
19
|
-
if not npc_name:
|
|
20
|
-
npc_name = "sibiji"
|
|
21
|
-
|
|
22
|
-
project_npc_path = os.path.abspath(f"./npc_team/{npc_name}.npc")
|
|
23
|
-
global_npc_path = os.path.expanduser(f"~/.npcsh/npc_team/{npc_name}.npc")
|
|
24
|
-
|
|
25
|
-
chosen_path = None
|
|
26
|
-
if os.path.exists(project_npc_path):
|
|
27
|
-
chosen_path = project_npc_path
|
|
28
|
-
elif os.path.exists(global_npc_path):
|
|
29
|
-
chosen_path = global_npc_path
|
|
30
|
-
elif os.path.exists(f"npcs/{npc_name}.npc"):
|
|
31
|
-
chosen_path = f"npcs/{npc_name}.npc"
|
|
32
|
-
|
|
33
|
-
if chosen_path:
|
|
34
|
-
try:
|
|
35
|
-
db_conn = sqlite3.connect(db_path)
|
|
36
|
-
npc = NPC(file=chosen_path, db_conn=db_conn)
|
|
37
|
-
return npc
|
|
38
|
-
except Exception as e:
|
|
39
|
-
print(f"Warning: Failed to load NPC '{npc_name}' from {chosen_path}: {e}", file=sys.stderr)
|
|
40
|
-
return None
|
|
41
|
-
else:
|
|
42
|
-
print(f"Warning: NPC file for '{npc_name}' not found in project or global paths.", file=sys.stderr)
|
|
43
|
-
if npc_name != "sibiji":
|
|
44
|
-
return load_npc_by_name("sibiji", db_path)
|
|
45
|
-
return None
|
|
46
|
-
|
|
47
|
-
def main():
|
|
48
|
-
parser = argparse.ArgumentParser(
|
|
49
|
-
description="NPC Command Line Utilities. Call a command or provide a prompt for the default NPC.",
|
|
50
|
-
usage="npc <command> [command_args...] | <prompt> [--npc NAME] [--model MODEL] [--provider PROV]"
|
|
51
|
-
)
|
|
52
|
-
parser.add_argument(
|
|
53
|
-
"--model", "-m", help="LLM model to use (overrides NPC/defaults)", type=str, default=None
|
|
54
|
-
)
|
|
55
|
-
parser.add_argument(
|
|
56
|
-
"--provider", "-pr", help="LLM provider to use (overrides NPC/defaults)", type=str, default=None
|
|
57
|
-
)
|
|
58
|
-
parser.add_argument(
|
|
59
|
-
"-n", "--npc", help="Name of the NPC to use (default: sibiji)", type=str, default="sibiji"
|
|
60
|
-
)
|
|
61
|
-
|
|
62
|
-
# No subparsers setup at first - we'll conditionally create them
|
|
63
|
-
|
|
64
|
-
# First, get any arguments without parsing commands
|
|
65
|
-
args, all_args = parser.parse_known_args()
|
|
66
|
-
global_model = args.model
|
|
67
|
-
global_provider = args.provider
|
|
68
|
-
|
|
69
|
-
# Check if the first argument is a known command
|
|
70
|
-
is_valid_command = False
|
|
71
|
-
command_name = None
|
|
72
|
-
if all_args and all_args[0] in router.get_commands():
|
|
73
|
-
is_valid_command = True
|
|
74
|
-
command_name = all_args[0]
|
|
75
|
-
all_args = all_args[1:] # Remove the command from arguments
|
|
76
|
-
|
|
77
|
-
# Only set up subparsers if we have a valid command
|
|
78
|
-
if is_valid_command:
|
|
79
|
-
subparsers = parser.add_subparsers(dest="command", title="Available Commands",
|
|
80
|
-
help="Run 'npc <command> --help' for command-specific help")
|
|
81
|
-
|
|
82
|
-
for cmd_name, help_text in router.help_info.items():
|
|
83
|
-
if router.shell_only.get(cmd_name, False):
|
|
84
|
-
continue
|
|
85
|
-
|
|
86
|
-
cmd_parser = subparsers.add_parser(cmd_name, help=help_text, add_help=False)
|
|
87
|
-
cmd_parser.add_argument('command_args', nargs=argparse.REMAINDER,
|
|
88
|
-
help='Arguments passed directly to the command handler')
|
|
89
|
-
|
|
90
|
-
# Re-parse with command subparsers
|
|
91
|
-
args = parser.parse_args([command_name] + all_args)
|
|
92
|
-
command_args = args.command_args if hasattr(args, 'command_args') else []
|
|
93
|
-
unknown_args = []
|
|
94
|
-
else:
|
|
95
|
-
# Treat all arguments as a prompt
|
|
96
|
-
args.command = None
|
|
97
|
-
command_args = []
|
|
98
|
-
unknown_args = all_args
|
|
99
|
-
|
|
100
|
-
if args.model is None:
|
|
101
|
-
args.model = global_model
|
|
102
|
-
if args.provider is None:
|
|
103
|
-
args.provider = global_provider
|
|
104
|
-
# --- END OF FIX ---
|
|
105
|
-
npc_instance = load_npc_by_name(args.npc, NPCSH_DB_PATH)
|
|
106
|
-
|
|
107
|
-
effective_model = args.model or NPCSH_CHAT_MODEL
|
|
108
|
-
effective_provider = args.provider or NPCSH_CHAT_PROVIDER
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
extras = {}
|
|
113
|
-
|
|
114
|
-
# Process command args if we have a valid command
|
|
115
|
-
if is_valid_command:
|
|
116
|
-
# Parse command args properly
|
|
117
|
-
if command_args:
|
|
118
|
-
i = 0
|
|
119
|
-
while i < len(command_args):
|
|
120
|
-
arg = command_args[i]
|
|
121
|
-
if arg.startswith("--"):
|
|
122
|
-
param = arg[2:] # Remove --
|
|
123
|
-
if "=" in param:
|
|
124
|
-
param_name, param_value = param.split("=", 1)
|
|
125
|
-
extras[param_name] = param_value
|
|
126
|
-
i += 1
|
|
127
|
-
elif i + 1 < len(command_args) and not command_args[i+1].startswith("--"):
|
|
128
|
-
extras[param] = command_args[i+1]
|
|
129
|
-
i += 2
|
|
130
|
-
else:
|
|
131
|
-
extras[param] = True
|
|
132
|
-
i += 1
|
|
133
|
-
else:
|
|
134
|
-
i += 1
|
|
135
|
-
|
|
136
|
-
handler = router.get_route(command_name)
|
|
137
|
-
if not handler:
|
|
138
|
-
print(f"Error: Command '{command_name}' recognized but no handler found.", file=sys.stderr)
|
|
139
|
-
sys.exit(1)
|
|
140
|
-
|
|
141
|
-
full_command_str = command_name
|
|
142
|
-
if command_args:
|
|
143
|
-
full_command_str += " " + " ".join(command_args)
|
|
144
|
-
|
|
145
|
-
handler_kwargs = {
|
|
146
|
-
"model": effective_model,
|
|
147
|
-
"provider": effective_provider,
|
|
148
|
-
"npc": npc_instance,
|
|
149
|
-
"api_url": NPCSH_API_URL,
|
|
150
|
-
"stream": NPCSH_STREAM_OUTPUT,
|
|
151
|
-
"messages": [],
|
|
152
|
-
"team": None,
|
|
153
|
-
"current_path": os.getcwd(),
|
|
154
|
-
**extras
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
try:
|
|
158
|
-
result = handler(command=full_command_str, **handler_kwargs)
|
|
159
|
-
|
|
160
|
-
if isinstance(result, dict):
|
|
161
|
-
output = result.get("output") or result.get("response")
|
|
162
|
-
|
|
163
|
-
if NPCSH_STREAM_OUTPUT and not isinstance(output, str):
|
|
164
|
-
print_and_process_stream_with_markdown(output, effective_model, effective_provider)
|
|
165
|
-
elif output is not None:
|
|
166
|
-
render_markdown(str(output))
|
|
167
|
-
elif result is not None:
|
|
168
|
-
render_markdown(str(result))
|
|
169
|
-
else:
|
|
170
|
-
print(f"Command '{command_name}' executed.")
|
|
171
|
-
|
|
172
|
-
except Exception as e:
|
|
173
|
-
print(f"Error executing command '{command_name}': {e}", file=sys.stderr)
|
|
174
|
-
traceback.print_exc()
|
|
175
|
-
sys.exit(1)
|
|
176
|
-
else:
|
|
177
|
-
# Process as a prompt
|
|
178
|
-
prompt = " ".join(unknown_args)
|
|
179
|
-
|
|
180
|
-
if not prompt:
|
|
181
|
-
# If no prompt and no command, show help
|
|
182
|
-
parser.print_help()
|
|
183
|
-
sys.exit(1)
|
|
184
|
-
|
|
185
|
-
print(f"Processing prompt: '{prompt}' with NPC: '{args.npc}'...")
|
|
186
|
-
try:
|
|
187
|
-
response_data = check_llm_command(
|
|
188
|
-
command=prompt,
|
|
189
|
-
model=effective_model,
|
|
190
|
-
provider=effective_provider,
|
|
191
|
-
npc=npc_instance,
|
|
192
|
-
stream=NPCSH_STREAM_OUTPUT,
|
|
193
|
-
messages=[],
|
|
194
|
-
team=None,
|
|
195
|
-
api_url=NPCSH_API_URL,
|
|
196
|
-
)
|
|
197
|
-
|
|
198
|
-
if isinstance(response_data, dict):
|
|
199
|
-
output = response_data.get("output")
|
|
200
|
-
if NPCSH_STREAM_OUTPUT and hasattr(output, '__iter__') and not isinstance(output, (str, bytes, dict, list)):
|
|
201
|
-
print_and_process_stream_with_markdown(output, effective_model, effective_provider)
|
|
202
|
-
elif output is not None:
|
|
203
|
-
render_markdown(str(output))
|
|
204
|
-
elif response_data is not None:
|
|
205
|
-
render_markdown(str(response_data))
|
|
206
|
-
|
|
207
|
-
except Exception as e:
|
|
208
|
-
print(f"Error processing prompt: {e}", file=sys.stderr)
|
|
209
|
-
traceback.print_exc()
|
|
210
|
-
sys.exit(1)
|
|
211
|
-
|
|
212
|
-
if __name__ == "__main__":
|
|
213
|
-
main()
|