ninegrid2 6.519.0 → 6.520.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,6 +5,8 @@ import { ChatOpenAI } from '@langchain/openai';
5
5
  import { HumanMessage, SystemMessage } from '@langchain/core/messages';
6
6
  import { OllamaEmbeddings } from "@langchain/ollama";
7
7
  import { QdrantClient } from "@qdrant/js-client-rest";
8
+ import { StringOutputParser } from "@langchain/core/output_parsers"
9
+ import { PromptTemplate} from "@langchain/core/prompts"
8
10
 
9
11
  class aiContainer extends HTMLElement
10
12
  {
@@ -103,6 +105,12 @@ class aiContainer extends HTMLElement
103
105
  return colInfo;
104
106
  };
105
107
 
108
+ #getUniqueKey = () => {
109
+ if (this.#target.tagName === "NINE-GRID") {
110
+ return this.#target.dataset.unique;
111
+ }
112
+ };
113
+
106
114
 
107
115
  #generateQdrantFilter = async () => {
108
116
 
@@ -221,20 +229,80 @@ class aiContainer extends HTMLElement
221
229
 
222
230
  #q1 = async () => {
223
231
  const filter = await this.#generateQdrantFilter();
224
- const d = await this.#searchWithQdrantFilter(filter);
225
- console.log(d);
232
+ return await this.#searchWithQdrantFilter(filter);
226
233
  };
227
234
 
228
235
  #q2 = async () => {
229
236
  const filter = await this.#generateQdrantFilter();
230
- const d = await this.#searchWithQdrantFilter(filter);
231
- console.log(d);
237
+ const searchResults = await this.#searchWithQdrantFilter(filter);
238
+
239
+ const elAiChat = this.shadowRoot.querySelector("nx-ai-chat");
240
+ const columnInfo = this.#getColumnInfo();
241
+ const uniqueKey = this.#getUniqueKey();
242
+
243
+ if (!searchResults || searchResults.length == 0) {
244
+ elAiChat.add("ai", "관련된 정보가 없습니다.");
245
+ }
246
+ else if (searchResults.length > 100) {
247
+ elAiChat.add("ai", `${searchResults.length}건의 정보를 찾았습니다.`, columnInfo, searchResults.map(item => item.payload), uniqueKey);
248
+ }
249
+ else {
250
+ let arr = searchResults.map(item => item.payload);
251
+ let contextText = `당신은 주어진 정보를 참고하여 답변하는 AI 입니다. 주어진 '정보'를 바탕으로 데이타를 분석해줘. 데이타는 "context" 항목에 있어. 제공될 데이터는 CSV 형식이며, 첫 번째 줄은 컬럼명입니다. 이전에 너가 찾아준 데이타를 다시 보내는거니깐 첫 줄에는 "${arr.length}건을 찾았습니다." 라고 답변을 달아줘.\n\ncontext: `;
252
+
253
+ let contextText1 = `당신은 주어진 데이터를 분석하고 핵심 인사이트를 도출하는 전문 데이터 분석가입니다.
254
+
255
+ 아래에 제공될 데이터는 CSV 형식이며, 첫 번째 줄은 컬럼명입니다.
256
+
257
+ 이 데이터를 철저히 분석하여 다음 질문에 대한 답변을 제공해주세요:
258
+ - 데이터의 주요 트렌드는 무엇인가요?
259
+ - 특이하거나 주목할 만한 패턴이 있나요?
260
+ - 가장 빈번하게 나타나는 항목(또는 값)은 무엇인가요?
261
+ - 데이터에서 발견할 수 있는 잠재적인 문제점이나 개선점은 무엇인가요?
262
+ - 각 데이터 레코드를 기반으로 한 간략한 요약 또는 분류가 가능할까요?
263
+
264
+ 분석 결과는 다음 형식으로 제공해주세요:
265
+ 1. **주요 트렌드**: 불릿 포인트 형식으로 요약
266
+ 2. **주목할 만한 패턴/이상치**: 구체적인 예시와 함께 설명
267
+ 3. **가장 빈번한 항목**: 항목명과 빈도수를 포함 (테이블 형식도 가능)
268
+ 4. **개선점/문제점**: 텍스트 설명
269
+ 5. **각 레코드에 대한 간략한 요약 또는 분류**: (선택 사항, 필요시)
270
+
271
+ context:\n`;
272
+
273
+ columnInfo.forEach(info => {
274
+ contextText += `${info.desc}\t`;
275
+ });
276
+ contextText += "\n";
277
+
278
+ for (const o of arr) {
279
+ columnInfo.forEach(info => {
280
+ contextText += `${o[info.name]}\t`;
281
+ });
282
+
283
+ contextText += "\n";
284
+ //contextText += `문서ID: ${o.doc_id}, 문서명: ${o.doc_nm}, 매출액: ${o.amt}, 수정자: ${o.update_user}, 수정일: ${o.update_dt}\n`;
285
+ }
286
+
287
+ //console.log(contextText);
288
+
289
+ const prompt = PromptTemplate.fromTemplate(
290
+ contextText
291
+ )
292
+
293
+ const chain = prompt
294
+ .pipe(this.#model)
295
+ .pipe(new StringOutputParser())
296
+
297
+ const result = await chain.invoke();
298
+
299
+ elAiChat.add("ai", result, columnInfo, arr, uniqueKey);
300
+ }
232
301
  };
