ninegrid2 6.504.0 → 6.506.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.
@@ -1,9 +1,13 @@
1
1
  import ninegrid from "../index.js";
2
+ import { ChatGoogleGenerativeAI } from "@langchain/google-genai";
3
+ import { Ollama } from "@langchain/ollama";
4
+ import { ChatOpenAI } from '@langchain/openai';
2
5
 
3
6
  class aiContainer extends HTMLElement
4
7
  {
5
8
  #target;
6
9
  #ing = false;
10
+ #model;
7
11
  //#elChat;
8
12
 
9
13
  constructor() {
@@ -57,10 +61,27 @@ class aiContainer extends HTMLElement
57
61
  this.#target = v;
58
62
  }
59
63
 
64
+ #createModel = () => {
65
+ const el = this.shadowRoot.querySelector("nx-ai-settings");
66
+ if (!el) return;
67
+
68
+ switch (el.server) {
69
+ case "gemini":
70
+ this.#model = new ChatGoogleGenerativeAI({ model: settingsRef.current.model, apiKey: googleApiKey, temperature: 0,});
71
+ break;
72
+ case "openai":
73
+ this.#model = new ChatOpenAI({ model: settingsRef.current.model, apiKey });
74
+ break;
75
+ case "ollama":
76
+ this.#model = new Ollama({ model: settingsRef.current.model });
77
+ break;
78
+ }
79
+ };
80
+
60
81
  #getColumnInfo = () => {
61
82
  let colInfo = "";
62
83
 
