patchpal 0.1.1__tar.gz → 0.1.3__tar.gz

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 (27) hide show
  1. {patchpal-0.1.1/patchpal.egg-info → patchpal-0.1.3}/PKG-INFO +82 -8
  2. {patchpal-0.1.1 → patchpal-0.1.3}/README.md +80 -7
  3. {patchpal-0.1.1 → patchpal-0.1.3}/patchpal/__init__.py +1 -1
  4. {patchpal-0.1.1 → patchpal-0.1.3}/patchpal/agent.py +16 -0
  5. {patchpal-0.1.1 → patchpal-0.1.3}/patchpal/cli.py +13 -0
  6. {patchpal-0.1.1 → patchpal-0.1.3/patchpal.egg-info}/PKG-INFO +82 -8
  7. {patchpal-0.1.1 → patchpal-0.1.3}/patchpal.egg-info/requires.txt +1 -0
  8. {patchpal-0.1.1 → patchpal-0.1.3}/pyproject.toml +1 -0
  9. {patchpal-0.1.1 → patchpal-0.1.3}/LICENSE +0 -0
  10. {patchpal-0.1.1 → patchpal-0.1.3}/MANIFEST.in +0 -0
  11. {patchpal-0.1.1 → patchpal-0.1.3}/patchpal/context.py +0 -0
  12. {patchpal-0.1.1 → patchpal-0.1.3}/patchpal/permissions.py +0 -0
  13. {patchpal-0.1.1 → patchpal-0.1.3}/patchpal/skills.py +0 -0
  14. {patchpal-0.1.1 → patchpal-0.1.3}/patchpal/system_prompt.md +0 -0
  15. {patchpal-0.1.1 → patchpal-0.1.3}/patchpal/tools.py +0 -0
  16. {patchpal-0.1.1 → patchpal-0.1.3}/patchpal.egg-info/SOURCES.txt +0 -0
  17. {patchpal-0.1.1 → patchpal-0.1.3}/patchpal.egg-info/dependency_links.txt +0 -0
  18. {patchpal-0.1.1 → patchpal-0.1.3}/patchpal.egg-info/entry_points.txt +0 -0
  19. {patchpal-0.1.1 → patchpal-0.1.3}/patchpal.egg-info/top_level.txt +0 -0
  20. {patchpal-0.1.1 → patchpal-0.1.3}/setup.cfg +0 -0
  21. {patchpal-0.1.1 → patchpal-0.1.3}/tests/test_agent.py +0 -0
  22. {patchpal-0.1.1 → patchpal-0.1.3}/tests/test_cli.py +0 -0
  23. {patchpal-0.1.1 → patchpal-0.1.3}/tests/test_context.py +0 -0
  24. {patchpal-0.1.1 → patchpal-0.1.3}/tests/test_guardrails.py +0 -0
  25. {patchpal-0.1.1 → patchpal-0.1.3}/tests/test_operational_safety.py +0 -0
  26. {patchpal-0.1.1 → patchpal-0.1.3}/tests/test_skills.py +0 -0
  27. {patchpal-0.1.1 → patchpal-0.1.3}/tests/test_tools.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: patchpal
3
- Version: 0.1.1
3
+ Version: 0.1.3
4
4
  Summary: A lean Claude Code clone in pure Python
5
5
  Author: PatchPal Contributors
6
6
  License-Expression: Apache-2.0
@@ -27,6 +27,7 @@ Requires-Dist: rich>=13.0.0
27
27
  Requires-Dist: pyyaml>=6.0.0
28
28
  Requires-Dist: prompt_toolkit>=3.0.0
29
29
  Requires-Dist: tiktoken>=0.5.0
30
+ Requires-Dist: boto3
30
31
  Provides-Extra: dev
31
32
  Requires-Dist: pytest>=7.0.0; extra == "dev"
32
33
  Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
@@ -69,7 +70,7 @@ pip install patchpal
69
70
  - **[Cloud]** For Anthropic models (default): Sign up at https://console.anthropic.com/
