ninegrid2 6.514.0 → 6.517.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 +53 -4
- package/dist/bundle.cjs.js +48 -4
- package/dist/bundle.esm.js +49 -5
- package/package.json +1 -1
- package/src/ai/aiContainer.js +53 -4
package/dist/ai/aiContainer.js
CHANGED
|
@@ -3,6 +3,7 @@ import { ChatGoogleGenerativeAI } from "@langchain/google-genai";
|
|
|
3
3
|
import { Ollama } from "@langchain/ollama";
|
|
4
4
|
import { ChatOpenAI } from '@langchain/openai';
|
|
5
5
|
import { HumanMessage, SystemMessage } from '@langchain/core/messages';
|
|
6
|
+
import { OllamaEmbeddings } from "@langchain/ollama";
|
|
6
7
|
|
|
7
8
|
class aiContainer extends HTMLElement
|
|
8
9
|
{
|
|
@@ -139,6 +140,8 @@ class aiContainer extends HTMLElement
|
|
|
139
140
|
new HumanMessage(prompt),
|
|
140
141
|
]);
|
|
141
142
|
|
|
143
|
+
console.log(response);
|
|
144
|
+
|
|
142
145
|
let filterString = response.content.trim();
|
|
143
146
|
if (filterString.startsWith("```json")) {
|
|
144
147
|
filterString = filterString.replace("```json", "");
|
|
@@ -150,7 +153,7 @@ class aiContainer extends HTMLElement
|
|
|
150
153
|
}
|
|
151
154
|
//filterString = filterString.replaceAll('"value"', '"text"')
|
|
152
155
|
console.log("Generated Filter String:", filterString);
|
|
153
|
-
|
|
156
|
+
|
|
154
157
|
// Gemini가 JSON 모드나 Structured Output을 지원하지 않는 경우, 직접 파싱 시도
|
|
155
158
|
// 안정적인 JSON 파싱을 위해 'JSON Mode' 또는 Function Calling 사용을 강력히 권장
|
|
156
159
|
// LangChain의 SelfQueryRetriever를 사용하면 이 부분을 자동화할 수 있습니다.
|
|
@@ -169,16 +172,62 @@ filterString = "a" + filterString;
|
|
|
169
172
|
//}
|
|
170
173
|
}
|
|
171
174
|
|
|
175
|
+
#searchWithQdrantFilter = async (filter) => {
|
|
176
|
+
|
|
177
|
+
const queryText = this.shadowRoot.querySelector("textarea").value.trim();
|
|
178
|
+
const collectionName = this.#target.collectionName;
|
|
179
|
+
|
|
180
|
+
//try {
|
|
181
|
+
// 쿼리 텍스트를 임베딩으로 변환 (Gemini Embedding 모델 사용)
|
|
182
|
+
// LangChain의 Embeddings 클래스 또는 @google/generative-ai SDK 직접 사용 가능
|
|
183
|
+
// 여기서는 예시를 위해 임시로 더미 벡터를 사용합니다.
|
|
184
|
+
// 실제로는 GoogleGenerativeAI.embedContent 등을 사용해야 합니다.
|
|
185
|
+
// const genAI = new GoogleGenerativeAI(GEMINI_API_KEY);
|
|
186
|
+
// const embeddingModel = genAI.get GenerativeModel({ model: "embedding-001" });
|
|
187
|
+
// const { embedding } = await embeddingModel.embedContent({
|
|
188
|
+
// content: queryText,
|
|
189
|
+
// taskType: "retrieval_query",
|
|
190
|
+
// });
|
|
191
|
+
//const queryVector = [0.1, 0.2, 0.3, 0.4, ...Array(764).fill(0)]; // 실제 임베딩 벡터로 대체
|
|
192
|
+
const embeddings = new OllamaEmbeddings({ model: "nomic-embed-text" });
|
|
193
|
+
const queryVector = await embeddings.embedQuery(queryText);
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
console.log(collectionName, filter);
|
|
197
|
+
|
|
198
|
+
const searchParams = {
|
|
199
|
+
vector: queryVector,
|
|
200
|
+
limit: 500, // 검색 결과 수
|
|
201
|
+
filter: filter, // Gemini가 생성한 필터 적용
|
|
202
|
+
with_payload: true, // 페이로드도 함께 가져오도록 설정
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
//console.log("Qdrant Search Params:", JSON.stringify(searchParams, null, 2));
|
|
206
|
+
|
|
207
|
+
return await qdrantClient.search(collectionName, searchParams);
|
|
208
|
+
|
|
209
|
+
//} catch (error) {
|
|
210
|
+
// console.error("Error during Qdrant search:", error);
|
|
211
|
+
return [];
|
|
212
|
+
//}
|
|
213
|
+
}
|
|
214
|
+
|
|
172
215
|
#q1 = async () => {
|
|
173
|
-
await this.#generateQdrantFilter();
|
|
216
|
+
const filter = await this.#generateQdrantFilter();
|
|
217
|
+
const d = await this.#searchWithQdrantFilter(filter);
|
|
218
|
+
console.log(d);
|
|
174
219
|
};
|
|
175
220
|
|
|
176
221
|
#q2 = async () => {
|
|
177
|
-
await this.#generateQdrantFilter();
|
|
222
|
+
const filter = await this.#generateQdrantFilter();
|
|
223
|
+
const d = await this.#searchWithQdrantFilter(filter);
|
|
224
|
+
console.log(d);
|
|
178
225
|
};
|
|
179
226
|
|
|
180
227
|
#q3 = async () => {
|
|
181
|
-
await this.#generateQdrantFilter();
|
|
228
|
+
const filter = await this.#generateQdrantFilter();
|
|
229
|
+
const d = await this.#searchWithQdrantFilter(filter);
|
|
230
|
+
console.log(d);
|
|
182
231
|
};
|
|
183
232
|
|
|
184
233
|
#init = (info) => {
|
package/dist/bundle.cjs.js
CHANGED
|
@@ -27993,6 +27993,8 @@ class aiContainer extends HTMLElement
|
|
|
27993
27993
|
new messages.HumanMessage(prompt),
|
|
27994
27994
|
]);
|
|
27995
27995
|
|
|
27996
|
+
console.log(response);
|
|
27997
|
+
|
|
27996
27998
|
let filterString = response.content.trim();
|
|
27997
27999
|
if (filterString.startsWith("```json")) {
|
|
27998
28000
|
filterString = filterString.replace("```json", "");
|
|
@@ -28004,7 +28006,7 @@ class aiContainer extends HTMLElement
|
|
|
28004
28006
|
}
|
|
28005
28007
|
//filterString = filterString.replaceAll('"value"', '"text"')
|
|
28006
28008
|
console.log("Generated Filter String:", filterString);
|
|
28007
|
-
|
|
28009
|
+
|
|
28008
28010
|
// Gemini가 JSON 모드나 Structured Output을 지원하지 않는 경우, 직접 파싱 시도
|
|
28009
28011
|
// 안정적인 JSON 파싱을 위해 'JSON Mode' 또는 Function Calling 사용을 강력히 권장
|
|
28010
28012
|
// LangChain의 SelfQueryRetriever를 사용하면 이 부분을 자동화할 수 있습니다.
|
|
@@ -28023,16 +28025,58 @@ filterString = "a" + filterString;
|
|
|
28023
28025
|
//}
|
|
28024
28026
|
}
|
|
28025
28027
|
|
|
28028
|
+
#searchWithQdrantFilter = async (filter) => {
|
|
28029
|
+
|
|
28030
|
+
const queryText = this.shadowRoot.querySelector("textarea").value.trim();
|
|
28031
|
+
const collectionName = this.#target.collectionName;
|
|
28032
|
+
|
|
28033
|
+
//try {
|
|
28034
|
+
// 쿼리 텍스트를 임베딩으로 변환 (Gemini Embedding 모델 사용)
|
|
28035
|
+
// LangChain의 Embeddings 클래스 또는 @google/generative-ai SDK 직접 사용 가능
|
|
28036
|
+
// 여기서는 예시를 위해 임시로 더미 벡터를 사용합니다.
|
|
28037
|
+
// 실제로는 GoogleGenerativeAI.embedContent 등을 사용해야 합니다.
|
|
28038
|
+
// const genAI = new GoogleGenerativeAI(GEMINI_API_KEY);
|
|
28039
|
+
// const embeddingModel = genAI.get GenerativeModel({ model: "embedding-001" });
|
|
28040
|
+
// const { embedding } = await embeddingModel.embedContent({
|
|
28041
|
+
// content: queryText,
|
|
28042
|
+
// taskType: "retrieval_query",
|
|
28043
|
+
// });
|
|
28044
|
+
//const queryVector = [0.1, 0.2, 0.3, 0.4, ...Array(764).fill(0)]; // 실제 임베딩 벡터로 대체
|
|
28045
|
+
const embeddings = new ollama.OllamaEmbeddings({ model: "nomic-embed-text" });
|
|
28046
|
+
const queryVector = await embeddings.embedQuery(queryText);
|
|
28047
|
+
|
|
28048
|
+
|
|
28049
|
+
console.log(collectionName, filter);
|
|
28050
|
+
|
|
28051
|
+
const searchParams = {
|
|
28052
|
+
vector: queryVector,
|
|
28053
|
+
limit: 500, // 검색 결과 수
|
|
28054
|
+
filter: filter, // Gemini가 생성한 필터 적용
|
|
28055
|
+
with_payload: true, // 페이로드도 함께 가져오도록 설정
|
|
28056
|
+
};
|
|
28057
|
+
|
|
28058
|
+
//console.log("Qdrant Search Params:", JSON.stringify(searchParams, null, 2));
|
|
28059
|
+
|
|
28060
|
+
return await qdrantClient.search(collectionName, searchParams);
|
|
28061
|
+
//}
|
|
28062
|
+
}
|
|
28063
|
+
|
|
28026
28064
|
#q1 = async () => {
|
|
28027
|
-
await this.#generateQdrantFilter();
|
|
28065
|
+
const filter = await this.#generateQdrantFilter();
|
|
28066
|
+
const d = await this.#searchWithQdrantFilter(filter);
|
|
28067
|
+
console.log(d);
|
|
28028
28068
|
};
|
|
28029
28069
|
|
|
28030
28070
|
#q2 = async () => {
|
|
28031
|
-
await this.#generateQdrantFilter();
|
|
28071
|
+
const filter = await this.#generateQdrantFilter();
|
|
28072
|
+
const d = await this.#searchWithQdrantFilter(filter);
|
|
28073
|
+
console.log(d);
|
|
28032
28074
|
};
|
|
28033
28075
|
|
|
28034
28076
|
#q3 = async () => {
|
|
28035
|
-
await this.#generateQdrantFilter();
|
|
28077
|
+
const filter = await this.#generateQdrantFilter();
|
|
28078
|
+
const d = await this.#searchWithQdrantFilter(filter);
|
|
28079
|
+
console.log(d);
|
|
28036
28080
|
};
|
|
28037
28081
|
|
|
28038
28082
|
#init = (info) => {
|
package/dist/bundle.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import ExcelJS$1 from 'exceljs';
|
|
2
2
|
import { ChatGoogleGenerativeAI } from '@langchain/google-genai';
|
|
3
|
-
import { Ollama } from '@langchain/ollama';
|
|
3
|
+
import { Ollama, OllamaEmbeddings } from '@langchain/ollama';
|
|
4
4
|
import { ChatOpenAI } from '@langchain/openai';
|
|
5
5
|
import { SystemMessage, HumanMessage } from '@langchain/core/messages';
|
|
6
6
|
|
|
@@ -27991,6 +27991,8 @@ class aiContainer extends HTMLElement
|
|
|
27991
27991
|
new HumanMessage(prompt),
|
|
27992
27992
|
]);
|
|
27993
27993
|
|
|
27994
|
+
console.log(response);
|
|
27995
|
+
|
|
27994
27996
|
let filterString = response.content.trim();
|
|
27995
27997
|
if (filterString.startsWith("```json")) {
|
|
27996
27998
|
filterString = filterString.replace("```json", "");
|
|
@@ -28002,7 +28004,7 @@ class aiContainer extends HTMLElement
|
|
|
28002
28004
|
}
|
|
28003
28005
|
//filterString = filterString.replaceAll('"value"', '"text"')
|
|
28004
28006
|
console.log("Generated Filter String:", filterString);
|
|
28005
|
-
|
|
28007
|
+
|
|
28006
28008
|
// Gemini가 JSON 모드나 Structured Output을 지원하지 않는 경우, 직접 파싱 시도
|
|
28007
28009
|
// 안정적인 JSON 파싱을 위해 'JSON Mode' 또는 Function Calling 사용을 강력히 권장
|
|
28008
28010
|
// LangChain의 SelfQueryRetriever를 사용하면 이 부분을 자동화할 수 있습니다.
|
|
@@ -28021,16 +28023,58 @@ filterString = "a" + filterString;
|
|
|
28021
28023
|
//}
|
|
28022
28024
|
}
|
|
28023
28025
|
|
|
28026
|
+
#searchWithQdrantFilter = async (filter) => {
|
|
28027
|
+
|
|
28028
|
+
const queryText = this.shadowRoot.querySelector("textarea").value.trim();
|
|
28029
|
+
const collectionName = this.#target.collectionName;
|
|
28030
|
+
|
|
28031
|
+
//try {
|
|
28032
|
+
// 쿼리 텍스트를 임베딩으로 변환 (Gemini Embedding 모델 사용)
|
|
28033
|
+
// LangChain의 Embeddings 클래스 또는 @google/generative-ai SDK 직접 사용 가능
|
|
28034
|
+
// 여기서는 예시를 위해 임시로 더미 벡터를 사용합니다.
|
|
28035
|
+
// 실제로는 GoogleGenerativeAI.embedContent 등을 사용해야 합니다.
|
|
28036
|
+
// const genAI = new GoogleGenerativeAI(GEMINI_API_KEY);
|
|
28037
|
+
// const embeddingModel = genAI.get GenerativeModel({ model: "embedding-001" });
|
|
28038
|
+
// const { embedding } = await embeddingModel.embedContent({
|
|
28039
|
+
// content: queryText,
|
|
28040
|
+
// taskType: "retrieval_query",
|
|
28041
|
+
// });
|
|
28042
|
+
//const queryVector = [0.1, 0.2, 0.3, 0.4, ...Array(764).fill(0)]; // 실제 임베딩 벡터로 대체
|
|
28043
|
+
const embeddings = new OllamaEmbeddings({ model: "nomic-embed-text" });
|
|
28044
|
+
const queryVector = await embeddings.embedQuery(queryText);
|
|
28045
|
+
|
|
28046
|
+
|
|
28047
|
+
console.log(collectionName, filter);
|
|
28048
|
+
|
|
28049
|
+
const searchParams = {
|
|
28050
|
+
vector: queryVector,
|
|
28051
|
+
limit: 500, // 검색 결과 수
|
|
28052
|
+
filter: filter, // Gemini가 생성한 필터 적용
|
|
28053
|
+
with_payload: true, // 페이로드도 함께 가져오도록 설정
|
|
28054
|
+
};
|
|
28055
|
+
|
|
28056
|
+
//console.log("Qdrant Search Params:", JSON.stringify(searchParams, null, 2));
|
|
28057
|
+
|
|
28058
|
+
return await qdrantClient.search(collectionName, searchParams);
|
|
28059
|
+
//}
|
|
28060
|
+
}
|
|
28061
|
+
|
|
28024
28062
|
#q1 = async () => {
|
|
28025
|
-
await this.#generateQdrantFilter();
|
|
28063
|
+
const filter = await this.#generateQdrantFilter();
|
|
28064
|
+
const d = await this.#searchWithQdrantFilter(filter);
|
|
28065
|
+
console.log(d);
|
|
28026
28066
|
};
|
|
28027
28067
|
|
|
28028
28068
|
#q2 = async () => {
|
|
28029
|
-
await this.#generateQdrantFilter();
|
|
28069
|
+
const filter = await this.#generateQdrantFilter();
|
|
28070
|
+
const d = await this.#searchWithQdrantFilter(filter);
|
|
28071
|
+
console.log(d);
|
|
28030
28072
|
};
|
|
28031
28073
|
|
|
28032
28074
|
#q3 = async () => {
|
|
28033
|
-
await this.#generateQdrantFilter();
|
|
28075
|
+
const filter = await this.#generateQdrantFilter();
|
|
28076
|
+
const d = await this.#searchWithQdrantFilter(filter);
|
|
28077
|
+
console.log(d);
|
|
28034
28078
|
};
|
|
28035
28079
|
|
|
28036
28080
|
#init = (info) => {
|
package/package.json
CHANGED
package/src/ai/aiContainer.js
CHANGED
|
@@ -3,6 +3,7 @@ import { ChatGoogleGenerativeAI } from "@langchain/google-genai";
|
|
|
3
3
|
import { Ollama } from "@langchain/ollama";
|
|
4
4
|
import { ChatOpenAI } from '@langchain/openai';
|
|
5
5
|
import { HumanMessage, SystemMessage } from '@langchain/core/messages';
|
|
6
|
+
import { OllamaEmbeddings } from "@langchain/ollama";
|
|
6
7
|
|
|
7
8
|
class aiContainer extends HTMLElement
|
|
8
9
|
{
|
|
@@ -139,6 +140,8 @@ class aiContainer extends HTMLElement
|
|
|
139
140
|
new HumanMessage(prompt),
|
|
140
141
|
]);
|
|
141
142
|
|
|
143
|
+
console.log(response);
|
|
144
|
+
|
|
142
145
|
let filterString = response.content.trim();
|
|
143
146
|
if (filterString.startsWith("```json")) {
|
|
144
147
|
filterString = filterString.replace("```json", "");
|
|
@@ -150,7 +153,7 @@ class aiContainer extends HTMLElement
|
|
|
150
153
|
}
|
|
151
154
|
//filterString = filterString.replaceAll('"value"', '"text"')
|
|
152
155
|
console.log("Generated Filter String:", filterString);
|
|
153
|
-
|
|
156
|
+
|
|
154
157
|
// Gemini가 JSON 모드나 Structured Output을 지원하지 않는 경우, 직접 파싱 시도
|
|
155
158
|
// 안정적인 JSON 파싱을 위해 'JSON Mode' 또는 Function Calling 사용을 강력히 권장
|
|
156
159
|
// LangChain의 SelfQueryRetriever를 사용하면 이 부분을 자동화할 수 있습니다.
|
|
@@ -169,16 +172,62 @@ filterString = "a" + filterString;
|
|
|
169
172
|
//}
|
|
170
173
|
}
|
|
171
174
|
|
|
175
|
+
#searchWithQdrantFilter = async (filter) => {
|
|
176
|
+
|
|
177
|
+
const queryText = this.shadowRoot.querySelector("textarea").value.trim();
|
|
178
|
+
const collectionName = this.#target.collectionName;
|
|
179
|
+
|
|
180
|
+
//try {
|
|
181
|
+
// 쿼리 텍스트를 임베딩으로 변환 (Gemini Embedding 모델 사용)
|
|
182
|
+
// LangChain의 Embeddings 클래스 또는 @google/generative-ai SDK 직접 사용 가능
|
|
183
|
+
// 여기서는 예시를 위해 임시로 더미 벡터를 사용합니다.
|
|
184
|
+
// 실제로는 GoogleGenerativeAI.embedContent 등을 사용해야 합니다.
|
|
185
|
+
// const genAI = new GoogleGenerativeAI(GEMINI_API_KEY);
|
|
186
|
+
// const embeddingModel = genAI.get GenerativeModel({ model: "embedding-001" });
|
|
187
|
+
// const { embedding } = await embeddingModel.embedContent({
|
|
188
|
+
// content: queryText,
|
|
189
|
+
// taskType: "retrieval_query",
|
|
190
|
+
// });
|
|
191
|
+
//const queryVector = [0.1, 0.2, 0.3, 0.4, ...Array(764).fill(0)]; // 실제 임베딩 벡터로 대체
|
|
192
|
+
const embeddings = new OllamaEmbeddings({ model: "nomic-embed-text" });
|
|
193
|
+
const queryVector = await embeddings.embedQuery(queryText);
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
console.log(collectionName, filter);
|
|
197
|
+
|
|
198
|
+
const searchParams = {
|
|
199
|
+
vector: queryVector,
|
|
200
|
+
limit: 500, // 검색 결과 수
|
|
201
|
+
filter: filter, // Gemini가 생성한 필터 적용
|
|
202
|
+
with_payload: true, // 페이로드도 함께 가져오도록 설정
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
//console.log("Qdrant Search Params:", JSON.stringify(searchParams, null, 2));
|
|
206
|
+
|
|
207
|
+
return await qdrantClient.search(collectionName, searchParams);
|
|
208
|
+
|
|
209
|
+
//} catch (error) {
|
|
210
|
+
// console.error("Error during Qdrant search:", error);
|
|
211
|
+
return [];
|
|
212
|
+
//}
|
|
213
|
+
}
|
|
214
|
+
|
|
172
215
|
#q1 = async () => {
|
|
173
|
-
await this.#generateQdrantFilter();
|
|
216
|
+
const filter = await this.#generateQdrantFilter();
|
|
217
|
+
const d = await this.#searchWithQdrantFilter(filter);
|
|
218
|
+
console.log(d);
|
|
174
219
|
};
|
|
175
220
|
|
|
176
221
|
#q2 = async () => {
|
|
177
|
-
await this.#generateQdrantFilter();
|
|
222
|
+
const filter = await this.#generateQdrantFilter();
|
|
223
|
+
const d = await this.#searchWithQdrantFilter(filter);
|
|
224
|
+
console.log(d);
|
|
178
225
|
};
|
|
179
226
|
|
|
180
227
|
#q3 = async () => {
|
|
181
|
-
await this.#generateQdrantFilter();
|
|
228
|
+
const filter = await this.#generateQdrantFilter();
|
|
229
|
+
const d = await this.#searchWithQdrantFilter(filter);
|
|
230
|
+
console.log(d);
|
|
182
231
|
};
|
|
183
232
|
|
|
184
233
|
#init = (info) => {
|