ide-assi 0.60.0 → 0.62.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.
@@ -29,6 +29,7 @@ var require$$4$2 = require('async_hooks');
29
29
  var require$$1$3 = require('console');
30
30
  var require$$1$4 = require('url');
31
31
  var require$$0$e = require('diagnostics_channel');
32
+ var fs = require('fs/promises');
32
33
 
33
34
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
34
35
 
@@ -193257,10 +193258,36 @@ window.jQuery = window.$ = $$1;
193257
193258
 
193258
193259
  //export default new ninegrid();
193259
193260
 
193261
+ class IdeAiPrompt
193262
+ {
193263
+ constructor() {
193264
+ }
193265
+
193266
+ static getDevelopActionClassification = async (userPrompt) => {
193267
+
193268
+ const template = await fs.readFile('prompts/meta/개발액션분류.txt', 'utf-8');
193269
+
193270
+ const prompt = new PromptTemplate({
193271
+ template,
193272
+ inputVariables: ['userPrompt'],
193273
+ });
193274
+
193275
+ console.log(prompt);
193276
+
193277
+ const formattedPrompt = await prompt.format({
193278
+ userPrompt: userPrompt,
193279
+ });
193280
+
193281
+ return formattedPrompt;
193282
+
193283
+ };
193284
+ }
193285
+
193260
193286
  class IdeAi
193261
193287
  {
193262
193288
  #API_URL = "http://localhost:8091";
193263
193289
  #SCHEMA = "booxtory_250131";
193290
+ #model;
193264
193291
 
193265
193292
  constructor() {
193266
193293
  }
@@ -193401,6 +193428,36 @@ class IdeAi
193401
193428
 
193402
193429
  return null;
193403
193430
  };
193431
+
193432
+ generateSourceClient = async (userPrompt) => {
193433
+
193434
+ const a = await IdeAiPrompt.getDevelopActionClassification(userPrompt);
193435
+
193436
+ console.log(a);
193437
+
193438
+ return;
193439
+
193440
+ /**
193441
+ let filterString;
193442
+ switch (this.settings.server) {
193443
+ case "openai":
193444
+ filterString = this.#extractJsonSnippet(response.content.trim());
193445
+ break;
193446
+ case "gemini":
193447
+ filterString = this.#extractJsonSnippet(response.content.trim());
193448
+ break;
193449
+ case "ollama":
193450
+ filterString = this.#extractJsonSnippet(response);
193451
+ break;
193452
+ default:
193453
+ break;
193454
+ }
193455
+
193456
+ //console.log(filterString);
193457
+
193458
+ return JSON.parse(filterString);
193459
+ */
193460
+ }
193404
193461
  }
193405
193462
 
193406
193463
  class IdeAssi extends HTMLElement
@@ -193496,8 +193553,8 @@ class IdeAssi extends HTMLElement
193496
193553
 
193497
193554
  e.preventDefault();
193498
193555
 
193499
- const question = e.target.value.trim();
193500
- if (!question) return;
193556
+ const userPrompt = e.target.value.trim();
193557
+ if (!userPrompt) return;
193501
193558
 
