ide-assi 0.59.0 → 0.61.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,6 +193258,31 @@ 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";
@@ -193401,6 +193427,36 @@ class IdeAi
193401
193427
 
193402
193428
  return null;
193403
193429
  };
193430
+
193431
+ generateSourceClient = async (userPrompt) => {
193432
+
193433
+ const a = await IdeAiPrompt.getDevelopActionClassification(userPrompt);
193434
+
193435
+ console.log(a);
193436
+
193437
+ return;
193438
+
193439
+ /**
193440
+ let filterString;
193441
+ switch (this.settings.server) {
193442
+ case "openai":
193443
+ filterString = this.#extractJsonSnippet(response.content.trim());
193444
+ break;
193445
+ case "gemini":
193446
+ filterString = this.#extractJsonSnippet(response.content.trim());
193447
+ break;
193448
+ case "ollama":
193449
+ filterString = this.#extractJsonSnippet(response);
193450
+ break;
193451
+ default:
193452
+ break;
193453
+ }
193454
+
193455
+ //console.log(filterString);
193456
+
193457
+ return JSON.parse(filterString);
193458
+ */
193459
+ }
193404
193460
  }
193405
193461
 
193406
193462
  class IdeAssi extends HTMLElement
@@ -193496,8 +193552,8 @@ class IdeAssi extends HTMLElement
193496
193552
 
193497
193553
  e.preventDefault();
193498
193554
 
193499
- const question = e.target.value.trim();
193500
- if (!question) return;
193555
+ const userPrompt = e.target.value.trim();
193556
+ if (!userPrompt) return;
193501
193557
 
193502
193558
  if (this.#ing) return;
193503
193559
  this.#ing = true;
@@ -193512,15 +193568,19 @@ class IdeAssi extends HTMLElement
193512
193568
 
193513
193569
  const elAiChat = this.shadowRoot.querySelector("nx-ai-chat");
193514
193570
 
193515
- elAiChat.add("me", question);
193571
+ elAiChat.add("me", userPrompt);
193516
193572
  elAiChat.add("ing", "...");
193517
193573
 
193518
193574
  try {
193519
193575
  this.#createModel();
193520
193576
 
193521
- const r = await this.#ai.generateSource(question);
193577
+ const r = await this.#ai.generateSourceClient(userPrompt);
193578
+
193579
+ /**
193580
+ const r = await this.#ai.generateSource(userPrompt);
193522
193581
  console.log(r);
193523
193582
  elAiChat.add("ai", r);
193583
+ */
193524
193584
  } catch (error) {
193525
193585
  console.error(error);
193526
193586
  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,6 +193254,31 @@ 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";
@@ -193397,6 +193423,36 @@ class IdeAi
193397
193423
 
193398
193424
  return null;
193399
193425
  };
193426
+
193427
+ generateSourceClient = async (userPrompt) => {
193428
+
193429
+ const a = await IdeAiPrompt.getDevelopActionClassification(userPrompt);
193430
+
193431
+ console.log(a);
193432
+
193433
+ return;
193434
+
193435
+ /**
193436
+ let filterString;
193437
+ switch (this.settings.server) {
193438
+ case "openai":
193439
+ filterString = this.#extractJsonSnippet(response.content.trim());
193440
+ break;
193441
+ case "gemini":
193442
+ filterString = this.#extractJsonSnippet(response.content.trim());
193443
+ break;
193444
+ case "ollama":
193445
+ filterString = this.#extractJsonSnippet(response);
193446
+ break;
193447
+ default:
193448
+ break;
193449
+ }
193450
+
193451
+ //console.log(filterString);
193452
+
193453
+ return JSON.parse(filterString);
193454
+ */
193455
+ }
193400
193456
  }
193401
193457
 
193402
193458
  class IdeAssi extends HTMLElement
@@ -193492,8 +193548,8 @@ class IdeAssi extends HTMLElement
193492
193548
 
193493
193549
  e.preventDefault();
193494
193550
 
193495
- const question = e.target.value.trim();
193496
- if (!question) return;
193551
+ const userPrompt = e.target.value.trim();
193552
+ if (!userPrompt) return;
193497
193553
 
