macrocosmos 1.2.21 → 1.2.23
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.
|
@@ -26,6 +26,12 @@ describe("ApexClient", () => {
|
|
|
26
26
|
maxNewTokens: 100,
|
|
27
27
|
doSample: true,
|
|
28
28
|
};
|
|
29
|
+
const createChatAndCompletionParams = {
|
|
30
|
+
userPrompt: "This is a test chat, how are you?",
|
|
31
|
+
chatType: "apex",
|
|
32
|
+
completionType: "basic",
|
|
33
|
+
title: "Test Chat",
|
|
34
|
+
};
|
|
29
35
|
let client;
|
|
30
36
|
beforeEach(() => {
|
|
31
37
|
client = new macrocosmos_1.ApexClient({
|
|
@@ -78,12 +84,7 @@ describe("ApexClient", () => {
|
|
|
78
84
|
}, 30000);
|
|
79
85
|
it("should append a chat completion", async () => {
|
|
80
86
|
// create a test chat
|
|
81
|
-
const create_chat_result = await client.createChatAndCompletion(
|
|
82
|
-
userPrompt: "This is a test chat, how are you?",
|
|
83
|
-
chatType: "apex",
|
|
84
|
-
completionType: "basic",
|
|
85
|
-
title: "Test Chat",
|
|
86
|
-
});
|
|
87
|
+
const create_chat_result = await client.createChatAndCompletion(createChatAndCompletionParams);
|
|
87
88
|
// Verify a chat id exists (i.e., a chat was created)
|
|
88
89
|
console.log("Create chat response:", create_chat_result);
|
|
89
90
|
expect(create_chat_result).toBeDefined();
|
|
@@ -114,12 +115,7 @@ describe("ApexClient", () => {
|
|
|
114
115
|
}, 30000);
|
|
115
116
|
it("should delete a chat", async () => {
|
|
116
117
|
// chat ID for testing
|
|
117
|
-
const create_chat_result = await client.createChatAndCompletion(
|
|
118
|
-
userPrompt: "This is a test chat, how are you?",
|
|
119
|
-
chatType: "apex",
|
|
120
|
-
completionType: "basic",
|
|
121
|
-
title: "Test Chat",
|
|
122
|
-
});
|
|
118
|
+
const create_chat_result = await client.createChatAndCompletion(createChatAndCompletionParams);
|
|
123
119
|
// Verify the response structure
|
|
124
120
|
console.log("Create chat response:", create_chat_result);
|
|
125
121
|
expect(create_chat_result).toBeDefined();
|
|
@@ -133,10 +129,34 @@ describe("ApexClient", () => {
|
|
|
133
129
|
// Verify the response structure
|
|
134
130
|
console.log("Stored chats:", get_chat_sessions_result);
|
|
135
131
|
expect(get_chat_sessions_result).toBeDefined();
|
|
136
|
-
//
|
|
132
|
+
// make sure the chat does not exist in the chats retrieved
|
|
137
133
|
expect(Array.isArray(get_chat_sessions_result.chatSessions)).toBe(true);
|
|
138
134
|
expect(get_chat_sessions_result.chatSessions.some(session => session.id === create_chat_result.parsedChat?.id)).toBe(false);
|
|
139
135
|
}, 30000);
|
|
136
|
+
it("should delete a completion", async () => {
|
|
137
|
+
// chat ID for testing
|
|
138
|
+
const create_completion_result = await client.createChatAndCompletion(createChatAndCompletionParams);
|
|
139
|
+
console.log("Create completion response:", create_completion_result);
|
|
140
|
+
expect(create_completion_result).toBeDefined();
|
|
141
|
+
// Delete test completion
|
|
142
|
+
const delete_completion_result = await client.deleteCompletions({
|
|
143
|
+
completionIds: [create_completion_result.parsedCompletion?.id ?? ""],
|
|
144
|
+
});
|
|
145
|
+
expect(delete_completion_result).toBeDefined();
|
|
146
|
+
expect(delete_completion_result.success).toBeTruthy();
|
|
147
|
+
const get_chat_completions_result = await client.getStoredChatCompletions({
|
|
148
|
+
chatId: create_completion_result.parsedChat?.id ?? "",
|
|
149
|
+
});
|
|
150
|
+
console.log("Stored completions:", get_chat_completions_result);
|
|
151
|
+
expect(get_chat_completions_result).toBeDefined();
|
|
152
|
+
// make sure the completion does not exist in the chats retrieved
|
|
153
|
+
expect(get_chat_completions_result.chatCompletions.some(completion => completion.id === create_completion_result.parsedCompletion?.id)).toBe(false);
|
|
154
|
+
// Now delete test chat
|
|
155
|
+
const delete_chat_result = await client.deleteChats({
|
|
156
|
+
chatIds: [create_completion_result.parsedChat?.id ?? ""],
|
|
157
|
+
});
|
|
158
|
+
expect(delete_chat_result.success).toBeTruthy();
|
|
159
|
+
}, 30000);
|
|
140
160
|
// Deep Researcher Tests
|
|
141
161
|
it("should create a deep research job", async () => {
|
|
142
162
|
// Create test parameters
|
|
@@ -192,12 +212,7 @@ describe("ApexClient", () => {
|
|
|
192
212
|
expect(Object.keys(result.chatIds[0] || {}).length).toBe(0);
|
|
193
213
|
}, 30000);
|
|
194
214
|
it("should create a chat and completion for a user", async () => {
|
|
195
|
-
const result = await client.createChatAndCompletion(
|
|
196
|
-
userPrompt: "This is a test chat, how are you?",
|
|
197
|
-
chatType: "apex",
|
|
198
|
-
completionType: "basic",
|
|
199
|
-
title: "Test Chat",
|
|
200
|
-
});
|
|
215
|
+
const result = await client.createChatAndCompletion(createChatAndCompletionParams);
|
|
201
216
|
// Verify the response structure
|
|
202
217
|
console.log("Create chat and completion response:", result);
|
|
203
218
|
expect(result).toBeDefined();
|
|
@@ -229,4 +244,25 @@ describe("ApexClient", () => {
|
|
|
229
244
|
expect(result).toBeDefined();
|
|
230
245
|
expect(Array.isArray(result.chatSessions)).toBe(true);
|
|
231
246
|
}, 30000);
|
|
247
|
+
it("should update chat attribute", async () => {
|
|
248
|
+
// chat ID for testing
|
|
249
|
+
const create_chat_result = await client.createChatAndCompletion(createChatAndCompletionParams);
|
|
250
|
+
// Verify the response structure
|
|
251
|
+
console.log("Create chat response:", create_chat_result);
|
|
252
|
+
expect(create_chat_result).toBeDefined();
|
|
253
|
+
const update_chat_attributes = await client.updateChatAttributes({
|
|
254
|
+
chatId: create_chat_result.parsedChat?.id ?? "",
|
|
255
|
+
attributes: {
|
|
256
|
+
title: "Updated Test Chat",
|
|
257
|
+
chat_type: "gravity",
|
|
258
|
+
},
|
|
259
|
+
});
|
|
260
|
+
expect(update_chat_attributes.chat?.title).toBe("Updated Test Chat");
|
|
261
|
+
expect(update_chat_attributes.chat?.chatType).toBe("gravity");
|
|
262
|
+
// Delete test chat
|
|
263
|
+
const delete_chat_result = await client.deleteChats({
|
|
264
|
+
chatIds: [create_chat_result.parsedChat?.id ?? ""],
|
|
265
|
+
});
|
|
266
|
+
expect(delete_chat_result.success).toBeTruthy();
|
|
267
|
+
}, 30000);
|
|
232
268
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApexServiceClient, ChatCompletionRequest as GeneratedChatCompletionRequest, ChatCompletionResponse, ChatCompletionChunkResponse, WebRetrievalRequest as GeneratedWebRetrievalRequest, WebRetrievalResponse, ChatMessage, SubmitDeepResearcherJobResponse, GetDeepResearcherJobRequest, GetDeepResearcherJobResponse, GetStoredChatCompletionsRequest, GetStoredChatCompletionsResponse, GetChatSessionsResponse, SearchChatIdsByPromptAndCompletionTextRequest, SearchChatIdsByPromptAndCompletionTextResponse, CreateChatAndCompletionRequest, CreateChatAndCompletionResponse, CreateCompletionRequest, CreateCompletionResponse, DeleteChatsRequest, DeleteChatsResponse } from "../../generated/apex/v1/apex";
|
|
1
|
+
import { ApexServiceClient, ChatCompletionRequest as GeneratedChatCompletionRequest, ChatCompletionResponse, ChatCompletionChunkResponse, WebRetrievalRequest as GeneratedWebRetrievalRequest, WebRetrievalResponse, ChatMessage, SubmitDeepResearcherJobResponse, GetDeepResearcherJobRequest, GetDeepResearcherJobResponse, GetStoredChatCompletionsRequest, GetStoredChatCompletionsResponse, GetChatSessionsResponse, SearchChatIdsByPromptAndCompletionTextRequest, SearchChatIdsByPromptAndCompletionTextResponse, CreateChatAndCompletionRequest, CreateChatAndCompletionResponse, CreateCompletionRequest, CreateCompletionResponse, DeleteChatsRequest, DeleteChatsResponse, DeleteCompletionsRequest, DeleteCompletionsResponse, UpdateChatAttributesRequest, UpdateChatAttributesResponse } from "../../generated/apex/v1/apex";
|
|
2
2
|
import * as grpc from "@grpc/grpc-js";
|
|
3
3
|
import { BaseClient, BaseClientOptions } from "../BaseClient";
|
|
4
4
|
import { ApexStream } from "./Stream";
|
|
@@ -85,4 +85,12 @@ export declare class ApexClient extends BaseClient {
|
|
|
85
85
|
* Delete a chat given its id
|
|
86
86
|
*/
|
|
87
87
|
deleteChats: (params: DeleteChatsRequest) => Promise<DeleteChatsResponse>;
|
|
88
|
+
/**
|
|
89
|
+
* Delete completions given their id
|
|
90
|
+
*/
|
|
91
|
+
deleteCompletions: (params: DeleteCompletionsRequest) => Promise<DeleteCompletionsResponse>;
|
|
92
|
+
/**
|
|
93
|
+
* Update chat attributes
|
|
94
|
+
*/
|
|
95
|
+
updateChatAttributes: (params: UpdateChatAttributesRequest) => Promise<UpdateChatAttributesResponse>;
|
|
88
96
|
}
|
package/dist/lib/apex/Client.js
CHANGED
|
@@ -231,6 +231,36 @@ class ApexClient extends BaseClient_1.BaseClient {
|
|
|
231
231
|
});
|
|
232
232
|
});
|
|
233
233
|
};
|
|
234
|
+
/**
|
|
235
|
+
* Delete completions given their id
|
|
236
|
+
*/
|
|
237
|
+
this.deleteCompletions = async (params) => {
|
|
238
|
+
const client = this.createGrpcClient();
|
|
239
|
+
return new Promise((resolve, reject) => {
|
|
240
|
+
client.deleteCompletions(params, (error, response) => {
|
|
241
|
+
if (error) {
|
|
242
|
+
reject(error);
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
resolve(response);
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
};
|
|
249
|
+
/**
|
|
250
|
+
* Update chat attributes
|
|
251
|
+
*/
|
|
252
|
+
this.updateChatAttributes = async (params) => {
|
|
253
|
+
const client = this.createGrpcClient();
|
|
254
|
+
return new Promise((resolve, reject) => {
|
|
255
|
+
client.updateChatAttributes(params, (error, response) => {
|
|
256
|
+
if (error) {
|
|
257
|
+
reject(error);
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
resolve(response);
|
|
261
|
+
});
|
|
262
|
+
});
|
|
263
|
+
};
|
|
234
264
|
this.defaultTimeout = options.timeout || 60;
|
|
235
265
|
this._grpcClient = grpcClient;
|
|
236
266
|
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "1.2.
|
|
1
|
+
export declare const VERSION = "1.2.23";
|
package/dist/version.js
CHANGED