193502
193559
  if (this.#ing) return;
193503
193560
  this.#ing = true;
@@ -193512,15 +193569,19 @@ class IdeAssi extends HTMLElement
193512
193569
 
193513
193570
  const elAiChat = this.shadowRoot.querySelector("nx-ai-chat");
193514
193571
 
193515
- elAiChat.add("me", question);
193572
+ elAiChat.add("me", userPrompt);
193516
193573
  elAiChat.add("ing", "...");
193517
193574
 
193518
193575
  try {
193519
193576
  this.#createModel();
193520
193577
 
193521
- const r = await this.#ai.generateSource(question);
193578
+ const r = await this.#ai.generateSourceClient(userPrompt);
193579
+
193580
+ /**
193581
+ const r = await this.#ai.generateSource(userPrompt);
193522
193582
  console.log(r);
193523
193583
  elAiChat.add("ai", r);
193584
+ */
193524
193585
  } catch (error) {
193525
193586
  console.error(error);
193526
193587
  elAiChat.add("ai", error);
@@ -25,6 +25,7 @@ import require$$4$2 from 'async_hooks';
25
25
  import require$$1$3 from 'console';
26
26
  import require$$1$4 from 'url';
27
27
  import require$$0$e from 'diagnostics_channel';
28
+ import fs from 'fs/promises';
28
29
 
29
30
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
30
31
 
@@ -193253,10 +193254,36 @@ window.jQuery = window.$ = $$1;
193253
193254
 
193254
193255
  //export default new ninegrid();
193255
193256
 
193257
+ class IdeAiPrompt
193258
+ {
193259
+ constructor() {
193260
+ }
193261
+
193262
+ static getDevelopActionClassification = async (userPrompt) => {
193263
+
193264
+ const template = await fs.readFile('prompts/meta/개발액션분류.txt', 'utf-8');
193265
+
193266
+ const prompt = new PromptTemplate({
193267
+ template,
193268
+ inputVariables: ['userPrompt'],
193269
+ });
193270
+
193271
+ console.log(prompt);
193272
+
193273
+ const formattedPrompt = await prompt.format({
193274
+ userPrompt: userPrompt,
193275
+ });
193276
+
193277
+ return formattedPrompt;
193278
+
193279
+ };
193280
+ }
193281
+
193256
193282
  class IdeAi
193257
193283
  {
193258
193284
  #API_URL = "http://localhost:8091";
193259
193285
  #SCHEMA = "booxtory_250131";
193286
+ #model;
193260
193287
 
193261
193288
  constructor() {
193262
193289
  }
@@ -193397,6 +193424,36 @@ class IdeAi
193397
193424
 
193398
193425
  return null;
193399
193426
  };
193427
+
193428
+ generateSourceClient = async (userPrompt) => {
193429
+
193430
+ const a = await IdeAiPrompt.getDevelopActionClassification(userPrompt);
193431
+
193432
+ console.log(a);
193433
+
193434
+ return;
193435
+
193436
+ /**
193437
+ let filterString;
193438
+ switch (this.settings.server) {
193439
+ case "openai":
193440
+ filterString = this.#extractJsonSnippet(response.content.trim());
193441
+ break;
193442
+ case "gemini":
193443
+ filterString = this.#extractJsonSnippet(response.content.trim());
193444
+ break;
193445
+ case "ollama":
193446
+ filterString = this.#extractJsonSnippet(response);
193447
+ break;
193448
+ default:
193449
+ break;
193450
+ }
193451
+
193452
+ //console.log(filterString);
193453
+
193454
+ return JSON.parse(filterString);
193455
+ */
193456
+ }
193400
193457
  }
193401
193458
 
193402
193459
  class IdeAssi extends HTMLElement
@@ -193492,8 +193549,8 @@ class IdeAssi extends HTMLElement
193492
193549
 
193493
193550
  e.preventDefault();
193494
193551
 
193495
- const question = e.target.value.trim();
193496
- if (!question) return;
193552
+ const userPrompt = e.target.value.trim();
193553
+ if (!userPrompt) return;
193497
193554
 
193498
193555
  if (this.#ing) return;
193499
193556
  this.#ing = true;
@@ -193508,15 +193565,19 @@ class IdeAssi extends HTMLElement
193508
193565
 
193509
193566
  const elAiChat = this.shadowRoot.querySelector("nx-ai-chat");
193510
193567
 
193511
- elAiChat.add("me", question);
193568
+ elAiChat.add("me", userPrompt);
193512
193569
  elAiChat.add("ing", "...");
193513
193570
 
193514
193571
  try {
193515
193572
  this.#createModel();
193516
193573
 
193517
- const r = await this.#ai.generateSource(question);
193574
+ const r = await this.#ai.generateSourceClient(userPrompt);
193575
+
193576
+ /**
193577
+ const r = await this.#ai.generateSource(userPrompt);
193518
193578
  console.log(r);
193519
193579
  elAiChat.add("ai", r);
193580
+ */
193520
193581
  } catch (error) {
193521
193582
  console.error(error);
193522
193583
  elAiChat.add("ai", error);
@@ -1,9 +1,11 @@
1
1
  import ninegrid from "ninegrid2";
2
+ import {IdeAiPrompt} from "./ideAiPrompt.js";
2
3
 
3
4
  export class IdeAi
4
5
  {
5
6
  #API_URL = "http://localhost:8091";
6
7
  #SCHEMA = "booxtory_250131";
8
+ #model;
7
9
 
8
10
  constructor() {
9
11
  }
@@ -144,5 +146,75 @@ export class IdeAi
144
146
 
145
147
  return null;
146
148
  };
149
+
150
+ generateSourceClient = async (userPrompt) => {
151
+
152
+ const a = await IdeAiPrompt.getDevelopActionClassification(userPrompt);
153
+
154
+ console.log(a);
155
+
156
+ return;
157
+
158
+
159
+ const systemMessage = "You are a helpful assistant.";
160
+ const prompt = `
161
+ 자연어 쿼리를 Qdrant 필터 JSON 객체로 변환하는 AI 비서입니다.
162
+
163
+ Qdrant 컬렉션에서 사용 가능한 메타데이터 필드와 유형은 다음과 같습니다.:
164
+ ${this.#getColumnInfoString()}
165
+
166
+ 필터 생성 규칙:
167
+ 1. 위에 제공된 필드만 사용하십시오. 새로운 필드를 만들지 마십시오.
168
+ 2. 조건이 명확하게 지정되지 않았거나 모호한 경우 필터에 포함하지 마십시오.
169
+ 3. AND 조건에는 'must', OR 조건에는 'should', NOT 조건에는 'must_not'을 사용하십시오.
170
+ 4. 문자열 일치에는 'match.text'를 사용하십시오.
171
+ 5. 날짜 조건은 'YYYY-MM-DD' 형식으로 변형해서 사용하십시요. 오늘날짜는 ${this.#getToday()} 입니다.
172
+ 6. 숫자 범위에는 'range.gte', 'range.lte', 'range.gt', 'range.lt'를 사용하십시오.
173
+ 7. 특정 값을 포함하는 배열에는 'contains', 'match.any' 또는 'match.all'을 사용하십시오.
174
+ 8. 출력은 Qdrant 필터를 나타내는 유효한 JSON 객체여야 합니다.
175
+ 9. 적용 가능한 필터가 없는 경우 빈 JSON 객체인 {}를 반환합니다.
176
+
177
+ 예:
178
+ - "500달러 미만의 전자제품 찾기" -> {"must": [{"key": "category", "match": {"text": "electronics"}}, {"key": "price", "range": {"lt": 500}}]}
179
+ - "John Doe 또는 Jane Smith의 책 보기" -> {"should": [{"key": "author", "match": {"text": "John Doe"}}, {"key": "author", "match": {"text": "Jane Smith"}}]}
180
+ - "재고 있는 품목(의류 제외)" -> {"must": [{"key": "in_stock", "match": {"text": true}}], "must_not": [{"key": "category", "match": {"text": "clothing"}}]}
181
+ - "다음이 포함된 제품 'new_arrival' 태그" -> {"must": [{"key": "tags", "match": {"text": "new_arrival"}}]}
182
+ - "2020년 이후 출판된 도서" -> {"must": [{"key": "published_year", "range": {"gt": 2020}}]}
183
+
184
+ 이제 다음 사용자 쿼리를 변환해 보겠습니다.
185
+ 사용자 쿼리: "${userInput}"
186
+
187
+ Qdrant 필터 JSON:
188
+ `;
189
+
190
+
191
+ const response = await this.#model.invoke([
192
+ new SystemMessage(systemMessage),
193
+ new HumanMessage(prompt),
194
+ ]);
195
+
196
+ console.log(response);
197
+
198
+ /**
199
+ let filterString;
200
+ switch (this.settings.server) {
201
+ case "openai":
202
+ filterString = this.#extractJsonSnippet(response.content.trim());
203
+ break;
204
+ case "gemini":
205
+ filterString = this.#extractJsonSnippet(response.content.trim());
206
+ break;
207
+ case "ollama":
208
+ filterString = this.#extractJsonSnippet(response);
209
+ break;
210
+ default:
211
+ break;
212
+ }
213
+
214
+ //console.log(filterString);
215
+
216
+ return JSON.parse(filterString);
217
+ */
218
+ }
147
219
  }
