npcsh 0.3.31__py3-none-any.whl → 1.0.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.
Files changed (91) hide show
  1. npcsh/_state.py +942 -0
  2. npcsh/alicanto.py +1074 -0
  3. npcsh/guac.py +785 -0
  4. npcsh/mcp_helpers.py +357 -0
  5. npcsh/mcp_npcsh.py +822 -0
  6. npcsh/mcp_server.py +184 -0
  7. npcsh/npc.py +218 -0
  8. npcsh/npcsh.py +1161 -0
  9. npcsh/plonk.py +387 -269
  10. npcsh/pti.py +234 -0
  11. npcsh/routes.py +958 -0
  12. npcsh/spool.py +315 -0
  13. npcsh/wander.py +550 -0
  14. npcsh/yap.py +573 -0
  15. npcsh-1.0.0.dist-info/METADATA +596 -0
  16. npcsh-1.0.0.dist-info/RECORD +21 -0
  17. {npcsh-0.3.31.dist-info → npcsh-1.0.0.dist-info}/WHEEL +1 -1
  18. npcsh-1.0.0.dist-info/entry_points.txt +9 -0
  19. {npcsh-0.3.31.dist-info → npcsh-1.0.0.dist-info}/licenses/LICENSE +1 -1
  20. npcsh/audio.py +0 -210
  21. npcsh/cli.py +0 -545
  22. npcsh/command_history.py +0 -566
  23. npcsh/conversation.py +0 -291
  24. npcsh/data_models.py +0 -46
  25. npcsh/dataframes.py +0 -163
  26. npcsh/embeddings.py +0 -168
  27. npcsh/helpers.py +0 -641
  28. npcsh/image.py +0 -298
  29. npcsh/image_gen.py +0 -79
  30. npcsh/knowledge_graph.py +0 -1006
  31. npcsh/llm_funcs.py +0 -2027
  32. npcsh/load_data.py +0 -83
  33. npcsh/main.py +0 -5
  34. npcsh/model_runner.py +0 -189
  35. npcsh/npc_compiler.py +0 -2870
  36. npcsh/npc_sysenv.py +0 -383
  37. npcsh/npc_team/assembly_lines/test_pipeline.py +0 -181
  38. npcsh/npc_team/corca.npc +0 -13
  39. npcsh/npc_team/foreman.npc +0 -7
  40. npcsh/npc_team/npcsh.ctx +0 -11
  41. npcsh/npc_team/sibiji.npc +0 -4
  42. npcsh/npc_team/templates/analytics/celona.npc +0 -0
  43. npcsh/npc_team/templates/hr_support/raone.npc +0 -0
  44. npcsh/npc_team/templates/humanities/eriane.npc +0 -4
  45. npcsh/npc_team/templates/it_support/lineru.npc +0 -0
  46. npcsh/npc_team/templates/marketing/slean.npc +0 -4
  47. npcsh/npc_team/templates/philosophy/maurawa.npc +0 -0
  48. npcsh/npc_team/templates/sales/turnic.npc +0 -4
  49. npcsh/npc_team/templates/software/welxor.npc +0 -0
  50. npcsh/npc_team/tools/bash_executer.tool +0 -32
  51. npcsh/npc_team/tools/calculator.tool +0 -8
  52. npcsh/npc_team/tools/code_executor.tool +0 -16
  53. npcsh/npc_team/tools/generic_search.tool +0 -27
  54. npcsh/npc_team/tools/image_generation.tool +0 -25
  55. npcsh/npc_team/tools/local_search.tool +0 -149
  56. npcsh/npc_team/tools/npcsh_executor.tool +0 -9
  57. npcsh/npc_team/tools/screen_cap.tool +0 -27
  58. npcsh/npc_team/tools/sql_executor.tool +0 -26
  59. npcsh/response.py +0 -623
  60. npcsh/search.py +0 -248
  61. npcsh/serve.py +0 -1460
  62. npcsh/shell.py +0 -538
  63. npcsh/shell_helpers.py +0 -3529
  64. npcsh/stream.py +0 -700
  65. npcsh/video.py +0 -49
  66. npcsh-0.3.31.data/data/npcsh/npc_team/bash_executer.tool +0 -32
  67. npcsh-0.3.31.data/data/npcsh/npc_team/calculator.tool +0 -8
  68. npcsh-0.3.31.data/data/npcsh/npc_team/celona.npc +0 -0
  69. npcsh-0.3.31.data/data/npcsh/npc_team/code_executor.tool +0 -16
  70. npcsh-0.3.31.data/data/npcsh/npc_team/corca.npc +0 -13
  71. npcsh-0.3.31.data/data/npcsh/npc_team/eriane.npc +0 -4
  72. npcsh-0.3.31.data/data/npcsh/npc_team/foreman.npc +0 -7
  73. npcsh-0.3.31.data/data/npcsh/npc_team/generic_search.tool +0 -27
  74. npcsh-0.3.31.data/data/npcsh/npc_team/image_generation.tool +0 -25
  75. npcsh-0.3.31.data/data/npcsh/npc_team/lineru.npc +0 -0
  76. npcsh-0.3.31.data/data/npcsh/npc_team/local_search.tool +0 -149
  77. npcsh-0.3.31.data/data/npcsh/npc_team/maurawa.npc +0 -0
  78. npcsh-0.3.31.data/data/npcsh/npc_team/npcsh.ctx +0 -11
  79. npcsh-0.3.31.data/data/npcsh/npc_team/npcsh_executor.tool +0 -9
  80. npcsh-0.3.31.data/data/npcsh/npc_team/raone.npc +0 -0
  81. npcsh-0.3.31.data/data/npcsh/npc_team/screen_cap.tool +0 -27
  82. npcsh-0.3.31.data/data/npcsh/npc_team/sibiji.npc +0 -4
  83. npcsh-0.3.31.data/data/npcsh/npc_team/slean.npc +0 -4
  84. npcsh-0.3.31.data/data/npcsh/npc_team/sql_executor.tool +0 -26
  85. npcsh-0.3.31.data/data/npcsh/npc_team/test_pipeline.py +0 -181
  86. npcsh-0.3.31.data/data/npcsh/npc_team/turnic.npc +0 -4
  87. npcsh-0.3.31.data/data/npcsh/npc_team/welxor.npc +0 -0
  88. npcsh-0.3.31.dist-info/METADATA +0 -1853
  89. npcsh-0.3.31.dist-info/RECORD +0 -76
  90. npcsh-0.3.31.dist-info/entry_points.txt +0 -3
  91. {npcsh-0.3.31.dist-info → npcsh-1.0.0.dist-info}/top_level.txt +0 -0
