New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

@dialogai/dialog-observers

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dialogai/dialog-observers - npm Package Compare versions

Comparing version

to
1.7.1

@@ -11,2 +11,3 @@ const {

const billing = require("@dieugene/billing");
const fs = require("@dieugene/file-service");

@@ -48,2 +49,6 @@ let observe_llm = new ChatOpenAI({

add_instruction.to_end = function (messages=[], instruction="", as_human = false) {
messages.push(get_instruction(instruction, {as_human}))
};
function break_lines(lines) {

@@ -205,3 +210,4 @@ function break_single_line(txt) {

super();
this.data['professional_skills'] = ''
this.data['professional_skills'] = '';
this.data['files_data'] = [];
}

@@ -214,8 +220,27 @@

async process_file(message) {
if (!message.includes('\nfile::')) return false;
console.log('Observer :: ' + this.constructor.name + ' :: EXTRACT FILES :: START');
message.split('\n').filter(s => s.startsWith('file::')).forEach(async s => {
let file_uuid = s.split('::').pop(),
file_data = await fs.getFile(file_uuid),
file_content = file_data.docs.map(doc => doc.pageContent).join('\n\n');
this.data['files_data'].push({file_uuid, file_content});
console.log('Observer :: ' + this.constructor.name + ' :: EXTRACT FILES :: IN PROGRESS');
});
console.log('Observer :: ' + this.constructor.name + ' :: EXTRACT FILES :: FINISH');
return true;
}
async pre_check(human_msg = "", messages = []) {
if (await this.process_file(human_msg))
add_instruction.to_end(messages,
'Полученный файл сохранен и будет использоваться в дальнейшем. Сообщи об этом пользователю',
true
);
let attr = this.data['professional_skills'] === '' ? 'init_msg' : 'msg',
message = this[attr].format(
this.host.session_history,
this.host.alias,
this.data['professional_skills']
this.host.session_history,
this.host.alias,
this.data['professional_skills']
),

@@ -222,0 +247,0 @@ result = (await this.llm.invoke(

@@ -14,3 +14,3 @@ {

"name": "@dialogai/dialog-observers",
"version": "1.7.0",
"version": "1.7.1",
"description": "",

@@ -17,0 +17,0 @@ "main": "dialog-observers.js",