mirror of
https://github.com/HeyPuter/puter.git
synced 2026-05-02 13:09:39 -05:00
dev: option to normalize AI response (non-streaming)
This commit is contained in:
@@ -547,6 +547,17 @@ class AIChatService extends BaseService {
|
||||
service_used,
|
||||
});
|
||||
|
||||
|
||||
if ( parameters.response?.normalize ) {
|
||||
ret.result.message =
|
||||
Messages.normalize_single_message(ret.result.message);
|
||||
ret.result = {
|
||||
message: ret.result.message,
|
||||
via_ai_chat_service: true,
|
||||
normalized: true,
|
||||
};
|
||||
}
|
||||
|
||||
return ret.result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,6 +78,7 @@ class AIInterfaceService extends BaseService {
|
||||
tools: { type: 'json' },
|
||||
vision: { type: 'flag' },
|
||||
stream: { type: 'flag' },
|
||||
response: { type: 'json' },
|
||||
model: { type: 'string' },
|
||||
},
|
||||
result: { type: 'json' },
|
||||
|
||||
@@ -285,8 +285,12 @@ class AI{
|
||||
options.stream = settings.stream;
|
||||
}
|
||||
|
||||
if ( settings.tools ) {
|
||||
options.tools = settings.tools;
|
||||
// settings to pass
|
||||
const SETTINGS_TO_PASS = ['tools', 'response'];
|
||||
for ( const name of SETTINGS_TO_PASS ) {
|
||||
if ( settings[name] ) {
|
||||
options[name] = settings[name];
|
||||
}
|
||||
}
|
||||
|
||||
// Call the original chat.complete method
|
||||
|
||||
Reference in New Issue
Block a user