233
302
 
234
303
  #q3 = async () => {
235
304
  const filter = await this.#generateQdrantFilter();
236
- const d = await this.#searchWithQdrantFilter(filter);
237
- console.log(d);
305
+ return await this.#searchWithQdrantFilter(filter);
238
306
  };
239
307
 
240
308
  #init = (info) => {
@@ -5,6 +5,8 @@ var googleGenai = require('@langchain/google-genai');
5
5
  var ollama = require('@langchain/ollama');
6
6
  var openai = require('@langchain/openai');
7
7
  var messages = require('@langchain/core/messages');
8
+ var output_parsers = require('@langchain/core/output_parsers');
9
+ var prompts = require('@langchain/core/prompts');
8
10
  var require$$0 = require('assert');
9
11
  var require$$4 = require('net');
10
12
  var require$$2 = require('http');
@@ -54197,6 +54199,12 @@ class aiContainer extends HTMLElement
54197
54199
  return colInfo;
54198
54200
  };
54199
54201
 
54202
+ #getUniqueKey = () => {
54203
+ if (this.#target.tagName === "NINE-GRID") {
54204
+ return this.#target.dataset.unique;
54205
+ }
54206
+ };
54207
+
54200
54208
 
54201
54209
  #generateQdrantFilter = async () => {
54202
54210
 
@@ -54311,20 +54319,60 @@ class aiContainer extends HTMLElement
54311
54319
 
54312
54320
  #q1 = async () => {
54313
54321
  const filter = await this.#generateQdrantFilter();
54314
- const d = await this.#searchWithQdrantFilter(filter);
54315
- console.log(d);
54322
+ return await this.#searchWithQdrantFilter(filter);
54316
54323
  };
54317
54324
 
54318
54325
  #q2 = async () => {
54319
54326
  const filter = await this.#generateQdrantFilter();