193498
193554
  if (this.#ing) return;
193499
193555
  this.#ing = true;
@@ -193508,15 +193564,19 @@ class IdeAssi extends HTMLElement
193508
193564
 
193509
193565
  const elAiChat = this.shadowRoot.querySelector("nx-ai-chat");
193510
193566
 
193511
- elAiChat.add("me", question);
193567
+ elAiChat.add("me", userPrompt);
193512
193568
  elAiChat.add("ing", "...");
193513
193569
 
193514
193570
  try {
193515
193571
  this.#createModel();
193516
193572
 
193517
- const r = await this.#ai.generateSource(question);
193573
+ const r = await this.#ai.generateSourceClient(userPrompt);
193574
+
193575
+ /**
193576
+ const r = await this.#ai.generateSource(userPrompt);
193518
193577
  console.log(r);
193519
193578
  elAiChat.add("ai", r);
193579
+ */
193520
193580
  } catch (error) {
193521
193581
  console.error(error);
193522
193582
  elAiChat.add("ai", error);
@@ -1,4 +1,5 @@
1
1
  import ninegrid from "ninegrid2";
2
+ import {IdeAiPrompt} from "./ideAiPrompt.js";
2
3
 
3
4
  export class IdeAi
4
5
  {
@@ -144,5 +145,75 @@ export class IdeAi
144
145
 
145
146
  return null;
146
147
  };
148
+
149
+ generateSourceClient = async (userPrompt) => {
150
+
151
+ const a = await IdeAiPrompt.getDevelopActionClassification(userPrompt);
152
+
153
+ console.log(a);
154
+
155
+ return;
156
+
157
+
158
+ const systemMessage = "You are a helpful assistant.";
159
+ const prompt = `
160
+ 자연어 쿼리를 Qdrant 필터 JSON 객체로 변환하는 AI 비서입니다.
161
+
162
+ Qdrant 컬렉션에서 사용 가능한 메타데이터 필드와 유형은 다음과 같습니다.:
163
+ ${this.#getColumnInfoString()}
164
+
165
+ 필터 생성 규칙:
166
+ 1. 위에 제공된 필드만 사용하십시오. 새로운 필드를 만들지 마십시오.
167
+ 2. 조건이 명확하게 지정되지 않았거나 모호한 경우 필터에 포함하지 마십시오.
168
+ 3. AND 조건에는 'must', OR 조건에는 'should', NOT 조건에는 'must_not'을 사용하십시오.
169
+ 4. 문자열 일치에는 'match.text'를 사용하십시오.
170
+ 5. 날짜 조건은 'YYYY-MM-DD' 형식으로 변형해서 사용하십시요. 오늘날짜는 ${this.#getToday()} 입니다.
171
+ 6. 숫자 범위에는 'range.gte', 'range.lte', 'range.gt', 'range.lt'를 사용하십시오.
172
+ 7. 특정 값을 포함하는 배열에는 'contains', 'match.any' 또는 'match.all'을 사용하십시오.
173
+ 8. 출력은 Qdrant 필터를 나타내는 유효한 JSON 객체여야 합니다.
174
+ 9. 적용 가능한 필터가 없는 경우 빈 JSON 객체인 {}를 반환합니다.
175
+
176
+ 예:
177
+ - "500달러 미만의 전자제품 찾기" -> {"must": [{"key": "category", "match": {"text": "electronics"}}, {"key": "price", "range": {"lt": 500}}]}
178
+ - "John Doe 또는 Jane Smith의 책 보기" -> {"should": [{"key": "author", "match": {"text": "John Doe"}}, {"key": "author", "match": {"text": "Jane Smith"}}]}
179
+ - "재고 있는 품목(의류 제외)" -> {"must": [{"key": "in_stock", "match": {"text": true}}], "must_not": [{"key": "category", "match": {"text": "clothing"}}]}
180
+ - "다음이 포함된 제품 'new_arrival' 태그" -> {"must": [{"key": "tags", "match": {"text": "new_arrival"}}]}
181
+ - "2020년 이후 출판된 도서" -> {"must": [{"key": "published_year", "range": {"gt": 2020}}]}
182
+
183
+ 이제 다음 사용자 쿼리를 변환해 보겠습니다.
184
+ 사용자 쿼리: "${userInput}"
185
+
186
+ Qdrant 필터 JSON:
187
+ `;
188
+
189
+
190
+ const response = await this.#model.invoke([
191
+ new SystemMessage(systemMessage),
192
+ new HumanMessage(prompt),
193
+ ]);
194
+
195
+ console.log(response);
196
+
197
+ /**
198
+ let filterString;
199
+ switch (this.settings.server) {
200
+ case "openai":
201
+ filterString = this.#extractJsonSnippet(response.content.trim());
202
+ break;
203
+ case "gemini":
204
+ filterString = this.#extractJsonSnippet(response.content.trim());
205
+ break;
206
+ case "ollama":
207
+ filterString = this.#extractJsonSnippet(response);
208
+ break;
209
+ default:
210
+ break;
211
+ }
212
+
213
+ //console.log(filterString);
214
+
215
+ return JSON.parse(filterString);
216
+ */
217
+ }
147
218
  }