@@ -1,1853 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: npcsh
3
- Version: 0.3.31
4
- Summary: npcsh is a command line tool for integrating LLMs into everyday workflows and for orchestrating teams of NPCs.
5
- Home-page: https://github.com/cagostino/npcsh
6
- Author: Christopher Agostino
7
- Author-email: info@npcworldwi.de
8
- Classifier: Programming Language :: Python :: 3
9
- Classifier: License :: OSI Approved :: MIT License
10
- Requires-Python: >=3.10
11
- Description-Content-Type: text/markdown
12
- License-File: LICENSE
13
- Requires-Dist: jinja2
14
- Requires-Dist: scipy
15
- Requires-Dist: numpy
16
- Requires-Dist: requests
17
- Requires-Dist: matplotlib
18
- Requires-Dist: markdown
19
- Requires-Dist: PyYAML
20
- Requires-Dist: PyMuPDF
21
- Requires-Dist: pyautogui
22
- Requires-Dist: pygments
23
- Requires-Dist: sqlalchemy
24
- Requires-Dist: termcolor
25
- Requires-Dist: rich
26
- Requires-Dist: colorama
27
- Requires-Dist: Pillow
28
- Requires-Dist: python-dotenv
29
- Requires-Dist: pandas
30
- Requires-Dist: beautifulsoup4
31
- Requires-Dist: duckduckgo-search
32
- Requires-Dist: flask
33
- Requires-Dist: flask_cors
34
- Requires-Dist: redis
35
- Requires-Dist: psycopg2-binary
36
- Requires-Dist: flask_sse
37
- Provides-Extra: lite
38
- Requires-Dist: anthropic; extra == "lite"
39
- Requires-Dist: openai; extra == "lite"
40
- Requires-Dist: google-generativeai; extra == "lite"
41
- Requires-Dist: google-genai; extra == "lite"
42
- Provides-Extra: local
43
- Requires-Dist: sentence_transformers; extra == "local"
44
- Requires-Dist: opencv-python; extra == "local"
45
- Requires-Dist: ollama; extra == "local"
46
- Requires-Dist: kuzu; extra == "local"
47
- Requires-Dist: chromadb; extra == "local"
48
- Requires-Dist: diffusers; extra == "local"
49
- Requires-Dist: nltk; extra == "local"
50
- Provides-Extra: whisper
51
- Requires-Dist: openai-whisper; extra == "whisper"
52
- Requires-Dist: pyaudio; extra == "whisper"
53
- Requires-Dist: gtts; extra == "whisper"
54
- Requires-Dist: playsound==1.2.2; extra == "whisper"
55
- Requires-Dist: pyttsx3; extra == "whisper"
56
- Provides-Extra: all
57
- Requires-Dist: anthropic; extra == "all"
58
- Requires-Dist: openai; extra == "all"
59
- Requires-Dist: google-generativeai; extra == "all"
60
- Requires-Dist: google-genai; extra == "all"
61
- Requires-Dist: sentence_transformers; extra == "all"
62
- Requires-Dist: opencv-python; extra == "all"
63
- Requires-Dist: ollama; extra == "all"
64
- Requires-Dist: kuzu; extra == "all"
65
- Requires-Dist: chromadb; extra == "all"
66
- Requires-Dist: diffusers; extra == "all"
67
- Requires-Dist: nltk; extra == "all"
68
- Requires-Dist: openai-whisper; extra == "all"
69
- Requires-Dist: pyaudio; extra == "all"
70
- Requires-Dist: gtts; extra == "all"
71
- Requires-Dist: playsound==1.2.2; extra == "all"
72
- Requires-Dist: pyttsx3; extra == "all"
73
- Dynamic: author
74
- Dynamic: author-email
75
- Dynamic: classifier
76
- Dynamic: description
77
- Dynamic: description-content-type
78
- Dynamic: home-page
79
- Dynamic: license-file
80
- Dynamic: provides-extra
81
- Dynamic: requires-dist
82
- Dynamic: requires-python
83
- Dynamic: summary
84
-
85
- <p align="center">
86
- <img src="https://raw.githubusercontent.com/cagostino/npcsh/main/npcsh/npcsh.png" alt="npcsh logo with sibiji the spider">
87
- </p>
88
-
89
-
90
- # npcsh
91
-
92
-
93
- - `npcsh` is a python-based AI Agent framework designed to integrate Large Language Models (LLMs) and Agents into one's daily workflow by making them available and easily configurable through a command line shell as well as an extensible python library.
94
-
95
- - **Smart Interpreter**: `npcsh` leverages the power of LLMs to understand your natural language commands and questions, executing tasks, answering queries, and providing relevant information from local files and the web.
96
-
97
- - **Macros**: `npcsh` provides macros to accomplish common tasks with LLMs like voice control (`/whisper`), image generation (`/vixynt`), screenshot capture and analysis (`/ots`), one-shot questions (`/sample`), computer use (`/plonk`), retrieval augmented generation (`/rag`), search (`/search`) and more. Users can also build their own tools and call them like macros from the shell.
98
-
99
-
100
- - **NPC-Driven Interactions**: `npcsh` allows users to take advantage of agents (i.e. NPCs) through a managed system. Users build a directory of NPCs and associated tools that can be used to accomplish complex tasks and workflows. NPCs can be tailored to specific tasks and have unique personalities, directives, and tools. Users can combine NPCs and tools in assembly line like workflows or use them in SQL-style models.
101
-
102
- * **Extensible with Python:** `npcsh`'s python package provides useful functions for interacting with LLMs, including explicit coverage for popular providers like ollama, anthropic, openai, gemini, deepseek, and openai-like providers. Each macro has a corresponding function and these can be used in python scripts. `npcsh`'s functions are purpose-built to simplify NPC interactions but NPCs are not required for them to work if you don't see the need.
103
-
104
- * **Simple, Powerful CLI:** Use the `npc` CLI commands to run `npcsh` macros or commands from one's regular shell. Set up a flask server so you can expose your NPC team for use as a backend service. You can also use the `npc` CLI to run SQL models defined in your project, execute assembly lines, and verify the integrity of your NPC team's interrelations. `npcsh`'s NPCs take advantage of jinja templating to reference other NPCs and tools in their properties, and the `npc` CLI can be used to verify these references.
105
-
106
- * **Powerful Tool integrations:** `npcsh` has built-in tools for users to have agents execute code, analyze data, generate images, search the web, and more. Tools can be defined in YAML files as part of project-specific `npc_team`s or in the global `~/.npcsh/npc_team` directory or simply in python scripts. Once compiled, the tools can be used as macros in the `npc` cli as well as `/{tool_name}` commands in the `npcsh` shell.
107
-
108
-
109
- Interested to stay in the loop and to hear the latest and greatest about `npcsh` ? Be sure to sign up for the [npcsh newsletter](https://forms.gle/n1NzQmwjsV4xv1B2A)!
110
-
111
-
112
- ## TLDR Cheat Sheet
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
-
115
-
116
-
117
-
118
- | Task | npc CLI | npcsh |
119
- |----------|----------|----------|
120
- | Ask a generic question | npc 'prompt' | 'prompt' |
121
- | Compile an NPC | npc compile /path/to/npc.npc | /compile /path/to/npc.npc |
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 ' |
123
- | Conjure an NPC team from context and templates | npc init -t 'template1, template2' -ctx 'context' | /conjure -t 'template1, 'template2' -ctx 'context' |
124
- | Enter a chat with an NPC (NPC needs to be compiled first) | npc chat -n npc_name | /spool npc=<npc_name> |
125
- | Generate image | npc vixynt 'prompt' | /vixynt prompt |
126
- | Get a sample LLM response | npc sample 'prompt' | /sample prompt for llm |
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' |
128
- | Search the web | npc search -q "cal golden bears football schedule" -sp perplexity | /search -p perplexity 'cal bears football schedule' |
129
- | Serve an NPC team | npc serve --port 5337 --cors='http://localhost:5137/' | /serve --port 5337 --cors='http://localhost:5137/' |
130
- | Screenshot analysis | npc ots | /ots |
131
- | Voice Chat | npc whisper -n 'npc_name' | /whisper |
132
-
133
-
134
- ## Python Examples
135
- Integrate npcsh into your Python projects for additional flexibility. Below are a few examples of how to use the library programmatically.
136
-
137
-
138
-
139
- ### Example 1: Creating and Using an NPC
140
- This example shows how to create and initialize an NPC and use it to answer a question.
141
- ```bash
142
- import sqlite3
143
- from npcsh.npc_compiler import NPC
144
-
145
- # Set up database connection
146
- db_path = '~/npcsh_history.db'
147
- conn = sqlite3.connect(db_path)
148
-
149
- # Load NPC from a file
150
- npc = NPC(
151
- name='Simon Bolivar',
152
- db_conn=conn,
153
- primary_directive='Liberate South America from the Spanish Royalists.',
154
- model='gpt-4o-mini',
155
- provider='openai',
156
- )
157
-
158
- response = npc.get_llm_response("What is the most important territory to retain in the Andes mountains?")
159
- print(response['response'])
160
- ```
161
- ```bash
162
- 'The most important territory to retain in the Andes mountains for the cause of liberation in South America would be the region of Quito in present-day Ecuador. This area is strategically significant due to its location and access to key trade routes. It also acts as a vital link between the northern and southern parts of the continent, influencing both military movements and the morale of the independence struggle. Retaining control over Quito would bolster efforts to unite various factions in the fight against Spanish colonial rule across the Andean states.'
163
- ```
164
- ### Example 2: Using an NPC to Analyze Data
165
- This example shows how to use an NPC to perform data analysis on a DataFrame using LLM commands.
166
- ```bash
167
- from npcsh.npc_compiler import NPC
168
- import sqlite3
169
- import os
170
- # Set up database connection
171
- db_path = '~/npcsh_history.db'
172
- conn = sqlite3.connect(os.path.expanduser(db_path))
173
-
174
- # make a table to put into npcsh_history.db or change this example to use an existing table in a database you have
175
- import pandas as pd
176
- data = {
177
- 'customer_feedback': ['The product is great!', 'The service was terrible.', 'I love the new feature.'],
178
- 'customer_id': [1, 2, 3],
179
- 'customer_rating': [5, 1, 3],
180
- 'timestamp': ['2022-01-01', '2022-01-02', '2022-01-03']
181
- }
182
-
183
-
184
- df = pd.DataFrame(data)
185
- df.to_sql('customer_feedback', conn, if_exists='replace', index=False)
186
-
187
-
188
- npc = NPC(
189
- name='Felix',
190
- db_conn=conn,
191
- primary_directive='Analyze customer feedback for sentiment.',
192
- model='gpt-4o-mini',
193
- provider='openai',
194
- )
195
- response = npc.analyze_db_data('Provide a detailed report on the data contained in the `customer_feedback` table?')
196
-
197
-
198
- ```
199
-
200
-
201
- ### Example 3: Creating and Using a Tool
202
- You can define a tool and execute it from within your Python script.
203
- Here we'll create a tool that will take in a pdf file, extract the text, and then answer a user request about the text.
204
-
205
- ```bash
206
- from npcsh.npc_compiler import Tool, NPC
207
- import sqlite3
208
- import os
209
-
210
- from jinja2 import Environment, FileSystemLoader
211
-
212
- # Create a proper Jinja environment
213
- jinja_env = Environment(loader=FileSystemLoader('.'))
214
-
215
-
216
- tool_data = {
217
- "tool_name": "pdf_analyzer",
218
- "inputs": ["request", "file"],
219
- "steps": [{ # Make this a list with one dict inside
220
- "engine": "python",
221
- "code": """
222
- try:
223
- import fitz # PyMuPDF
224
-
225
- shared_context = {}
226
- shared_context['inputs'] = '{{request}}'
227
-
228
- pdf_path = '{{file}}'
229
-
230
-
231
-
232
- # Open the PDF
233
- doc = fitz.open(pdf_path)
234
- text = ""
235
-
236
- # Extract text from each page
237
- for page_num in range(len(doc)):
238
- page = doc[page_num]
239
- text += page.get_text()
240
-
241
- # Close the document
242
- doc.close()
243
-
244
- print(f"Extracted text length: {len(text)}")
245
- if len(text) > 100:
246
- print(f"First 100 characters: {text[:100]}...")
247
-
248
- shared_context['extracted_text'] = text
249
- print("Text extraction completed successfully")
250
-
251
- except Exception as e:
252
- error_msg = f"Error processing PDF: {str(e)}"
253
- print(error_msg)
254
- shared_context['extracted_text'] = f"Error: {error_msg}"
255
- """
256
- },
257
- {
258
- "engine": "natural",
259
- "code": """
260
- {% if shared_context and shared_context.extracted_text %}
261
- {% if shared_context.extracted_text.startswith('Error:') %}
262
- {{ shared_context.extracted_text }}
263
- {% else %}
264
- Here is the text extracted from the PDF:
265
-
266
- {{ shared_context.extracted_text }}
267
-
268
- Please provide a response to user request: {{ request }} using the information extracted above.
269
- {% endif %}
270
- {% else %}
271
- Error: No text was extracted from the PDF.
272
- {% endif %}
273
- """
274
- },]
275
- }
276
-
277
- # Instantiate the tool
278
- tool = Tool(tool_data)
279
-
280
- # Create an NPC instance
281
- npc = NPC(
282
- name='starlana',
283
- primary_directive='Analyze text from Astrophysics papers with a keen attention to theoretical machinations and mechanisms.',
284
- model = 'llama3.2',
285
- provider='ollama',
286
- db_conn=sqlite3.connect(os.path.expanduser('~/npcsh_database.db'))
287
- )
288
-
289
- # Define input values dictionary
290
- input_values = {
291
- "request": "what is the point of the yuan and narayanan work?",
292
- "file": os.path.abspath("test_data/yuan2004.pdf")
293
- }
294
-
295
- print(f"Attempting to read file: {input_values['file']}")
296
- print(f"File exists: {os.path.exists(input_values['file'])}")
297
-
298
- # Execute the tool
299
- output = tool.execute(input_values, npc.tools_dict, jinja_env, 'Sample Command',model=npc.model, provider=npc.provider, npc=npc)
300
-
301
- print('Tool Output:', output)
302
- ```
303
-
304
- ### Example 4: Orchestrating a team
305
-
306
-
307
-
308
- ```python
309
- import pandas as pd
310
- import numpy as np
311
- import os
312
- from npcsh.npc_compiler import NPC, NPCTeam, Tool
313
-
314
-
315
- # Create test data and save to CSV
316
- def create_test_data(filepath="sales_data.csv"):
317
- sales_data = pd.DataFrame(
318
- {
319
- "date": pd.date_range(start="2024-01-01", periods=90),
320
- "revenue": np.random.normal(10000, 2000, 90),
321
- "customer_count": np.random.poisson(100, 90),
322
- "avg_ticket": np.random.normal(100, 20, 90),
323
- "region": np.random.choice(["North", "South", "East", "West"], 90),
324
- "channel": np.random.choice(["Online", "Store", "Mobile"], 90),
325
- }
326
- )
327
-
328
- # Add patterns to make data more realistic
329
- sales_data["revenue"] *= 1 + 0.3 * np.sin(
330
- np.pi * np.arange(90) / 30
331
- ) # Seasonal pattern
332
- sales_data.loc[sales_data["channel"] == "Mobile", "revenue"] *= 1.1 # Mobile growth
333
- sales_data.loc[
334
- sales_data["channel"] == "Online", "customer_count"
335
- ] *= 1.2 # Online customer growth
336
-
337
- sales_data.to_csv(filepath, index=False)
338
- return filepath, sales_data
339
-
340
-
341
- code_execution_tool = Tool(
342
- {
343
- "tool_name": "execute_code",
344
- "description": """Executes a Python code block with access to pandas,
345
- numpy, and matplotlib.
346
- Results should be stored in the 'results' dict to be returned.
347
- The only input should be a single code block with \n characters included.
348
- The code block must use only the libraries or methods contained withen the
349
- pandas, numpy, and matplotlib libraries or using builtin methods.
350
- do not include any json formatting or markdown formatting.
351
-
352
- When generating your script, the final output must be encoded in a variable
353
- named "output". e.g.
354
-
355
- output = some_analysis_function(inputs, derived_data_from_inputs)
356
- Adapt accordingly based on the scope of the analysis
357
-
358
- """,
359
- "inputs": ["script"],
360
- "steps": [
361
- {
362
- "engine": "python",
363
- "code": """{{script}}""",
364
- }
365
- ],
366
- }
367
- )
368
-
369
- # Analytics team definition
370
- analytics_team = [
371
- {
372
- "name": "analyst",
373
- "primary_directive": "You analyze sales performance data, focusing on revenue trends, customer behavior metrics, and market indicators. Your expertise is in extracting actionable insights from complex datasets.",
374
- "model": "gpt-4o-mini",
375
- "provider": "openai",
376
- "tools": [code_execution_tool], # Only the code execution tool
377
- },
378
- {
379
- "name": "researcher",
380
- "primary_directive": "You specialize in causal analysis and experimental design. Given data insights, you determine what factors drive observed patterns and design tests to validate hypotheses.",
381
- "model": "gpt-4o-mini",
382
- "provider": "openai",
383
- "tools": [code_execution_tool], # Only the code execution tool
384
- },
385
- {
386
- "name": "engineer",
387
- "primary_directive": "You implement data pipelines and optimize data processing. When given analysis requirements, you create efficient workflows to automate insights generation.",
388
- "model": "gpt-4o-mini",
389
- "provider": "openai",
390
- "tools": [code_execution_tool], # Only the code execution tool
391
- },
392
- ]
393
-
394
-
395
- def create_analytics_team():
396
- # Initialize NPCs with just the code execution tool
397
- npcs = []
398
- for npc_data in analytics_team:
399
- npc = NPC(
400
- name=npc_data["name"],
401
- primary_directive=npc_data["primary_directive"],
402
- model=npc_data["model"],
403
- provider=npc_data["provider"],
404
- tools=[code_execution_tool], # Only code execution tool
405
- )
406
- npcs.append(npc)
407
-
408
- # Create coordinator with just code execution tool
409
- coordinator = NPC(
410
- name="coordinator",
411
- primary_directive="You coordinate the analytics team, ensuring each specialist contributes their expertise effectively. You synthesize insights and manage the workflow.",
412
- model="gpt-4o-mini",
413
- provider="openai",
414
- tools=[code_execution_tool], # Only code execution tool
415
- )
416
-
417
- # Create team
418
- team = NPCTeam(npcs=npcs, foreman=coordinator)
419
- return team
420
-
421
-
422
- def main():
423
- # Create and save test data
424
- data_path, sales_data = create_test_data()
425
-
426
- # Initialize team
427
- team = create_analytics_team()
428
-
429
- # Run analysis - updated prompt to reflect code execution approach
430
- results = team.orchestrate(
431
- f"""
432
- Analyze the sales data at {data_path} to:
433
- 1. Identify key performance drivers
434
- 2. Determine if mobile channel growth is significant
435
- 3. Recommend tests to validate growth hypotheses
436
-
437
- Here is a header for the data file at {data_path}:
438
- {sales_data.head()}
439
-
440
- When working with dates, ensure that date columns are converted from raw strings. e.g. use the pd.to_datetime function.
441
-
442
-
443
- When working with potentially messy data, handle null values by using nan versions of numpy functions or
444
- by filtering them with a mask .
445
-
446
- Use Python code execution to perform the analysis - load the data and perform statistical analysis directly.
447
- """
448
- )
449
-
450
- print(results)
451
-
452
- # Cleanup
453
- os.remove(data_path)
454
-
455
-
456
- if __name__ == "__main__":
457
- main()
458
-
459
- ```
460
-
461
-
462
-
463
- ## Star History
464
-
465
- [![Star History Chart](https://api.star-history.com/svg?repos=cagostino/npcsh&type=Date)](https://star-history.com/#cagostino/npcsh&Date)
466
-
467
- ## Installation
468
- `npcsh` is available on PyPI and can be installed using pip. Before installing, make sure you have the necessary dependencies installed on your system. Below are the instructions for installing such dependencies on Linux, Mac, and Windows. If you find any other dependencies that are needed, please let us know so we can update the installation instructions to be more accommodating.
469
-
470
- ### Linux install
471
- ```bash
472
-
473
- # for audio primarily
474
- sudo apt-get install espeak
475
- sudo apt-get install portaudio19-dev python3-pyaudio
476
- sudo apt-get install alsa-base alsa-utils
477
- sudo apt-get install libcairo2-dev
478
- sudo apt-get install libgirepository1.0-dev
479
- sudo apt-get install ffmpeg
480
-
481
- # for triggers
482
- sudo apt install inotify-tools
483
-
484
-
485
- #And if you don't have ollama installed, use this:
486
- curl -fsSL https://ollama.com/install.sh | sh
487
-
488
- ollama pull llama3.2
489
- ollama pull llava:7b
490
- ollama pull nomic-embed-text
491
- pip install npcsh
492
- # if you want to install with the API libraries
493
- pip install npcsh[lite]
494
- # if you want the full local package set up (ollama, diffusers, transformers, cuda etc.)
495
- pip install npcsh[local]
496
- # if you want to use tts/stt
497
- pip install npcsh[whisper]
498
-
499
- # if you want everything:
500
- pip install npcsh[all]
501
-
502
-
503
-
504
-
505
- ### Mac install
506
- ```bash
507
- #mainly for audio
508
- brew install portaudio
509
- brew install ffmpeg
510
- brew install pygobject3
511
-
512
- # for triggers
513
- brew install ...
514
-
515
-
516
- brew install ollama
517
- brew services start ollama
518
- ollama pull llama3.2
519
- ollama pull llava:7b
520
- ollama pull nomic-embed-text
521
- pip install npcsh
522
- # if you want to install with the API libraries
523
- pip install npcsh[lite]
524
- # if you want the full local package set up (ollama, diffusers, transformers, cuda etc.)
525
- pip install npcsh[local]
526
- # if you want to use tts/stt
527
- pip install npcsh[whisper]
528
-
529
- # if you want everything:
530
- pip install npcsh[all]
531
-
532
- ```
533
- ### Windows Install
534
-
535
- Download and install ollama exe.
536
-
537
- Then, in a powershell. Download and install ffmpeg.
538
-
539
- ```
540
- ollama pull llama3.2
541
- ollama pull llava:7b
542
- ollama pull nomic-embed-text
543
- pip install npcsh
544
- # if you want to install with the API libraries
545
- pip install npcsh[lite]
546
- # if you want the full local package set up (ollama, diffusers, transformers, cuda etc.)
547
- pip install npcsh[local]
548
- # if you want to use tts/stt
549
- pip install npcsh[whisper]
550
-
551
- # if you want everything:
552
- pip install npcsh[all]
553
-
554
- ```
555
- As of now, npcsh appears to work well with some of the core functionalities like /ots and /whisper.
556
-
557
-
558
- ### Fedora Install (under construction)
559
-
560
- python3-dev (fixes hnswlib issues with chroma db)
561
- xhost + (pyautogui)
562
- python-tkinter (pyautogui)
563
-
564
- ## Startup Configuration and Project Structure
565
- After it has been pip installed, `npcsh` can be used as a command line tool. Start it by typing:
566
- ```bash
567
- npcsh
568
- ```
569
- When initialized, `npcsh` will generate a .npcshrc file in your home directory that stores your npcsh settings.
570
- Here is an example of what the .npcshrc file might look like after this has been run.
571
- ```bash
572
- # NPCSH Configuration File
573
- export NPCSH_INITIALIZED=1
574
- export NPCSH_CHAT_PROVIDER='ollama'
575
- export NPCSH_CHAT_MODEL='llama3.2'
576
- export NPCSH_DB_PATH='~/npcsh_history.db'
577
- ```
578
- `npcsh` also comes with a set of tools and NPCs that are used in processing. It will generate a folder at ~/.npcsh/ that contains the tools and NPCs that are used in the shell and these will be used in the absence of other project-specific ones. Additionally, `npcsh` records interactions and compiled information about npcs within a local SQLite database at the path specified in the .npcshrc file. This will default to ~/npcsh_history.db if not specified. When the data mode is used to load or analyze data in CSVs or PDFs, these data will be stored in the same database for future reference.
579
-
580
- The installer will automatically add this file to your shell config, but if it does not do so successfully for whatever reason you can add the following to your .bashrc or .zshrc:
581
-
582
- ```bash
583
- # Source NPCSH configuration
584
- if [ -f ~/.npcshrc ]; then
585
- . ~/.npcshrc
586
- fi
587
- ```
588
-
589
- We support inference via `openai`, `anthropic`, `ollama`,`gemini`, `deepseek`, and `openai-like` APIs. The default provider must be one of `['openai','anthropic','ollama', 'gemini', 'deepseek', 'openai-like']` and the model must be one available from those providers.
590
-
591
- To use tools that require API keys, create an `.env` file up in the folder where you are working or place relevant API keys as env variables in your ~/.npcshrc. If you already have these API keys set in a ~/.bashrc or a ~/.zshrc or similar files, you need not additionally add them to ~/.npcshrc or to an `.env` file. Here is an example of what an `.env` file might look like:
592
-
593
- ```bash
594
- export OPENAI_API_KEY="your_openai_key"
595
- export ANTHROPIC_API_KEY="your_anthropic_key"
596
- export DEEPSEEK_API_KEY='your_deepseek_key'
597
- export GEMINI_API_KEY='your_gemini_key'
598
- export PERPLEXITY_API_KEY='your_perplexity_key'
599
- ```
600
-
601
-
602
- Individual npcs can also be set to use different models and providers by setting the `model` and `provider` keys in the npc files.
603
- Once initialized and set up, you will find the following in your ~/.npcsh directory:
604
- ```bash
605
- ~/.npcsh/
606
- ├── npc_team/ # Global NPCs
607
- │ ├── tools/ # Global tools
608
- │ └── assembly_lines/ # Workflow pipelines
609
-
610
- ```
611
- For cases where you wish to set up a project specific set of NPCs, tools, and assembly lines, add a `npc_team` directory to your project and `npcsh` should be able to pick up on its presence, like so:
612
- ```bash
613
- ./npc_team/ # Project-specific NPCs
614
- ├── tools/ # Project tools #example tool next
615
- │ └── example.tool
616
- └── assembly_lines/ # Project workflows
617
- └── example.pipe
618
- └── models/ # Project workflows
619
- └── example.model
620
- └── example1.npc # Example NPC
621
- └── example2.npc # Example NPC
622
- └── example1.ctx # Example NPC
623
- └── example2.ctx # Example NPC
624
-
625
- ```
626
-
627
- ## IMPORTANT: migrations and deprecations
628
-
629
- ### v0.3.4
630
- -In v0.3.4, the structure for tools was adjusted. If you have made custom tools please refer to the structure within npc_compiler to ensure that they are in the correct format. Otherwise, do the following
631
- ```bash
632
- rm ~/.npcsh/npc_team/tools/*.tool
633
- ```
634
- and then
635
- ```bash
636
- npcsh
637
- ```
638
- and the updated tools will be copied over into the correct location.
639
-
640
- ### v0.3.5
641
- -Version 0.3.5 included a complete overhaul and refactoring of the llm_funcs module. This was done to make it not as horribly long and to make it easier to add new models and providers
642
-
643
-
644
- -in version 0.3.5, a change was introduced to the database schema for messages to add npcs, models, providers, and associated attachments to data. If you have used `npcsh` before this version, you will need to run this migration script to update your database schema: [migrate_conversation_history_v0.3.5.py](https://github.com/cagostino/npcsh/blob/cfb9dc226e227b3e888f3abab53585693e77f43d/npcsh/migrations/migrate_conversation_history_%3Cv0.3.4-%3Ev0.3.5.py)
645
-
646
- -additionally, NPCSH_MODEL and NPCSH_PROVIDER have been renamed to NPCSH_CHAT_MODEL and NPCSH_CHAT_PROVIDER
647
- to provide a more consistent naming scheme now that we have additionally introduced `NPCSH_VISION_MODEL` and `NPCSH_VISION_PROVIDER`, `NPCSH_EMBEDDING_MODEL`, `NPCSH_EMBEDDING_PROVIDER`, `NPCSH_REASONING_MODEL`, `NPCSH_REASONING_PROVIDER`, `NPCSH_IMAGE_GEN_MODEL`, and `NPCSH_IMAGE_GEN_PROVIDER`.
648
- - In addition, we have added NPCSH_API_URL to better accommodate openai-like apis that require a specific url to be set as well as `NPCSH_STREAM_OUTPUT` to indicate whether or not to use streaming in one's responses. It will be set to 0 (false) by default as it has only been tested and verified for a small subset of the models and providers we have available (openai, anthropic, and ollama). If you try it and run into issues, please post them here so we can correct them as soon as possible !
649
-
650
-
651
- ## npcsh usage
652
- In the `npcsh` shell, users can ask LLMs questions, have LLMLs execute commands or use tools, or utilize macros that provide additional functionality. When a user does not invoke a specific macro, the shell will automatically decide which tool to use based on the user's input. Here are some examples of things one might ask the npcsh shell.
653
-
654
- Here are some examples of how you can use npcsh
655
- ```npcsh
656
- npcsh>Who was Simon Bolivar?
657
-
658
- Simón Bolívar, often referred to as "El Libertador," was a Venezuelan military and political leader who played a key role in the Latin American wars of independence against Spanish
659
- colonial rule in the early 19th century. He was born on July 24, 1783, in Caracas, Venezuela, into a wealthy Creole family.
660
- Bolívar's vision extended beyond merely liberating territories; he aspired to unify the newly independent nations of South America into a single federation, which he called "Gran
661
- Colombia," consisting of present-day Colombia, Venezuela, Ecuador, and Panama. He was known for his exceptional military strategies and leadership, which led to successful campaigns in
662
- various regions, including the battles of Boyacá, Carabobo, and Ayacucho.
663
- He faced numerous challenges, including political fragmentation, regional rivalries, and personal betrayals. Despite his initial successes, the unity he sought for Latin America proved
664
- difficult to achieve, and Gran Colombia eventually disintegrated in the early 1830s.
665
- Bolívar's influence and legacy extend far beyond his lifetime. He is celebrated in various countries across Latin America as a national hero and symbol of independence. His thoughts on
666
- liberty, governance, and social issues continue to inspire movements for democracy and social justice in the region. Simón Bolívar died on December 17, 1830, but remains a pivotal figure
667
- in the history of Latin America.
668
- ```
669
-
670
-
671
- ```npcsh
672
- npcsh> What is the capital of France?
673
- The capital of France is Paris. It is the largest city in the country and is known for its rich history, art, culture, and architecture, including famous landmarks such as the Eiffel Tower, Notre-Dame Cathedral, and the Louvre Museum.
674
- ```
675
-
676
- ```npcsh
677
- npcsh> can you tell me a joke about my favorite city?
678
-
679
- Additional input needed: The user did not specify their favorite city, which is necessary to generate a relevant joke.
680
- Please tell me your favorite city so I can share a joke about it!: boston
681
-
682
- Sure! Here's a joke about Boston:
683
- Why do Bostonians like to play hide and seek?
684
- Because good luck hiding when everyone yells, "Wicked awesome, ya gotta be here!"
685
- ```
686
-
687
- ```npcsh
688
- npcsh> What's the weather in Tokyo?
689
-
690
- handle_tool_call invoked with tool_name: generic_search_tool
691
-
692
- The weather in Tokyo, Japan, is expected to be mixed with sun and clouds. Here are some details from the recent forecasts:
693
-
694
- • Highs: Around 53°F to 58°F with a few variations depending on the day.
695
-
696
- • Lows: Approximately 35°F to 40°F.
697
-
698
- • Winds: Generally from the northwest at 5 to 10 mph.
699
-
700
- • Condition: Mainly sunny, but there may be periods of clouds and some overcast conditions throughout the week.
701
- For more detailed information, you can refer to sources like The Weather Channel or AccuWeather.
702
- /home/caug/npcww/npcsh:npcsh>
703
-
704
- ```
705
- In the below example, the code that was open was the screen capture analysis tool itself.
706
- ```npcsh
707
- npcsh> Can you explain what the code does in the currently open VS code window?
708
-
709
- handle_tool_call invoked with tool_name: screen_capture_analysis_tool
710
-
711
- Screenshot saved as screenshot_20241223_225815.png
712
-
713
- The code in the visible section of your VS Code window appears to be a script for capturing and analyzing screenshots. Here's a breakdown of what the code does:
714
-
715
- 1 Import Necessary Libraries: It imports required libraries like system, datetime, and pyautogui, which are essential for capturing screenshots and handling date-time operations.
716
-
717
- 2 Capture the Screen: The code captures the current screen using pyautogui.screenshot(), taking a screenshot of the entire screen.
718
-
719
- 3 File Management: It generates a unique filename for the screenshot using the current date and time. This ensures that each screenshot file is distinct.
720
-
721
- 4 Save the Screenshot: The captured screenshot is saved to a file with the generated filename.
722
-
723
- 5 Image Analysis: It likely imports a functionality (analyze_image_base) to analyze the screenshot for specific content or information.
724
-
725
- 6 Run the Analysis: While not explicitly shown, it appears to call this analysis function to process the saved screenshot.
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.
727
-
728
-
729
- ```
730
-
731
- ```npcsh
732
- npcsh>What is the best way to implement a linked list in Python?
733
-
734
- The best way to implement a linked list in Python is to define a Node class for the individual elements and a LinkedList class to manage the nodes. Here's a basic implementation:
735
- class Node:
736
- def __init__(self, data):
737
- self.data = data # Store the data
738
- self.next = None # Initialize the next node as None
739
-
740
- class LinkedList:
741
- def __init__(self):
742
- self.head = None # Initialize the head of the list
743
-
744
- def insert(self, data):
745
- """Inserts a new node at the end of the linked list."""
746
- new_node = Node(data)
747
- if not self.head: # If list is empty, set new node as head
748
- self.head = new_node
749
- return
750
- last_node = self.head
751
- while last_node.next: # Traverse to the last node
752
- last_node = last_node.next
753
- last_node.next = new_node # Link the new node
754
-
755
- def display(self):
756
- """Prints the linked list."""
757
- current = self.head
758
- while current:
759
- print(current.data, end=" -> ")
760
- current = current.next
761
- print("None")
762
-
763
- # Example usage:
764
- llist = LinkedList()
765
- llist.insert(1)
766
- llist.insert(2)
767
- llist.insert(3)
768
- llist.display() # Output: 1 -> 2 -> 3 -> None
769
- Explanation:
770
-
771
- 1 Node Class: Represents each node in the linked list. It has two attributes: data (to store the value) and next (to point to the next node).
772
-
773
- 2 LinkedList Class: Manages the linked list. It has a head attribute pointing to the first node.
774
-
775
- 3 Insert Method: Adds a new node to the end of the list.
776
-
777
- 4 Display Method: Prints the elements of the list in order.
778
- This implementation is simple and can be extended with more methods (e.g., deletion, searching, etc.) as needed.
779
-
780
- ```
781
-
782
- ```npcsh
783
- npcsh> In which of the files in the current directory is "Simon Bolivar" mentioned?
784
-
785
- The user's query was about "Simon Bolivar." Based on the relevant context from the codebase, I found specific mentions and relevant information regarding Simon Bolívar in the documentation provided
786
- in the README.md file.
787
- From the relevant context, specifically in the section of README.md, it shared a code example that demonstrates how to load an NPC (Non-Player Character) named "Simon Bolivar" using SQLite and
788
- answer a question about project updates. This code snippet indicates that "Simon Bolivar" is represented in the NPC system, allowing for interaction through questions to retrieve information.
789
- Additionally, there is another passage that directly answers the query. It reads:
790
-
791
- ▌ "Simón Bolívar, often referred to as 'El Libertador,' was a Venezuelan military and political leader who played a key role in the Latin American wars of independence against Spanish colonial
792
- ▌ rule in the early 19th century."
793
- This information highlights Bolívar's significant historical role and achievements, answering the query regarding who Simon Bolivar was, thus making it clear that he was a prominent leader in Latin
794
- America's fight for independence.
795
- To summarize, I arrived at this answer by examining the provided context in the README.md file that includes both the coding example that initializes an NPC named "Simon Bolivar" and a historical
796
- overview of his contributions, which directly addresses the user's inquiry.
797
-
798
-
799
- ```
800
-
801
-
802
- ```npcsh
803
- npcsh>what process is using the most ram on my computer right now?
804
-
805
- LLM suggests the following bash command: ps aux --sort=-%mem | head -n 10
806
- Running command: ps aux --sort=-%mem | head -n 10
807
- Command executed with output: USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
808
- caug 1040046 1.1 2.7 1226193464 1598980 ? SNl Dec22 23:30 /opt/vivaldi/vivaldi-bin --type=renderer --crashpad-handler-pid=4529 --enable-crash-reporter=,stable --change-stack-guard-on-fork=
809
- caug 683148 0.0 1.9 2047464 1137232 ? SNl Dec13 10:11 io.elementary.appcenter
810
- ollama 1884 0.0 1.8 3683920 1051020 ? SNsl Dec02 0:30 /usr/local/bin/ollama serve
811
- caug 1191836 5.3 1.6 7346052 964988 pts/17 Sl+ 22:57 0:22 /home/caug/.pyenv/versions/npcsh/bin/python /home/caug/.pyenv/versions/3.11.0/envs/npcsh/bin/npcsh
812
- caug 1145749 0.0 1.5 7068128 892500 pts/13 Sl+ Dec22 0:15 /home/caug/.pyenv/versions/3.11.0/bin/python3.11 /home/caug/.pyenv/versions/3.11.0/bin/npcsh
813
- caug 493912 0.0 1.5 7050968 890012 pts/11 Sl+ Dec10 0:14 /home/caug/.pyenv/versions/npcsh/bin/python /home/caug/.pyenv/versions/npcsh/bin/npcsh
814
- caug 4522 0.9 1.5 34391236 874756 ? SNLl Dec02 295:06 /opt/vivaldi/vivaldi-bin
815
- caug 3995 0.7 1.1 6051812 683916 ? R<sl Dec02 221:19 /usr/bin/gnome-shell
816
- caug 501721 0.3 1.0 1212584660 626248 ? SNl Dec10 60:22 /opt/vivaldi/vivaldi-bin --type=renderer --crashpad-handler-pid=4529 --enable-crash-reporter=,stable --change-stack-guard-on-fork=
817
-
818
- To determine which processes are using the most RAM on your computer, I executed the command ps aux --sort=-%mem | head -n 10.
819
- This command lists all running processes (ps aux), sorts them by memory usage in descending order (--sort=-%mem), and then retrieves the top 10 entries (head -n 10).
820
- The output shows the processes currently consuming the most memory. In the results, the process using the most RAM is Vivaldi's renderer, followed by other applications such as the Elementary App Center, Ollama server, and several instances of Python related to your NPC shell.
821
- ```
822
-
823
- ```npcsh
824
- npcsh> can you generate an image of a calico cat and an orange tabby cat in the style of a japanese woodblock print where the two cats are engaged in a samurai battle but instead of samurai swords they are holding cat toys that are like wands with felt birds on the ends of them on strings
825
-
826
- handle_tool_call invoked with tool_name: image_generation_tool
827
- ```
828
- ![catfight](test_data/catfight.PNG)
829
-
830
-
831
- In addition to its ability to execute one-off tasks or tool calls, npcsh also has
832
- the ability to generate tool call sequences when asked:
833
- ```npcsh
834
-
835
- npcsh> can you use a tool sequence to find the gdp of russia in 2024 and then to use that information to generate an image?
836
-
837
- handle_tool_call invoked with tool_name: generic_search_tool
838
- Tool found: generic_search_tool
839
- handle_tool_call invoked with tool_name: image_generation_tool
840
- Tool found: image_generation_tool
841
-
842
- The Gross Domestic Product (GDP) of Russia is estimated to be $8.311 trillion by the end of 2024, according to World Economics.
843
- This figure is significantly larger than the official estimate of $5.804 trillion published by the World Bank for the end of 2023.
844
-
845
- It seems that you've generated an image. If you have any questions or need assistance related to this image, please let me know how I can help!
846
- ```
847
- and then the associated image :
848
- ![gdp](test_data/r8ss9a.PNG)
849
-
850
-
851
-
852
-
853
-
854
-
855
-
856
- ### Piping outputs
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:
858
- ```npcsh
859
- npcsh> what is the gdp of russia in 2024? | /vixynt 'generate an image that contains {0}'
860
- ```
861
- ### Executing Bash Commands
862
- You can execute bash commands directly within npcsh. The LLM can also generate and execute bash commands based on your natural language requests.
863
- For example:
864
- ```npcsh
865
- npcsh> ls -l
866
-
867
- npcsh> cp file1.txt file2.txt
868
- npcsh> mv file1.txt file2.txt
869
- npcsh> mkdir new_directory
870
- npcsh> git status
871
- npcsh> vim file.txt
872
-
873
- ```
874
-
875
- ### NPC CLI
876
- When npcsh is installed, it comes with the `npc` cli as well. The `npc` cli has various command to make initializing and serving NPC projects easier.
877
-
878
- Users can make queries like so:
879
- ```bash
880
- $ npc 'whats the biggest filei n my computer'
881
- Loaded .env file from /home/caug/npcww/npcsh
882
- action chosen: request_input
883
- explanation given: The user needs to provide more context about their operating system or specify which directory to search for the biggest file.
884
-
885
- Additional input needed: The user did not specify their operating system or the directory to search for the biggest file, making it unclear how to execute the command.
886
- Please specify your operating system (e.g., Windows, macOS, Linux) and the directory you want to search in.: linux and root
887
- action chosen: execute_command
888
- explanation given: The user is asking for the biggest file on their computer, which can be accomplished with a simple bash command that searches for the largest files.
889
- sibiji generating command
890
- LLM suggests the following bash command: sudo find / -type f -exec du -h {} + | sort -rh | head -n 1
891
- Running command: sudo find / -type f -exec du -h {} + | sort -rh | head -n 1
892
- Command executed with output: 11G /home/caug/.cache/huggingface/hub/models--state-spaces--mamba-2.8b/blobs/39911a8470a2b256016b57cc71c68e0f96751cba5b229216ab1f4f9d82096a46
893
-
894
- I ran a command on your Linux system that searches for the largest files on your computer. The command `sudo find / -type f -exec du -h {} + | sort -rh | head -n 1` performs the following steps:
895
-
896
- 1. **Find Command**: It searches for all files (`-type f`) starting from the root directory (`/`).
897
- 2. **Disk Usage**: For each file found, it calculates its disk usage in a human-readable format (`du -h`).
898
- 3. **Sort**: It sorts the results in reverse order based on size (`sort -rh`), so the largest files appear first.
899
- 4. **Head**: Finally, it retrieves just the largest file using `head -n 1`.
900
-
901
- The output indicates that the biggest file on your system is located at `/home/caug/.cache/huggingface/hub/models--state-spaces--mamba-2.8b/blobs/39911a8470a2b256016b57cc71c68e0f96751cba5b229216ab1f4f9d82096a46` and is 11GB in size.
902
-
903
- ```
904
-
905
- ```bash
906
- $ npc 'whats the weather in tokyo'
907
- Loaded .env file from /home/caug/npcww/npcsh
908
- action chosen: invoke_tool
909
- explanation given: The user's request for the current weather in Tokyo requires up-to-date information, which can be best obtained through an internet search.
910
- Tool found: internet_search
911
- Executing tool with input values: {'query': 'whats the weather in tokyo'}
912
- QUERY in tool whats the weather in tokyo
913
- [{'title': 'Tokyo, Tokyo, Japan Weather Forecast | AccuWeather', 'href': 'https://www.accuweather.com/en/jp/tokyo/226396/weather-forecast/226396', 'body': 'Tokyo, Tokyo, Japan Weather Forecast, with current conditions, wind, air quality, and what to expect for the next 3 days.'}, {'title': 'Tokyo, Japan 14 day weather forecast - timeanddate.com', 'href': 'https://www.timeanddate.com/weather/japan/tokyo/ext', 'body': 'Tokyo Extended Forecast with high and low temperatures. °F. Last 2 weeks of weather'}, {'title': 'Tokyo, Tokyo, Japan Current Weather | AccuWeather', 'href': 'https://www.accuweather.com/en/jp/tokyo/226396/current-weather/226396', 'body': 'Current weather in Tokyo, Tokyo, Japan. Check current conditions in Tokyo, Tokyo, Japan with radar, hourly, and more.'}, {'title': 'Weather in Tokyo, Japan - timeanddate.com', 'href': 'https://www.timeanddate.com/weather/japan/tokyo', 'body': 'Current weather in Tokyo and forecast for today, tomorrow, and next 14 days'}, {'title': 'Tokyo Weather Forecast Today', 'href': 'https://japanweather.org/tokyo', 'body': "For today's mild weather in Tokyo, with temperatures between 13ºC to 16ºC (55.4ºF to 60.8ºF), consider wearing: - Comfortable jeans or slacks - Sun hat (if spending time outdoors) - Lightweight sweater or cardigan - Long-sleeve shirt or blouse. Temperature. Day. 14°C. Night. 10°C. Morning. 10°C. Afternoon."}] <class 'list'>
914
- RESULTS in tool ["Tokyo, Tokyo, Japan Weather Forecast, with current conditions, wind, air quality, and what to expect for the next 3 days.\n Citation: https://www.accuweather.com/en/jp/tokyo/226396/weather-forecast/226396\n\n\n\nTokyo Extended Forecast with high and low temperatures. °F. Last 2 weeks of weather\n Citation: https://www.timeanddate.com/weather/japan/tokyo/ext\n\n\n\nCurrent weather in Tokyo, Tokyo, Japan. Check current conditions in Tokyo, Tokyo, Japan with radar, hourly, and more.\n Citation: https://www.accuweather.com/en/jp/tokyo/226396/current-weather/226396\n\n\n\nCurrent weather in Tokyo and forecast for today, tomorrow, and next 14 days\n Citation: https://www.timeanddate.com/weather/japan/tokyo\n\n\n\nFor today's mild weather in Tokyo, with temperatures between 13ºC to 16ºC (55.4ºF to 60.8ºF), consider wearing: - Comfortable jeans or slacks - Sun hat (if spending time outdoors) - Lightweight sweater or cardigan - Long-sleeve shirt or blouse. Temperature. Day. 14°C. Night. 10°C. Morning. 10°C. Afternoon.\n Citation: https://japanweather.org/tokyo\n\n\n", 'https://www.accuweather.com/en/jp/tokyo/226396/weather-forecast/226396\n\nhttps://www.timeanddate.com/weather/japan/tokyo/ext\n\nhttps://www.accuweather.com/en/jp/tokyo/226396/current-weather/226396\n\nhttps://www.timeanddate.com/weather/japan/tokyo\n\nhttps://japanweather.org/tokyo\n']
915
- The current weather in Tokyo, Japan is mild, with temperatures ranging from 13°C to 16°C (approximately 55.4°F to 60.8°F). For today's conditions, it is suggested to wear comfortable jeans or slacks, a lightweight sweater or cardigan, and a long-sleeve shirt or blouse, especially if spending time outdoors. The temperature today is expected to reach a high of 14°C (57.2°F) during the day and a low of 10°C (50°F) at night.
916
-
917
- For more detailed weather information, you can check out the following sources:
918
- - [AccuWeather Forecast](https://www.accuweather.com/en/jp/tokyo/226396/weather-forecast/226396)
919
- - [Time and Date Extended Forecast](https://www.timeanddate.com/weather/japan/tokyo/ext)
920
- - [Current Weather on AccuWeather](https://www.accuweather.com/en/jp/tokyo/226396/current-weather/226396)
921
- - [More on Time and Date](https://www.timeanddate.com/weather/japan/tokyo)
922
- - [Japan Weather](https://japanweather.org/tokyo)
923
- ```
924
-
925
-
926
- ### Serving
927
- To serve an NPC project, first install redis-server and start it
928
-
929
- on Ubuntu:
930
- ```bash
931
- sudo apt update && sudo apt install redis-server
932
- redis-server
933
- ```
934
-
935
- on macOS:
936
- ```bash
937
- brew install redis
938
- redis-server
939
- ```
940
- Then navigate to the project directory and run:
941
-
942
- ```bash
943
- npc serve
944
- ```
945
- If you want to specify a certain port, you can do so with the `-p` flag:
946
- ```bash
947
- npc serve -p 5337
948
- ```
949
- or with the `--port` flag:
950
- ```bash
951
- npc serve --port 5337
952
-
953
- ```
954
- If you want to initialize a project based on templates and then make it available for serving, you can do so like this
955
- ```bash
956
- npc serve -t 'sales, marketing' -ctx 'im developing a team that will focus on sales and marketing within the logging industry. I need a team that can help me with the following: - generate leads - create marketing campaigns - build a sales funnel - close deals - manage customer relationships - manage sales pipeline - manage marketing campaigns - manage marketing budget' -m llama3.2 -pr ollama
957
- ```
958
- This will use the specified model and provider to generate a team of npcs to fit the templates and context provided.
959
-
960
-
961
- Once the server is up and running, you can access the API endpoints at `http://localhost:5337/api/`. Here are some example curl commands to test the endpoints:
962
-
963
- ```bash
964
- echo "Testing health endpoint..."
965
- curl -s http://localhost:5337/api/health | jq '.'
966
-
967
- echo -e "\nTesting execute endpoint..."
968
- curl -s -X POST http://localhost:5337/api/execute \
969
- -H "Content-Type: application/json" \
970
- -d '{"commandstr": "hello world", "currentPath": "~/", "conversationId": "test124"}' | jq '.'
971
-
972
- echo -e "\nTesting conversations endpoint..."
973
- curl -s "http://localhost:5337/api/conversations?path=/tmp" | jq '.'
974
-
975
- echo -e "\nTesting conversation messages endpoint..."
976
- curl -s http://localhost:5337/api/conversation/test123/messages | jq '.'
977
- ```
978
-
979
- ###
980
-
981
-
982
- * **Planned:** -npc scripts
983
- -npc run select +sql_model <run up>
984
- -npc run select +sql_model+ <run up and down>
985
- -npc run select sql_model+ <run down>
986
- -npc run line <assembly_line>
987
- -npc conjure fabrication_plan.fab
988
-
989
-
990
-
991
- ## Macros
992
-
993
- While npcsh can decide the best option to use based on the user's input, the user can also execute certain actions with a macro. Macros are commands within the NPC shell that start with a forward slash (/) and are followed (in some cases) by the relevant arguments for those macros. Each macro is also available as a sub-program within the NPC CLI. In the following examples we demonstrate how to carry out the same operations from within npcsh and from a regular shell.
994
-
995
-
996
- To learn about the available macros from within the shell, type:
997
- ```npcsh
998
- npcsh> /help
999
- ```
1000
-
1001
- or from bash
1002
- ```bash
1003
- npc --help
1004
- #alternatively
1005
- npc -h
1006
- ```
1007
-
1008
- To exit the shell:
1009
- ```npcsh
1010
- npcsh> /exit
1011
- ```
1012
-
1013
- Otherwise, here are some more detailed examples of macros that can be used in npcsh:
1014
- ### Conjure (under construction)
1015
- Use the `/conjure` macro to generate an NPC, a NPC tool, an assembly line, a job, or an SQL model
1016
-
1017
- ```bash
1018
- npc conjure -n name -t 'templates'
1019
- ```
1020
-
1021
-
1022
- ### Data Interaction and analysis (under construction)
1023
-
1024
-
1025
- ### Debate (under construction)
1026
- Use the `/debate` macro to have two or more NPCs debate a topic, problem, or question.
1027
-
1028
- For example:
1029
- ```npcsh
1030
- npcsh> /debate Should humans colonize Mars? npcs = ['sibiji', 'mark', 'ted']
1031
- ```
1032
-
1033
-
1034
-
1035
- ### Notes
1036
- Jot down notes and store them within the npcsh database and in the current directory as a text file.
1037
- ```npcsh
1038
- npcsh> /notes
1039
- ```
1040
-
1041
-
1042
- ### Over-the-shoulder: Screenshots and image analysis
1043
-
1044
- Use the /ots macro to take a screenshot and write a prompt for an LLM to answer about the screenshot.
1045
- ```npcsh
1046
- npcsh> /ots
1047
-
1048
- Screenshot saved to: /home/caug/.npcsh/screenshots/screenshot_1735015011.png
1049
-
1050
- Enter a prompt for the LLM about this image (or press Enter to skip): describe whats in this image
1051
-
1052
- The image displays a source control graph, likely from a version control system like Git. It features a series of commits represented by colored dots connected by lines, illustrating the project's development history. Each commit message provides a brief description of the changes made, including tasks like fixing issues, merging pull requests, updating README files, and adjusting code or documentation. Notably, several commits mention specific users, particularly "Chris Agostino," indicating collaboration and contributions to the project. The graph visually represents the branching and merging of code changes.
1053
- ```
1054
-
1055
- In bash:
1056
- ```bash
1057
- npc ots
1058
- ```
1059
-
1060
-
1061
-
1062
- Alternatively, pass an existing image in like :
1063
- ```npcsh
1064
- npcsh> /ots test_data/catfight.PNG
1065
- Enter a prompt for the LLM about this image (or press Enter to skip): whats in this ?
1066
-
1067
- The image features two cats, one calico and one orange tabby, playing with traditional Japanese-style toys. They are each holding sticks attached to colorful pom-pom balls, which resemble birds. The background includes stylized waves and a red sun, accentuating a vibrant, artistic style reminiscent of classic Japanese art. The playful interaction between the cats evokes a lively, whimsical scene.
1068
- ```
1069
-
1070
- ```bash
1071
- npc ots -f test_data/catfight.PNG
1072
- ```
1073
-
1074
-
1075
- ### Plan : Schedule tasks to be run at regular intervals (under construction)
1076
- Use the /plan macro to schedule tasks to be run at regular intervals.
1077
- ```npcsh
1078
- npcsh> /plan run a rag search for 'moonbeam' on the files in the current directory every 5 minutes
1079
- ```
1080
-
1081
- ```npcsh
1082
- npcsh> /plan record the cpu usage every 5 minutes
1083
- ```
1084
-
1085
- ```npcsh
1086
- npcsh> /plan record the apps that are using the most ram every 5 minutes
1087
- ```
1088
-
1089
-
1090
-
1091
-
1092
- ```bash
1093
- npc plan -f 30m -t 'task'
1094
- ```
1095
-
1096
- Plan will use platform-specific scheduling tools. In particular, it uses crontab on Linux and launchd on macOS and Schedule Tasks on Windows.
1097
-
1098
- Implementations have been provided for Mac and Windows but only has been tested as of 3/23/2025 on Linux.
1099
-
1100
-
1101
-
1102
- ### Plonk : Computer Control
1103
- Use the /plonk macro to allow the LLM to control your computer.
1104
- ```npcsh
1105
- npcsh> /plonk go to a web browser and go to wikipedia and find out information about simon bolivar
1106
- ```
1107
-
1108
- ```bash
1109
- npc plonk 'use a web browser to find out information about simon boliver'
1110
- ```
1111
-
1112
- ### RAG
1113
-
1114
- Use the /rag macro to perform a local rag search.
1115
- If you pass a `-f` flag with a filename or list of filenames (e.g. *.py) then it will embed the documents and perform the cosine similarity scoring.
1116
-
1117
- ```npcsh
1118
- npcsh> /rag -f *.py what is the best way to implement a linked list in Python?
1119
- ```
1120
-
1121
- Alternatively , if you want to perform rag on your past conversations, you can do so like this:
1122
- ```npcsh
1123
- npcsh> /rag what is the best way to implement a linked list in Python?
1124
- ```
1125
- and it will automatically look through the recorded conversations in the ~/npcsh_history.db
1126
-
1127
-
1128
- In bash:
1129
- ```bash
1130
- npc rag -f *.py
1131
- ```
1132
-
1133
- ### Rehash
1134
-
1135
- Use the /rehash macro to re-send the last message to the LLM.
1136
- ```npcsh
1137
- npcsh> /rehash
1138
- ```
1139
-
1140
- ### Sample
1141
- Send a one-shot question to the LLM.
1142
- ```npcsh
1143
- npcsh> /sample What is the capital of France?
1144
- ```
1145
-
1146
- Bash:
1147
- ```bash
1148
- npc sample 'thing' -m model -p provider
1149
-
1150
- ```
1151
-
1152
-
1153
- ### Search
1154
- Search can be accomplished through the `/search` macro. You can specify the provider as being "perplexity" or "duckduckgo". For the former,
1155
- you must set a perplexity api key as an environment variable as described above. The default provider is duckduckgo.
1156
-
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.
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
-
1162
-
1163
-
1164
- ```npcsh
1165
- npcsh!> /search -p duckduckgo who is the current us president
1166
-
1167
-
1168
- President Donald J. Trump entered office on January 20, 2025. News, issues, and photos of the President Footer Disclaimer This is the official website of the U.S. Mission to the United Nations. External links to other Internet sites should not be construed as an endorsement of the views or privacy policies contained therein.
1169
-
1170
- Citation: https://usun.usmission.gov/our-leaders/the-president-of-the-united-states/
1171
- 45th & 47th President of the United States After a landslide election victory in 2024, President Donald J. Trump is returning to the White House to build upon his previous successes and use his mandate to reject the extremist policies of the radical left while providing tangible quality of life improvements for the American people. Vice President of the United States In 2024, President Donald J. Trump extended JD the incredible honor of asking him to serve as the Vice-Presidential Nominee for th...
1172
- Citation: https://www.whitehouse.gov/administration/
1173
- Citation: https://www.instagram.com/potus/?hl=en
1174
- The president of the United States (POTUS)[B] is the head of state and head of government of the United States. The president directs the executive branch of the federal government and is the commander-in-chief of the United States Armed Forces. The power of the presidency has grown substantially[12] since the first president, George Washington, took office in 1789.[6] While presidential power has ebbed and flowed over time, the presidency has played an increasingly significant role in American ...
1175
- Citation: https://en.wikipedia.org/wiki/President_of_the_United_States
1176
- Citation Links: https://usun.usmission.gov/our-leaders/the-president-of-the-united-states/
1177
- https://www.whitehouse.gov/administration/
1178
- https://www.instagram.com/potus/?hl=en
1179
- https://en.wikipedia.org/wiki/President_of_the_United_States
1180
- ```
1181
-
1182
-
1183
- ```npcsh
1184
- npcsh> /search -p perplexity who is the current us president
1185
- The current President of the United States is Donald Trump, who assumed office on January 20, 2025, for his second non-consecutive term as the 47th president[1].
1186
-
1187
- Citation Links: ['https://en.wikipedia.org/wiki/List_of_presidents_of_the_United_States',
1188
- 'https://en.wikipedia.org/wiki/Joe_Biden',
1189
- 'https://www.britannica.com/topic/Presidents-of-the-United-States-1846696',
1190
- 'https://news.gallup.com/poll/329384/presidential-approval-ratings-joe-biden.aspx',
1191
- 'https://www.usa.gov/presidents']
1192
- ```
1193
-
1194
- Bash:
1195
-
1196
- ```bash
1197
- (npcsh) caug@pop-os:~/npcww/npcsh$ npc search 'simon bolivar' -sp perplexity
1198
- Loaded .env file from /home/caug/npcww/npcsh
1199
- urls ['https://en.wikipedia.org/wiki/Sim%C3%B3n_Bol%C3%ADvar', 'https://www.britannica.com/biography/Simon-Bolivar', 'https://en.wikipedia.org/wiki/File:Sim%C3%B3n_Bol%C3%ADvar_2.jpg', 'https://www.historytoday.com/archive/simon-bolivar-and-spanish-revolutions', 'https://kids.britannica.com/kids/article/Sim%C3%B3n-Bol%C3%ADvar/352872']
1200
- openai
1201
- - Simón José Antonio de la Santísima Trinidad Bolívar Palacios Ponte y Blanco[c] (24 July 1783 – 17 December 1830) was a Venezuelan statesman and military officer who led what are currently the countries of Colombia, Venezuela, Ecuador, Peru, Panama, and Bolivia to independence from the Spanish Empire. He is known colloquially as El Libertador, or the Liberator of America. Simón Bolívar was born in Caracas in the Captaincy General of Venezuela into a wealthy family of American-born Spaniards (crio...
1202
- Citation: https://en.wikipedia.org/wiki/Sim%C3%B3n_Bol%C3%ADvar
1203
-
1204
-
1205
-
1206
- Our editors will review what you’ve submitted and determine whether to revise the article. Simón Bolívar was a Venezuelan soldier and statesman who played a central role in the South American independence movement. Bolívar served as president of Gran Colombia (1819–30) and as dictator of Peru (1823–26). The country of Bolivia is named for him. Simón Bolívar was born on July 24, 1783, in Caracas, Venezuela. Neither Bolívar’s aristocrat father nor his mother lived to see his 10th birthday. Bolívar...
1207
- Citation: https://www.britannica.com/biography/Simon-Bolivar
1208
-
1209
-
1210
-
1211
- Original file (1,525 × 1,990 pixels, file size: 3.02 MB, MIME type: image/jpeg) Derivative works of this file: Simón Bolívar 5.jpg This work is in the public domain in its country of origin and other countries and areas where the copyright term is the author's life plus 100 years or fewer. This work is in the public domain in the United States because it was published (or registered with the U.S. Copyright Office) before January 1, 1930. https://creativecommons.org/publicdomain/mark/1.0/PDMCreat...
1212
- Citation: https://en.wikipedia.org/wiki/File:Sim%C3%B3n_Bol%C3%ADvar_2.jpg
1213
-
1214
-
1215
-
1216
- SubscriptionOffers Give a Gift Subscribe A map of Gran Colombia showing the 12 departments created in 1824 and territories disputed with neighboring countries. What role did Simon Bolivar play in the history of Latin America's independence from Spain? Simon Bolivar lived a short but comprehensive life. History records his extraordinary versatility. He was a revolutionary who freed six countries, an intellectual who argued the problems of national liberation, a general who fought a war of unremit...
1217
- Citation: https://www.historytoday.com/archive/simon-bolivar-and-spanish-revolutions
1218
-
1219
-
1220
-
1221
- Known as the Liberator, Simón Bolívar led revolutions against Spanish rule in South America. The countries of Venezuela, Colombia, Ecuador, Panama, Peru, and Bolivia all owe their independence largely to him. Bolívar was born on July 24, 1783, in Caracas, New Granada (now in Venezuela). After studying in Europe, he returned to South America and began to fight Spanish rule. Between 1810 and 1814 Venezuela made two failed tries to break free from Spain. After the second defeat, Bolívar fled to Jam...
1222
- Citation: https://kids.britannica.com/kids/article/Sim%C3%B3n-Bol%C3%ADvar/352872
1223
-
1224
-
1225
-
1226
- - https://en.wikipedia.org/wiki/Sim%C3%B3n_Bol%C3%ADvar
1227
-
1228
- https://www.britannica.com/biography/Simon-Bolivar
1229
-
1230
- https://en.wikipedia.org/wiki/File:Sim%C3%B3n_Bol%C3%ADvar_2.jpg
1231
-
1232
- https://www.historytoday.com/archive/simon-bolivar-and-spanish-revolutions
1233
-
1234
- https://kids.britannica.com/kids/article/Sim%C3%B3n-Bol%C3%ADvar/352872
1235
- ```
1236
-
1237
- ```bash
1238
- npc search 'snipers on the roof indiana university' -sp duckduckgo
1239
- ```
1240
-
1241
-
1242
- ### Set: Changing defaults from within npcsh
1243
- Users can change the default model and provider from within npcsh by using the following commands:
1244
- ```npcsh
1245
- npcsh> /set model ollama
1246
- npcsh> /set provider llama3.2
1247
- ```
1248
-
1249
-
1250
- ### Sleep : a method for creating and updating a knowledge graph (under construction)
1251
-
1252
- Use the `/sleep` macro to create or update a knowledge graph. A knowledge graph is a structured representation of facts about you as a user that the NPCs can determine based on the conversations you have had with it.
1253
- ```npcsh
1254
- npcsh> /sleep
1255
- ```
1256
-
1257
- ### breathe: a method for condensing context on a regular cadence (# messages, len(context), etc) (under construction)
1258
- -every 10 messages/7500 characters, condense the conversation into lessons learned. write the lessons learned down by the np
1259
- for the day, then the npc will see the lessons they have learned that day in that folder as part of the context.
1260
-
1261
-
1262
-
1263
- ### Spool
1264
- Spool mode allows one to enter into a conversation with a specific LLM or a specific NPC.
1265
- This is used for having distinct interactions from those in the base shell and these will be separately contained.
1266
-
1267
-
1268
- Start the spool mode:
1269
- ```npcsh
1270
- npcsh> /spool
1271
- ```
1272
- Start the spool mode with a specific npc
1273
-
1274
- ```npcsh
1275
- npcsh> /spool npc=foreman
1276
- ```
1277
-
1278
- Start the spool mode with specific files in context that will be referenced through RAG searches when relevant.
1279
-
1280
- ```npcsh
1281
- npcsh> /spool files=[*.py,*.md] # Load specific files for context
1282
- ```
1283
-
1284
- Have a conversation and switch between text and voice mode by invoking `/whisper` mode from within spool mode.
1285
- ```npcsh
1286
- spool> what can you tell me about green bull from one piece?
1287
-
1288
- Green Bull, also known as Ryokugyu, is a character from the popular anime and manga series One Piece. He is one of the Marine Admirals and was introduced during the Wano Country arc. Here are some key points about Green
1289
- Bull:
1290
- 1 Real Name: His real name is Aramaki, but he is primarily known by his title, Green Bull (Ryokugyu in Japanese).
1291
- 2 Appearance: Green Bull has a distinct look characterized by a green military uniform, a long cape, and a
1292
- noticeable plant-based theme, which aligns with his powers.
1293
- 3 Devil Fruit: Green Bull is a user of the Mori Mori no Mi (Forest Forest Fruit), a Logia-type Devil Fruit that
1294
- allows him to generate and manipulate plant matter. This ability can be seen in his combat style, which utilizes
1295
- plants to entrap and attack opponents.
1296
- 4 Role as an Admiral: As an Admiral, Green Bull holds a high-ranking position in the Marines and is
1297
- known for his strength and authority. He is fiercely loyal to the Marine organization and its goals.
1298
- 5 Personality: Green Bull displays a laid-back attitude and often appears more relaxed compared to other Admirals.
1299
- His personality can be somewhat ambiguous, which adds depth to his character.
1300
- 6 Involvement in the Story: Green Bull's introduction brings anticipation regarding his potential confrontations with
1301
- key characters in the series. His role in major arcs like Wano and his interactions with the Straw Hat Pirates and
1302
- other significant figures are crucial for the unfolding storyline.
1303
- Overall, Green Bull is an intriguing character with unique abilities and a significant role within the One Piece universe.
1304
-
1305
- spool> /whisper
1306
-
1307
- Calibrating silence level. Please remain quiet...
1308
- Silence threshold set to: 5679.193548387097
1309
- Listening... (speak now)
1310
- ...............
1311
- Max duration reached.
1312
-
1313
- Processing...
1314
- You said: What do you think his greatest weakness is?
1315
-
1316
-
1317
- Based on what we know about Green Bull from the One Piece series, I can identify a few potential weaknesses:
1318
-
1319
- 1. **Extreme Laziness**:
1320
- - Green Bull is known for being incredibly lazy, often refusing to move or exert himself unnecessarily.
1321
- - This laziness could be exploited by opponents who understand how to manipulate or provoke him into action.
1322
-
1323
- 2. **Dependency on External Nutrition**:
1324
- - His Devil Fruit power allows him to absorb nutrients from the environment, which suggests he might become weakened in environments with limited plant life or nutrients.
1325
- - In extremely barren or non-vegetative settings, his regenerative and plant-based abilities might be significantly reduced.
1326
-
1327
- 3. **Pride and Marine Ideology**:
1328
- - Like many Marines, he likely has a rigid sense of justice that could be used against him strategically.
1329
- - His commitment to Marine principles might make him predictable in certain confrontational scenarios.
1330
-
1331
- 4. **Potential Overconfidence**:
1332
- - As an Admiral, he might underestimate opponents, especially pirates, due to his high-ranking status.
1333
- - His laid-back nature might lead him to not take threats seriously until it's too late.
1334
-
1335
- The most pronounced weakness seems to be his extreme laziness, which could potentially be exploited tactically by skilled opponents who understand how to force him into action or create scenarios that challenge his passive nature.
1336
-
1337
- Here are some additional details about Green Bull (Aramaki) in "One Piece":
1338
-
1339
- 1 Devil Fruit Name:
1340
-
1341
- • Green Bull's Devil Fruit has been confirmed to be the Mori Mori no Mi, which is a mythical Zoan-type fruit. This allows him to utilize various forms of plant life in combat and has regenerative
1342
- capabilities.
1343
-
1344
- 2 Combat Abilities:
1345
-
1346
- • His ability to control vegetation gives him significant advantages in battle. He can generate plants to attack or defend and possibly use them for tactical advantages, such as creating barriers
1347
- or entangling enemies.
1348
-
1349
- 3 Reputation:
1350
-
1351
- • As an Admiral, Green Bull holds a position of great power and authority within the Marines. His reputation is likely formidable among pirates and other opponents.
1352
-
1353
- 4 Interactions with Other Characters:
1354
-
1355
- • Green Bull's character dynamics with others in the series, particularly with fellow Marines and pirates, can provide insight into his personality and values. His interactions during missions or
1356
- discussions about justice will reveal more about his character.
1357
-
1358
- 5 Appearance and Style:
1359
-
1360
- • He has a rather unique aesthetic, characterized by his green clothing that symbolizes his connection to nature. His overall appearance contributes to his identity as a plant-based fighter.
1361
-
1362
- 6 Backstory:
1363
-
1364
- • As of now, specific details about his backstory and how he rose to the rank of Admiral are not extensively explored in the series. This leaves room for further character development and
1365
- background to be unveiled in future chapters.
1366
-
1367
- 7 Ambiguous Personality:
1368
-
1369
- • While his laziness and laid-back demeanor are evident, it is possible that there are deeper layers to his character that might be revealed through his actions and motivations within the
1370
- overarching narrative of "One Piece."
1371
-
1372
- 8 Role in the Marine Organization:
1373
-
1374
- • His position as Admiral places him in direct opposition to the main pirate characters, particularly the Straw Hat crew, making him a significant figure in the ongoing conflict between pirates
1375
- and the Marines.
1376
- As the story continues to develop, Green Bull's character may evolve and reveal more complexities, weaknesses, and relationships within the world of "One Piece."
1377
- ```
1378
-
1379
-
1380
- Start the spool with a specific llm model:
1381
- ```npcsh
1382
- #note this is not yet implemented
1383
- npcsh> /spool model=llama3.3
1384
- ```
1385
-
1386
- ```bash
1387
- npc spool -n npc.npc
1388
- ```
1389
-
1390
- ### Trigger
1391
- Use the /trigger macro to execute specific actionss based on certain conditions.
1392
-
1393
- ```npcsh
1394
- npcsh> /trigger watch for new PDF downloads in the ~/Downloads directory and move them
1395
- to the ~/Documents/PDFs directory . Ensure that the directory exists or create it if it does not.
1396
- ```
1397
-
1398
- On Linux, trigger makes use of inotify-tools to watch for file system events. On macOS, it uses fswatch, and on Windows, it uses Watch-Command.
1399
-
1400
-
1401
-
1402
-
1403
-
1404
- ### Vixynt: Image Generation
1405
- Image generation can be done with the /vixynt macro.
1406
-
1407
- Use /vixynt like so where you can also specify the model to use with an @ reference. This @ reference will override the default model in ~/.npcshrc.
1408
-
1409
- ```npcsh
1410
- npcsh> /vixynt A futuristic cityscape @dall-e-3
1411
- ```
1412
- ![futuristic cityscape](test_data/futuristic_cityscape.PNG)
1413
-
1414
- ```npcsh
1415
- npcsh> /vixynt A peaceful landscape @runwayml/stable-diffusion-v1-5
1416
- ```
1417
- ![peaceful landscape](test_data/peaceful_landscape_stable_diff.png)
1418
-
1419
-
1420
- Similarly, use vixynt with the NPC CLI from a regular shell:
1421
- ```bash
1422
- $ npc --model 'dall-e-2' --provider 'openai' vixynt 'whats a french man to do in the southern bayeaux'
1423
- ```
1424
-
1425
-
1426
-
1427
-
1428
- ### Whisper: Voice Control
1429
- Enter into a voice-controlled mode to interact with the LLM. This mode can executet commands and use tools just like the basic npcsh shell.
1430
- ```npcsh
1431
- npcsh> /whisper
1432
- ```
1433
-
1434
-
1435
-
1436
-
1437
- ### Compilation and NPC Interaction
1438
- Compile a specified NPC profile. This will make it available for use in npcsh interactions.
1439
- ```npcsh
1440
- npcsh> /compile <npc_file>
1441
- ```
1442
- You can also use `/com` as an alias for `/compile`. If no NPC file is specified, all NPCs in the npc_team directory will be compiled.
1443
-
1444
- Begin a conversations with a specified NPC by referencing their name
1445
- ```npcsh
1446
- npcsh> /<npc_name>:
1447
- ```
1448
-
1449
-
1450
-
1451
- ## NPC Data Layer
1452
-
1453
- What principally powers the capabilities of npcsh is the NPC Data Layer. In the `~/.npcsh/` directory after installation, you will find
1454
- the npc teaam with its tools, models, contexts, assembly lines, and NPCs. By making tools, NPCs, contexts, and assembly lines simple data structures with
1455
- a fixed set of parameters, we can let users define them in easy-to-read YAML files, allowing for a modular and extensible system that can be easily modified and expanded upon. Furthermore, this data layer relies heavily on jinja templating to allow for dynamic content generation and the ability to reference other NPCs, tools, and assembly lines in the system.
1456
-
1457
- ### Creating NPCs
1458
- NPCs are defined in YAML files within the npc_team directory. Each NPC must have a name and a primary directive. Optionally, one can specify an LLM model/provider for the NPC as well as provide an explicit list of tools and whether or not to use the globally available tools. See the data models contained in `npcsh/data_models.py` for more explicit type details on the NPC data structure.
1459
-
1460
-
1461
-
1462
- Here is a typical NPC file:
1463
- ```yaml
1464
- name: sibiji
1465
- primary_directive: You are a foundational AI assistant. Your role is to provide basic support and information. Respond to queries concisely and accurately.
1466
- tools:
1467
- - simple data retrieval
1468
- model: llama3.2
1469
- provider: ollama
1470
- ```
1471
-
1472
-
1473
- ## Creating Tools
1474
- Tools are defined as YAMLs with `.tool` extension within the npc_team/tools directory. Each tool has a name, inputs, and consists of three distinct steps: preprocess, prompt, and postprocess. The idea here is that a tool consists of a stage where information is preprocessed and then passed to a prompt for some kind of analysis and then can be passed to another stage for postprocessing. In each of these three cases, the engine must be specified. The engine can be either "natural" for natural language processing or "python" for Python code. The code is the actual code that will be executed.
1475
-
1476
- Here is an example of a tool file:
1477
- ```yaml
1478
- tool_name: "screen_capture_analysis_tool"
1479
- description: Captures the whole screen and sends the image for analysis
1480
- inputs:
1481
- - "prompt"
1482
- steps:
1483
- - engine: "python"
1484
- code: |
1485
- # Capture the screen
1486
- import pyautogui
1487
- import datetime
1488
- import os
1489
- from PIL import Image
1490
- import time
1491
- from npcsh.image import analyze_image_base, capture_screenshot
1492
-
1493
- out = capture_screenshot(npc = npc, full = True)
1494
-
1495
- llm_response = analyze_image_base( '{{prompt}}' + "\n\nAttached is a screenshot of my screen currently. Please use this to evaluate the situation. If the user asked for you to explain what's on their screen or something similar, they are referring to the details contained within the attached image. You do not need to actually view their screen. You do not need to mention that you cannot view or interpret images directly. You only need to answer the user's request based on the attached screenshot!",
1496
- out['file_path'],
1497
- out['filename'],
1498
- npc=npc,
1499
- **out['model_kwargs'])
1500
- # To this:
1501
- if isinstance(llm_response, dict):
1502
- llm_response = llm_response.get('response', 'No response from image analysis')
1503
- else:
1504
- llm_response = 'No response from image analysis'
1505
-
1506
- ```
1507
-
1508
-
1509
- When you have created a tool, it will be surfaced as a potential option to be used when you ask a question in the base npcsh shell. The LLM will decide if it is the best tool to use based on the user's input. Alternatively, if you'd like, you can call the tools directly, without needing to let the AI decide if it's the right one to use.
1510
-
1511
- ```npcsh
1512
- npcsh> /screen_cap_tool <prompt>
1513
- ```
1514
- or
1515
- ```npcsh
1516
- npcsh> /sql_executor select * from conversation_history limit 1
1517
-
1518
- ```
1519
- or
1520
- ```npcsh
1521
- npcsh> /calculator 5+6
1522
- ```
1523
-
1524
-
1525
- ## NPC Pipelines
1526
-
1527
-
1528
-
1529
- Let's say you want to create a pipeline of steps where NPCs are used along the way. Let's initialize with a pipeline file we'll call `morning_routine.pipe`:
1530
- ```yaml
1531
- steps:
1532
- - step_name: "review_email"
1533
- npc: "{{ ref('email_assistant') }}"
1534
- task: "Get me up to speed on my recent emails: {{source('emails')}}."
1535
-
1536
-
1537
- - step_name: "market_update"
1538
- npc: "{{ ref('market_analyst') }}"
1539
- task: "Give me an update on the latest events in the market: {{source('market_events')}}."
1540
-
1541
- - step_name: "summarize"
1542
- npc: "{{ ref('sibiji') }}"
1543
- model: llama3.2
1544
- provider: ollama
1545
- task: "Review the outputs from the {{review_email}} and {{market_update}} and provide me with a summary."
1546
-
1547
- ```
1548
- Now youll see that we reference NPCs in the pipeline file. We'll need to make sure we have each of those NPCs available.
1549
- Here is an example for the email assistant:
1550
- ```yaml
1551
- name: email_assistant
1552
- primary_directive: You are an AI assistant specialized in managing and summarizing emails. You should present the information in a clear and concise manner.
1553
- model: gpt-4o-mini
1554
- provider: openai
1555
- ```
1556
- Now for the marketing analyst:
1557
- ```yaml
1558
- name: market_analyst
1559
- primary_directive: You are an AI assistant focused on monitoring and analyzing market trends. Provide de
1560
- model: llama3.2
1561
- provider: ollama
1562
- ```
1563
- and then here is our trusty friend sibiji:
1564
- ```yaml
1565
- name: sibiji
1566
- primary_directive: You are a foundational AI assistant. Your role is to provide basic support and information. Respond to queries concisely and accurately.
1567
- suggested_tools_to_use:
1568
- - simple data retrieval
1569
- model: claude-3-5-sonnet-latest
1570
- provider: anthropic
1571
- ```
1572
- Now that we have our pipeline and NPCs defined, we also need to ensure that the source data we are referencing will be there. When we use source('market_events') and source('emails') we are asking npcsh to pull those data directly from tables in our npcsh database. For simplicity we will just make these in python to insert them for this demo:
1573
- ```python
1574
- import pandas as pd
1575
- from sqlalchemy import create_engine
1576
- import os
1577
-
1578
- # Sample market events data
1579
- market_events_data = {
1580
- "datetime": [
1581
- "2023-10-15 09:00:00",
1582
- "2023-10-16 10:30:00",
1583
- "2023-10-17 11:45:00",
1584
- "2023-10-18 13:15:00",
1585
- "2023-10-19 14:30:00",
1586
- ],
1587
- "headline": [
1588
- "Stock Market Rallies Amid Positive Economic Data",
1589
- "Tech Giant Announces New Product Line",
1590
- "Federal Reserve Hints at Interest Rate Pause",
1591
- "Oil Prices Surge Following Supply Concerns",
1592
- "Retail Sector Reports Record Q3 Earnings",
1593
- ],
1594
- }
1595
-
1596
- # Create a DataFrame
1597
- market_events_df = pd.DataFrame(market_events_data)
1598
-
1599
- # Define database path relative to user's home directory
1600
- db_path = os.path.expanduser("~/npcsh_history.db")
1601
-
1602
- # Create a connection to the SQLite database
1603
- engine = create_engine(f"sqlite:///{db_path}")
1604
- with engine.connect() as connection:
1605
- # Write the data to a new table 'market_events', replacing existing data
1606
- market_events_df.to_sql(
1607
- "market_events", con=connection, if_exists="replace", index=False
1608
- )
1609
-
1610
- print("Market events have been added to the database.")
1611
-
1612
- email_data = {
1613
- "datetime": [
1614
- "2023-10-10 10:00:00",
1615
- "2023-10-11 11:00:00",
1616
- "2023-10-12 12:00:00",
1617
- "2023-10-13 13:00:00",
1618
- "2023-10-14 14:00:00",
1619
- ],
1620
- "subject": [
1621
- "Meeting Reminder",
1622
- "Project Update",
1623
- "Invoice Attached",
1624
- "Weekly Report",
1625
- "Holiday Notice",
1626
- ],
1627
- "sender": [
1628
- "alice@example.com",
1629
- "bob@example.com",
1630
- "carol@example.com",
1631
- "dave@example.com",
1632
- "eve@example.com",
1633
- ],
1634
- "recipient": [
1635
- "bob@example.com",
1636
- "carol@example.com",
1637
- "dave@example.com",
1638
- "eve@example.com",
1639
- "alice@example.com",
1640
- ],
1641
- "body": [
1642
- "Don't forget the meeting tomorrow at 10 AM.",
1643
- "The project is progressing well, see attached update.",
1644
- "Please find your invoice attached.",
1645
- "Here is the weekly report.",
1646
- "The office will be closed on holidays, have a great time!",
1647
- ],
1648
- }
1649
-
1650
- # Create a DataFrame
1651
- emails_df = pd.DataFrame(email_data)
1652
-
1653
- # Define database path relative to user's home directory
1654
- db_path = os.path.expanduser("~/npcsh_history.db")
1655
-
1656
- # Create a connection to the SQLite database
1657
- engine = create_engine(f"sqlite:///{db_path}")
1658
- with engine.connect() as connection:
1659
- # Write the data to a new table 'emails', replacing existing data
1660
- emails_df.to_sql("emails", con=connection, if_exists="replace", index=False)
1661
-
1662
- print("Sample emails have been added to the database.")
1663
-
1664
- ```
1665
-
1666
-
1667
- With these data now in place, we can proceed with running the pipeline. We can do this in npcsh by using the /compile command.
1668
-
1669
-
1670
-
1671
-
1672
- ```npcsh
1673
- npcsh> /compile morning_routine.pipe
1674
- ```
1675
-
1676
-
1677
-
1678
- Alternatively we can run a pipeline like so in Python:
1679
-
1680
- ```bash
1681
- from npcsh.npc_compiler import PipelineRunner
1682
- import os
1683
-
1684
- pipeline_runner = PipelineRunner(
1685
- pipeline_file="morning_routine.pipe",
1686
- npc_root_dir=os.path.abspath("./"),
1687
- db_path="~/npcsh_history.db",
1688
- )
1689
- pipeline_runner.execute_pipeline(inputs)
1690
- ```
1691
-
1692
- What if you wanted to run operations on each row and some operations on all the data at once? We can do this with the pipelines as well. Here we will build a pipeline for news article analysis.
1693
- First we make the data for the pipeline that well use:
1694
- ```python
1695
- import pandas as pd
1696
- from sqlalchemy import create_engine
1697
- import os
1698
-
1699
- # Sample data generation for news articles
1700
- news_articles_data = {
1701
- "news_article_id": list(range(1, 21)),
1702
- "headline": [
1703
- "Economy sees unexpected growth in Q4",
1704
- "New tech gadget takes the world by storm",
1705
- "Political debate heats up over new policy",
1706
- "Health concerns rise amid new disease outbreak",
1707
- "Sports team secures victory in last minute",
1708
- "New economic policy introduced by government",
1709
- "Breakthrough in AI technology announced",
1710
- "Political leader delivers speech on reforms",
1711
- "Healthcare systems pushed to limits",
1712
- "Celebrated athlete breaks world record",
1713
- "Controversial economic measures spark debate",
1714
- "Innovative tech startup gains traction",
1715
- "Political scandal shakes administration",
1716
- "Healthcare workers protest for better pay",
1717
- "Major sports event postponed due to weather",
1718
- "Trade tensions impact global economy",
1719
- "Tech company accused of data breach",
1720
- "Election results lead to political upheaval",
1721
- "Vaccine developments offer hope amid pandemic",
1722
- "Sports league announces return to action",
1723
- ],
1724
- "content": ["Article content here..." for _ in range(20)],
1725
- "publication_date": pd.date_range(start="1/1/2023", periods=20, freq="D"),
1726
- }
1727
- ```
1728
-
1729
- Then we will create the pipeline file:
1730
- ```yaml
1731
- # news_analysis.pipe
1732
- steps:
1733
- - step_name: "classify_news"
1734
- npc: "{{ ref('news_assistant') }}"
1735
- task: |
1736
- Classify the following news articles into one of the categories:
1737
- ["Politics", "Economy", "Technology", "Sports", "Health"].
1738
- {{ source('news_articles') }}
1739
-
1740
- - step_name: "analyze_news"
1741
- npc: "{{ ref('news_assistant') }}"
1742
- batch_mode: true # Process articles with knowledge of their tags
1743
- task: |
1744
- Based on the category assigned in {{classify_news}}, provide an in-depth
1745
- analysis and perspectives on the article. Consider these aspects:
1746
- ["Impacts", "Market Reaction", "Cultural Significance", "Predictions"].
1747
- {{ source('news_articles') }}
1748
- ```
1749
-
1750
- Then we can run the pipeline like so:
1751
- ```bash
1752
- /compile ./npc_team/news_analysis.pipe
1753
- ```
1754
- or in python like:
1755
-
1756
- ```bash
1757
-
1758
- from npcsh.npc_compiler import PipelineRunner
1759
- import os
1760
- runner = PipelineRunner(
1761
- "./news_analysis.pipe",
1762
- db_path=os.path.expanduser("~/npcsh_history.db"),
1763
- npc_root_dir=os.path.abspath("."),
1764
- )
1765
- results = runner.execute_pipeline()
1766
- ```
1767
-
1768
- Alternatively, if youd like to use a mixture of agents in your pipeline, set one up like this:
1769
- ```yaml
1770
- steps:
1771
- - step_name: "classify_news"
1772
- npc: "news_assistant"
1773
- mixa: true
1774
- mixa_agents:
1775
- - "{{ ref('news_assistant') }}"
1776
- - "{{ ref('journalist_npc') }}"
1777
- - "{{ ref('data_scientist_npc') }}"
1778
- mixa_voters:
1779
- - "{{ ref('critic_npc') }}"
1780
- - "{{ ref('editor_npc') }}"
1781
- - "{{ ref('researcher_npc') }}"
1782
- mixa_voter_count: 5
1783
- mixa_turns: 3
1784
- mixa_strategy: "vote"
1785
- task: |
1786
- Classify the following news articles...
1787
- {{ source('news_articles') }}
1788
- ```
1789
- You'll have to make npcs for these references to work, here are versions that should work with the above:
1790
- ```yaml
1791
- name: news_assistant
1792
- ```
1793
- Then, we can run the mixture of agents method like:
1794
-
1795
- ```bash
1796
- /compile ./npc_team/news_analysis_mixa.pipe
1797
- ```
1798
- or in python like:
1799
-
1800
- ```bash
1801
-
1802
- from npcsh.npc_compiler import PipelineRunner
1803
- import os
1804
-
1805
- runner = PipelineRunner(
1806
- "./news_analysis_mixa.pipe",
1807
- db_path=os.path.expanduser("~/npcsh_history.db"),
1808
- npc_root_dir=os.path.abspath("."),
1809
- )
1810
- results = runner.execute_pipeline()
1811
- ```
1812
-
1813
-
1814
-
1815
- Note, in the future we will aim to separate compilation and running so that we will have a compilation step that is more like a jinja rendering of the relevant information so that it can be more easily audited.
1816
-
1817
-
1818
- ## npcsql: SQL Integration and pipelines (UNDER CONSTRUCTION)
1819
-
1820
-
1821
- In addition to NPCs being used in `npcsh` and through the python package, users may wish to take advantage of agentic interactions in SQL-like pipelines.
1822
- `npcsh` contains a pseudo-SQL interpreter that processes SQL models which lets users write queries containing LLM-function calls that reference specific NPCs. `npcsh` interprets these queries, renders any jinja template references through its python implementation, and then executes them accordingly.
1823
-
1824
- Here is an example of a SQL-like query that uses NPCs to analyze data:
1825
- ```sql
1826
- SELECT debate(['logician','magician'], 'Analyze the sentiment of the customer feedback.') AS sentiment_analysis
1827
- ```
1828
-
1829
- ### squish
1830
- squish is an aggregate NPC LLM function that compresses information contained in whole columns or grouped chunks of data based on the SQL aggregation.
1831
-
1832
- ### splat
1833
- Splat is a row-wise NPC LLM function that allows for the application of an LLM function on each row of a dataset or a re-sampling
1834
-
1835
-
1836
-
1837
-
1838
-
1839
-
1840
-
1841
- ## Contributing
1842
- Contributions are welcome! Please submit issues and pull requests on the GitHub repository.
1843
-
1844
- ## Support
1845
- If you appreciate the work here, [consider supporting NPC Worldwide](https://buymeacoffee.com/npcworldwide). If you'd like to explore how to use `npcsh` to help your business, please reach out to info@npcworldwi.de .
1846
-
1847
-
1848
- ## NPC Studio
1849
- Coming soon! NPC Studio will be a desktop application for managing chats and agents on your own machine.
1850
- Be sure to sign up for the [npcsh newsletter](https://forms.gle/n1NzQmwjsV4xv1B2A) to hear updates!
1851
-
1852
- ## License
1853
- This project is licensed under the MIT License.