54320
- const d = await this.#searchWithQdrantFilter(filter);
54321
- console.log(d);
54327
+ const searchResults = await this.#searchWithQdrantFilter(filter);
54328
+
54329
+ const elAiChat = this.shadowRoot.querySelector("nx-ai-chat");
54330
+ const columnInfo = this.#getColumnInfo();
54331
+ const uniqueKey = this.#getUniqueKey();
54332
+
54333
+ if (!searchResults || searchResults.length == 0) {
54334
+ elAiChat.add("ai", "관련된 정보가 없습니다.");
54335
+ }
54336
+ else if (searchResults.length > 100) {
54337
+ elAiChat.add("ai", `${searchResults.length}건의 정보를 찾았습니다.`, columnInfo, searchResults.map(item => item.payload), uniqueKey);
54338
+ }
54339
+ else {
54340
+ let arr = searchResults.map(item => item.payload);
54341
+ let contextText = `당신은 주어진 정보를 참고하여 답변하는 AI 입니다. 주어진 '정보'를 바탕으로 데이타를 분석해줘. 데이타는 "context" 항목에 있어. 제공될 데이터는 CSV 형식이며, 첫 번째 줄은 컬럼명입니다. 이전에 너가 찾아준 데이타를 다시 보내는거니깐 첫 줄에는 "${arr.length}건을 찾았습니다." 라고 답변을 달아줘.\n\ncontext: `;
54342
+
54343
+ columnInfo.forEach(info => {
54344
+ contextText += `${info.desc}\t`;
54345
+ });
54346
+ contextText += "\n";
54347
+
54348
+ for (const o of arr) {
54349
+ columnInfo.forEach(info => {
54350
+ contextText += `${o[info.name]}\t`;
54351
+ });
54352
+
54353
+ contextText += "\n";
54354
+ //contextText += `문서ID: ${o.doc_id}, 문서명: ${o.doc_nm}, 매출액: ${o.amt}, 수정자: ${o.update_user}, 수정일: ${o.update_dt}\n`;
54355
+ }
54356
+
54357
+ //console.log(contextText);
54358
+
54359
+ const prompt = prompts.PromptTemplate.fromTemplate(
54360
+ contextText
54361
+ );
54362
+
54363
+ const chain = prompt
54364
+ .pipe(this.#model)
54365
+ .pipe(new output_parsers.StringOutputParser());
54366
+
54367
+ const result = await chain.invoke();
54368
+
54369
+ elAiChat.add("ai", result, columnInfo, arr, uniqueKey);
54370
+ }
54322
54371
  };
54323
54372
 
54324
54373
  #q3 = async () => {
54325
54374
  const filter = await this.#generateQdrantFilter();
54326
- const d = await this.#searchWithQdrantFilter(filter);
54327
- console.log(d);
54375
+ return await this.#searchWithQdrantFilter(filter);
54328
54376
  };
54329
54377
 
54330
54378
  #init = (info) => {
@@ -3,6 +3,8 @@ import { ChatGoogleGenerativeAI } from '@langchain/google-genai';
3
3
  import { Ollama, OllamaEmbeddings } from '@langchain/ollama';
4
4
  import { ChatOpenAI } from '@langchain/openai';
5
5
  import { SystemMessage, HumanMessage } from '@langchain/core/messages';
6
+ import { StringOutputParser } from '@langchain/core/output_parsers';
7
+ import { PromptTemplate } from '@langchain/core/prompts';
6
8
  import require$$0 from 'assert';
7
9
  import require$$4 from 'net';
8
10
  import require$$2 from 'http';
@@ -54195,6 +54197,12 @@ class aiContainer extends HTMLElement
54195
54197
  return colInfo;
54196
54198
  };
54197
54199
 
54200
+ #getUniqueKey = () => {
54201
+ if (this.#target.tagName === "NINE-GRID") {
54202
+ return this.#target.dataset.unique;
54203
+ }
54204
+ };
54205
+
54198
54206
 
54199
54207
  #generateQdrantFilter = async () => {
54200
54208
 
@@ -54309,20 +54317,60 @@ class aiContainer extends HTMLElement
54309
54317
 
54310
54318
  #q1 = async () => {
54311
54319
  const filter = await this.#generateQdrantFilter();
54312
- const d = await this.#searchWithQdrantFilter(filter);
54313
- console.log(d);
54320
+ return await this.#searchWithQdrantFilter(filter);
54314
54321
  };
54315
54322
 
54316
54323
  #q2 = async () => {
54317
54324
  const filter = await this.#generateQdrantFilter();