70
71
  - **[Cloud]** For OpenAI models: Get a key from https://platform.openai.com/
71
72
  - **[Local]** For vLLM: Install from https://docs.vllm.ai/ (free - no API charges) **Recommended for Local Use**
72
- - **[Local]** For Ollama: Install from https://ollama.com/ (⚠️ not well-suited for agents - use vLLM)
73
+ - **[Local]** For Ollama: Install from https://ollama.com/ (⚠️ requires `OLLAMA_CONTEXT_LENGTH=32768` - see Ollama section below)
73
74
  - For other providers: Check the [LiteLLM documentation](https://docs.litellm.ai/docs/providers)
74
75
 
75
76
  2. **Set up your API key as environment variable**:
@@ -103,8 +104,9 @@ export HOSTED_VLLM_API_BASE=http://localhost:8000
103
104
  export HOSTED_VLLM_API_KEY=token-abc123
104
105
  patchpal --model hosted_vllm/openai/gpt-oss-20b
105
106
 
106
- # Use Ollama (local, ⚠️ not recommended - use vLLM)
107
- patchpal --model ollama_chat/qwen3:32b # vLLM is better for agents
107
+ # Use Ollama (local - requires OLLAMA_CONTEXT_LENGTH=32768)
108
+ export OLLAMA_CONTEXT_LENGTH=32768
109
+ patchpal --model ollama_chat/qwen3:32b
108
110
 
109
111
  # Or set the model via environment variable
110
112
  export PATCHPAL_MODEL=openai/gpt-5
@@ -401,14 +403,86 @@ Different models require different parsers. Common parsers include: `qwen3_xml`,
401
403
 
402
404
  #### Ollama
403
405
 
404
- We find that Ollama models do not work well in agentic settings. For instance, while [gpt-oss-20b](https://huggingface.co/openai/gpt-oss-20b) works well in vLLM, the [Ollama version](https://ollama.com/library/gpt-oss) of the same model performs poorly. vLLM is recommended for local deployments.
406
+ Ollama v0.14+ supports tool calling for agentic workflows. However, proper configuration is **critical** for reliable operation.
407
+
408
+ **Requirements:**
409
+
410
+ 1. **Ollama v0.14.0 or later** - Required for tool calling support
411
+ 2. **Sufficient context window** - Default 4096 tokens is too small; increase to at least 32K
412
+
413
+ **Setup Instructions:**
414
+
415
+ **For Native Ollama Installation:**
416
+
417
+ ```bash
418
+ # Set context window size (required!)
419
+ export OLLAMA_CONTEXT_LENGTH=32768
420
+
421
+ # Start Ollama server
422
+ ollama serve
423
+
424
+ # In another terminal, use with PatchPal
425
+ patchpal --model ollama_chat/gpt-oss:20b
426
+ ```
427
+
428
+ **For Docker:**
429
+
430
+ ```bash
431
+ # Stop existing container (if running)
432
+ docker stop ollama
433
+ docker rm ollama
434
+
435
+ # Start with proper configuration
436
+ docker run -d \
437
+ -e OLLAMA_CONTEXT_LENGTH=32768 \
438
+ -v ollama:/root/.ollama \
439
+ -p 11434:11434 \
440
+ --name ollama \
441
+ ollama/ollama
442
+
443
+ # Verify configuration
444
+ docker exec -it ollama ollama run gpt-oss:20b
445
+ # In the Ollama prompt, type: /show parameters
446
+ # Should show num_ctx much larger than default 4096
447
+
448
+ # Use with PatchPal
449
+ patchpal --model ollama_chat/gpt-oss:20b
450
+ ```
451
+
452
+ **Verifying Context Window Size:**
453
+
454
+ ```bash
455
+ # Check your Ollama container configuration
456
+ docker inspect ollama | grep OLLAMA_CONTEXT_LENGTH
457
+
458
+ # Or run a model and check parameters
459
+ docker exec -it ollama ollama run gpt-oss:20b
460
+ >>> /show parameters
461
+ ```
462
+
463
+ **Recommended Models for Tool Calling:**
464
+
465
+ - `gpt-oss:20b` - OpenAI's open-source model, excellent tool calling
466
+ - `qwen3:32b` - Qwen3 model with good agentic capabilities
467
+ - `qwen3-coder` - Specialized for coding tasks
468
+
469
+ **Performance Note:**
470
+
471
+ While Ollama now works with proper configuration, vLLM is still recommended for production use due to:
472
+ - 3-10x faster inference
473
+ - More robust tool calling implementation
474
+ - Better memory management
405
475
 
406
476
  **Examples:**
407
477
 
408
478
  ```bash
409
- patchpal --model ollama_chat/qwen3:32b # local model: performs poorly
410
- patchpal --model ollama_chat/gpt-oss:20b # local model: performs poorly
411
- patchpal --model hosted_vllm/openai/gpt-oss-20b # local model: performs well
479
+ # Ollama (works with proper configuration)
480
+ export OLLAMA_CONTEXT_LENGTH=32768
481
+ patchpal --model ollama_chat/qwen3:32b
482
+ patchpal --model ollama_chat/gpt-oss:20b
483
+
484
+ # vLLM (recommended for production)
485
+ patchpal --model hosted_vllm/openai/gpt-oss-20b
412
486
  ```
413
487
 
414
488
  ### Air-Gapped and Offline Environments
@@ -33,7 +33,7 @@ pip install patchpal
33
33
  - **[Cloud]** For Anthropic models (default): Sign up at https://console.anthropic.com/
34
34
  - **[Cloud]** For OpenAI models: Get a key from https://platform.openai.com/
35
35
  - **[Local]** For vLLM: Install from https://docs.vllm.ai/ (free - no API charges) **Recommended for Local Use**
36
- - **[Local]** For Ollama: Install from https://ollama.com/ (⚠️ not well-suited for agents - use vLLM)
36
+ - **[Local]** For Ollama: Install from https://ollama.com/ (⚠️ requires `OLLAMA_CONTEXT_LENGTH=32768` - see Ollama section below)
37
37
  - For other providers: Check the [LiteLLM documentation](https://docs.litellm.ai/docs/providers)
38
38
 
39
39
  2. **Set up your API key as environment variable**:
@@ -67,8 +67,9 @@ export HOSTED_VLLM_API_BASE=http://localhost:8000
67
67
  export HOSTED_VLLM_API_KEY=token-abc123
68
68
  patchpal --model hosted_vllm/openai/gpt-oss-20b
69
69
 
70
- # Use Ollama (local, ⚠️ not recommended - use vLLM)
71
- patchpal --model ollama_chat/qwen3:32b # vLLM is better for agents
70
+ # Use Ollama (local - requires OLLAMA_CONTEXT_LENGTH=32768)
71
+ export OLLAMA_CONTEXT_LENGTH=32768
72
+ patchpal --model ollama_chat/qwen3:32b
72
73
 
73
74
  # Or set the model via environment variable
74
75
  export PATCHPAL_MODEL=openai/gpt-5
@@ -365,14 +366,86 @@ Different models require different parsers. Common parsers include: `qwen3_xml`,
365
366
 
366
367
  #### Ollama
367
368
 
368
- We find that Ollama models do not work well in agentic settings. For instance, while [gpt-oss-20b](https://huggingface.co/openai/gpt-oss-20b) works well in vLLM, the [Ollama version](https://ollama.com/library/gpt-oss) of the same model performs poorly. vLLM is recommended for local deployments.
369
+ Ollama v0.14+ supports tool calling for agentic workflows. However, proper configuration is **critical** for reliable operation.
370
+
371
+ **Requirements:**
372
+
373
+ 1. **Ollama v0.14.0 or later** - Required for tool calling support
374
+ 2. **Sufficient context window** - Default 4096 tokens is too small; increase to at least 32K
375
+
376
+ **Setup Instructions:**
377
+
378
+ **For Native Ollama Installation:**
379
+
380
+ ```bash
381
+ # Set context window size (required!)
382
+ export OLLAMA_CONTEXT_LENGTH=32768
383
+
384
+ # Start Ollama server
385
+ ollama serve
386
+
387
+ # In another terminal, use with PatchPal
388
+ patchpal --model ollama_chat/gpt-oss:20b
389
+ ```
390
+
391
+ **For Docker:**
392
+
393
+ ```bash
394
+ # Stop existing container (if running)
395
+ docker stop ollama
396
+ docker rm ollama
397
+
398
+ # Start with proper configuration
399
+ docker run -d \
400
+ -e OLLAMA_CONTEXT_LENGTH=32768 \
401
+ -v ollama:/root/.ollama \
402
+ -p 11434:11434 \
403
+ --name ollama \
404
+ ollama/ollama
405
+
406
+ # Verify configuration
407
+ docker exec -it ollama ollama run gpt-oss:20b
408
+ # In the Ollama prompt, type: /show parameters
409
+ # Should show num_ctx much larger than default 4096
410
+
411
+ # Use with PatchPal
412
+ patchpal --model ollama_chat/gpt-oss:20b
413
+ ```
414
+
415
+ **Verifying Context Window Size:**
416
+
417
+ ```bash
418
+ # Check your Ollama container configuration
419
+ docker inspect ollama | grep OLLAMA_CONTEXT_LENGTH
420
+
421
+ # Or run a model and check parameters
422
+ docker exec -it ollama ollama run gpt-oss:20b
423
+ >>> /show parameters
424
+ ```
425
+
426
+ **Recommended Models for Tool Calling:**
427
+
428
+ - `gpt-oss:20b` - OpenAI's open-source model, excellent tool calling
429
+ - `qwen3:32b` - Qwen3 model with good agentic capabilities
430
+ - `qwen3-coder` - Specialized for coding tasks
431
+
432
+ **Performance Note:**
433
+
434
+ While Ollama now works with proper configuration, vLLM is still recommended for production use due to:
435
+ - 3-10x faster inference
436
+ - More robust tool calling implementation
437
+ - Better memory management
369
438
 
370
439
  **Examples:**
371
440
 
372
441
  ```bash
373
- patchpal --model ollama_chat/qwen3:32b # local model: performs poorly
374
- patchpal --model ollama_chat/gpt-oss:20b # local model: performs poorly
375
- patchpal --model hosted_vllm/openai/gpt-oss-20b # local model: performs well
442
+ # Ollama (works with proper configuration)
443
+ export OLLAMA_CONTEXT_LENGTH=32768
444
+ patchpal --model ollama_chat/qwen3:32b
445
+ patchpal --model ollama_chat/gpt-oss:20b
446
+
447
+ # vLLM (recommended for production)
448
+ patchpal --model hosted_vllm/openai/gpt-oss-20b
376
449
  ```
377
450
 
378
451
  ### Air-Gapped and Offline Environments
@@ -1,6 +1,6 @@
1
1
  """PatchPal - An open-source Claude Code clone implemented purely in Python."""
2
2
 
3
- __version__ = "0.1.1"
3
+ __version__ = "0.1.3"
4
4
 
5
5
  from patchpal.agent import create_agent
6
6
  from patchpal.tools import (
@@ -540,6 +540,22 @@ class PatchPalAgent:
540
540
 
541
541
  self.model_id = _normalize_bedrock_model_id(model_id)
542
542
 
543
+ # Register Ollama models as supporting native function calling
544
+ # LiteLLM defaults to JSON mode if not explicitly registered
545
+ if self.model_id.startswith("ollama_chat/"):
546
+ # Suppress verbose output from register_model
547
+ import sys
548
+ from io import StringIO
549
+
550
+ old_stdout = sys.stdout
551
+ sys.stdout = StringIO()
552
+ try:
553
+ litellm.register_model(
554
+ {"model_cost": {self.model_id: {"supports_function_calling": True}}}
555
+ )
556
+ finally:
557
+ sys.stdout = old_stdout
558
+
543
559
  # Set up Bedrock environment if needed
544
560
  if self.model_id.startswith("bedrock/"):
545
561
  _setup_bedrock_env()
@@ -92,6 +92,13 @@ class SmartPathCompleter(Completer):
92
92
  )
93
93
 
94
94
 
95
+ def _get_version() -> str:
96
+ """Get the PatchPal version string."""
97
+ from patchpal import __version__
98
+
99
+ return __version__
100
+
101
+
95
102
  def _get_patchpal_dir() -> Path:
96
103
  """Get the patchpal directory for this repository.
97
104
 
@@ -174,6 +181,12 @@ Supported models: Any LiteLLM-supported model
174
181
  - Others: See https://docs.litellm.ai/docs/providers
175
182
  """,
176
183
  )
184
+ parser.add_argument(
185
+ "--version",
186
+ action="version",
187
+ version=f"%(prog)s {_get_version()}",
188
+ help="Show program's version number and exit",
189
+ )
177
190
  parser.add_argument(
178
191
  "--model",
179
192
  type=str,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: patchpal
3
- Version: 0.1.1
3
+ Version: 0.1.3
4
4
  Summary: A lean Claude Code clone in pure Python
5
5
  Author: PatchPal Contributors
6
6
  License-Expression: Apache-2.0
@@ -27,6 +27,7 @@ Requires-Dist: rich>=13.0.0
27
27
  Requires-Dist: pyyaml>=6.0.0
28
28
  Requires-Dist: prompt_toolkit>=3.0.0
29
29
  Requires-Dist: tiktoken>=0.5.0
30
+ Requires-Dist: boto3
30
31
  Provides-Extra: dev
31
32
  Requires-Dist: pytest>=7.0.0; extra == "dev"
32
33
  Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
@@ -69,7 +70,7 @@ pip install patchpal
69
70
  - **[Cloud]** For Anthropic models (default): Sign up at https://console.anthropic.com/
70
71
  - **[Cloud]** For OpenAI models: Get a key from https://platform.openai.com/
71
72
  - **[Local]** For vLLM: Install from https://docs.vllm.ai/ (free - no API charges) **Recommended for Local Use**
72
- - **[Local]** For Ollama: Install from https://ollama.com/ (⚠️ not well-suited for agents - use vLLM)
73
+ - **[Local]** For Ollama: Install from https://ollama.com/ (⚠️ requires `OLLAMA_CONTEXT_LENGTH=32768` - see Ollama section below)
73
74
  - For other providers: Check the [LiteLLM documentation](https://docs.litellm.ai/docs/providers)
74
75
 
75
76
  2. **Set up your API key as environment variable**:
@@ -103,8 +104,9 @@ export HOSTED_VLLM_API_BASE=http://localhost:8000
103
104
  export HOSTED_VLLM_API_KEY=token-abc123
104
105
  patchpal --model hosted_vllm/openai/gpt-oss-20b
105
106
 
106
- # Use Ollama (local, ⚠️ not recommended - use vLLM)
107
- patchpal --model ollama_chat/qwen3:32b # vLLM is better for agents
107
+ # Use Ollama (local - requires OLLAMA_CONTEXT_LENGTH=32768)
108
+ export OLLAMA_CONTEXT_LENGTH=32768
109
+ patchpal --model ollama_chat/qwen3:32b
108
110
 
109
111
  # Or set the model via environment variable
110
112
  export PATCHPAL_MODEL=openai/gpt-5
@@ -401,14 +403,86 @@ Different models require different parsers. Common parsers include: `qwen3_xml`,
401
403
 
402
404
  #### Ollama
403
405
 
404
- We find that Ollama models do not work well in agentic settings. For instance, while [gpt-oss-20b](https://huggingface.co/openai/gpt-oss-20b) works well in vLLM, the [Ollama version](https://ollama.com/library/gpt-oss) of the same model performs poorly. vLLM is recommended for local deployments.
406
+ Ollama v0.14+ supports tool calling for agentic workflows. However, proper configuration is **critical** for reliable operation.
407
+
408
+ **Requirements:**
409
+
410
+ 1. **Ollama v0.14.0 or later** - Required for tool calling support
411
+ 2. **Sufficient context window** - Default 4096 tokens is too small; increase to at least 32K
412
+
413
+ **Setup Instructions:**
414
+
415
+ **For Native Ollama Installation:**
416
+
417
+ ```bash
418
+ # Set context window size (required!)
419
+ export OLLAMA_CONTEXT_LENGTH=32768
420
+
421
+ # Start Ollama server
422
+ ollama serve
423
+
424
+ # In another terminal, use with PatchPal
425
+ patchpal --model ollama_chat/gpt-oss:20b
426
+ ```
427
+
428
+ **For Docker:**
429
+
430
+ ```bash
431
+ # Stop existing container (if running)
432
+ docker stop ollama
433
+ docker rm ollama
434
+
435
+ # Start with proper configuration
436
+ docker run -d \
437
+ -e OLLAMA_CONTEXT_LENGTH=32768 \
438
+ -v ollama:/root/.ollama \
439
+ -p 11434:11434 \
440
+ --name ollama \
441
+ ollama/ollama
442
+
443
+ # Verify configuration
444
+ docker exec -it ollama ollama run gpt-oss:20b
445
+ # In the Ollama prompt, type: /show parameters
446
+ # Should show num_ctx much larger than default 4096
447
+
448
+ # Use with PatchPal
449
+ patchpal --model ollama_chat/gpt-oss:20b
450
+ ```
451
+
452
+ **Verifying Context Window Size:**
453
+
454
+ ```bash
455
+ # Check your Ollama container configuration
456
+ docker inspect ollama | grep OLLAMA_CONTEXT_LENGTH
457
+
458
+ # Or run a model and check parameters
459
+ docker exec -it ollama ollama run gpt-oss:20b
460
+ >>> /show parameters
461
+ ```
462
+
463
+ **Recommended Models for Tool Calling:**
464
+
465
+ - `gpt-oss:20b` - OpenAI's open-source model, excellent tool calling
466
+ - `qwen3:32b` - Qwen3 model with good agentic capabilities
467
+ - `qwen3-coder` - Specialized for coding tasks
468
+
469
+ **Performance Note:**
470
+
471
+ While Ollama now works with proper configuration, vLLM is still recommended for production use due to:
472
+ - 3-10x faster inference
473
+ - More robust tool calling implementation
474
+ - Better memory management
405
475
 
406
476
  **Examples:**
407
477
 
408
478
  ```bash
409
- patchpal --model ollama_chat/qwen3:32b # local model: performs poorly
410
- patchpal --model ollama_chat/gpt-oss:20b # local model: performs poorly
411
- patchpal --model hosted_vllm/openai/gpt-oss-20b # local model: performs well
479
+ # Ollama (works with proper configuration)
480
+ export OLLAMA_CONTEXT_LENGTH=32768
481
+ patchpal --model ollama_chat/qwen3:32b
482
+ patchpal --model ollama_chat/gpt-oss:20b
483
+
484
+ # vLLM (recommended for production)
485
+ patchpal --model hosted_vllm/openai/gpt-oss-20b
412
486
  ```
413
487
 
414
488
  ### Air-Gapped and Offline Environments
@@ -6,6 +6,7 @@ rich>=13.0.0
6
6
  pyyaml>=6.0.0
7
7
  prompt_toolkit>=3.0.0
8
8
  tiktoken>=0.5.0
9
+ boto3
9
10
 
10
11
  [dev]
11
12
  pytest>=7.0.0
@@ -33,6 +33,7 @@ dependencies = [
33
33
  "pyyaml>=6.0.0",
34
34
  "prompt_toolkit>=3.0.0",
35
35
  "tiktoken>=0.5.0",
36
+ "boto3"
36
37
  ]
37
38
 
38
39
  [project.optional-dependencies]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes