Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:
working-directory: packages/genkit_llamadart
run: |
dart --version
dart pub add crypto@3.0.7 genkit@1.0.0 http@1.6.0 llamadart@0.19.0 schemantic@1.0.0
dart pub add crypto@3.0.7 genkit@1.0.0 http@1.6.0 llamadart@0.19.7 schemantic@1.0.0
- name: Analyze and test minimum dependencies
if: matrix.part == 'lower bounds and published'
working-directory: packages/genkit_llamadart
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish_genkit_pubdev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:
sdk: 3.12.0
- name: Resolve lower-bound runtime dependencies
working-directory: packages/genkit_llamadart
run: dart pub add crypto@3.0.7 genkit@1.0.0 http@1.6.0 llamadart@0.19.0 schemantic@1.0.0
run: dart pub add crypto@3.0.7 genkit@1.0.0 http@1.6.0 llamadart@0.19.7 schemantic@1.0.0
- name: Analyze and test
working-directory: packages/genkit_llamadart
run: |
Expand Down
4 changes: 4 additions & 0 deletions packages/genkit_llamadart/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Unreleased

- Structured output builds its thinking budget with llamadart's `ChatTemplateEngine.resolveThinkingBudget`, so a Qwen3.5 or Qwen3-Coder XML template closes a spent budget with `\n</think>` instead of a bare `</think>`. Requires llamadart 0.19.7.

## 3.8.0 - 2026-11-08

- Upgrade to llamadart 0.19.0 and matching 0.19.x Apple companions.
Expand Down
2 changes: 1 addition & 1 deletion packages/genkit_llamadart/doc/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Upgrading to llamadart 0.19

The current plugin requires llamadart `^0.19.0`. Genkit 1.0, Schemantic 1.0,
The current plugin requires llamadart `^0.19.7`. Genkit 1.0, Schemantic 1.0,
the Dart 3.12 minimum and the plugin API are unchanged. Flutter iOS and macOS
apps must use matching `^0.19.0` runtime companions. See
[llamadart's migration guide](https://github.com/leehack/llamadart/blob/main/MIGRATION.md).
Expand Down
2 changes: 1 addition & 1 deletion packages/genkit_llamadart/doc/tool-input-schemas.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Tool input schemas

The plugin requires llamadart `^0.19.0`. Genkit continues to own handlers,
The plugin requires llamadart `^0.19.7`. Genkit continues to own handlers,
interrupts and message history. Tool input and tool-call argument roots must
be JSON objects; scalar and array roots are unsupported.

Expand Down
4 changes: 3 additions & 1 deletion packages/genkit_llamadart/doc/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,9 @@ for model guidance and qualification limits.
block; zero closes the block immediately. Enable thinking separately with
`enableThinking: true`. Chat and constrained JSON both resolve omitted
`startTag`/`endTag` from the selected template; custom delimiters and
`forcedMessage` pass through unchanged. Budgets need runtime support and cannot
`forcedMessage` pass through unchanged, except that on Qwen3-Coder XML
templates (Qwen3.5) with no `endTag` set, a `\n` is appended to `forcedMessage`
before `</think>`. Budgets need runtime support and cannot
be combined with media or speculative decoding.

`reusePromptPrefix: false` disables native llama.cpp prefix reuse. It does not
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,17 +343,9 @@ Future<genkit.ModelResponse> _runStructuredModel({
}

final budget = params.thinkingBudget;
final tags = budget == null
? null
: llama.ChatTemplateEngine.thinkingTagsFor(template.format);
final resolvedBudget = budget == null
? null
: llama.ThinkingBudget(
maxTokens: budget.maxTokens,
startTag: budget.startTag ?? tags!.startTag,
endTag: budget.endTag ?? tags!.endTag,
forcedMessage: budget.forcedMessage,
);
: llama.ChatTemplateEngine.resolveThinkingBudget(template.format, budget);
final rawOutput = StringBuffer();
await for (final token in runtime.generate(
template.prompt,
Expand Down
2 changes: 1 addition & 1 deletion packages/genkit_llamadart/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ dependencies:
crypto: ^3.0.7
genkit: ^1.0.0
http: ^1.6.0
llamadart: ^0.19.0
llamadart: ^0.19.7
schemantic: ^1.0.0

dev_dependencies:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,46 @@ void main() {
},
);

group('Qwen3-Coder XML thinking budget', () {
Future<llama.ThinkingBudget> budgetFor(ThinkingBudget budget) async {
runtime.templateResult = llama.LlamaChatTemplateResult(
prompt: 'prompt',
format: llama.ChatFormat.qwen3CoderXml.index,
grammar: 'root ::= "{}"',
);
await generate(
LlamaDartGenerationConfig(thinkingBudget: budget),
structured: true,
);
return runtime.lastGenerationParams!.thinkingBudget!;
}

test('appends the line break to the caller forced message', () async {
final budget = await budgetFor(
const ThinkingBudget(maxTokens: 8, forcedMessage: 'wrap up'),
);
expect(budget.forcedMessage, 'wrap up\n');
expect(budget.endTag, '</think>');
});

test('forces the line break alone without a forced message', () async {
final budget = await budgetFor(const ThinkingBudget(maxTokens: 8));
expect(budget.forcedMessage, '\n');
});

test('adds no line break when the caller sets an end tag', () async {
final budget = await budgetFor(
const ThinkingBudget(
maxTokens: 8,
endTag: '</custom>',
forcedMessage: 'wrap up',
),
);
expect(budget.endTag, '</custom>');
expect(budget.forcedMessage, 'wrap up');
});
});

test(
'typed speculation takes precedence over disabled default flag',
() async {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/tooling/ci_workflow_selection_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,7 @@ for event,flag,native,cancel,good,main in itertools.product(('push','pull_reques
contains('crypto@3.0.7'),
contains('genkit@1.0.0'),
contains('http@1.6.0'),
contains('llamadart@0.19.0'),
contains('llamadart@0.19.7'),
contains('schemantic@1.0.0'),
),
);
Expand Down
2 changes: 1 addition & 1 deletion website/docs/maintainers/genkit-package.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ selected lane participates in the existing truthful aggregate.

The adapter CI job runs two parallel legs. The first checks lower bounds: on
Dart 3.12.0, before Flutter is set up, it uses exact runtime dependency minima,
including published llamadart 0.19.0, then restores the package. It then
including published llamadart 0.19.7, then restores the package. It then
resolves published dependencies and checks docs, tests and publication. The
second creates an ignored `pubspec_overrides.yaml` to test against checkout
core, analyzes/tests again, runs the real-model contracts and checks browser
Expand Down
Loading