Skip to content

Commit 796b525

Browse files
committed
fixed a few issues with /sample.
1 parent e6094d5 commit 796b525

File tree

9 files changed

+525
-496
lines changed

9 files changed

+525
-496
lines changed

docs/pti.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,12 @@
1-
# pti
1+
# PTI
2+
3+
Pardon-the-interruption (PTI) mode is a mode that probes thinking LLMs in the midst of their response so that they ask users for input and clarification earlier rather than later after going down a rabiit hole.
4+
5+
```bash
6+
pti
7+
```
8+
9+
10+
```pti
11+
user> who is the moon's president?
12+
```

npcpy/gen/response.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def get_litellm_response(
208208
model = "llava:7b"
209209
else:
210210
model = "llama3.2"
211-
print(model, provider )
211+
#print(model, provider )
212212

213213
# Handle Ollama separately
214214
if provider == "ollama":

npcpy/memory/command_history.py

Lines changed: 418 additions & 399 deletions
Large diffs are not rendered by default.

npcpy/modes/npc.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,9 @@
77

88
from npcpy.npc_sysenv import (
99
NPCSH_CHAT_MODEL, NPCSH_CHAT_PROVIDER,
10-
NPCSH_IMAGE_GEN_MODEL, NPCSH_IMAGE_GEN_PROVIDER,
11-
NPCSH_VISION_MODEL, NPCSH_VISION_PROVIDER,
12-
NPCSH_REASONING_MODEL, NPCSH_REASONING_PROVIDER,
13-
NPCSH_EMBEDDING_MODEL, NPCSH_EMBEDDING_PROVIDER,
14-
NPCSH_VIDEO_GEN_MODEL, NPCSH_VIDEO_GEN_PROVIDER,
1510
NPCSH_API_URL, NPCSH_DB_PATH, NPCSH_STREAM_OUTPUT,
16-
NPCSH_SEARCH_PROVIDER,
17-
print_and_process_stream,
1811
print_and_process_stream_with_markdown,
1912
render_markdown,
20-
get_npc_path
2113
)
2214
from npcpy.npc_compiler import NPC, Team
2315
from npcpy.routes import router
@@ -136,8 +128,9 @@ def main():
136128
result = handler(command=full_command_str, **handler_kwargs)
137129

138130
if isinstance(result, dict):
139-
output = result.get("output", "Command executed, but no specific output returned.")
140-
if NPCSH_STREAM_OUTPUT and hasattr(output, '__iter__') and not isinstance(output, (str, bytes, dict, list)):
131+
output = result.get("output") or result.get("response")
132+
133+
if NPCSH_STREAM_OUTPUT and not isinstance(output, str):
141134
print_and_process_stream_with_markdown(output, effective_model, effective_provider)
142135
elif output is not None:
143136
render_markdown(str(output))

npcpy/modes/npcsh.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ def execute_slash_command(command: str, stdin_input: Optional[str], state: Shell
448448
command_parts = command.split()
449449
command_name = command_parts[0].lstrip('/')
450450
handler = router.get_route(command_name)
451-
451+
#print(handler)
452452
if handler:
453453
# Prepare kwargs for the handler
454454
handler_kwargs = {
@@ -461,14 +461,16 @@ def execute_slash_command(command: str, stdin_input: Optional[str], state: Shell
461461
'api_url': state.api_url,
462462
'api_key': state.api_key,
463463
}
464+
#print(handler_kwargs, command)
464465
if stdin_input is not None:
465466
handler_kwargs['stdin_input'] = stdin_input
466467

467468
try:
468469
result_dict = handler(command, **handler_kwargs)
469470

470471
if isinstance(result_dict, dict):
471-
output = result_dict.get("output")
472+
#some respond with output, some with response, needs to be fixed upstream
473+
output = result_dict.get("output") or result_dict.get("response")
472474
state.messages = result_dict.get("messages", state.messages)
473475
return state, output
474476
else:
@@ -537,6 +539,7 @@ def process_pipeline_command(
537539
exec_provider = provider_override or state.chat_provider
538540

539541
if cmd_to_process.startswith("/"):
542+
#print(cmd_to_process)
540543
return execute_slash_command(cmd_to_process, stdin_input, state, stream_final)
541544
else:
542545
try:
@@ -845,7 +848,7 @@ def run_repl(command_history: CommandHistory, initial_state: ShellState):
845848
state.current_path = os.getcwd()
846849

847850
state, output = execute_command(user_input, state)
848-
851+
#(state, output)
849852
process_result(user_input, state, output, command_history)
850853

851854
except (KeyboardInterrupt):

npcpy/modes/wander.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def enter_wander_mode(problem,
6565
if chunk_content:
6666
conversation_result += chunk_content
6767
print(chunk_content, end="")
68-
print('beginning to wander')
68+
#print('beginning to wander')
6969
high_temp_streams = []
7070
high_temp_samples = []
7171
for n in range(n_high_temp_streams):

0 commit comments

Comments
 (0)