macrocosmos 1.2.20 → 1.2.21
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.
- package/dist/__tests__/apex/client-chat.test.js +112 -87
- package/dist/lib/apex/Client.d.ts +5 -1
- package/dist/lib/apex/Client.js +15 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -76,42 +76,67 @@ describe("ApexClient", () => {
|
|
|
76
76
|
// chat id doesn't exist so check first element is an empty object
|
|
77
77
|
expect(Object.keys(result.chatCompletions[0] || {}).length).toBe(0);
|
|
78
78
|
}, 30000);
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
79
|
+
it("should append a chat completion", async () => {
|
|
80
|
+
// 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
|
+
// Verify a chat id exists (i.e., a chat was created)
|
|
88
|
+
console.log("Create chat response:", create_chat_result);
|
|
89
|
+
expect(create_chat_result).toBeDefined();
|
|
90
|
+
expect(create_chat_result.parsedChat?.id).toBeDefined();
|
|
91
|
+
// Create Completion under this chat
|
|
92
|
+
const result = await client.createCompletion({
|
|
93
|
+
chatId: create_chat_result.parsedChat?.id ?? "",
|
|
94
|
+
userPrompt: "This is a test completion, how are you?",
|
|
95
|
+
completionType: "basic",
|
|
96
|
+
});
|
|
97
|
+
// Verify the response structure
|
|
98
|
+
console.log("Create completion response:", result);
|
|
99
|
+
expect(result).toBeDefined();
|
|
100
|
+
// Check ParsedCompletion
|
|
101
|
+
expect(result.parsedCompletion).toBeDefined();
|
|
102
|
+
expect(result.parsedCompletion.id).toBeDefined();
|
|
103
|
+
expect(result.parsedCompletion.chatId).toBe(create_chat_result.parsedChat.id);
|
|
104
|
+
// make sure the completion type is basic
|
|
105
|
+
expect(result.parsedCompletion.completionType).toBe("basic");
|
|
106
|
+
// make sure the completion text is what we sent
|
|
107
|
+
expect(result.parsedCompletion.userPromptText).toBe("This is a test completion, how are you?");
|
|
108
|
+
// Delete test chat
|
|
109
|
+
const delete_chat_result = await client.deleteChats({
|
|
110
|
+
chatIds: [create_chat_result.parsedChat?.id ?? ""],
|
|
111
|
+
});
|
|
112
|
+
expect(delete_chat_result).toBeDefined();
|
|
113
|
+
expect(delete_chat_result.success).toBeTruthy();
|
|
114
|
+
}, 30000);
|
|
115
|
+
it("should delete a chat", async () => {
|
|
116
|
+
// 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
|
+
});
|
|
123
|
+
// Verify the response structure
|
|
124
|
+
console.log("Create chat response:", create_chat_result);
|
|
125
|
+
expect(create_chat_result).toBeDefined();
|
|
126
|
+
// Delete test chat
|
|
127
|
+
const delete_chat_result = await client.deleteChats({
|
|
128
|
+
chatIds: [create_chat_result.parsedChat?.id ?? ""],
|
|
129
|
+
});
|
|
130
|
+
expect(delete_chat_result).toBeDefined();
|
|
131
|
+
expect(delete_chat_result.success).toBeTruthy();
|
|
132
|
+
const get_chat_sessions_result = await client.getChatSessions();
|
|
133
|
+
// Verify the response structure
|
|
134
|
+
console.log("Stored chats:", get_chat_sessions_result);
|
|
135
|
+
expect(get_chat_sessions_result).toBeDefined();
|
|
136
|
+
// should be an empty array as we just deleted the chat
|
|
137
|
+
expect(Array.isArray(get_chat_sessions_result.chatSessions)).toBe(true);
|
|
138
|
+
expect(get_chat_sessions_result.chatSessions.some(session => session.id === create_chat_result.parsedChat?.id)).toBe(false);
|
|
139
|
+
}, 30000);
|
|
115
140
|
// Deep Researcher Tests
|
|
116
141
|
it("should create a deep research job", async () => {
|
|
117
142
|
// Create test parameters
|
|
@@ -153,55 +178,55 @@ describe("ApexClient", () => {
|
|
|
153
178
|
// Log response for debugging
|
|
154
179
|
console.log("Get Job Results Response:", response);
|
|
155
180
|
}, 60000); // Longer timeout for this test as it involves multiple API calls
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
181
|
+
it("should retrieve a user's completions based on the search term", async () => {
|
|
182
|
+
const searchTerm = "France?";
|
|
183
|
+
// Get stored chat completions
|
|
184
|
+
const result = await client.searchChatIdsByPromptAndCompletionText({
|
|
185
|
+
searchTerm: searchTerm,
|
|
186
|
+
});
|
|
187
|
+
// Verify the response structure
|
|
188
|
+
console.log("Stored chats:", result);
|
|
189
|
+
expect(result).toBeDefined();
|
|
190
|
+
expect(Array.isArray(result.chatIds)).toBe(true);
|
|
191
|
+
// chat id doesn't exist so check first element is an empty object
|
|
192
|
+
expect(Object.keys(result.chatIds[0] || {}).length).toBe(0);
|
|
193
|
+
}, 30000);
|
|
194
|
+
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
|
+
});
|
|
201
|
+
// Verify the response structure
|
|
202
|
+
console.log("Create chat and completion response:", result);
|
|
203
|
+
expect(result).toBeDefined();
|
|
204
|
+
// Check ParsedChat
|
|
205
|
+
expect(result.parsedChat).toBeDefined();
|
|
206
|
+
expect(result.parsedChat.id).toBeDefined();
|
|
207
|
+
expect(result.parsedChat.title).toBe("Test Chat");
|
|
208
|
+
expect(result.parsedChat.chatType).toBe("apex");
|
|
209
|
+
expect(result.parsedChat.createdAt).toBeDefined();
|
|
210
|
+
// Check ParsedCompletion
|
|
211
|
+
expect(result.parsedCompletion).toBeDefined();
|
|
212
|
+
expect(result.parsedCompletion.id).toBeDefined();
|
|
213
|
+
expect(result.parsedCompletion.chatId).toBe(result.parsedChat.id);
|
|
214
|
+
expect(result.parsedCompletion.completionType).toBe("basic");
|
|
215
|
+
expect(result.parsedCompletion.userPromptText).toBe("This is a test chat, how are you?");
|
|
216
|
+
expect(result.parsedCompletion.completionText).toBeDefined();
|
|
217
|
+
expect(result.parsedCompletion.createdAt).toBeDefined();
|
|
218
|
+
// Delete test chat
|
|
219
|
+
const delete_chat_result = await client.deleteChats({
|
|
220
|
+
chatIds: [result.parsedChat?.id ?? ""],
|
|
221
|
+
});
|
|
222
|
+
expect(delete_chat_result.success).toBeTruthy();
|
|
223
|
+
}, 30000);
|
|
224
|
+
it("should retrieve a user's stored chats", async () => {
|
|
225
|
+
// Get stored chat completions
|
|
226
|
+
const result = await client.getChatSessions();
|
|
227
|
+
// Verify the response structure
|
|
228
|
+
console.log("Stored chats:", result);
|
|
229
|
+
expect(result).toBeDefined();
|
|
230
|
+
expect(Array.isArray(result.chatSessions)).toBe(true);
|
|
231
|
+
}, 30000);
|
|
207
232
|
});
|
|
@@ -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 } 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 } 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";
|
|
@@ -81,4 +81,8 @@ export declare class ApexClient extends BaseClient {
|
|
|
81
81
|
* Create completion for a chat
|
|
82
82
|
*/
|
|
83
83
|
createCompletion: (params: CreateCompletionRequest) => Promise<CreateCompletionResponse>;
|
|
84
|
+
/**
|
|
85
|
+
* Delete a chat given its id
|
|
86
|
+
*/
|
|
87
|
+
deleteChats: (params: DeleteChatsRequest) => Promise<DeleteChatsResponse>;
|
|
84
88
|
}
|
package/dist/lib/apex/Client.js
CHANGED
|
@@ -216,6 +216,21 @@ class ApexClient extends BaseClient_1.BaseClient {
|
|
|
216
216
|
});
|
|
217
217
|
});
|
|
218
218
|
};
|
|
219
|
+
/**
|
|
220
|
+
* Delete a chat given its id
|
|
221
|
+
*/
|
|
222
|
+
this.deleteChats = async (params) => {
|
|
223
|
+
const client = this.createGrpcClient();
|
|
224
|
+
return new Promise((resolve, reject) => {
|
|
225
|
+
client.deleteChats(params, (error, response) => {
|
|
226
|
+
if (error) {
|
|
227
|
+
reject(error);
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
resolve(response);
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
};
|
|
219
234
|
this.defaultTimeout = options.timeout || 60;
|
|
220
235
|
this._grpcClient = grpcClient;
|
|
221
236
|
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "1.2.
|
|
1
|
+
export declare const VERSION = "1.2.21";
|
package/dist/version.js
CHANGED