ninegrid2 6.502.0 → 6.504.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.
- package/dist/ai/aiContainer.js +45 -39
- package/dist/bundle.cjs.js +44 -39
- package/dist/bundle.esm.js +44 -39
- package/package.json +1 -1
- package/src/ai/aiContainer.js +45 -39
package/dist/ai/aiContainer.js
CHANGED
|
@@ -62,32 +62,24 @@ class aiContainer extends HTMLElement
|
|
|
62
62
|
|
|
63
63
|
console.log(this.#target, this.#target.tagName);
|
|
64
64
|
|
|
65
|
-
this.#target.
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
if (this.#target.tagName === "NINE-GRID") {
|
|
66
|
+
this.#target.columns.info().forEach(info => {
|
|
67
|
+
colInfo += `- "${info.name}": ${info.desc}, ${info.type}\n`;
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return colInfo;
|
|
70
72
|
};
|
|
71
73
|
|
|
72
74
|
#generateQdrantFilter = async (userInput) => {
|
|
73
75
|
|
|
74
|
-
//console.log(document.querySelector("nine-grid").body.querySelector(`thead [data-col="6"]`));
|
|
75
|
-
//console.log(document.querySelector("nine-grid").columns.info());
|
|
76
|
-
|
|
77
|
-
let colInfo = "";
|
|
78
|
-
document.querySelector("nine-grid").columns.info().forEach(info => {
|
|
79
|
-
colInfo += `- "${info.name}": ${info.desc}, ${info.type}\n`;
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
//console.log(colInfo);
|
|
83
|
-
|
|
84
76
|
// Qdrant 필터로 변환하기 위한 프롬프트 엔지니어링
|
|
85
77
|
// 중요: 실제 컬렉션의 payload 필드와 그 데이터 타입을 정확히 알려줘야 Gemini가 올바른 필터를 생성합니다.
|
|
86
78
|
const prompt = `
|
|
87
79
|
자연어 쿼리를 Qdrant 필터 JSON 객체로 변환하는 AI 비서입니다.
|
|
88
80
|
|
|
89
81
|
Qdrant 컬렉션에서 사용 가능한 메타데이터 필드와 유형은 다음과 같습니다.:
|
|
90
|
-
${
|
|
82
|
+
${this.#getColumnInfo()}
|
|
91
83
|
|
|
92
84
|
필터 생성 규칙:
|
|
93
85
|
1. 위에 제공된 필드만 사용하십시오. 새로운 필드를 만들지 마십시오.
|
|
@@ -112,7 +104,7 @@ class aiContainer extends HTMLElement
|
|
|
112
104
|
Qdrant 필터 JSON:
|
|
113
105
|
`;
|
|
114
106
|
|
|
115
|
-
try {
|
|
107
|
+
//try {
|
|
116
108
|
const response = await chatModel.invoke([
|
|
117
109
|
new SystemMessage("You are a helpful assistant."),
|
|
118
110
|
new HumanMessage(prompt),
|
|
@@ -129,34 +121,35 @@ class aiContainer extends HTMLElement
|
|
|
129
121
|
}
|
|
130
122
|
//filterString = filterString.replaceAll('"value"', '"text"')
|
|
131
123
|
console.log("Generated Filter String:", filterString);
|
|
132
|
-
|
|
124
|
+
filterString = "a" + filterString;
|
|
133
125
|
// Gemini가 JSON 모드나 Structured Output을 지원하지 않는 경우, 직접 파싱 시도
|
|
134
126
|
// 안정적인 JSON 파싱을 위해 'JSON Mode' 또는 Function Calling 사용을 강력히 권장
|
|
135
127
|
// LangChain의 SelfQueryRetriever를 사용하면 이 부분을 자동화할 수 있습니다.
|
|
136
|
-
try {
|
|
128
|
+
//try {
|
|
137
129
|
return JSON.parse(filterString);
|
|
138
|
-
} catch (parseError) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
130
|
+
//} catch (parseError) {
|
|
131
|
+
// console.error("Failed to parse filter string as JSON:", parseError);
|
|
132
|
+
// console.error("String that failed to parse:", filterString);
|
|
133
|
+
// return null; // 파싱 실패 시 null 반환 또는 적절한 에러 처리
|
|
134
|
+
//}
|
|
143
135
|
|
|
144
|
-
} catch (error) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
136
|
+
//} catch (error) {
|
|
137
|
+
|
|
138
|
+
// console.error("Error generating Qdrant filter with Gemini:", error);
|
|
139
|
+
// return null;
|
|
140
|
+
//}
|
|
148
141
|
}
|
|
149
142
|
|
|
150
143
|
#q1 = () => {
|
|
151
|
-
this.#
|
|
144
|
+
this.#generateQdrantFilter();
|
|
152
145
|
};
|
|
153
146
|
|
|
154
147
|
#q2 = () => {
|
|
155
|
-
this.#
|
|
148
|
+
this.#generateQdrantFilter();
|
|
156
149
|
};
|
|
157
150
|
|
|
158
151
|
#q3 = () => {
|
|
159
|
-
this.#
|
|
152
|
+
this.#generateQdrantFilter();
|
|
160
153
|
};
|
|
161
154
|
|
|
162
155
|
#init = (info) => {
|
|
@@ -174,6 +167,12 @@ this.#getColumnInfo();
|
|
|
174
167
|
#keydownHandler = (e) => {
|
|
175
168
|
if (e.key !== "Enter") return;
|
|
176
169
|
|
|
170
|
+
if (this.#target.tagName === "NINE-GRID") {
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
throw new Error("지원하지 않는 그리드 입니다.");
|
|
174
|
+
}
|
|
175
|
+
|
|
177
176
|
e.preventDefault();
|
|
178
177
|
|
|
179
178
|
const question = e.target.value.trim();
|
|
@@ -190,15 +189,22 @@ this.#getColumnInfo();
|
|
|
190
189
|
this.shadowRoot.querySelector("nx-ai-chat").add("me", question);
|
|
191
190
|
this.shadowRoot.querySelector("nx-ai-chat").add("ing", question);
|
|
192
191
|
|
|
193
|
-
|
|
194
|
-
this
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
this
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
192
|
+
try {
|
|
193
|
+
if (this.shadowRoot.querySelector(".menu-filter").classList.contains("active")) {
|
|
194
|
+
this.#q1();
|
|
195
|
+
}
|
|
196
|
+
else if (this.shadowRoot.querySelector(".menu-general").classList.contains("active")) {
|
|
197
|
+
this.#q2();
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
this.#q3();
|
|
201
|
+
}
|
|
202
|
+
} catch (error) {
|
|
203
|
+
|
|
204
|
+
console.error("Error generating Qdrant filter with Gemini:", error);
|
|
205
|
+
return null;
|
|
201
206
|
}
|
|
207
|
+
|
|
202
208
|
|
|
203
209
|
this.#ing = false;
|
|
204
210
|
}
|
package/dist/bundle.cjs.js
CHANGED
|
@@ -27916,32 +27916,24 @@ class aiContainer extends HTMLElement
|
|
|
27916
27916
|
|
|
27917
27917
|
console.log(this.#target, this.#target.tagName);
|
|
27918
27918
|
|
|
27919
|
-
this.#target.
|
|
27920
|
-
|
|
27921
|
-
|
|
27922
|
-
|
|
27923
|
-
|
|
27919
|
+
if (this.#target.tagName === "NINE-GRID") {
|
|
27920
|
+
this.#target.columns.info().forEach(info => {
|
|
27921
|
+
colInfo += `- "${info.name}": ${info.desc}, ${info.type}\n`;
|
|
27922
|
+
});
|
|
27923
|
+
}
|
|
27924
|
+
|
|
27925
|
+
return colInfo;
|
|
27924
27926
|
};
|
|
27925
27927
|
|
|
27926
27928
|
#generateQdrantFilter = async (userInput) => {
|
|
27927
27929
|
|
|
27928
|
-
//console.log(document.querySelector("nine-grid").body.querySelector(`thead [data-col="6"]`));
|
|
27929
|
-
//console.log(document.querySelector("nine-grid").columns.info());
|
|
27930
|
-
|
|
27931
|
-
let colInfo = "";
|
|
27932
|
-
document.querySelector("nine-grid").columns.info().forEach(info => {
|
|
27933
|
-
colInfo += `- "${info.name}": ${info.desc}, ${info.type}\n`;
|
|
27934
|
-
});
|
|
27935
|
-
|
|
27936
|
-
//console.log(colInfo);
|
|
27937
|
-
|
|
27938
27930
|
// Qdrant 필터로 변환하기 위한 프롬프트 엔지니어링
|
|
27939
27931
|
// 중요: 실제 컬렉션의 payload 필드와 그 데이터 타입을 정확히 알려줘야 Gemini가 올바른 필터를 생성합니다.
|
|
27940
27932
|
const prompt = `
|
|
27941
27933
|
자연어 쿼리를 Qdrant 필터 JSON 객체로 변환하는 AI 비서입니다.
|
|
27942
27934
|
|
|
27943
27935
|
Qdrant 컬렉션에서 사용 가능한 메타데이터 필드와 유형은 다음과 같습니다.:
|
|
27944
|
-
${
|
|
27936
|
+
${this.#getColumnInfo()}
|
|
27945
27937
|
|
|
27946
27938
|
필터 생성 규칙:
|
|
27947
27939
|
1. 위에 제공된 필드만 사용하십시오. 새로운 필드를 만들지 마십시오.
|
|
@@ -27966,7 +27958,7 @@ class aiContainer extends HTMLElement
|
|
|
27966
27958
|
Qdrant 필터 JSON:
|
|
27967
27959
|
`;
|
|
27968
27960
|
|
|
27969
|
-
try {
|
|
27961
|
+
//try {
|
|
27970
27962
|
const response = await chatModel.invoke([
|
|
27971
27963
|
new SystemMessage("You are a helpful assistant."),
|
|
27972
27964
|
new HumanMessage(prompt),
|
|
@@ -27983,34 +27975,35 @@ class aiContainer extends HTMLElement
|
|
|
27983
27975
|
}
|
|
27984
27976
|
//filterString = filterString.replaceAll('"value"', '"text"')
|
|
27985
27977
|
console.log("Generated Filter String:", filterString);
|
|
27986
|
-
|
|
27978
|
+
filterString = "a" + filterString;
|
|
27987
27979
|
// Gemini가 JSON 모드나 Structured Output을 지원하지 않는 경우, 직접 파싱 시도
|
|
27988
27980
|
// 안정적인 JSON 파싱을 위해 'JSON Mode' 또는 Function Calling 사용을 강력히 권장
|
|
27989
27981
|
// LangChain의 SelfQueryRetriever를 사용하면 이 부분을 자동화할 수 있습니다.
|
|
27990
|
-
try {
|
|
27982
|
+
//try {
|
|
27991
27983
|
return JSON.parse(filterString);
|
|
27992
|
-
} catch (parseError) {
|
|
27993
|
-
|
|
27994
|
-
|
|
27995
|
-
|
|
27996
|
-
}
|
|
27984
|
+
//} catch (parseError) {
|
|
27985
|
+
// console.error("Failed to parse filter string as JSON:", parseError);
|
|
27986
|
+
// console.error("String that failed to parse:", filterString);
|
|
27987
|
+
// return null; // 파싱 실패 시 null 반환 또는 적절한 에러 처리
|
|
27988
|
+
//}
|
|
27997
27989
|
|
|
27998
|
-
} catch (error) {
|
|
27999
|
-
|
|
28000
|
-
|
|
28001
|
-
|
|
27990
|
+
//} catch (error) {
|
|
27991
|
+
|
|
27992
|
+
// console.error("Error generating Qdrant filter with Gemini:", error);
|
|
27993
|
+
// return null;
|
|
27994
|
+
//}
|
|
28002
27995
|
}
|
|
28003
27996
|
|
|
28004
27997
|
#q1 = () => {
|
|
28005
|
-
this.#
|
|
27998
|
+
this.#generateQdrantFilter();
|
|
28006
27999
|
};
|
|
28007
28000
|
|
|
28008
28001
|
#q2 = () => {
|
|
28009
|
-
this.#
|
|
28002
|
+
this.#generateQdrantFilter();
|
|
28010
28003
|
};
|
|
28011
28004
|
|
|
28012
28005
|
#q3 = () => {
|
|
28013
|
-
this.#
|
|
28006
|
+
this.#generateQdrantFilter();
|
|
28014
28007
|
};
|
|
28015
28008
|
|
|
28016
28009
|
#init = (info) => {
|
|
@@ -28028,6 +28021,11 @@ this.#getColumnInfo();
|
|
|
28028
28021
|
#keydownHandler = (e) => {
|
|
28029
28022
|
if (e.key !== "Enter") return;
|
|
28030
28023
|
|
|
28024
|
+
if (this.#target.tagName === "NINE-GRID") ;
|
|
28025
|
+
else {
|
|
28026
|
+
throw new Error("지원하지 않는 그리드 입니다.");
|
|
28027
|
+
}
|
|
28028
|
+
|
|
28031
28029
|
e.preventDefault();
|
|
28032
28030
|
|
|
28033
28031
|
const question = e.target.value.trim();
|
|
@@ -28044,15 +28042,22 @@ this.#getColumnInfo();
|
|
|
28044
28042
|
this.shadowRoot.querySelector("nx-ai-chat").add("me", question);
|
|
28045
28043
|
this.shadowRoot.querySelector("nx-ai-chat").add("ing", question);
|
|
28046
28044
|
|
|
28047
|
-
|
|
28048
|
-
this
|
|
28049
|
-
|
|
28050
|
-
|
|
28051
|
-
this
|
|
28052
|
-
|
|
28053
|
-
|
|
28054
|
-
|
|
28045
|
+
try {
|
|
28046
|
+
if (this.shadowRoot.querySelector(".menu-filter").classList.contains("active")) {
|
|
28047
|
+
this.#q1();
|
|
28048
|
+
}
|
|
28049
|
+
else if (this.shadowRoot.querySelector(".menu-general").classList.contains("active")) {
|
|
28050
|
+
this.#q2();
|
|
28051
|
+
}
|
|
28052
|
+
else {
|
|
28053
|
+
this.#q3();
|
|
28054
|
+
}
|
|
28055
|
+
} catch (error) {
|
|
28056
|
+
|
|
28057
|
+
console.error("Error generating Qdrant filter with Gemini:", error);
|
|
28058
|
+
return null;
|
|
28055
28059
|
}
|
|
28060
|
+
|
|
28056
28061
|
|
|
28057
28062
|
this.#ing = false;
|
|
28058
28063
|
}
|
package/dist/bundle.esm.js
CHANGED
|
@@ -27914,32 +27914,24 @@ class aiContainer extends HTMLElement
|
|
|
27914
27914
|
|
|
27915
27915
|
console.log(this.#target, this.#target.tagName);
|
|
27916
27916
|
|
|
27917
|
-
this.#target.
|
|
27918
|
-
|
|
27919
|
-
|
|
27920
|
-
|
|
27921
|
-
|
|
27917
|
+
if (this.#target.tagName === "NINE-GRID") {
|
|
27918
|
+
this.#target.columns.info().forEach(info => {
|
|
27919
|
+
colInfo += `- "${info.name}": ${info.desc}, ${info.type}\n`;
|
|
27920
|
+
});
|
|
27921
|
+
}
|
|
27922
|
+
|
|
27923
|
+
return colInfo;
|
|
27922
27924
|
};
|
|
27923
27925
|
|
|
27924
27926
|
#generateQdrantFilter = async (userInput) => {
|
|
27925
27927
|
|
|
27926
|
-
//console.log(document.querySelector("nine-grid").body.querySelector(`thead [data-col="6"]`));
|
|
27927
|
-
//console.log(document.querySelector("nine-grid").columns.info());
|
|
27928
|
-
|
|
27929
|
-
let colInfo = "";
|
|
27930
|
-
document.querySelector("nine-grid").columns.info().forEach(info => {
|
|
27931
|
-
colInfo += `- "${info.name}": ${info.desc}, ${info.type}\n`;
|
|
27932
|
-
});
|
|
27933
|
-
|
|
27934
|
-
//console.log(colInfo);
|
|
27935
|
-
|
|
27936
27928
|
// Qdrant 필터로 변환하기 위한 프롬프트 엔지니어링
|
|
27937
27929
|
// 중요: 실제 컬렉션의 payload 필드와 그 데이터 타입을 정확히 알려줘야 Gemini가 올바른 필터를 생성합니다.
|
|
27938
27930
|
const prompt = `
|
|
27939
27931
|
자연어 쿼리를 Qdrant 필터 JSON 객체로 변환하는 AI 비서입니다.
|
|
27940
27932
|
|
|
27941
27933
|
Qdrant 컬렉션에서 사용 가능한 메타데이터 필드와 유형은 다음과 같습니다.:
|
|
27942
|
-
${
|
|
27934
|
+
${this.#getColumnInfo()}
|
|
27943
27935
|
|
|
27944
27936
|
필터 생성 규칙:
|
|
27945
27937
|
1. 위에 제공된 필드만 사용하십시오. 새로운 필드를 만들지 마십시오.
|
|
@@ -27964,7 +27956,7 @@ class aiContainer extends HTMLElement
|
|
|
27964
27956
|
Qdrant 필터 JSON:
|
|
27965
27957
|
`;
|
|
27966
27958
|
|
|
27967
|
-
try {
|
|
27959
|
+
//try {
|
|
27968
27960
|
const response = await chatModel.invoke([
|
|
27969
27961
|
new SystemMessage("You are a helpful assistant."),
|
|
27970
27962
|
new HumanMessage(prompt),
|
|
@@ -27981,34 +27973,35 @@ class aiContainer extends HTMLElement
|
|
|
27981
27973
|
}
|
|
27982
27974
|
//filterString = filterString.replaceAll('"value"', '"text"')
|
|
27983
27975
|
console.log("Generated Filter String:", filterString);
|
|
27984
|
-
|
|
27976
|
+
filterString = "a" + filterString;
|
|
27985
27977
|
// Gemini가 JSON 모드나 Structured Output을 지원하지 않는 경우, 직접 파싱 시도
|
|
27986
27978
|
// 안정적인 JSON 파싱을 위해 'JSON Mode' 또는 Function Calling 사용을 강력히 권장
|
|
27987
27979
|
// LangChain의 SelfQueryRetriever를 사용하면 이 부분을 자동화할 수 있습니다.
|
|
27988
|
-
try {
|
|
27980
|
+
//try {
|
|
27989
27981
|
return JSON.parse(filterString);
|
|
27990
|
-
} catch (parseError) {
|
|
27991
|
-
|
|
27992
|
-
|
|
27993
|
-
|
|
27994
|
-
}
|
|
27982
|
+
//} catch (parseError) {
|
|
27983
|
+
// console.error("Failed to parse filter string as JSON:", parseError);
|
|
27984
|
+
// console.error("String that failed to parse:", filterString);
|
|
27985
|
+
// return null; // 파싱 실패 시 null 반환 또는 적절한 에러 처리
|
|
27986
|
+
//}
|
|
27995
27987
|
|
|
27996
|
-
} catch (error) {
|
|
27997
|
-
|
|
27998
|
-
|
|
27999
|
-
|
|
27988
|
+
//} catch (error) {
|
|
27989
|
+
|
|
27990
|
+
// console.error("Error generating Qdrant filter with Gemini:", error);
|
|
27991
|
+
// return null;
|
|
27992
|
+
//}
|
|
28000
27993
|
}
|
|
28001
27994
|
|
|
28002
27995
|
#q1 = () => {
|
|
28003
|
-
this.#
|
|
27996
|
+
this.#generateQdrantFilter();
|
|
28004
27997
|
};
|
|
28005
27998
|
|
|
28006
27999
|
#q2 = () => {
|
|
28007
|
-
this.#
|
|
28000
|
+
this.#generateQdrantFilter();
|
|
28008
28001
|
};
|
|
28009
28002
|
|
|
28010
28003
|
#q3 = () => {
|
|
28011
|
-
this.#
|
|
28004
|
+
this.#generateQdrantFilter();
|
|
28012
28005
|
};
|
|
28013
28006
|
|
|
28014
28007
|
#init = (info) => {
|
|
@@ -28026,6 +28019,11 @@ this.#getColumnInfo();
|
|
|
28026
28019
|
#keydownHandler = (e) => {
|
|
28027
28020
|
if (e.key !== "Enter") return;
|
|
28028
28021
|
|
|
28022
|
+
if (this.#target.tagName === "NINE-GRID") ;
|
|
28023
|
+
else {
|
|
28024
|
+
throw new Error("지원하지 않는 그리드 입니다.");
|
|
28025
|
+
}
|
|
28026
|
+
|
|
28029
28027
|
e.preventDefault();
|
|
28030
28028
|
|
|
28031
28029
|
const question = e.target.value.trim();
|
|
@@ -28042,15 +28040,22 @@ this.#getColumnInfo();
|
|
|
28042
28040
|
this.shadowRoot.querySelector("nx-ai-chat").add("me", question);
|
|
28043
28041
|
this.shadowRoot.querySelector("nx-ai-chat").add("ing", question);
|
|
28044
28042
|
|
|
28045
|
-
|
|
28046
|
-
this
|
|
28047
|
-
|
|
28048
|
-
|
|
28049
|
-
this
|
|
28050
|
-
|
|
28051
|
-
|
|
28052
|
-
|
|
28043
|
+
try {
|
|
28044
|
+
if (this.shadowRoot.querySelector(".menu-filter").classList.contains("active")) {
|
|
28045
|
+
this.#q1();
|
|
28046
|
+
}
|
|
28047
|
+
else if (this.shadowRoot.querySelector(".menu-general").classList.contains("active")) {
|
|
28048
|
+
this.#q2();
|
|
28049
|
+
}
|
|
28050
|
+
else {
|
|
28051
|
+
this.#q3();
|
|
28052
|
+
}
|
|
28053
|
+
} catch (error) {
|
|
28054
|
+
|
|
28055
|
+
console.error("Error generating Qdrant filter with Gemini:", error);
|
|
28056
|
+
return null;
|
|
28053
28057
|
}
|
|
28058
|
+
|
|
28054
28059
|
|
|
28055
28060
|
this.#ing = false;
|
|
28056
28061
|
}
|
package/package.json
CHANGED
package/src/ai/aiContainer.js
CHANGED
|
@@ -62,32 +62,24 @@ class aiContainer extends HTMLElement
|
|
|
62
62
|
|
|
63
63
|
console.log(this.#target, this.#target.tagName);
|
|
64
64
|
|
|
65
|
-
this.#target.
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
if (this.#target.tagName === "NINE-GRID") {
|
|
66
|
+
this.#target.columns.info().forEach(info => {
|
|
67
|
+
colInfo += `- "${info.name}": ${info.desc}, ${info.type}\n`;
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return colInfo;
|
|
70
72
|
};
|
|
71
73
|
|
|
72
74
|
#generateQdrantFilter = async (userInput) => {
|
|
73
75
|
|
|
74
|
-
//console.log(document.querySelector("nine-grid").body.querySelector(`thead [data-col="6"]`));
|
|
75
|
-
//console.log(document.querySelector("nine-grid").columns.info());
|
|
76
|
-
|
|
77
|
-
let colInfo = "";
|
|
78
|
-
document.querySelector("nine-grid").columns.info().forEach(info => {
|
|
79
|
-
colInfo += `- "${info.name}": ${info.desc}, ${info.type}\n`;
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
//console.log(colInfo);
|
|
83
|
-
|
|
84
76
|
// Qdrant 필터로 변환하기 위한 프롬프트 엔지니어링
|
|
85
77
|
// 중요: 실제 컬렉션의 payload 필드와 그 데이터 타입을 정확히 알려줘야 Gemini가 올바른 필터를 생성합니다.
|
|
86
78
|
const prompt = `
|
|
87
79
|
자연어 쿼리를 Qdrant 필터 JSON 객체로 변환하는 AI 비서입니다.
|
|
88
80
|
|
|
89
81
|
Qdrant 컬렉션에서 사용 가능한 메타데이터 필드와 유형은 다음과 같습니다.:
|
|
90
|
-
${
|
|
82
|
+
${this.#getColumnInfo()}
|
|
91
83
|
|
|
92
84
|
필터 생성 규칙:
|
|
93
85
|
1. 위에 제공된 필드만 사용하십시오. 새로운 필드를 만들지 마십시오.
|
|
@@ -112,7 +104,7 @@ class aiContainer extends HTMLElement
|
|
|
112
104
|
Qdrant 필터 JSON:
|
|
113
105
|
`;
|
|
114
106
|
|
|
115
|
-
try {
|
|
107
|
+
//try {
|
|
116
108
|
const response = await chatModel.invoke([
|
|
117
109
|
new SystemMessage("You are a helpful assistant."),
|
|
118
110
|
new HumanMessage(prompt),
|
|
@@ -129,34 +121,35 @@ class aiContainer extends HTMLElement
|
|
|
129
121
|
}
|
|
130
122
|
//filterString = filterString.replaceAll('"value"', '"text"')
|
|
131
123
|
console.log("Generated Filter String:", filterString);
|
|
132
|
-
|
|
124
|
+
filterString = "a" + filterString;
|
|
133
125
|
// Gemini가 JSON 모드나 Structured Output을 지원하지 않는 경우, 직접 파싱 시도
|
|
134
126
|
// 안정적인 JSON 파싱을 위해 'JSON Mode' 또는 Function Calling 사용을 강력히 권장
|
|
135
127
|
// LangChain의 SelfQueryRetriever를 사용하면 이 부분을 자동화할 수 있습니다.
|
|
136
|
-
try {
|
|
128
|
+
//try {
|
|
137
129
|
return JSON.parse(filterString);
|
|
138
|
-
} catch (parseError) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
130
|
+
//} catch (parseError) {
|
|
131
|
+
// console.error("Failed to parse filter string as JSON:", parseError);
|
|
132
|
+
// console.error("String that failed to parse:", filterString);
|
|
133
|
+
// return null; // 파싱 실패 시 null 반환 또는 적절한 에러 처리
|
|
134
|
+
//}
|
|
143
135
|
|
|
144
|
-
} catch (error) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
136
|
+
//} catch (error) {
|
|
137
|
+
|
|
138
|
+
// console.error("Error generating Qdrant filter with Gemini:", error);
|
|
139
|
+
// return null;
|
|
140
|
+
//}
|
|
148
141
|
}
|
|
149
142
|
|
|
150
143
|
#q1 = () => {
|
|
151
|
-
this.#
|
|
144
|
+
this.#generateQdrantFilter();
|
|
152
145
|
};
|
|
153
146
|
|
|
154
147
|
#q2 = () => {
|
|
155
|
-
this.#
|
|
148
|
+
this.#generateQdrantFilter();
|
|
156
149
|
};
|
|
157
150
|
|
|
158
151
|
#q3 = () => {
|
|
159
|
-
this.#
|
|
152
|
+
this.#generateQdrantFilter();
|
|
160
153
|
};
|
|
161
154
|
|
|
162
155
|
#init = (info) => {
|
|
@@ -174,6 +167,12 @@ this.#getColumnInfo();
|
|
|
174
167
|
#keydownHandler = (e) => {
|
|
175
168
|
if (e.key !== "Enter") return;
|
|
176
169
|
|
|
170
|
+
if (this.#target.tagName === "NINE-GRID") {
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
throw new Error("지원하지 않는 그리드 입니다.");
|
|
174
|
+
}
|
|
175
|
+
|
|
177
176
|
e.preventDefault();
|
|
178
177
|
|
|
179
178
|
const question = e.target.value.trim();
|
|
@@ -190,15 +189,22 @@ this.#getColumnInfo();
|
|
|
190
189
|
this.shadowRoot.querySelector("nx-ai-chat").add("me", question);
|
|
191
190
|
this.shadowRoot.querySelector("nx-ai-chat").add("ing", question);
|
|
192
191
|
|
|
193
|
-
|
|
194
|
-
this
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
this
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
192
|
+
try {
|
|
193
|
+
if (this.shadowRoot.querySelector(".menu-filter").classList.contains("active")) {
|
|
194
|
+
this.#q1();
|
|
195
|
+
}
|
|
196
|
+
else if (this.shadowRoot.querySelector(".menu-general").classList.contains("active")) {
|
|
197
|
+
this.#q2();
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
this.#q3();
|
|
201
|
+
}
|
|
202
|
+
} catch (error) {
|
|
203
|
+
|
|
204
|
+
console.error("Error generating Qdrant filter with Gemini:", error);
|
|
205
|
+
return null;
|
|
201
206
|
}
|
|
207
|
+
|
|
202
208
|
|
|
203
209
|
this.#ing = false;
|
|
204
210
|
}
|