54318
- const d = await this.#searchWithQdrantFilter(filter);
54319
- console.log(d);
54325
+ const searchResults = await this.#searchWithQdrantFilter(filter);
54326
+
54327
+ const elAiChat = this.shadowRoot.querySelector("nx-ai-chat");
54328
+ const columnInfo = this.#getColumnInfo();
54329
+ const uniqueKey = this.#getUniqueKey();
54330
+
54331
+ if (!searchResults || searchResults.length == 0) {
54332
+ elAiChat.add("ai", "관련된 정보가 없습니다.");
54333
+ }
54334
+ else if (searchResults.length > 100) {
54335
+ elAiChat.add("ai", `${searchResults.length}건의 정보를 찾았습니다.`, columnInfo, searchResults.map(item => item.payload), uniqueKey);
54336
+ }
54337
+ else {
54338
+ let arr = searchResults.map(item => item.payload);
54339
+ let contextText = `당신은 주어진 정보를 참고하여 답변하는 AI 입니다. 주어진 '정보'를 바탕으로 데이타를 분석해줘. 데이타는 "context" 항목에 있어. 제공될 데이터는 CSV 형식이며, 첫 번째 줄은 컬럼명입니다. 이전에 너가 찾아준 데이타를 다시 보내는거니깐 첫 줄에는 "${arr.length}건을 찾았습니다." 라고 답변을 달아줘.\n\ncontext: `;
54340
+
54341
+ columnInfo.forEach(info => {
54342
+ contextText += `${info.desc}\t`;
54343
+ });
54344
+ contextText += "\n";
54345
+
54346
+ for (const o of arr) {
54347
+ columnInfo.forEach(info => {
54348
+ contextText += `${o[info.name]}\t`;
54349
+ });
54350
+
54351
+ contextText += "\n";
54352
+ //contextText += `문서ID: ${o.doc_id}, 문서명: ${o.doc_nm}, 매출액: ${o.amt}, 수정자: ${o.update_user}, 수정일: ${o.update_dt}\n`;
54353
+ }
54354
+
54355
+ //console.log(contextText);
54356
+
54357
+ const prompt = PromptTemplate.fromTemplate(
54358
+ contextText
54359
+ );
54360
+
54361
+ const chain = prompt
54362
+ .pipe(this.#model)
54363
+ .pipe(new StringOutputParser());
54364
+
54365
+ const result = await chain.invoke();
54366
+
54367
+ elAiChat.add("ai", result, columnInfo, arr, uniqueKey);
54368
+ }
54320
54369
  };
54321
54370
 
54322
54371
  #q3 = async () => {
54323
54372
  const filter = await this.#generateQdrantFilter();
54324
- const d = await this.#searchWithQdrantFilter(filter);
54325
- console.log(d);
54373
+ return await this.#searchWithQdrantFilter(filter);
54326
54374
  };
54327
54375
 
54328
54376
  #init = (info) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ninegrid2",
3
3
  "type": "module",
4
- "version": "6.519.0",
4
+ "version": "6.520.0",
5
5
  "main": "dist/index.js",
6
6
  "exports": {
7
7
  "import": "./dist/index.js",
@@ -5,6 +5,8 @@ import { ChatOpenAI } from '@langchain/openai';
5
5
  import { HumanMessage, SystemMessage } from '@langchain/core/messages';
6
6
  import { OllamaEmbeddings } from "@langchain/ollama";
7
7
  import { QdrantClient } from "@qdrant/js-client-rest";
8
+ import { StringOutputParser } from "@langchain/core/output_parsers"
9
+ import { PromptTemplate} from "@langchain/core/prompts"
8
10
 
9
11
  class aiContainer extends HTMLElement
10
12
  {
@@ -103,6 +105,12 @@ class aiContainer extends HTMLElement
103
105
  return colInfo;
104
106
  };
105
107
 
108
+ #getUniqueKey = () => {
109
+ if (this.#target.tagName === "NINE-GRID") {
110
+ return this.#target.dataset.unique;
111
+ }
112
+ };
113
+
106
114
 
107
115
  #generateQdrantFilter = async () => {
108
116
 
@@ -221,20 +229,80 @@ class aiContainer extends HTMLElement
221
229
 
222
230
  #q1 = async () => {
223
231
  const filter = await this.#generateQdrantFilter();
224
- const d = await this.#searchWithQdrantFilter(filter);
225
- console.log(d);
232
+ return await this.#searchWithQdrantFilter(filter);
226
233
  };
227
234
 
228
235
  #q2 = async () => {
229
236
  const filter = await this.#generateQdrantFilter();
