You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<imgsrc="https://raw.githubusercontent.com/cagostino/npcpy/main/npcpy.png"alt="npcpy logo of a solarpunk sign">
4
3
</p>
@@ -102,8 +101,98 @@ handling agent pass
102
101
{'debrief': {'summary': "The responses provided detailed accounts of the books that the NPC team members, Gabriel Garcia Marquez and Isabel Allende, are most proud of. Gabriel highlighted 'Cien años de soledad,' while Isabel spoke of 'La Casa de los Espíritus.' Both authors expressed deep personal connections to their works, illustrating their significance in Latin American literature and their own identities.", 'recommendations': 'Encourage further engagement with each author to explore more about their literary contributions, or consider asking about themes in their works or their thoughts on current literary trends.'}, 'execution_history': [{'messages': ...}]}
103
102
```
104
103
104
+
LLM responses can be obtained without NPCs as well.
105
+
106
+
```
107
+
from npcpy.llm_funcs import get_llm_response
108
+
response = get_llm_response("Who was the celtic Messenger god?", model='llama3.2', provider='ollama')
109
+
print(response['response'])
110
+
```
111
+
112
+
```
113
+
The Celtic messenger god is often associated with the figure of Tylwyth Teg, also known as the Tuatha Dé Danann (meaning "the people of the goddess Danu"). However, among the various Celtic cultures, there are a few gods and goddesses that served similar roles.
114
+
115
+
One of the most well-known Celtic messengers is Brigid's servant, Líth (also spelled Lid or Lith), who was believed to be a spirit guide for messengers and travelers in Irish mythology.
116
+
```
117
+
The structure of npcpy also allows one to pass an npc
118
+
to `get_llm_response` in addition to using the NPC's wrapped method,
119
+
allowing you to be flexible in your implementation and testing.
120
+
```
121
+
from npcpy.npc_compiler import NPC
122
+
from npcpy.llm_funcs import get_llm_response
123
+
simon = NPC(
124
+
name='Simon Bolivar',
125
+
primary_directive='Liberate South America from the Spanish Royalists.',
126
+
model='qwen3',
127
+
provider='ollama'
128
+
)
129
+
response = get_llm_response("Who was the mythological chilean bird that guides lucky visitors to gold?", npc=simon)
130
+
print(response['response'])
131
+
```
132
+
133
+
134
+
135
+
`npcpy` also supports streaming responses, with the `response` key containing a generator in such cases which can be printed and processed through the print_and
136
+
137
+
138
+
```
139
+
from npcpy.npc_sysenv import print_and_process_stream
140
+
from npcpy.llm_funcs import get_llm_response
141
+
response = get_llm_response("When did the united states government begin sendinng advisors to vietnam?", model='llama3.2', provider='ollama', stream = True)
Return structured outputs by specifying `format='json'` or passing a Pydantic schema. When specific formats are extracted, `npcpy`'s `get_llm_response` will convert the response from its string representation so you don't have to worry about that.
146
+
147
+
```
148
+
from npcpy.llm_funcs import get_llm_response
149
+
response = get_llm_response("What is the sentiment of the american people towards the repeal of Roe v Wade? Return a json object with `sentiment` as the key and a float value from -1 to 1 as the value", model='gemma3:1b', provider='ollama', format='json')
150
+
151
+
print(response['response'])
152
+
```
153
+
```
154
+
{'sentiment': -0.7}
155
+
```
156
+
157
+
The `get_llm_response` function also can take a list of messages and will additionally return the messages with the user prompt and the assistant response appended if the response is not streamed. If it is streamed, the user must manually append the conversation result as part of their workflow if they want to then pass the messages back in.
158
+
159
+
Additionally, one can pass attachments. Here we demonstrate both
160
+
```
161
+
from npcpy.llm_funcs import get_llm_response
162
+
messages = [{'role': 'system', 'content': 'You are an annoyed assistant.'}]
163
+
164
+
response = get_llm_response("What is the meaning of caesar salad", model='gpt-4o-mini', provider='openai', images=['./Language_Evolution_and_Innovation_experiment.png'], messages=messages)
165
+
166
+
167
+
168
+
```
169
+
Easily create images with the generate_image function, using models available through Huggingface's diffusers library or from OpenAI or Gemini.
170
+
```
171
+
from npcpy.llm_funcs import gen_image
172
+
image = gen_image("make a picture of the moon in the summer of marco polo", model='runwayml/stable-diffusion-v1-5', provider='diffusers')
173
+
174
+
175
+
image = gen_image("make a picture of the moon in the summer of marco polo", model='dall-e-2', provider='openai')
176
+
177
+
178
+
# edit images with 'gpt-image-1' or gemini's multimodal models, passing image paths, byte code images, or PIL instances.
179
+
180
+
image = gen_image("make a picture of the moon in the summer of marco polo", model='gpt-image-1', provider='openai', attachments=['/path/to/your/image.jpg', your_byte_code_image_here, your_PIL_image_here])
181
+
182
+
183
+
image = gen_image("edit this picture of the moon in the summer of marco polo so that it looks like it is in the winter of nishitani", model='gemini-2.0-flash', provider='gemini', attachments= [])
184
+
185
+
```
186
+
187
+
Likewise, generate videos :
188
+
189
+
```
190
+
from npcpy.llm_funcs import gen_video
191
+
image = gen_video("make a video of the moon in the summer of marco polo", model='runwayml/stable-diffusion-v1-5', provider='diffusers')
192
+
```
193
+
105
194
106
-
See more examples of how to use `npcpy` to create agents and agentic systems [here](https://github.com/cagostino/npcpy/blob/main/docs/npcpy.md). `npcpy` can include images, pdfs, and csvs in its llm response generation.
195
+
For more examples of how to use `npcpy` to simplify your LLM workflows or to create agents or multi-agent systems, see[here](https://github.com/cagostino/npcpy/blob/main/docs/npcpy.md). `npcpy` can include images, pdfs, and csvs in its llm response generation.
107
196
108
197
109
198
## Inference Capabilities
@@ -322,19 +411,37 @@ The following are the current programs in the NPC shell:
322
411
<img src="https://raw.githubusercontent.com/cagostino/npcpy/main/npcpy/npc_team/alicanto.png" alt="logo for deep research", width=250></a>
323
412
</p>
324
413
325
-
- start a sequence:
414
+
- Examples:
326
415
```
327
416
npc alicanto "What are the implications of quantum computing for cybersecurity?"
<img src="https://raw.githubusercontent.com/cagostino/npcpy/main/npcpy/npc_team/frederic4.png" alt="npcpy logo of frederic the bear and the pti logo", width=250></a>
335
441
</p>
336
-
Speak frederic the bear who, once he's done thinking, asks you for input before trudging on so it can work with confidence.
337
-
```
442
+
Speak with frederic the bear who, once he's done thinking, asks you for input before trudging on so it can work with confidence.
443
+
444
+
```bash
338
445
pti
339
446
```
340
447
@@ -353,7 +460,8 @@ pti
353
460
<img src="https://raw.githubusercontent.com/cagostino/npcpy/main/npcpy/npc_team/yap.png" alt="logo for yap ", width=250></a>
354
461
</p>
355
462
356
-
- an agentic voice control loop with a specified agent.
463
+
- an agentic voice control loop with a specified agent. When launching `yap`, the user enters the typical `npcsh` agentic loop except that the system is waiting for either text or audio input.
464
+
357
465
```
358
466
yap
359
467
```
@@ -379,6 +487,7 @@ yap
379
487
npc wander "How can I improve my creative writing?" --num-events 5
380
488
```
381
489
490
+
382
491
## Enabling Innovation
383
492
- `npcpy` is a framework that speeds up and simplifies the development of NLP-based or Agent-based applications and provides developers and researchers with methods to explore and test across dozens of models, providers, and personas as well as other model-level hyperparameters (e.g. `temperature`, `top_k`, etc.), incorporating an array of data sources and common tools.
384
493
- The `npcpy` agent data layer makes it easy to set up teams and serve them so you can focus more on the agent personas and less on the nitty gritty of inference.
@@ -420,14 +529,13 @@ ollama pull llava:7b
420
529
ollama pull nomic-embed-text
421
530
pip install npcpy
422
531
# if you want to install with the API libraries
423
-
pip install npcpy[lite]
532
+
pip install 'npcpy[lite]'
424
533
# if you want the full local package set up (ollama, diffusers, transformers, cuda etc.)
425
-
pip install npcpy[local]
534
+
pip install 'npcpy[local]'
426
535
# if you want to use tts/stt
427
-
pip install npcpy[yap]
428
-
536
+
pip install 'npcpy[yap]'
429
537
# if you want everything:
430
-
pip install npcpy[all]
538
+
pip install 'npcpy[all]'
431
539
```
432
540
</details>
433
541
@@ -473,9 +581,9 @@ Then, in a powershell. Download and install ffmpeg.
473
581
ollama pull llama3.2
474
582
ollama pull llava:7b
475
583
ollama pull nomic-embed-text
476
-
pip install npcsh
584
+
pip install npcpy
477
585
# if you want to install with the API libraries
478
-
pip install npcsh[lite]
586
+
pip install npcpy[lite]
479
587
# if you want the full local package set up (ollama, diffusers, transformers, cuda etc.)
480
588
pip install npcpy[local]
481
589
# if you want to use tts/stt
@@ -484,7 +592,7 @@ pip install npcpy[yap]
484
592
# if you want everything:
485
593
pip install npcpy[all]
486
594
```
487
-
As of now, npcsh appears to work well with some of the core functionalities like /ots and /whisper.
595
+
As of now, npcsh appears to work well with some of the core functionalities like /ots and /yap.
Alicanto is a deep research method inspired by the Chilean mythological bird that can lead miners to gold or to death. In NPC Shell, Alicanto conducts extensive multi-perspective research on any topic by exploring with both breadth (across different expert perspectives) and depth (diving deeper into promising directions).
4
+
5
+
## Overview
6
+
7
+
Alicanto creates a team of diverse AI researchers who explore your research question from multiple angles. It then analyzes their findings, identifies thematic clusters, evaluates the quality and risk of each insight, and produces a comprehensive report with "gold insights" (high quality, low risk) and "cliff warnings" (high risk).
8
+
9
+
## Usage
10
+
11
+
```bash
12
+
# Basic usage
13
+
npc alicanto "What are the implications of quantum computing for cybersecurity?"
npc alicanto "What ethical considerations should guide AI development?" --exploration 0.5
20
+
21
+
# Different output formats
22
+
npc alicanto "What is the future of remote work?" --format report
23
+
```
24
+
25
+
## Options
26
+
27
+
-`--num-npcs N`: Number of researcher NPCs to use (default: 5)
28
+
-`--depth N`: Depth of research chains for each NPC (default: 3)
29
+
-`--exploration FLOAT`: Balance between exploration and exploitation (0.0-1.0, default: 0.3)
30
+
-`--format FORMAT`: Output format: "report" (default), "summary", or "full"
31
+
32
+
## How it Works
33
+
34
+
1.**Expert Generation**: Creates a diverse team of AI researchers with different expertise and perspectives
35
+
2.**Research Chains**: Each researcher conducts a series of research steps, going deeper with each iteration
36
+
3.**Insight Extraction**: Key insights are extracted from each research chain
37
+
4.**Thematic Grouping**: Insights are grouped into thematic clusters across researchers
38
+
5.**Quality Evaluation**: Each theme is evaluated for quality (novelty, depth, practicality, evidence) and risk
39
+
6.**Gold and Cliff Identification**: High-quality insights with low risk are marked as "gold insights," while high-risk insights are flagged as "cliff warnings"
40
+
7.**Integration**: A comprehensive research report synthesizes findings and provides guidance
41
+
42
+
## Example Output
43
+
44
+
The output includes:
45
+
- An integrated overview connecting all themes
46
+
- The most significant overall findings
47
+
- Specific recommendations for further research
48
+
- Particular cautions and limitations
49
+
- Clearly marked gold insights and cliff warnings
50
+
- Detailed thematic findings with quality and risk scores
51
+
52
+
## Use Cases
53
+
54
+
- Exploring complex, multifaceted topics
55
+
- Getting diverse perspectives on controversial issues
56
+
- Identifying promising research directions
57
+
- Evaluating the quality and risk of different approaches
58
+
- Discovering connections between seemingly unrelated ideas
Interested to stay in the loop and to hear the latest and greatest about `npcpy` ? Be sure to sign up for the [npcsh newsletter](https://forms.gle/n1NzQmwjsV4xv1B2A)!
7
+
Interested to stay in the loop and to hear the latest and greatest about `npcpy` ? Be sure to sign up for the [npcpy newsletter](https://forms.gle/n1NzQmwjsV4xv1B2A)!
11
8
12
9
Welcome to `npcpy`, the python library for the NPC Toolkit and the home of the core command-line programs that make up the NPC Shell (`npcsh`).
13
10
@@ -119,7 +116,7 @@ handling agent pass
119
116
-[NPC Shell](npcsh.md)
120
117
-[NPC CLI ](api/npc_cli.md)
121
118
122
-
-[Alicanto](akicanto.md)
119
+
-[Alicanto](alicanto.md)
123
120
-[Guac](guac.md)
124
121
-[PTI](pti.md)
125
122
-[Spool](spool.md)
@@ -139,12 +136,12 @@ handling agent pass
139
136
Contributions are welcome! Please submit issues and pull requests on the GitHub repository.
140
137
141
138
## Support
142
-
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 .
139
+
If you appreciate the work here, [consider supporting NPC Worldwide](https://buymeacoffee.com/npcworldwide). If you'd like to explore how to use `npcpy` to help your business, please reach out to info@npcworldwi.de .
143
140
144
141
145
142
## NPC Studio
146
143
Coming soon! NPC Studio will be a desktop application for managing chats and agents on your own machine.
147
-
Be sure to sign up for the [npcsh newsletter](https://forms.gle/n1NzQmwjsV4xv1B2A) to hear updates!
144
+
Be sure to sign up for the [npcpy newsletter](https://forms.gle/n1NzQmwjsV4xv1B2A) to hear updates!
0 commit comments