@cobrowser/chatgpt 0.7.32-dev.2 → 0.7.32-dev.4

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.
@@ -88,7 +88,9 @@ class BaseService {
88
88
  methodName.startsWith('handle') ||
89
89
  methodName.includes('Sanitize') ||
90
90
  methodName.includes('sanitize') ||
91
- methodName.includes('createConversation')) {
91
+ methodName.includes('createConversation') ||
92
+ methodName.includes('isAssistantIdFormat') ||
93
+ methodName.includes('isPromptIdFormat')) {
92
94
  continue;
93
95
  }
94
96
  const originalMethod = method.bind(this);
@@ -33,6 +33,5 @@ export declare class CopilotService extends BaseService {
33
33
  getAssistantSuggestions(conversation: string): Promise<ChatGPTResponse | undefined>;
34
34
  private isAssistantIdFormat;
35
35
  private isPromptIdFormat;
36
- private ensureConversation;
37
36
  getPromptSuggestions(message: string): Promise<ChatGPTResponse | undefined>;
38
37
  }
@@ -77,7 +77,7 @@ class CopilotService extends BaseService_1.default {
77
77
  return Promise.reject(new Error('last customer message not found'));
78
78
  }
79
79
  // Route based on id shape: asst_* => Assistant API, prompt_* => Responses API
80
- if (this.isAssistantIdFormat(this.assistantId)) {
80
+ if (yield this.isAssistantIdFormat(this.assistantId)) {
81
81
  return yield this.getAssistantSuggestions(conversation);
82
82
  }
83
83
  return yield this.getPromptSuggestions(lastCustomerMessage);
@@ -172,29 +172,23 @@ class CopilotService extends BaseService_1.default {
172
172
  isPromptIdFormat(id) {
173
173
  return !!id && /^pmpt_[A-Za-z0-9]+$/.test(id);
174
174
  }
175
- ensureConversation(openai) {
176
- return __awaiter(this, void 0, void 0, function* () {
177
- if (this.conversationId) {
178
- return this.conversationId;
179
- }
180
- const conv = yield openai.conversations.create();
181
- this.conversationId = conv.id;
182
- return conv.id;
183
- });
184
- }
185
175
  getPromptSuggestions(message) {
186
176
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
187
177
  return __awaiter(this, void 0, void 0, function* () {
188
178
  const openai = new openai_1.default({ apiKey: this.openaiApiKey });
189
- const conversationId = yield this.ensureConversation(openai);
179
+ let conversationId = this.conversationId;
180
+ if (!conversationId) {
181
+ const conv = yield openai.conversations.create();
182
+ conversationId = conv.id;
183
+ }
190
184
  const request = {
191
185
  //model: this.chatGptModel || 'gpt-4o-mini',
192
186
  input: message,
193
187
  store: true,
194
- conversation: conversationId,
188
+ conversation: { id: conversationId },
195
189
  include: ['file_search_call.results'],
196
190
  };
197
- if (this.assistantId && this.isPromptIdFormat(this.assistantId)) {
191
+ if (this.assistantId && (yield this.isPromptIdFormat(this.assistantId))) {
198
192
  request.prompt = { id: this.assistantId };
199
193
  }
200
194
  const response = yield openai.responses.create(request);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cobrowser/chatgpt",
3
- "version": "0.7.32-dev.2",
3
+ "version": "0.7.32-dev.4",
4
4
  "description": "chatgpt services to connect our projects with chatgpt api",
5
5
  "keywords": [
6
6
  "chatgpt",
@@ -40,5 +40,5 @@
40
40
  "bugs": {
41
41
  "url": "https://bitbucket.org/cobrowser/cb_utils/issues"
42
42
  },
43
- "gitHead": "599a71119dc7aadc13737d41bea48957b738dfa8"
43
+ "gitHead": "8dbd83dfdfcab960b0ed0cedc8a3e39a8254181b"
44
44
  }