mirror of
https://github.com/HeyPuter/puter.git
synced 2025-01-23 22:40:20 +08:00
dev: allow extensions to audit prompts
This commit is contained in:
parent
df42d433c9
commit
ef7047ede4
@ -83,8 +83,19 @@ class AIChatService extends BaseService {
|
||||
},
|
||||
async complete (parameters) {
|
||||
const client_driver_call = Context.get('client_driver_call');
|
||||
const { test_mode } = client_driver_call;
|
||||
let { intended_service } = client_driver_call;
|
||||
let { test_mode, intended_service } = client_driver_call;
|
||||
|
||||
this.log.noticeme('AIChatService.complete', { intended_service, parameters, test_mode });
|
||||
const svc_event = this.services.get('event');
|
||||
const event = {
|
||||
allow: true,
|
||||
intended_service,
|
||||
parameters
|
||||
};
|
||||
await svc_event.emit('ai.prompt.validate', event);
|
||||
if ( ! event.allow ) {
|
||||
test_mode = true;
|
||||
}
|
||||
|
||||
if ( test_mode ) {
|
||||
intended_service = 'fake-chat';
|
||||
|
@ -30,6 +30,21 @@ class OpenAICompletionService extends BaseService {
|
||||
];
|
||||
},
|
||||
async complete ({ messages, test_mode, stream, model }) {
|
||||
|
||||
// for now this code (also in AIChatService.js) needs to be
|
||||
// duplicated because this hasn't been moved to be under
|
||||
// the centralised controller yet
|
||||
const svc_event = this.services.get('event');
|
||||
const event = {
|
||||
allow: true,
|
||||
intended_service: 'openai',
|
||||
parameters: { messages }
|
||||
};
|
||||
await svc_event.emit('ai.prompt.validate', event);
|
||||
if ( ! event.allow ) {
|
||||
test_mode = true;
|
||||
}
|
||||
|
||||
if ( test_mode ) {
|
||||
const { LoremIpsum } = require('lorem-ipsum');
|
||||
const li = new LoremIpsum({
|
||||
|
Loading…
Reference in New Issue
Block a user