Skip to content

Commit 17450c7

Browse files
committed
feature #669 [Platform][Ollama] Better regex for qwen tool pattern (sonnymilton)
This PR was merged into the main branch. Discussion ---------- [Platform][Ollama] Better regex for qwen tool pattern | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes<!-- please update src/**/CHANGELOG.md files --> | Docs? | yes/no <!-- required for new features --> | Issues | - <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT The current regex for QWEN models does not cover model size notation like `qwen3:32b` or `qwen3-coder:32b`. I changed the regular expression to support notations with model sizes. Commits ------- f8e328b1 [Platform][OLLAMA] Update tool pattern regex for qwen to support models with size
2 parents d626780 + 8c8f4ee commit 17450c7

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/Bridge/Ollama/Ollama.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class Ollama extends Model
2323
public const GEMMA_3_N = 'gemma3n';
2424
public const GEMMA_3 = 'gemma3';
2525
public const QWEN_3 = 'qwen3';
26+
public const QWEN_3_32B = 'qwen3:32b';
2627
public const QWEN_2_5_VL = 'qwen2.5vl';
2728
public const LLAMA_3_1 = 'llama3.1';
2829
public const LLAMA_3_2 = 'llama3.2';
@@ -33,6 +34,7 @@ class Ollama extends Model
3334
public const PHI_3 = 'phi3';
3435
public const GEMMA_2 = 'gemma2';
3536
public const QWEN_2_5_CODER = 'qwen2.5-coder';
37+
public const QWEN_2_5_CODER_32B = 'qwen2.5-coder:32b';
3638
public const GEMMA = 'gemma';
3739
public const QWEN = 'qwen';
3840
public const QWEN_2 = 'qwen2';
@@ -50,7 +52,7 @@ class Ollama extends Model
5052
'/^llama\D*3(\D*\d+)/' => [
5153
Capability::TOOL_CALLING,
5254
],
53-
'/^qwen\d(\.\d)?(-coder)?$/' => [
55+
'/^qwen\d(\.\d)?(-coder)?(:\d+(\.\d+)?b)?$/' => [
5456
Capability::TOOL_CALLING,
5557
],
5658
'/^(deepseek|mistral)/' => [

tests/Bridge/Ollama/OllamaTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ public static function provideModelsWithToolCallingCapability(): iterable
6464
yield 'qwen2' => [Ollama::QWEN_2];
6565
yield 'qwen2.5' => [Ollama::QWEN_2_5];
6666
yield 'qwen2.5-coder' => [Ollama::QWEN_2_5_CODER];
67+
yield 'qwen2.5-coder:32b' => [Ollama::QWEN_2_5_CODER_32B];
6768
yield 'qwen3' => [Ollama::QWEN_3];
69+
yield 'qwen3:32b' => [Ollama::QWEN_3_32B];
6870

6971
// Models that match the deepseek pattern
7072
yield 'deepseek-r1' => [Ollama::DEEPSEEK_R_1];

0 commit comments

Comments
 (0)