230
- const d = await this.#searchWithQdrantFilter(filter);
231
- console.log(d);
237
+ const searchResults = await this.#searchWithQdrantFilter(filter);
238
+
239
+ const elAiChat = this.shadowRoot.querySelector("nx-ai-chat");
240
+ const columnInfo = this.#getColumnInfo();
241
+ const uniqueKey = this.#getUniqueKey();
242
+
243
+ if (!searchResults || searchResults.length == 0) {
244
+ elAiChat.add("ai", "관련된 정보가 없습니다.");
245
+ }
246
+ else if (searchResults.length > 100) {
247
+ elAiChat.add("ai", `${searchResults.length}건의 정보를 찾았습니다.`, columnInfo, searchResults.map(item => item.payload), uniqueKey);
248
+ }
249
+ else {
250
+ let arr = searchResults.map(item => item.payload);
251
+ let contextText = `당신은 주어진 정보를 참고하여 답변하는 AI 입니다. 주어진 '정보'를 바탕으로 데이타를 분석해줘. 데이타는 "context" 항목에 있어. 제공될 데이터는 CSV 형식이며, 첫 번째 줄은 컬럼명입니다. 이전에 너가 찾아준 데이타를 다시 보내는거니깐 첫 줄에는 "${arr.length}건을 찾았습니다." 라고 답변을 달아줘.\n\ncontext: `;
252
+
253
+ let contextText1 = `당신은 주어진 데이터를 분석하고 핵심 인사이트를 도출하는 전문 데이터 분석가입니다.
254
+
255
+ 아래에 제공될 데이터는 CSV 형식이며, 첫 번째 줄은 컬럼명입니다.
256
+
257
+ 이 데이터를 철저히 분석하여 다음 질문에 대한 답변을 제공해주세요:
258
+ - 데이터의 주요 트렌드는 무엇인가요?
259
+ - 특이하거나 주목할 만한 패턴이 있나요?
260
+ - 가장 빈번하게 나타나는 항목(또는 값)은 무엇인가요?
261
+ - 데이터에서 발견할 수 있는 잠재적인 문제점이나 개선점은 무엇인가요?
262
+ - 각 데이터 레코드를 기반으로 한 간략한 요약 또는 분류가 가능할까요?
263
+
264
+ 분석 결과는 다음 형식으로 제공해주세요:
265
+ 1. **주요 트렌드**: 불릿 포인트 형식으로 요약
266
+ 2. **주목할 만한 패턴/이상치**: 구체적인 예시와 함께 설명
267
+ 3. **가장 빈번한 항목**: 항목명과 빈도수를 포함 (테이블 형식도 가능)
268
+ 4. **개선점/문제점**: 텍스트 설명
269
+ 5. **각 레코드에 대한 간략한 요약 또는 분류**: (선택 사항, 필요시)
270
+
271
+ context:\n`;
272
+
273
+ columnInfo.forEach(info => {
274
+ contextText += `${info.desc}\t`;
275
+ });
276
+ contextText += "\n";
277
+
278
+ for (const o of arr) {
279
+ columnInfo.forEach(info => {
280
+ contextText += `${o[info.name]}\t`;
281
+ });
282
+
283
+ contextText += "\n";
284
+ //contextText += `문서ID: ${o.doc_id}, 문서명: ${o.doc_nm}, 매출액: ${o.amt}, 수정자: ${o.update_user}, 수정일: ${o.update_dt}\n`;
285
+ }
286
+
287
+ //console.log(contextText);
288
+
289
+ const prompt = PromptTemplate.fromTemplate(
290
+ contextText
291
+ )
292
+
293
+ const chain = prompt
294
+ .pipe(this.#model)
295
+ .pipe(new StringOutputParser())
296
+
297
+ const result = await chain.invoke();
298
+
299
+ elAiChat.add("ai", result, columnInfo, arr, uniqueKey);
300
+ }
232
301
  };
233
302
 
234
303
  #q3 = async () => {
235
304
  const filter = await this.#generateQdrantFilter();
236
- const d = await this.#searchWithQdrantFilter(filter);
237
- console.log(d);
305
+ return await this.#searchWithQdrantFilter(filter);
238
306
  };
239
307
 
240
308
  #init = (info) => {