148
220
 
@@ -0,0 +1,28 @@
1
+ import fs from 'fs/promises';
2
+ import { PromptTemplate } from '@langchain/core/prompts';
3
+
4
+ export class IdeAiPrompt
5
+ {
6
+ constructor() {
7
+ }
8
+
9
+ static getDevelopActionClassification = async (userPrompt) => {
10
+
11
+ const template = await fs.readFile('prompts/meta/개발액션분류.txt', 'utf-8');
12
+
13
+ const prompt = new PromptTemplate({
14
+ template,
15
+ inputVariables: ['userPrompt'],
16
+ });
17
+
18
+ console.log(prompt);
19
+
20
+ const formattedPrompt = await prompt.format({
21
+ userPrompt: userPrompt,
22
+ });
23
+
24
+ return formattedPrompt;
25
+
26
+ };
27
+ }
28
+
@@ -97,8 +97,8 @@ export class IdeAssi extends HTMLElement
97
97
 
98
98
  e.preventDefault();
99
99
 
100
- const question = e.target.value.trim();
101
- if (!question) return;
100
+ const userPrompt = e.target.value.trim();
101
+ if (!userPrompt) return;
102
102
 
103
103
  if (this.#ing) return;
104
104
  this.#ing = true;
@@ -113,15 +113,19 @@ export class IdeAssi extends HTMLElement
113
113
 
114
114
  const elAiChat = this.shadowRoot.querySelector("nx-ai-chat");
115
115
 
116
- elAiChat.add("me", question);
116
+ elAiChat.add("me", userPrompt);
117
117
  elAiChat.add("ing", "...");
118
118
 
119
119
  try {
120
120
  this.#createModel();
121
121
 
122
- const r = await this.#ai.generateSource(question);
122
+ const r = await this.#ai.generateSourceClient(userPrompt);
123
+
124
+ /**
125
+ const r = await this.#ai.generateSource(userPrompt);
123
126
  console.log(r);
124
127
  elAiChat.add("ai", r);
128
+ */
125
129
  } catch (error) {
126
130
  console.error(error);
127
131
  elAiChat.add("ai", error);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ide-assi",
3
3
  "type": "module",
4
- "version": "0.60.0",
4
+ "version": "0.62.0",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {
@@ -1,9 +1,11 @@
1
1
  import ninegrid from "ninegrid2";
2
+ import {IdeAiPrompt} from "./ideAiPrompt.js";
2
3
 
3
4
  export class IdeAi
4
5
  {
5
6
  #API_URL = "http://localhost:8091";
6
7
  #SCHEMA = "booxtory_250131";
8
+ #model;
7
9
 
8
10
  constructor() {
9
11
  }
@@ -144,5 +146,75 @@ export class IdeAi
144
146
 
145
147
  return null;
146
148
  };
149
+
150
+ generateSourceClient = async (userPrompt) => {
151
+
152
+ const a = await IdeAiPrompt.getDevelopActionClassification(userPrompt);
153
+
154
+ console.log(a);
155
+
156
+ return;
157
+
158
+
159
+ const systemMessage = "You are a helpful assistant.";
160
+ const prompt = `
161
+ 자연어 쿼리를 Qdrant 필터 JSON 객체로 변환하는 AI 비서입니다.
162
+
163
+ Qdrant 컬렉션에서 사용 가능한 메타데이터 필드와 유형은 다음과 같습니다.:
164
+ ${this.#getColumnInfoString()}
165
+
166
+ 필터 생성 규칙:
167
+ 1. 위에 제공된 필드만 사용하십시오. 새로운 필드를 만들지 마십시오.
168
+ 2. 조건이 명확하게 지정되지 않았거나 모호한 경우 필터에 포함하지 마십시오.
169
+ 3. AND 조건에는 'must', OR 조건에는 'should', NOT 조건에는 'must_not'을 사용하십시오.
170
+ 4. 문자열 일치에는 'match.text'를 사용하십시오.
171
+ 5. 날짜 조건은 'YYYY-MM-DD' 형식으로 변형해서 사용하십시요. 오늘날짜는 ${this.#getToday()} 입니다.
172
+ 6. 숫자 범위에는 'range.gte', 'range.lte', 'range.gt', 'range.lt'를 사용하십시오.
173
+ 7. 특정 값을 포함하는 배열에는 'contains', 'match.any' 또는 'match.all'을 사용하십시오.
174
+ 8. 출력은 Qdrant 필터를 나타내는 유효한 JSON 객체여야 합니다.
175
+ 9. 적용 가능한 필터가 없는 경우 빈 JSON 객체인 {}를 반환합니다.
176
+
177
+ 예:
178
+ - "500달러 미만의 전자제품 찾기" -> {"must": [{"key": "category", "match": {"text": "electronics"}}, {"key": "price", "range": {"lt": 500}}]}
179
+ - "John Doe 또는 Jane Smith의 책 보기" -> {"should": [{"key": "author", "match": {"text": "John Doe"}}, {"key": "author", "match": {"text": "Jane Smith"}}]}
180
+ - "재고 있는 품목(의류 제외)" -> {"must": [{"key": "in_stock", "match": {"text": true}}], "must_not": [{"key": "category", "match": {"text": "clothing"}}]}
181
+ - "다음이 포함된 제품 'new_arrival' 태그" -> {"must": [{"key": "tags", "match": {"text": "new_arrival"}}]}
182
+ - "2020년 이후 출판된 도서" -> {"must": [{"key": "published_year", "range": {"gt": 2020}}]}
183
+
184
+ 이제 다음 사용자 쿼리를 변환해 보겠습니다.
185
+ 사용자 쿼리: "${userInput}"
186
+
187
+ Qdrant 필터 JSON:
188
+ `;
189
+
190
+
191
+ const response = await this.#model.invoke([
192
+ new SystemMessage(systemMessage),
193
+ new HumanMessage(prompt),
194
+ ]);
195
+
196
+ console.log(response);
197
+
198
+ /**
199
+ let filterString;
200
+ switch (this.settings.server) {
201
+ case "openai":
202
+ filterString = this.#extractJsonSnippet(response.content.trim());
203
+ break;
204
+ case "gemini":
205
+ filterString = this.#extractJsonSnippet(response.content.trim());
206
+ break;
207
+ case "ollama":
208
+ filterString = this.#extractJsonSnippet(response);
209
+ break;
210
+ default:
211
+ break;
212
+ }
213
+
214
+ //console.log(filterString);
215
+
216
+ return JSON.parse(filterString);
217
+ */
218
+ }
147
219
  }
