ninegrid2 6.504.0 → 6.505.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.
@@ -4,6 +4,7 @@ class aiContainer extends HTMLElement
4
4
  {
5
5
  #target;
6
6
  #ing = false;
7
+ #model;
7
8
  //#elChat;
8
9
 
9
10
  constructor() {
@@ -57,10 +58,27 @@ class aiContainer extends HTMLElement
57
58
  this.#target = v;
58
59
  }
59
60
 
61
+ #createModel = () => {
62
+ const el = this.shadowRoot.querySelector("nx-ai-settings");
63
+ if (!el) return;
64
+
65
+ switch (el.server) {
66
+ case "gemini":
67
+ this.#model = new ChatGoogleGenerativeAI({ model: settingsRef.current.model, apiKey: googleApiKey, temperature: 0,});
68
+ break;
69
+ case "openai":
70
+ this.#model = new ChatOpenAI({ model: settingsRef.current.model, apiKey });
71
+ break;
72
+ case "ollama":
73
+ this.#model = new Ollama({ model: settingsRef.current.model });
74
+ break;
75
+ }
76
+ };
77
+
60
78
  #getColumnInfo = () => {
61
79
  let colInfo = "";
62
80
 
63
- console.log(this.#target, this.#target.tagName);
81
+ //console.log(this.#target, this.#target.tagName);
64
82
 
65
83
  if (this.#target.tagName === "NINE-GRID") {
66
84
  this.#target.columns.info().forEach(info => {
@@ -73,6 +91,7 @@ class aiContainer extends HTMLElement
73
91
 
74
92
  #generateQdrantFilter = async (userInput) => {
75
93
 
94
+ const systemMessage = "You are a helpful assistant.";
76
95
  // Qdrant 필터로 변환하기 위한 프롬프트 엔지니어링
77
96
  // 중요: 실제 컬렉션의 payload 필드와 그 데이터 타입을 정확히 알려줘야 Gemini가 올바른 필터를 생성합니다.
78
97
  const prompt = `
@@ -105,8 +124,8 @@ class aiContainer extends HTMLElement
105
124
  `;
106
125
 
107
126
  //try {
108
- const response = await chatModel.invoke([
109
- new SystemMessage("You are a helpful assistant."),
127
+ const response = await this.#model.invoke([
128
+ new SystemMessage(systemMessage),
110
129
  new HumanMessage(prompt),
111
130
  ]);
112
131
 
@@ -190,6 +209,8 @@ this.#generateQdrantFilter();
190
209
  this.shadowRoot.querySelector("nx-ai-chat").add("ing", question);
191
210
 
192
211
  try {
212
+ this.#createModel();
213
+
193
214
  if (this.shadowRoot.querySelector(".menu-filter").classList.contains("active")) {
194
215
  this.#q1();
195
216
  }
@@ -200,7 +221,6 @@ this.#generateQdrantFilter();
200
221
  this.#q3();
201
222
  }
202
223
  } catch (error) {
203
-
204
224
  console.error("Error generating Qdrant filter with Gemini:", error);
205
225
  return null;
206
226
  }
@@ -27858,6 +27858,7 @@ class aiContainer extends HTMLElement
27858
27858
  {
27859
27859
  #target;
27860
27860
  #ing = false;
27861
+ #model;
27861
27862
  //#elChat;
27862
27863
 
27863
27864
  constructor() {
@@ -27911,10 +27912,27 @@ class aiContainer extends HTMLElement
27911
27912
  this.#target = v;
27912
27913
  }
27913
27914
 
27915
+ #createModel = () => {
27916
+ const el = this.shadowRoot.querySelector("nx-ai-settings");
27917
+ if (!el) return;
27918
+
27919
+ switch (el.server) {
27920
+ case "gemini":
27921
+ this.#model = new ChatGoogleGenerativeAI({ model: settingsRef.current.model, apiKey: googleApiKey, temperature: 0,});
27922
+ break;
27923
+ case "openai":
27924
+ this.#model = new ChatOpenAI({ model: settingsRef.current.model, apiKey });
27925
+ break;
27926
+ case "ollama":
27927
+ this.#model = new Ollama({ model: settingsRef.current.model });
27928
+ break;
27929
+ }
27930
+ };
27931
+
27914
27932
  #getColumnInfo = () => {
27915
27933
  let colInfo = "";
27916
27934
 
27917
- console.log(this.#target, this.#target.tagName);
27935
+ //console.log(this.#target, this.#target.tagName);
27918
27936
 
27919
27937
  if (this.#target.tagName === "NINE-GRID") {
27920
27938
  this.#target.columns.info().forEach(info => {
@@ -27927,6 +27945,7 @@ class aiContainer extends HTMLElement
27927
27945
 
27928
27946
  #generateQdrantFilter = async (userInput) => {
27929
27947
 
27948
+ const systemMessage = "You are a helpful assistant.";
27930
27949
  // Qdrant 필터로 변환하기 위한 프롬프트 엔지니어링
27931
27950
  // 중요: 실제 컬렉션의 payload 필드와 그 데이터 타입을 정확히 알려줘야 Gemini가 올바른 필터를 생성합니다.
27932
27951
  const prompt = `
@@ -27959,8 +27978,8 @@ class aiContainer extends HTMLElement
27959
27978
  `;
27960
27979
 
27961
27980
  //try {
27962
- const response = await chatModel.invoke([
27963
- new SystemMessage("You are a helpful assistant."),
27981
+ const response = await this.#model.invoke([
27982
+ new SystemMessage(systemMessage),
27964
27983
  new HumanMessage(prompt),
27965
27984
  ]);
27966
27985
 
@@ -28043,6 +28062,8 @@ this.#generateQdrantFilter();
28043
28062
  this.shadowRoot.querySelector("nx-ai-chat").add("ing", question);
28044
28063
 
28045
28064
  try {
28065
+ this.#createModel();
28066
+
28046
28067
  if (this.shadowRoot.querySelector(".menu-filter").classList.contains("active")) {
28047
28068
  this.#q1();
28048
28069
  }
@@ -28053,7 +28074,6 @@ this.#generateQdrantFilter();
28053
28074
  this.#q3();
28054
28075
  }
28055
28076
  } catch (error) {
28056
-
28057
28077
  console.error("Error generating Qdrant filter with Gemini:", error);
28058
28078
  return null;
28059
28079
  }
@@ -27856,6 +27856,7 @@ class aiContainer extends HTMLElement
27856
27856
  {
27857
27857
  #target;
27858
27858
  #ing = false;
27859
+ #model;
27859
27860
  //#elChat;
27860
27861
 
27861
27862
  constructor() {
@@ -27909,10 +27910,27 @@ class aiContainer extends HTMLElement
27909
27910
  this.#target = v;
27910
27911
  }
27911
27912
 
27913
+ #createModel = () => {
27914
+ const el = this.shadowRoot.querySelector("nx-ai-settings");
27915
+ if (!el) return;
27916
+
27917
+ switch (el.server) {
27918
+ case "gemini":
27919
+ this.#model = new ChatGoogleGenerativeAI({ model: settingsRef.current.model, apiKey: googleApiKey, temperature: 0,});
27920
+ break;
27921
+ case "openai":
27922
+ this.#model = new ChatOpenAI({ model: settingsRef.current.model, apiKey });
27923
+ break;
27924
+ case "ollama":
27925
+ this.#model = new Ollama({ model: settingsRef.current.model });
27926
+ break;
27927
+ }
27928
+ };
27929
+
27912
27930
  #getColumnInfo = () => {
27913
27931
  let colInfo = "";
27914
27932
 
27915
- console.log(this.#target, this.#target.tagName);
27933
+ //console.log(this.#target, this.#target.tagName);
27916
27934
 
27917
27935
  if (this.#target.tagName === "NINE-GRID") {
27918
27936
  this.#target.columns.info().forEach(info => {
@@ -27925,6 +27943,7 @@ class aiContainer extends HTMLElement
27925
27943
 
27926
27944
  #generateQdrantFilter = async (userInput) => {
27927
27945
 
27946
+ const systemMessage = "You are a helpful assistant.";
27928
27947
  // Qdrant 필터로 변환하기 위한 프롬프트 엔지니어링
27929
27948
  // 중요: 실제 컬렉션의 payload 필드와 그 데이터 타입을 정확히 알려줘야 Gemini가 올바른 필터를 생성합니다.
27930
27949
  const prompt = `
@@ -27957,8 +27976,8 @@ class aiContainer extends HTMLElement
27957
27976
  `;
27958
27977
 
27959
27978
  //try {
27960
- const response = await chatModel.invoke([
27961
- new SystemMessage("You are a helpful assistant."),
27979
+ const response = await this.#model.invoke([
27980
+ new SystemMessage(systemMessage),
27962
27981
  new HumanMessage(prompt),
27963
27982
  ]);
27964
27983
 
@@ -28041,6 +28060,8 @@ this.#generateQdrantFilter();
28041
28060
  this.shadowRoot.querySelector("nx-ai-chat").add("ing", question);
28042
28061
 
28043
28062
  try {
28063
+ this.#createModel();
28064
+
28044
28065
  if (this.shadowRoot.querySelector(".menu-filter").classList.contains("active")) {
28045
28066
  this.#q1();
28046
28067
  }
@@ -28051,7 +28072,6 @@ this.#generateQdrantFilter();
28051
28072
  this.#q3();
28052
28073
  }
28053
28074
  } catch (error) {
28054
-
28055
28075
  console.error("Error generating Qdrant filter with Gemini:", error);
28056
28076
  return null;
28057
28077
  }
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.505.0",
5
5
  "main": "dist/index.js",
6
6
  "exports": {
7
7
  "import": "./dist/index.js",
@@ -4,6 +4,7 @@ class aiContainer extends HTMLElement
4
4
  {
5
5
  #target;
6
6
  #ing = false;
7
+ #model;
7
8
  //#elChat;
8
9
 
9
10
  constructor() {
@@ -57,10 +58,27 @@ class aiContainer extends HTMLElement
57
58
  this.#target = v;
58
59
  }
59
60
 
61
+ #createModel = () => {
62
+ const el = this.shadowRoot.querySelector("nx-ai-settings");
63
+ if (!el) return;
64
+
65
+ switch (el.server) {
66
+ case "gemini":
67
+ this.#model = new ChatGoogleGenerativeAI({ model: settingsRef.current.model, apiKey: googleApiKey, temperature: 0,});
68
+ break;
69
+ case "openai":
70
+ this.#model = new ChatOpenAI({ model: settingsRef.current.model, apiKey });
71
+ break;
72
+ case "ollama":
73
+ this.#model = new Ollama({ model: settingsRef.current.model });
74
+ break;
75
+ }
76
+ };
77
+
60
78
  #getColumnInfo = () => {
61
79
  let colInfo = "";
62
80
 
63
- console.log(this.#target, this.#target.tagName);
81
+ //console.log(this.#target, this.#target.tagName);
64
82
 
65
83
  if (this.#target.tagName === "NINE-GRID") {
66
84
  this.#target.columns.info().forEach(info => {
@@ -73,6 +91,7 @@ class aiContainer extends HTMLElement
73
91
 
74
92
  #generateQdrantFilter = async (userInput) => {
75
93
 
94
+ const systemMessage = "You are a helpful assistant.";
76
95
  // Qdrant 필터로 변환하기 위한 프롬프트 엔지니어링
77
96
  // 중요: 실제 컬렉션의 payload 필드와 그 데이터 타입을 정확히 알려줘야 Gemini가 올바른 필터를 생성합니다.
78
97
  const prompt = `
@@ -105,8 +124,8 @@ class aiContainer extends HTMLElement
105
124
  `;
106
125
 
107
126
  //try {
108
- const response = await chatModel.invoke([
109
- new SystemMessage("You are a helpful assistant."),
127
+ const response = await this.#model.invoke([
128
+ new SystemMessage(systemMessage),
110
129
  new HumanMessage(prompt),
111
130
  ]);
112
131
 
@@ -190,6 +209,8 @@ this.#generateQdrantFilter();
190
209
  this.shadowRoot.querySelector("nx-ai-chat").add("ing", question);
191
210
 
192
211
  try {
212
+ this.#createModel();
213
+
193
214
  if (this.shadowRoot.querySelector(".menu-filter").classList.contains("active")) {
194
215
  this.#q1();
195
216
  }
@@ -200,7 +221,6 @@ this.#generateQdrantFilter();
200
221
  this.#q3();
201
222
  }
202
223
  } catch (error) {
203
-
204
224
  console.error("Error generating Qdrant filter with Gemini:", error);
205
225
  return null;
206
226
  }