npcsh 0.3.29__py3-none-any.whl → 0.3.31__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.
- npcsh/cli.py +30 -10
- npcsh/image.py +0 -2
- npcsh/llm_funcs.py +32 -23
- npcsh/npc_compiler.py +35 -4
- npcsh/npc_team/npcsh.ctx +8 -2
- npcsh/npc_team/tools/bash_executer.tool +32 -0
- npcsh/npc_team/tools/code_executor.tool +16 -0
- npcsh/npc_team/tools/generic_search.tool +9 -1
- npcsh/npc_team/tools/npcsh_executor.tool +9 -0
- npcsh/npc_team/tools/sql_executor.tool +2 -2
- npcsh/search.py +15 -8
- npcsh/shell.py +103 -89
- npcsh/shell_helpers.py +75 -52
- npcsh-0.3.31.data/data/npcsh/npc_team/bash_executer.tool +32 -0
- npcsh-0.3.31.data/data/npcsh/npc_team/code_executor.tool +16 -0
- {npcsh-0.3.29.data → npcsh-0.3.31.data}/data/npcsh/npc_team/generic_search.tool +9 -1
- {npcsh-0.3.29.data → npcsh-0.3.31.data}/data/npcsh/npc_team/npcsh.ctx +8 -2
- npcsh-0.3.31.data/data/npcsh/npc_team/npcsh_executor.tool +9 -0
- {npcsh-0.3.29.data → npcsh-0.3.31.data}/data/npcsh/npc_team/sql_executor.tool +2 -2
- {npcsh-0.3.29.dist-info → npcsh-0.3.31.dist-info}/METADATA +12 -21
- {npcsh-0.3.29.dist-info → npcsh-0.3.31.dist-info}/RECORD +41 -35
- {npcsh-0.3.29.dist-info → npcsh-0.3.31.dist-info}/WHEEL +1 -1
- {npcsh-0.3.29.data → npcsh-0.3.31.data}/data/npcsh/npc_team/calculator.tool +0 -0
- {npcsh-0.3.29.data → npcsh-0.3.31.data}/data/npcsh/npc_team/celona.npc +0 -0
- {npcsh-0.3.29.data → npcsh-0.3.31.data}/data/npcsh/npc_team/corca.npc +0 -0
- {npcsh-0.3.29.data → npcsh-0.3.31.data}/data/npcsh/npc_team/eriane.npc +0 -0
- {npcsh-0.3.29.data → npcsh-0.3.31.data}/data/npcsh/npc_team/foreman.npc +0 -0
- {npcsh-0.3.29.data → npcsh-0.3.31.data}/data/npcsh/npc_team/image_generation.tool +0 -0
- {npcsh-0.3.29.data → npcsh-0.3.31.data}/data/npcsh/npc_team/lineru.npc +0 -0
- {npcsh-0.3.29.data → npcsh-0.3.31.data}/data/npcsh/npc_team/local_search.tool +0 -0
- {npcsh-0.3.29.data → npcsh-0.3.31.data}/data/npcsh/npc_team/maurawa.npc +0 -0
- {npcsh-0.3.29.data → npcsh-0.3.31.data}/data/npcsh/npc_team/raone.npc +0 -0
- {npcsh-0.3.29.data → npcsh-0.3.31.data}/data/npcsh/npc_team/screen_cap.tool +0 -0
- {npcsh-0.3.29.data → npcsh-0.3.31.data}/data/npcsh/npc_team/sibiji.npc +0 -0
- {npcsh-0.3.29.data → npcsh-0.3.31.data}/data/npcsh/npc_team/slean.npc +0 -0
- {npcsh-0.3.29.data → npcsh-0.3.31.data}/data/npcsh/npc_team/test_pipeline.py +0 -0
- {npcsh-0.3.29.data → npcsh-0.3.31.data}/data/npcsh/npc_team/turnic.npc +0 -0
- {npcsh-0.3.29.data → npcsh-0.3.31.data}/data/npcsh/npc_team/welxor.npc +0 -0
- {npcsh-0.3.29.dist-info → npcsh-0.3.31.dist-info}/entry_points.txt +0 -0
- {npcsh-0.3.29.dist-info → npcsh-0.3.31.dist-info}/licenses/LICENSE +0 -0
- {npcsh-0.3.29.dist-info → npcsh-0.3.31.dist-info}/top_level.txt +0 -0
npcsh/shell.py
CHANGED
|
@@ -378,6 +378,7 @@ def main() -> None:
|
|
|
378
378
|
|
|
379
379
|
current_npc = result["current_npc"]
|
|
380
380
|
output = result.get("output")
|
|
381
|
+
|
|
381
382
|
conversation_id = result.get("conversation_id")
|
|
382
383
|
model = result.get("model")
|
|
383
384
|
provider = result.get("provider")
|
|
@@ -404,102 +405,115 @@ def main() -> None:
|
|
|
404
405
|
npc=npc_name,
|
|
405
406
|
attachments=attachments,
|
|
406
407
|
)
|
|
407
|
-
if NPCSH_STREAM_OUTPUT and (
|
|
408
|
-
isgenerator(output)
|
|
409
|
-
or (hasattr(output, "__iter__") and hasattr(output, "__next__"))
|
|
410
|
-
):
|
|
411
|
-
str_output = ""
|
|
412
|
-
buffer = ""
|
|
413
|
-
in_code = False
|
|
414
|
-
code_buffer = ""
|
|
415
408
|
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
409
|
+
str_output = ""
|
|
410
|
+
try:
|
|
411
|
+
if NPCSH_STREAM_OUTPUT and hasattr(output, "__iter__"):
|
|
412
|
+
|
|
413
|
+
buffer = ""
|
|
414
|
+
in_code = False
|
|
415
|
+
code_buffer = ""
|
|
416
|
+
|
|
417
|
+
for chunk in output:
|
|
418
|
+
|
|
419
|
+
if provider == "anthropic":
|
|
420
|
+
chunk_content = (
|
|
421
|
+
chunk.delta.text
|
|
422
|
+
if chunk.type == "content_block_delta"
|
|
423
|
+
else None
|
|
424
|
+
)
|
|
425
|
+
elif provider in ["openai", "deepseek", "openai-like"]:
|
|
426
|
+
chunk_content = "".join(
|
|
427
|
+
c.delta.content
|
|
428
|
+
for c in chunk.choices
|
|
429
|
+
if c.delta.content
|
|
430
|
+
)
|
|
431
|
+
elif provider == "ollama":
|
|
432
|
+
chunk_content = chunk["message"]["content"]
|
|
433
|
+
else:
|
|
434
|
+
continue
|
|
432
435
|
|
|
433
|
-
|
|
434
|
-
|
|
436
|
+
if not chunk_content:
|
|
437
|
+
continue
|
|
435
438
|
|
|
436
|
-
|
|
439
|
+
str_output += chunk_content
|
|
440
|
+
# print(str_output, "str_output")
|
|
441
|
+
# Process the content character by character
|
|
442
|
+
for char in chunk_content:
|
|
443
|
+
buffer += char
|
|
437
444
|
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
445
|
+
# Check for triple backticks
|
|
446
|
+
if buffer.endswith("```"):
|
|
447
|
+
if not in_code:
|
|
448
|
+
# Start of code block
|
|
449
|
+
in_code = True
|
|
450
|
+
# Print everything before the backticks
|
|
451
|
+
print(buffer[:-3], end="")
|
|
452
|
+
buffer = ""
|
|
453
|
+
code_buffer = ""
|
|
454
|
+
else:
|
|
455
|
+
# End of code block
|
|
456
|
+
in_code = False
|
|
457
|
+
# Remove the backticks from the end of the buffer
|
|
458
|
+
buffer = buffer[:-3]
|
|
459
|
+
# Add buffer to code content and render
|
|
460
|
+
code_buffer += buffer
|
|
461
|
+
|
|
462
|
+
# Check for and strip language tag
|
|
463
|
+
if (
|
|
464
|
+
"\n" in code_buffer
|
|
465
|
+
and code_buffer.index("\n") < 15
|
|
466
|
+
):
|
|
467
|
+
first_line, rest = code_buffer.split("\n", 1)
|
|
468
|
+
if (
|
|
469
|
+
first_line.strip()
|
|
470
|
+
and not "```" in first_line
|
|
471
|
+
):
|
|
472
|
+
code_buffer = rest
|
|
473
|
+
|
|
474
|
+
# Render the code block
|
|
475
|
+
render_code_block(code_buffer)
|
|
476
|
+
|
|
477
|
+
# Reset buffers
|
|
478
|
+
buffer = ""
|
|
479
|
+
code_buffer = ""
|
|
480
|
+
elif in_code:
|
|
481
|
+
# Just add to code buffer
|
|
482
|
+
code_buffer += char
|
|
483
|
+
if len(buffer) >= 3: # Keep buffer small while in code
|
|
484
|
+
buffer = buffer[-3:]
|
|
451
485
|
else:
|
|
452
|
-
#
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
buffer = ""
|
|
470
|
-
code_buffer = ""
|
|
471
|
-
elif in_code:
|
|
472
|
-
# Just add to code buffer
|
|
473
|
-
code_buffer += char
|
|
474
|
-
if len(buffer) >= 3: # Keep buffer small while in code
|
|
475
|
-
buffer = buffer[-3:]
|
|
476
|
-
else:
|
|
477
|
-
# Regular text - print if buffer gets too large
|
|
478
|
-
if len(buffer) > 100:
|
|
479
|
-
print(buffer[:-3], end="")
|
|
480
|
-
buffer = buffer[
|
|
481
|
-
-3:
|
|
482
|
-
] # Keep last 3 chars to check for backticks
|
|
483
|
-
|
|
484
|
-
# Handle any remaining content
|
|
485
|
-
if in_code:
|
|
486
|
-
render_code_block(code_buffer)
|
|
487
|
-
else:
|
|
488
|
-
print(buffer, end="")
|
|
486
|
+
# Regular text - print if buffer gets too large
|
|
487
|
+
if len(buffer) > 100:
|
|
488
|
+
print(buffer[:-3], end="")
|
|
489
|
+
buffer = buffer[
|
|
490
|
+
-3:
|
|
491
|
+
] # Keep last 3 chars to check for backticks
|
|
492
|
+
|
|
493
|
+
# Handle any remaining content
|
|
494
|
+
if in_code:
|
|
495
|
+
render_code_block(code_buffer)
|
|
496
|
+
else:
|
|
497
|
+
print(buffer, end="")
|
|
498
|
+
|
|
499
|
+
if str_output:
|
|
500
|
+
output = str_output
|
|
501
|
+
except:
|
|
502
|
+
output = None
|
|
489
503
|
|
|
490
|
-
if str_output:
|
|
491
|
-
output = str_output
|
|
492
504
|
print("\n")
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
505
|
+
|
|
506
|
+
if isinstance(output, str):
|
|
507
|
+
save_conversation_message(
|
|
508
|
+
command_history,
|
|
509
|
+
conversation_id,
|
|
510
|
+
"assistant",
|
|
511
|
+
output,
|
|
512
|
+
wd=current_path,
|
|
513
|
+
model=model,
|
|
514
|
+
provider=provider,
|
|
515
|
+
npc=npc_name,
|
|
516
|
+
)
|
|
503
517
|
|
|
504
518
|
# if there are attachments in most recent user sent message, save them
|
|
505
519
|
# save_attachment_to_message(command_history, message_id, # file_path, attachment_name, attachment_type)
|
npcsh/shell_helpers.py
CHANGED
|
@@ -1631,6 +1631,9 @@ def ots(
|
|
|
1631
1631
|
output = analyze_image(
|
|
1632
1632
|
user_prompt, file_path, filename, npc=npc, model=model, provider=provider
|
|
1633
1633
|
)
|
|
1634
|
+
messages = [
|
|
1635
|
+
{"role": "user", "content": user_prompt},
|
|
1636
|
+
]
|
|
1634
1637
|
|
|
1635
1638
|
else:
|
|
1636
1639
|
output = capture_screenshot(npc=npc)
|
|
@@ -1651,12 +1654,15 @@ def ots(
|
|
|
1651
1654
|
# messages = output["messages"]
|
|
1652
1655
|
|
|
1653
1656
|
output = output["response"]
|
|
1654
|
-
|
|
1657
|
+
messages = [
|
|
1658
|
+
{"role": "user", "content": user_prompt},
|
|
1659
|
+
]
|
|
1655
1660
|
if output:
|
|
1656
1661
|
if isinstance(output, dict) and "filename" in output:
|
|
1657
1662
|
message = f"Screenshot captured: {output['filename']}\nFull path: {output['file_path']}\nLLM-ready data available."
|
|
1658
1663
|
else: # This handles both LLM responses and error messages (both strings)
|
|
1659
1664
|
message = output
|
|
1665
|
+
messages.append({"role": "assistant", "content": message})
|
|
1660
1666
|
return {"messages": messages, "output": message} # Return the message
|
|
1661
1667
|
else: # Handle the case where capture_screenshot returns None
|
|
1662
1668
|
print("Screenshot capture failed.")
|
|
@@ -2042,6 +2048,18 @@ def execute_slash_command(
|
|
|
2042
2048
|
device = part.split("=")[1]
|
|
2043
2049
|
if part.startswith("rag_similarity_threshold="):
|
|
2044
2050
|
rag_similarity_threshold = float(part.split("=")[1])
|
|
2051
|
+
if part.startswith("model="):
|
|
2052
|
+
model = part.split("=")[1]
|
|
2053
|
+
|
|
2054
|
+
if part.startswith("provider="):
|
|
2055
|
+
provider = part.split("=")[1]
|
|
2056
|
+
if part.startswith("api_url="):
|
|
2057
|
+
api_url = part.split("=")[1]
|
|
2058
|
+
if part.startswith("api_key="):
|
|
2059
|
+
api_key = part.split("=")[1]
|
|
2060
|
+
|
|
2061
|
+
# load the npc properly
|
|
2062
|
+
|
|
2045
2063
|
match = re.search(r"files=\s*\[(.*?)\]", command)
|
|
2046
2064
|
files = []
|
|
2047
2065
|
if match:
|
|
@@ -2066,10 +2084,11 @@ def execute_slash_command(
|
|
|
2066
2084
|
|
|
2067
2085
|
print(f"Reattached to previous conversation:\n\n")
|
|
2068
2086
|
output = enter_spool_mode(
|
|
2069
|
-
command_history,
|
|
2070
2087
|
inherit_last,
|
|
2071
2088
|
files=files,
|
|
2072
2089
|
npc=npc,
|
|
2090
|
+
model=model,
|
|
2091
|
+
provider=provider,
|
|
2073
2092
|
rag_similarity_threshold=rag_similarity_threshold,
|
|
2074
2093
|
device=device,
|
|
2075
2094
|
messages=spool_context,
|
|
@@ -2082,7 +2101,6 @@ def execute_slash_command(
|
|
|
2082
2101
|
return {"messages": [], "output": "No previous conversation found."}
|
|
2083
2102
|
|
|
2084
2103
|
output = enter_spool_mode(
|
|
2085
|
-
command_history,
|
|
2086
2104
|
inherit_last,
|
|
2087
2105
|
files=files,
|
|
2088
2106
|
npc=npc,
|
|
@@ -2367,11 +2385,13 @@ def execute_command(
|
|
|
2367
2385
|
valid_npcs = get_db_npcs(db_path)
|
|
2368
2386
|
|
|
2369
2387
|
npc_name = get_npc_from_command(command)
|
|
2388
|
+
|
|
2370
2389
|
if npc_name is None:
|
|
2371
2390
|
npc_name = "sibiji" # Default NPC
|
|
2372
2391
|
npc_path = get_npc_path(npc_name, db_path)
|
|
2373
2392
|
|
|
2374
2393
|
npc = load_npc_from_file(npc_path, db_conn)
|
|
2394
|
+
current_npc = npc
|
|
2375
2395
|
else:
|
|
2376
2396
|
valid_npcs = [current_npc]
|
|
2377
2397
|
npc = current_npc
|
|
@@ -2546,60 +2566,62 @@ def execute_command(
|
|
|
2546
2566
|
except AttributeError:
|
|
2547
2567
|
print(output)
|
|
2548
2568
|
|
|
2549
|
-
|
|
2569
|
+
piped_outputs.append(f'"{output}"')
|
|
2550
2570
|
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2571
|
+
try:
|
|
2572
|
+
# Prepare text to embed (both command and response)
|
|
2573
|
+
texts_to_embed = [command, str(output) if output else ""]
|
|
2554
2574
|
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2575
|
+
# Generate embeddings
|
|
2576
|
+
embeddings = get_embeddings(
|
|
2577
|
+
texts_to_embed,
|
|
2578
|
+
)
|
|
2559
2579
|
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
+
# Prepare metadata
|
|
2581
|
+
metadata = [
|
|
2582
|
+
{
|
|
2583
|
+
"type": "command",
|
|
2584
|
+
"timestamp": datetime.datetime.now().isoformat(),
|
|
2585
|
+
"path": os.getcwd(),
|
|
2586
|
+
"npc": npc.name if npc else None,
|
|
2587
|
+
"conversation_id": conversation_id,
|
|
2588
|
+
},
|
|
2589
|
+
{
|
|
2590
|
+
"type": "response",
|
|
2591
|
+
"timestamp": datetime.datetime.now().isoformat(),
|
|
2592
|
+
"path": os.getcwd(),
|
|
2593
|
+
"npc": npc.name if npc else None,
|
|
2594
|
+
"conversation_id": conversation_id,
|
|
2595
|
+
},
|
|
2596
|
+
]
|
|
2597
|
+
embedding_model = os.environ.get("NPCSH_EMBEDDING_MODEL")
|
|
2598
|
+
embedding_provider = os.environ.get("NPCSH_EMBEDDING_PROVIDER")
|
|
2599
|
+
collection_name = (
|
|
2600
|
+
f"{embedding_provider}_{embedding_model}_embeddings"
|
|
2601
|
+
)
|
|
2580
2602
|
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2603
|
+
try:
|
|
2604
|
+
collection = chroma_client.get_collection(collection_name)
|
|
2605
|
+
except Exception as e:
|
|
2606
|
+
print(f"Warning: Failed to get collection: {str(e)}")
|
|
2607
|
+
print("Creating new collection...")
|
|
2608
|
+
collection = chroma_client.create_collection(collection_name)
|
|
2609
|
+
date_str = datetime.datetime.now().isoformat()
|
|
2610
|
+
# print(date_str)
|
|
2611
|
+
|
|
2612
|
+
# Add to collection
|
|
2613
|
+
current_ids = [f"cmd_{date_str}", f"resp_{date_str}"]
|
|
2614
|
+
collection.add(
|
|
2615
|
+
embeddings=embeddings,
|
|
2616
|
+
documents=texts_to_embed, # Adjust as needed
|
|
2617
|
+
metadatas=metadata, # Adjust as needed
|
|
2618
|
+
ids=current_ids,
|
|
2619
|
+
)
|
|
2598
2620
|
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2621
|
+
# print("Stored embeddings.")
|
|
2622
|
+
# print("collection", collection)
|
|
2623
|
+
except Exception as e:
|
|
2624
|
+
print(f"Warning: Failed to store embeddings: {str(e)}")
|
|
2603
2625
|
|
|
2604
2626
|
# return following
|
|
2605
2627
|
# print(current_npc)
|
|
@@ -3161,6 +3183,7 @@ def enter_spool_mode(
|
|
|
3161
3183
|
Dict : The messages and output.
|
|
3162
3184
|
|
|
3163
3185
|
"""
|
|
3186
|
+
|
|
3164
3187
|
command_history = CommandHistory()
|
|
3165
3188
|
npc_info = f" (NPC: {npc.name})" if npc else ""
|
|
3166
3189
|
print(f"Entering spool mode{npc_info}. Type '/sq' to exit spool mode.")
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
tool_name: bash_executor
|
|
2
|
+
description: Execute bash queries.
|
|
3
|
+
inputs:
|
|
4
|
+
- bash_command
|
|
5
|
+
- user_request
|
|
6
|
+
steps:
|
|
7
|
+
- engine: python
|
|
8
|
+
code: |
|
|
9
|
+
import subprocess
|
|
10
|
+
import os
|
|
11
|
+
cmd = '{{bash_command}}' # Properly quote the command input
|
|
12
|
+
def run_command(cmd):
|
|
13
|
+
process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
14
|
+
stdout, stderr = process.communicate()
|
|
15
|
+
if stderr:
|
|
16
|
+
print(f"Error: {stderr.decode('utf-8')}")
|
|
17
|
+
return stderr
|
|
18
|
+
return stdout
|
|
19
|
+
result = run_command(cmd)
|
|
20
|
+
output = result.decode('utf-8')
|
|
21
|
+
|
|
22
|
+
- engine: natural
|
|
23
|
+
code: |
|
|
24
|
+
|
|
25
|
+
Here is the result of the bash command:
|
|
26
|
+
```
|
|
27
|
+
{{ output }}
|
|
28
|
+
```
|
|
29
|
+
This was the original user request: {{ user_request }}
|
|
30
|
+
|
|
31
|
+
Please provide a response accordingly.
|
|
32
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
tool_name: code_executor
|
|
2
|
+
description: Execute scripts with a specified language. choose from python, bash, R, or javascript. Set the ultimate result as the "output" variable. It must be a string. Do not add unnecessary print statements.
|
|
3
|
+
inputs:
|
|
4
|
+
- code
|
|
5
|
+
- language
|
|
6
|
+
steps:
|
|
7
|
+
- engine: '{{ language }}'
|
|
8
|
+
code: |
|
|
9
|
+
{{code}}
|
|
10
|
+
- engine: natural
|
|
11
|
+
code: |
|
|
12
|
+
Here is the result of the code execution that an agent ran.
|
|
13
|
+
```
|
|
14
|
+
{{ output }}
|
|
15
|
+
```
|
|
16
|
+
please provide a response accordingly.
|
|
@@ -2,13 +2,21 @@ tool_name: "internet_search"
|
|
|
2
2
|
description: Searches the web for information based on a query in order to verify timiely details (e.g. current events) or to corroborate information in uncertain situations. Should be mainly only used when users specifically request a search, otherwise an LLMs basic knowledge should be sufficient.
|
|
3
3
|
inputs:
|
|
4
4
|
- query
|
|
5
|
+
- provider: ''
|
|
5
6
|
steps:
|
|
6
7
|
- engine: "python"
|
|
7
8
|
code: |
|
|
8
9
|
from npcsh.search import search_web
|
|
10
|
+
from npcsh.npc_sysenv import NPCSH_SEARCH_PROVIDER
|
|
9
11
|
query = "{{ query }}"
|
|
12
|
+
provider = '{{ provider }}'
|
|
13
|
+
if provider.strip() != '':
|
|
14
|
+
results = search_web(query, num_results=5, provider = provider)
|
|
15
|
+
else:
|
|
16
|
+
results = search_web(query, num_results=5, provider = NPCSH_SEARCH_PROVIDER)
|
|
17
|
+
|
|
10
18
|
print('QUERY in tool', query)
|
|
11
|
-
results = search_web(query, num_results=5)
|
|
19
|
+
results = search_web(query, num_results=5, provider = NPCSH_SEARCH_PROVIDER)
|
|
12
20
|
print('RESULTS in tool', results)
|
|
13
21
|
- engine: "natural"
|
|
14
22
|
code: |
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
context: |
|
|
2
2
|
The npcsh NPC team is devoted to providing a safe and helpful
|
|
3
3
|
environment for users where they can work and be as successful as possible.
|
|
4
4
|
npcsh is a command-line tool that makes it easy for users to harness
|
|
5
|
-
the power of LLMs from a command line shell.
|
|
5
|
+
the power of LLMs from a command line shell.
|
|
6
|
+
databases:
|
|
7
|
+
- ~/npcsh_history.db
|
|
8
|
+
mcp_servers:
|
|
9
|
+
- /path/to/mcp/server.py
|
|
10
|
+
- @npm for server
|
|
11
|
+
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
tool_name:
|
|
2
|
-
description: Execute
|
|
1
|
+
tool_name: data_pull
|
|
2
|
+
description: Execute queries on the ~/npcsh_history.db to pull data. The database contains only information about conversations and other user-provided data. It does not store any information about individual files.
|
|
3
3
|
inputs:
|
|
4
4
|
- sql_query
|
|
5
5
|
- interpret: false # Note that this is not a boolean, but a string
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: npcsh
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.31
|
|
4
4
|
Summary: npcsh is a command line tool for integrating LLMs into everyday workflows and for orchestrating teams of NPCs.
|
|
5
5
|
Home-page: https://github.com/cagostino/npcsh
|
|
6
6
|
Author: Christopher Agostino
|
|
@@ -112,22 +112,23 @@ Interested to stay in the loop and to hear the latest and greatest about `npcsh`
|
|
|
112
112
|
## TLDR Cheat Sheet
|
|
113
113
|
Users can take advantage of `npcsh` through its custom shell or through a command-line interface (CLI) tool. Below is a cheat sheet that shows how to use `npcsh` commands in both the shell and the CLI. For the npcsh commands to work, one must activate `npcsh` by typing it in a shell.
|
|
114
114
|
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
115
118
|
| Task | npc CLI | npcsh |
|
|
116
119
|
|----------|----------|----------|
|
|
117
120
|
| Ask a generic question | npc 'prompt' | 'prompt' |
|
|
118
121
|
| Compile an NPC | npc compile /path/to/npc.npc | /compile /path/to/npc.npc |
|
|
119
122
|
| Computer use | npc plonk -n 'npc_name' -sp 'task for plonk to carry out '| /plonk -n 'npc_name' -sp 'task for plonk to carry out ' |
|
|
120
123
|
| Conjure an NPC team from context and templates | npc init -t 'template1, template2' -ctx 'context' | /conjure -t 'template1, 'template2' -ctx 'context' |
|
|
121
|
-
| Enter a chat with an NPC (NPC needs to be compiled first) | npc npc_name | /npc_name |
|
|
124
|
+
| Enter a chat with an NPC (NPC needs to be compiled first) | npc chat -n npc_name | /spool npc=<npc_name> |
|
|
122
125
|
| Generate image | npc vixynt 'prompt' | /vixynt prompt |
|
|
123
126
|
| Get a sample LLM response | npc sample 'prompt' | /sample prompt for llm |
|
|
124
|
-
| Invoke a tool | npc tool {tool_name} -args --flags | /tool_name -args --flags |
|
|
125
|
-
| Search locally | npc tool local_search -args --flags | /local_search -args --flags |
|
|
126
127
|
| Search for a term in the npcsh_db only in conversations with a specific npc | npc rag -n 'npc_name' -f 'filename' -q 'query' | /rag -n 'npc_name' -f 'filename' -q 'query' |
|
|
127
|
-
| Search the web | npc search -
|
|
128
|
+
| Search the web | npc search -q "cal golden bears football schedule" -sp perplexity | /search -p perplexity 'cal bears football schedule' |
|
|
128
129
|
| Serve an NPC team | npc serve --port 5337 --cors='http://localhost:5137/' | /serve --port 5337 --cors='http://localhost:5137/' |
|
|
129
130
|
| Screenshot analysis | npc ots | /ots |
|
|
130
|
-
| Voice Chat | npc whisper 'npc_name' | /whisper |
|
|
131
|
+
| Voice Chat | npc whisper -n 'npc_name' | /whisper |
|
|
131
132
|
|
|
132
133
|
|
|
133
134
|
## Python Examples
|
|
@@ -725,19 +726,6 @@ The code in the visible section of your VS Code window appears to be a script fo
|
|
|
725
726
|
In summary, this code automates the process of capturing a screenshot, saving it with a unique filename, and analyzing that image for specific content or patterns.
|
|
726
727
|
|
|
727
728
|
|
|
728
|
-
```
|
|
729
|
-
|
|
730
|
-
```npcsh
|
|
731
|
-
npcsh> What is the biggest file in my current folder?
|
|
732
|
-
|
|
733
|
-
LLM suggests the following bash command: ls -S | head -n 1
|
|
734
|
-
|
|
735
|
-
Running command: ls -S | head -n 1
|
|
736
|
-
|
|
737
|
-
Command executed with output: image_20241111_000033.png
|
|
738
|
-
|
|
739
|
-
I ran the command ls -S | head -n 1 in your current folder. This command sorts all files by size in descending order and then selects the first entry, which represents the largest file. The result of this operation shows that the biggest file in your current folder is image_20241111_000033.png.
|
|
740
|
-
|
|
741
729
|
```
|
|
742
730
|
|
|
743
731
|
```npcsh
|
|
@@ -869,7 +857,7 @@ and then the associated image :
|
|
|
869
857
|
An important facet that makes `npcsh` so powerful is the ability to pipe outputs from one tool call to another. This allows for the chaining of commands and the creation of complex workflows. For example, you can use the output of a search to generate an image, or you can use the output of an image analysis to generate a report. Here is an example of how this might look in practice:
|
|
870
858
|
```npcsh
|
|
871
859
|
npcsh> what is the gdp of russia in 2024? | /vixynt 'generate an image that contains {0}'
|
|
872
|
-
|
|
860
|
+
```
|
|
873
861
|
### Executing Bash Commands
|
|
874
862
|
You can execute bash commands directly within npcsh. The LLM can also generate and execute bash commands based on your natural language requests.
|
|
875
863
|
For example:
|
|
@@ -1167,7 +1155,10 @@ Search can be accomplished through the `/search` macro. You can specify the prov
|
|
|
1167
1155
|
you must set a perplexity api key as an environment variable as described above. The default provider is duckduckgo.
|
|
1168
1156
|
|
|
1169
1157
|
NOTE: while google is an available search engine, they recently implemented changes (early 2025) that make the python google search package no longer as reliable.
|
|
1170
|
-
|
|
1158
|
+
Duckduckgo's search toool also givies rate limit errors often, so until a more robust
|
|
1159
|
+
solution is implemented for it, Perplexity's will be the most reliable.
|
|
1160
|
+
|
|
1161
|
+
|
|
1171
1162
|
|
|
1172
1163
|
|
|
1173
1164
|
```npcsh
|