148
220
 
@@ -0,0 +1,28 @@
1
+ import fs from 'fs/promises';
2
+ import { PromptTemplate } from '@langchain/core/prompts';
3
+
4
+ export class IdeAiPrompt
5
+ {
6
+ constructor() {
7
+ }
8
+
9
+ static getDevelopActionClassification = async (userPrompt) => {
10
+
11
+ const template = await fs.readFile('prompts/meta/개발액션분류.txt', 'utf-8');
12
+
13
+ const prompt = new PromptTemplate({
14
+ template,
15
+ inputVariables: ['userPrompt'],
16
+ });
17
+
18
+ console.log(prompt);
19
+
20
+ const formattedPrompt = await prompt.format({
21
+ userPrompt: userPrompt,
22
+ });
23
+
24
+ return formattedPrompt;
25
+
26
+ };
27
+ }
28
+
@@ -97,8 +97,8 @@ export class IdeAssi extends HTMLElement
97
97
 
98
98
  e.preventDefault();
99
99
 
100
- const question = e.target.value.trim();
101
- if (!question) return;
100
+ const userPrompt = e.target.value.trim();
101
+ if (!userPrompt) return;
102
102
 
103
103
  if (this.#ing) return;
104
104
  this.#ing = true;
@@ -113,15 +113,19 @@ export class IdeAssi extends HTMLElement
113
113
 
114
114
  const elAiChat = this.shadowRoot.querySelector("nx-ai-chat");
115
115
 
116
- elAiChat.add("me", question);
116
+ elAiChat.add("me", userPrompt);
117
117
  elAiChat.add("ing", "...");
118
118
 
119
119
  try {
120
120
  this.#createModel();
121
121
 
122
- const r = await this.#ai.generateSource(question);
122
+ const r = await this.#ai.generateSourceClient(userPrompt);
123
+
124
+ /**
125
+ const r = await this.#ai.generateSource(userPrompt);
123
126
  console.log(r);
124
127
  elAiChat.add("ai", r);
128
+ */
125
129
  } catch (error) {
126
130
  console.error(error);
127
131
  elAiChat.add("ai", error);