Files
pipelines/app/tool/perf/chat_effort_fixture.dart
T

48 lines
1.3 KiB
Dart

import 'package:pipelines_app/core/api_gateway.dart';
/// `?header=1` thinking levels: the fixture model's levels as a Codex
/// model/list reports them, and the level each chat last chose.
const _levels = [
{
'id': 'low',
'name': 'Low',
'description': 'Fast responses with lighter reasoning',
},
{
'id': 'medium',
'name': 'Medium',
'description': 'Balances speed and reasoning depth',
},
{
'id': 'high',
'name': 'High',
'description': 'Greater reasoning depth for complex problems',
},
{
'id': 'xhigh',
'name': 'Extra high',
'description': 'Extra high reasoning depth for complex problems',
},
];
final Map<String, String> _chosen = {};
/// The row fields a server sends for a chat whose model has levels.
JsonMap chatEffortRowFields(String id) => {
'effort': _chosen[id] ?? '',
'efforts': _levels,
'default_effort': 'medium',
};
/// The `chat_effort` reply: the stored level with the model's levels.
JsonMap chatEffortReply(JsonMap request) {
final body = request['chat_effort'];
final id = body is Map ? '${body['session_id'] ?? ''}' : '';
final effort = body is Map ? '${body['effort'] ?? ''}' : '';
_chosen[id] = effort;
return {
'type': 'chat_effort',
'chat_effort': {'session_id': id, ...chatEffortRowFields(id)},
};
}