148
219
 
@@ -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.59.0",
4
+ "version": "0.61.0",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {
@@ -1,4 +1,5 @@
1
1
  import ninegrid from "ninegrid2";
2
+ import {IdeAiPrompt} from "./ideAiPrompt.js";
2
3
 
3
4
  export class IdeAi
4
5
  {
@@ -144,5 +145,75 @@ export class IdeAi
144
145
 
145
146
  return null;
146
147
  };
148
+
149
+ generateSourceClient = async (userPrompt) => {
150
+
151
+ const a = await IdeAiPrompt.getDevelopActionClassification(userPrompt);
152
+
153
+ console.log(a);
154
+
155
+ return;
156
+
157
+
158
+ const systemMessage = "You are a helpful assistant.";
159
+ const prompt = `
160
+ 자연어 쿼리를 Qdrant 필터 JSON 객체로 변환하는 AI 비서입니다.
161
+
162
+ Qdrant 컬렉션에서 사용 가능한 메타데이터 필드와 유형은 다음과 같습니다.:
163
+ ${this.#getColumnInfoString()}
164
+
165
+ 필터 생성 규칙:
166
+ 1. 위에 제공된 필드만 사용하십시오. 새로운 필드를 만들지 마십시오.
167
+ 2. 조건이 명확하게 지정되지 않았거나 모호한 경우 필터에 포함하지 마십시오.
168
+ 3. AND 조건에는 'must', OR 조건에는 'should', NOT 조건에는 'must_not'을 사용하십시오.
169
+ 4. 문자열 일치에는 'match.text'를 사용하십시오.
170
+ 5. 날짜 조건은 'YYYY-MM-DD' 형식으로 변형해서 사용하십시요. 오늘날짜는 ${this.#getToday()} 입니다.
171
+ 6. 숫자 범위에는 'range.gte', 'range.lte', 'range.gt', 'range.lt'를 사용하십시오.
172
+ 7. 특정 값을 포함하는 배열에는 'contains', 'match.any' 또는 'match.all'을 사용하십시오.
173
+ 8. 출력은 Qdrant 필터를 나타내는 유효한 JSON 객체여야 합니다.
174
+ 9. 적용 가능한 필터가 없는 경우 빈 JSON 객체인 {}를 반환합니다.
175
+
176
+ 예:
177
+ - "500달러 미만의 전자제품 찾기" -> {"must": [{"key": "category", "match": {"text": "electronics"}}, {"key": "price", "range": {"lt": 500}}]}
178
+ - "John Doe 또는 Jane Smith의 책 보기" -> {"should": [{"key": "author", "match": {"text": "John Doe"}}, {"key": "author", "match": {"text": "Jane Smith"}}]}
179
+ - "재고 있는 품목(의류 제외)" -> {"must": [{"key": "in_stock", "match": {"text": true}}], "must_not": [{"key": "category", "match": {"text": "clothing"}}]}
180
+ - "다음이 포함된 제품 'new_arrival' 태그" -> {"must": [{"key": "tags", "match": {"text": "new_arrival"}}]}
181
+ - "2020년 이후 출판된 도서" -> {"must": [{"key": "published_year", "range": {"gt": 2020}}]}
182
+
183
+ 이제 다음 사용자 쿼리를 변환해 보겠습니다.
184
+ 사용자 쿼리: "${userInput}"
185
+
186
+ Qdrant 필터 JSON:
187
+ `;
188
+
189
+
190
+ const response = await this.#model.invoke([
191
+ new SystemMessage(systemMessage),
192
+ new HumanMessage(prompt),
193
+ ]);
194
+
195
+ console.log(response);
196
+
197
+ /**
198
+ let filterString;
199
+ switch (this.settings.server) {
200
+ case "openai":
201
+ filterString = this.#extractJsonSnippet(response.content.trim());
202
+ break;
203
+ case "gemini":
204
+ filterString = this.#extractJsonSnippet(response.content.trim());
205
+ break;
206
+ case "ollama":
207
+ filterString = this.#extractJsonSnippet(response);
208
+ break;
209
+ default:
210
+ break;
211
+ }
212
+
213
+ //console.log(filterString);
214
+
215
+ return JSON.parse(filterString);
216
+ */
217
+ }
147
218
  }
148
219
 
@@ -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);