draftify-cli 1.0.54 → 1.0.56

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.
Files changed (2) hide show
  1. package/dist/utils/api.js +12 -11
  2. package/package.json +2 -1
package/dist/utils/api.js CHANGED
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.refactorCodeApi = refactorCodeApi;
7
7
  exports.getUserProfile = getUserProfile;
8
8
  const config_1 = require("./config");
9
- const genai_1 = require("@google/genai");
9
+ const vertexai_1 = require("@google-cloud/vertexai");
10
10
  const dotenv_1 = __importDefault(require("dotenv"));
11
11
  dotenv_1.default.config();
12
12
  async function refactorCodeApi(fileName, code, instruction, history, modelName, skillsData, thinkingLevel, onChunk, abortSignal) {
@@ -14,7 +14,7 @@ async function refactorCodeApi(fileName, code, instruction, history, modelName,
14
14
  // 1. HELYI VÉGREHAJTÁS (Ha van GEMINI_API_KEY a .env-ben, közvetlenül a Geminit hívjuk)
15
15
  // Ez tökéletes a helyi teszteléshez, mielőtt a backendre (Vercel) kerül a kód.
16
16
  if (apiKey) {
17
- const ai = new genai_1.GoogleGenAI({ apiKey: apiKey });
17
+ const ai = new vertexai_1.VertexAI({ project: 'draftify-prod', location: 'us-central1' });
18
18
  // Modell kiválasztása a kívánt logika alapján
19
19
  let geminiModel = 'gemini-3.5-flash'; // Alapértelmezett (Medium, Low, Adaptive)
20
20
  if (thinkingLevel === 'High') {
@@ -160,23 +160,24 @@ Throughout, balance deep technical proficiency with an accessible, friendly, wel
160
160
  abortSignal.addEventListener("abort", onAbort);
161
161
  }
162
162
  try {
163
- const responseStream = await ai.models.generateContentStream({
163
+ const generativeModel = ai.getGenerativeModel({
164
164
  model: geminiModel,
165
- contents: contents,
166
- config: {
167
- systemInstruction: systemInstruction
168
- }
165
+ systemInstruction: { role: 'system', parts: [{ text: systemInstruction }] }
166
+ });
167
+ const responseStream = await generativeModel.generateContentStream({
168
+ contents: contents
169
169
  });
170
170
  let tempResult = "";
171
- for await (const chunk of responseStream) {
171
+ for await (const chunk of responseStream.stream) {
172
172
  if (abortSignal?.aborted) {
173
173
  reject(new Error("Aborted"));
174
174
  return;
175
175
  }
176
- if (chunk.text) {
177
- tempResult += chunk.text;
176
+ const text = chunk.candidates?.[0]?.content?.parts?.[0]?.text || "";
177
+ if (text) {
178
+ tempResult += text;
178
179
  if (onChunk)
179
- onChunk(chunk.text);
180
+ onChunk(text);
180
181
  }
181
182
  }
182
183
  resolve(tempResult);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "draftify-cli",
3
- "version": "1.0.54",
3
+ "version": "1.0.56",
4
4
  "description": "Draftify AI CLI tool",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -24,6 +24,7 @@
24
24
  "author": "",
25
25
  "license": "ISC",
26
26
  "dependencies": {
27
+ "@google-cloud/vertexai": "^1.12.0",
27
28
  "@google/genai": "^2.8.0",
28
29
  "ansi-escapes": "^7.3.0",
29
30
  "axios": "^1.7.2",