63
- console.log(this.#target, this.#target.tagName);
84
+ //console.log(this.#target, this.#target.tagName);
64
85
 
65
86
  if (this.#target.tagName === "NINE-GRID") {
66
87
  this.#target.columns.info().forEach(info => {
@@ -73,6 +94,7 @@ class aiContainer extends HTMLElement
73
94
 
74
95
  #generateQdrantFilter = async (userInput) => {
75
96
 
97
+ const systemMessage = "You are a helpful assistant.";
76
98
  // Qdrant 필터로 변환하기 위한 프롬프트 엔지니어링
77
99
  // 중요: 실제 컬렉션의 payload 필드와 그 데이터 타입을 정확히 알려줘야 Gemini가 올바른 필터를 생성합니다.
78
100
  const prompt = `
@@ -105,8 +127,8 @@ class aiContainer extends HTMLElement
105
127
  `;
106
128
 
107
129
  //try {
108
- const response = await chatModel.invoke([
109
- new SystemMessage("You are a helpful assistant."),
130
+ const response = await this.#model.invoke([
131
+ new SystemMessage(systemMessage),
110
132
  new HumanMessage(prompt),
111
133
  ]);
112
134
 
@@ -190,6 +212,8 @@ this.#generateQdrantFilter();
190
212
  this.shadowRoot.querySelector("nx-ai-chat").add("ing", question);
191
213
 
192
214
  try {
215
+ this.#createModel();
216
+
193
217
  if (this.shadowRoot.querySelector(".menu-filter").classList.contains("active")) {
194
218
  this.#q1();
195
219
  }
@@ -200,7 +224,6 @@ this.#generateQdrantFilter();
200
224
  this.#q3();
201
225
  }
202
226
  } catch (error) {
203
-
204
227
  console.error("Error generating Qdrant filter with Gemini:", error);
205
228
  return null;
206
229
  }
@@ -1,6 +1,9 @@
1
1
  'use strict';
2
2
 
3
3
  var ExcelJS$1 = require('exceljs');
4
+ var googleGenai = require('@langchain/google-genai');
5
+ var ollama = require('@langchain/ollama');
6
+ var openai = require('@langchain/openai');
4
7
 
5
8
  function getDefaultExportFromCjs (x) {
6
9
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
@@ -27858,6 +27861,7 @@ class aiContainer extends HTMLElement
27858
27861
  {
27859
27862
  #target;
27860
27863
  #ing = false;
27864
+ #model;
27861
27865
  //#elChat;
27862
27866
 
27863
27867
  constructor() {
@@ -27911,10 +27915,27 @@ class aiContainer extends HTMLElement
27911
27915
  this.#target = v;
27912
27916
  }
27913
27917
 
27918
+ #createModel = () => {
27919
+ const el = this.shadowRoot.querySelector("nx-ai-settings");
27920
+ if (!el) return;
27921
+
27922
+ switch (el.server) {
27923
+ case "gemini":
27924
+ this.#model = new googleGenai.ChatGoogleGenerativeAI({ model: settingsRef.current.model, apiKey: googleApiKey, temperature: 0,});
27925
+ break;
27926
+ case "openai":
27927
+ this.#model = new openai.ChatOpenAI({ model: settingsRef.current.model, apiKey });
27928
+ break;
27929
+ case "ollama":
27930
+ this.#model = new ollama.Ollama({ model: settingsRef.current.model });
27931
+ break;
27932
+ }
27933
+ };
27934
+
27914
27935
  #getColumnInfo = () => {
27915
27936
  let colInfo = "";
27916
27937
 
27917
- console.log(this.#target, this.#target.tagName);
27938
+ //console.log(this.#target, this.#target.tagName);
27918
27939
 
27919
27940
  if (this.#target.tagName === "NINE-GRID") {
27920
27941
  this.#target.columns.info().forEach(info => {
@@ -27927,6 +27948,7 @@ class aiContainer extends HTMLElement
27927
27948
 
27928
27949
  #generateQdrantFilter = async (userInput) => {
27929
27950
 
27951
+ const systemMessage = "You are a helpful assistant.";
27930
27952
  // Qdrant 필터로 변환하기 위한 프롬프트 엔지니어링
27931
27953
  // 중요: 실제 컬렉션의 payload 필드와 그 데이터 타입을 정확히 알려줘야 Gemini가 올바른 필터를 생성합니다.
27932
27954
  const prompt = `
@@ -27959,8 +27981,8 @@ class aiContainer extends HTMLElement
27959
27981
  `;
27960
27982
 
27961
27983
  //try {
27962
- const response = await chatModel.invoke([
27963
- new SystemMessage("You are a helpful assistant."),
27984
+ const response = await this.#model.invoke([
27985
+ new SystemMessage(systemMessage),
27964
27986
  new HumanMessage(prompt),
27965
27987
  ]);
27966
27988
 
@@ -28043,6 +28065,8 @@ this.#generateQdrantFilter();
28043
28065
  this.shadowRoot.querySelector("nx-ai-chat").add("ing", question);
28044
28066
 
28045
28067
  try {
28068
+ this.#createModel();
28069
+
28046
28070
  if (this.shadowRoot.querySelector(".menu-filter").classList.contains("active")) {
28047
28071
  this.#q1();
28048
28072
  }
@@ -28053,7 +28077,6 @@ this.#generateQdrantFilter();
28053
28077
  this.#q3();
28054
28078
  }
28055
28079
  } catch (error) {
28056
-
28057
28080
  console.error("Error generating Qdrant filter with Gemini:", error);
28058
28081
  return null;
28059
28082
  }
@@ -1,4 +1,7 @@
1
1
  import ExcelJS$1 from 'exceljs';
2
+ import { ChatGoogleGenerativeAI } from '@langchain/google-genai';
3
+ import { Ollama } from '@langchain/ollama';
4
+ import { ChatOpenAI } from '@langchain/openai';
2
5
 
3
6
  function getDefaultExportFromCjs (x) {
4
7
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
@@ -27856,6 +27859,7 @@ class aiContainer extends HTMLElement
27856
27859
  {
27857
27860
  #target;
27858
27861
  #ing = false;
27862
+ #model;
27859
27863
  //#elChat;
27860
27864
 
27861
27865
  constructor() {
@@ -27909,10 +27913,27 @@ class aiContainer extends HTMLElement
27909
27913
  this.#target = v;
27910
27914
  }
27911
27915
 
27916
+ #createModel = () => {
27917
+ const el = this.shadowRoot.querySelector("nx-ai-settings");
27918
+ if (!el) return;
27919
+
27920
+ switch (el.server) {
27921
+ case "gemini":
27922
+ this.#model = new ChatGoogleGenerativeAI({ model: settingsRef.current.model, apiKey: googleApiKey, temperature: 0,});
27923
+ break;
27924
+ case "openai":
27925
+ this.#model = new ChatOpenAI({ model: settingsRef.current.model, apiKey });
27926
+ break;
27927
+ case "ollama":
27928
+ this.#model = new Ollama({ model: settingsRef.current.model });
27929
+ break;
27930
+ }
27931
+ };
27932
+
27912
27933
  #getColumnInfo = () => {
27913
27934
  let colInfo = "";
27914
27935
 
27915
- console.log(this.#target, this.#target.tagName);
27936
+ //console.log(this.#target, this.#target.tagName);
27916
27937
 
27917
27938
  if (this.#target.tagName === "NINE-GRID") {
27918
27939
  this.#target.columns.info().forEach(info => {
@@ -27925,6 +27946,7 @@ class aiContainer extends HTMLElement
27925
27946
 
27926
27947
  #generateQdrantFilter = async (userInput) => {
27927
27948
 
27949
+ const systemMessage = "You are a helpful assistant.";
27928
27950
  // Qdrant 필터로 변환하기 위한 프롬프트 엔지니어링
27929
27951
  // 중요: 실제 컬렉션의 payload 필드와 그 데이터 타입을 정확히 알려줘야 Gemini가 올바른 필터를 생성합니다.
27930
27952
  const prompt = `
@@ -27957,8 +27979,8 @@ class aiContainer extends HTMLElement
27957
27979
  `;
27958
27980
 
27959
27981
  //try {
27960
- const response = await chatModel.invoke([
27961
- new SystemMessage("You are a helpful assistant."),
27982
+ const response = await this.#model.invoke([
27983
+ new SystemMessage(systemMessage),
27962
27984
  new HumanMessage(prompt),
27963
27985
  ]);
27964
27986
 
@@ -28041,6 +28063,8 @@ this.#generateQdrantFilter();
28041
28063
  this.shadowRoot.querySelector("nx-ai-chat").add("ing", question);
28042
28064
 
28043
28065
  try {
28066
+ this.#createModel();
28067
+
28044
28068
  if (this.shadowRoot.querySelector(".menu-filter").classList.contains("active")) {
28045
28069
  this.#q1();
28046
28070
  }
@@ -28051,7 +28075,6 @@ this.#generateQdrantFilter();
28051
28075
  this.#q3();
28052
28076
  }
28053
28077
  } catch (error) {
28054
-
28055
28078
  console.error("Error generating Qdrant filter with Gemini:", error);
28056
28079
  return null;
28057
28080
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ninegrid2",
3
3
  "type": "module",
4
- "version": "6.504.0",
4
+ "version": "6.506.0",
5
5
  "main": "dist/index.js",
6
6
  "exports": {
7
7
  "import": "./dist/index.js",
@@ -1,9 +1,13 @@
1
1
  import ninegrid from "../index.js";
2
+ import { ChatGoogleGenerativeAI } from "@langchain/google-genai";
3
+ import { Ollama } from "@langchain/ollama";
4
+ import { ChatOpenAI } from '@langchain/openai';
2
5
 
3
6
  class aiContainer extends HTMLElement
4
7
  {
5
8
  #target;
6
9
  #ing = false;
10
+ #model;
7
11
  //#elChat;
8
12
 
9
13
  constructor() {
@@ -57,10 +61,27 @@ class aiContainer extends HTMLElement
57
61
  this.#target = v;
58
62
  }
59
63
 
64
+ #createModel = () => {
65
+ const el = this.shadowRoot.querySelector("nx-ai-settings");
66
+ if (!el) return;
67
+
68
+ switch (el.server) {
69
+ case "gemini":
70
+ this.#model = new ChatGoogleGenerativeAI({ model: settingsRef.current.model, apiKey: googleApiKey, temperature: 0,});
71
+ break;
72
+ case "openai":
73
+ this.#model = new ChatOpenAI({ model: settingsRef.current.model, apiKey });
74
+ break;
75
+ case "ollama":
76
+ this.#model = new Ollama({ model: settingsRef.current.model });
77
+ break;
78
+ }
79
+ };
80
+
60
81
  #getColumnInfo = () => {
61
82
  let colInfo = "";
62
83
 
63
- console.log(this.#target, this.#target.tagName);
84
+ //console.log(this.#target, this.#target.tagName);
64
85
 
65
86
  if (this.#target.tagName === "NINE-GRID") {
66
87
  this.#target.columns.info().forEach(info => {
@@ -73,6 +94,7 @@ class aiContainer extends HTMLElement
73
94
 
74
95
  #generateQdrantFilter = async (userInput) => {
75
96
 
97
+ const systemMessage = "You are a helpful assistant.";
76
98
  // Qdrant 필터로 변환하기 위한 프롬프트 엔지니어링
77
99
  // 중요: 실제 컬렉션의 payload 필드와 그 데이터 타입을 정확히 알려줘야 Gemini가 올바른 필터를 생성합니다.
78
100
  const prompt = `
@@ -105,8 +127,8 @@ class aiContainer extends HTMLElement
105
127
  `;
106
128
 
107
129
  //try {
108
- const response = await chatModel.invoke([
109
- new SystemMessage("You are a helpful assistant."),
130
+ const response = await this.#model.invoke([
131
+ new SystemMessage(systemMessage),
110
132
  new HumanMessage(prompt),
111
133
  ]);
112
134
 
@@ -190,6 +212,8 @@ this.#generateQdrantFilter();
190
212
  this.shadowRoot.querySelector("nx-ai-chat").add("ing", question);
191
213
 
192
214
  try {
215
+ this.#createModel();
216
+
193
217
  if (this.shadowRoot.querySelector(".menu-filter").classList.contains("active")) {
194
218
  this.#q1();
195
219
  }
@@ -200,7 +224,6 @@ this.#generateQdrantFilter();
200
224
  this.#q3();
201
225
  }
202
226
  } catch (error) {
203
-
204
227
  console.error("Error generating Qdrant filter with Gemini:", error);
205
228
  return null;
206
229
  }