toYaml method
Serializes to the map form (round-trips with ModelRef.fromYaml).
Implementation
String toYaml() {
final buffer = StringBuffer()
..write('provider: $provider\n')
..write('model: $modelId\n');
if (apiKeyName != null) buffer.write('apiKeyName: $apiKeyName\n');
if (baseUrl != null) buffer.write('baseUrl: $baseUrl\n');
if (contextWindow != null) buffer.write('contextWindow: $contextWindow\n');
if (maxTokens != null) buffer.write('maxTokens: $maxTokens\n');
if (thinkingLevel != null) {
buffer.write('thinkingLevel: $thinkingLevel\n');
}
if (input != null) {
buffer.write('input: [${input!.join(', ')}]\n');
}
if (authHeader != null) {
// RFC 7230 tokens may lead with yaml specials (`#`, `*`, `!`): a raw
// scalar would round-trip as a comment/alias. JSON quoting keeps the
// round-trip lossless (issue #964 review).
buffer.write('authHeader: ${jsonEncode(authHeader)}\n');
}
if (connectTimeout != null) {
buffer.write('connectTimeoutMs: ${connectTimeout!.inMilliseconds}\n');
}
if (streamIdleTimeout != null) {
buffer.write(
'streamIdleTimeoutMs: ${streamIdleTimeout!.inMilliseconds}\n',
);
}
if (keyless) buffer.write('keyless: true\n');
return buffer.toString();
}