macrocosmos 1.2.10 → 1.2.12

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/README.md CHANGED
@@ -90,3 +90,25 @@ const cancelDataset = await client.cancelDataset({
90
90
  datasetId: 'dataset-id'
91
91
  });
92
92
  ```
93
+
94
+ ### SN13 Client
95
+
96
+ The SN13 client provides an interface for the SN13 Validator API.
97
+
98
+ ```typescript
99
+ import { Sn13Client } from 'macrocosmos';
100
+
101
+ // Initialize the client
102
+ const client = new Sn13Client({apiKey: 'your-api-key'});
103
+
104
+ // Get the onDemandData response
105
+ const response = await client.onDemandData({
106
+ source: 'x',
107
+ usernames: ['nasa', 'spacex'],
108
+ keywords: ['photo', 'space', 'mars'],
109
+ startDate: '2024-04-01',
110
+ endDate: '2025-04-25',
111
+ limit: 3
112
+ });
113
+
114
+ ```
package/dist/README.md CHANGED
@@ -90,3 +90,25 @@ const cancelDataset = await client.cancelDataset({
90
90
  datasetId: 'dataset-id'
91
91
  });
92
92
  ```
93
+
94
+ ### SN13 Client
95
+
96
+ The SN13 client provides an interface for the SN13 Validator API.
97
+
98
+ ```typescript
99
+ import { Sn13Client } from 'macrocosmos';
100
+
101
+ // Initialize the client
102
+ const client = new Sn13Client({apiKey: 'your-api-key'});
103
+
104
+ // Get the onDemandData response
105
+ const response = await client.onDemandData({
106
+ source: 'x',
107
+ usernames: ['nasa', 'spacex'],
108
+ keywords: ['photo', 'space', 'mars'],
109
+ startDate: '2024-04-01',
110
+ endDate: '2025-04-25',
111
+ limit: 3
112
+ });
113
+
114
+ ```
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const dotenv_1 = require("dotenv");
4
- // Load environment variables from .env file
5
4
  (0, dotenv_1.config)();
@@ -28,4 +28,30 @@ describe("Sn13Client", () => {
28
28
  // Log response for debugging
29
29
  console.log("Validation Response:", response);
30
30
  }, 30000); // Increase timeout to 30 seconds
31
+ it("should fetch on-demand data", async () => {
32
+ // Create Sn13Client
33
+ const client = new macrocosmos_1.Sn13Client({
34
+ apiKey: API_KEY,
35
+ appName: "sn13-client.test.ts",
36
+ });
37
+ // Create request
38
+ const request = {
39
+ source: "x",
40
+ usernames: ["nasa", "spacex"],
41
+ keywords: ["photo", "space", "mars"],
42
+ startDate: "2024-04-01",
43
+ endDate: "2025-04-25",
44
+ limit: 3,
45
+ };
46
+ // Fetch on-demand data
47
+ const response = await client.onDemandData(request);
48
+ // Verify response structure
49
+ expect(response).toBeDefined();
50
+ expect(typeof response.status).toBe("string");
51
+ expect(Array.isArray(response.data)).toBe(true);
52
+ expect(response.data.length).toBeLessThanOrEqual(request.limit);
53
+ expect(response.meta).toBeDefined();
54
+ // Log response for debugging
55
+ console.log("On-Demand Data Response:", response);
56
+ }, 30000); // Increase timeout to 30 seconds
31
57
  });
@@ -1,5 +1,6 @@
1
1
  import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
2
2
  import { type CallOptions, ChannelCredentials, Client, type ClientOptions, type ClientReadableStream, type ClientUnaryCall, type handleServerStreamingCall, type handleUnaryCall, Metadata, type ServiceError, type UntypedServiceImplementation } from "@grpc/grpc-js";
3
+ import { Empty } from "../../google/protobuf/empty";
3
4
  export declare const protobufPackage = "apex.v1";
4
5
  /**
5
6
  * A request to generate completions following Apex CompletionsRequest format.
@@ -332,7 +333,7 @@ export interface PromptTokensDetails {
332
333
  cachedTokens: number;
333
334
  }
334
335
  /**
335
- * A web retrival request from Apex
336
+ * A web retrieval request from Apex
336
337
  * Parsed from https://github.com/macrocosm-os/prompting/blob/main/validator_api/serializers.py
337
338
  */
338
339
  export interface WebRetrievalRequest {
@@ -369,6 +370,81 @@ export interface WebRetrievalResponse {
369
370
  /** results: the results of the web retrieval. */
370
371
  results: WebSearchResult[];
371
372
  }
373
+ /** A response containing the deep researcher job submission details */
374
+ export interface SubmitDeepResearcherJobResponse {
375
+ /** job_id: unique identifier for the submitted job */
376
+ jobId: string;
377
+ /** status: current status of the job */
378
+ status: string;
379
+ /** created_at: timestamp when the job was created */
380
+ createdAt: string;
381
+ /** updated_at: timestamp when the job was last updated */
382
+ updatedAt: string;
383
+ }
384
+ /** A response containing the deep researcher job status and results */
385
+ export interface GetDeepResearcherJobResponse {
386
+ /** job_id: unique identifier for the job */
387
+ jobId: string;
388
+ /** status: current status of the job */
389
+ status: string;
390
+ /** created_at: timestamp when the job was created */
391
+ createdAt: string;
392
+ /** updated_at: timestamp when the job was last updated */
393
+ updatedAt: string;
394
+ /** result: array of result chunks */
395
+ result: DeepResearcherResultChunk[];
396
+ /** error: error message if the job failed */
397
+ error?: string | undefined;
398
+ }
399
+ /** A chunk of the deep researcher result */
400
+ export interface DeepResearcherResultChunk {
401
+ /** seq_id: sequence identifier for the chunk */
402
+ seqId: number;
403
+ /** chunk: the content of the chunk */
404
+ chunk: string;
405
+ }
406
+ /** A request to get the status of a deep researcher job */
407
+ export interface GetDeepResearcherJobRequest {
408
+ /** job_id: the ID of the job to retrieve */
409
+ jobId: string;
410
+ }
411
+ /** A GetChatSession message repeated in GetChatSessionsResponse */
412
+ export interface ChatSession {
413
+ /** id: chat id */
414
+ id: string;
415
+ /** user_id: user id */
416
+ userId: string;
417
+ /** title: title of chat */
418
+ title: string;
419
+ /** chat_type: e.g. apex */
420
+ chatType: string;
421
+ /** created_at: when the chat was created */
422
+ createdAt?: Date | undefined;
423
+ /** updated_at: when the chat was updated */
424
+ updatedAt?: Date | undefined;
425
+ }
426
+ /** A GetChatSessionsResponse response */
427
+ export interface GetChatSessionsResponse {
428
+ /** chat_sessions: the chat sessions */
429
+ chatSessions: ChatSession[];
430
+ }
431
+ /** Directly model the attributes as a map */
432
+ export interface UpdateChatAttributeRequest {
433
+ /** chat_id: the unique id associated to a users chat message */
434
+ chatId: string;
435
+ /** attributes: the data attributes captured in the chat logging process */
436
+ attributes: {
437
+ [key: string]: string;
438
+ };
439
+ }
440
+ export interface UpdateChatAttributeRequest_AttributesEntry {
441
+ key: string;
442
+ value: string;
443
+ }
444
+ export interface UpdateChatAttributeResponse {
445
+ /** success: indicates if an attribute update was successful */
446
+ success: boolean;
447
+ }
372
448
  export declare const ChatCompletionRequest: MessageFns<ChatCompletionRequest>;
373
449
  export declare const SamplingParameters: MessageFns<SamplingParameters>;
374
450
  export declare const ChatCompletionResponse: MessageFns<ChatCompletionResponse>;
@@ -395,6 +471,15 @@ export declare const PromptTokensDetails: MessageFns<PromptTokensDetails>;
395
471
  export declare const WebRetrievalRequest: MessageFns<WebRetrievalRequest>;
396
472
  export declare const WebSearchResult: MessageFns<WebSearchResult>;
397
473
  export declare const WebRetrievalResponse: MessageFns<WebRetrievalResponse>;
474
+ export declare const SubmitDeepResearcherJobResponse: MessageFns<SubmitDeepResearcherJobResponse>;
475
+ export declare const GetDeepResearcherJobResponse: MessageFns<GetDeepResearcherJobResponse>;
476
+ export declare const DeepResearcherResultChunk: MessageFns<DeepResearcherResultChunk>;
477
+ export declare const GetDeepResearcherJobRequest: MessageFns<GetDeepResearcherJobRequest>;
478
+ export declare const ChatSession: MessageFns<ChatSession>;
479
+ export declare const GetChatSessionsResponse: MessageFns<GetChatSessionsResponse>;
480
+ export declare const UpdateChatAttributeRequest: MessageFns<UpdateChatAttributeRequest>;
481
+ export declare const UpdateChatAttributeRequest_AttributesEntry: MessageFns<UpdateChatAttributeRequest_AttributesEntry>;
482
+ export declare const UpdateChatAttributeResponse: MessageFns<UpdateChatAttributeResponse>;
398
483
  export type ApexServiceService = typeof ApexServiceService;
399
484
  export declare const ApexServiceService: {
400
485
  /** ChatCompletion generates a completion for a given request. */
@@ -427,6 +512,46 @@ export declare const ApexServiceService: {
427
512
  readonly responseSerialize: (value: WebRetrievalResponse) => Buffer<ArrayBuffer>;
428
513
  readonly responseDeserialize: (value: Buffer) => WebRetrievalResponse;
429
514
  };
515
+ /** SubmitDeepResearcherJob submits a new deep researcher job for processing. */
516
+ readonly submitDeepResearcherJob: {
517
+ readonly path: "/apex.v1.ApexService/SubmitDeepResearcherJob";
518
+ readonly requestStream: false;
519
+ readonly responseStream: false;
520
+ readonly requestSerialize: (value: ChatCompletionRequest) => Buffer<ArrayBuffer>;
521
+ readonly requestDeserialize: (value: Buffer) => ChatCompletionRequest;
522
+ readonly responseSerialize: (value: SubmitDeepResearcherJobResponse) => Buffer<ArrayBuffer>;
523
+ readonly responseDeserialize: (value: Buffer) => SubmitDeepResearcherJobResponse;
524
+ };
525
+ /** GetDeepResearcherJob retrieves the status and results of a deep researcher job. */
526
+ readonly getDeepResearcherJob: {
527
+ readonly path: "/apex.v1.ApexService/GetDeepResearcherJob";
528
+ readonly requestStream: false;
529
+ readonly responseStream: false;
530
+ readonly requestSerialize: (value: GetDeepResearcherJobRequest) => Buffer<ArrayBuffer>;
531
+ readonly requestDeserialize: (value: Buffer) => GetDeepResearcherJobRequest;
532
+ readonly responseSerialize: (value: GetDeepResearcherJobResponse) => Buffer<ArrayBuffer>;
533
+ readonly responseDeserialize: (value: Buffer) => GetDeepResearcherJobResponse;
534
+ };
535
+ /** GetChatSessions retrieves a user's chats */
536
+ readonly getChatSessions: {
537
+ readonly path: "/apex.v1.ApexService/GetChatSessions";
538
+ readonly requestStream: false;
539
+ readonly responseStream: false;
540
+ readonly requestSerialize: (value: Empty) => Buffer<ArrayBuffer>;
541
+ readonly requestDeserialize: (value: Buffer) => Empty;
542
+ readonly responseSerialize: (value: GetChatSessionsResponse) => Buffer<ArrayBuffer>;
543
+ readonly responseDeserialize: (value: Buffer) => GetChatSessionsResponse;
544
+ };
545
+ /** UpdateChatAttribute updates attribute after asking LLM for one */
546
+ readonly updateChatAttribute: {
547
+ readonly path: "/apex.v1.ApexService/UpdateChatAttribute";
548
+ readonly requestStream: false;
549
+ readonly responseStream: false;
550
+ readonly requestSerialize: (value: UpdateChatAttributeRequest) => Buffer<ArrayBuffer>;
551
+ readonly requestDeserialize: (value: Buffer) => UpdateChatAttributeRequest;
552
+ readonly responseSerialize: (value: UpdateChatAttributeResponse) => Buffer<ArrayBuffer>;
553
+ readonly responseDeserialize: (value: Buffer) => UpdateChatAttributeResponse;
554
+ };
430
555
  };
431
556
  export interface ApexServiceServer extends UntypedServiceImplementation {
432
557
  /** ChatCompletion generates a completion for a given request. */
@@ -435,6 +560,14 @@ export interface ApexServiceServer extends UntypedServiceImplementation {
435
560
  chatCompletionStream: handleServerStreamingCall<ChatCompletionRequest, ChatCompletionChunkResponse>;
436
561
  /** WebRetrieval retrieves web search results for a given request. */
437
562
  webRetrieval: handleUnaryCall<WebRetrievalRequest, WebRetrievalResponse>;
563
+ /** SubmitDeepResearcherJob submits a new deep researcher job for processing. */
564
+ submitDeepResearcherJob: handleUnaryCall<ChatCompletionRequest, SubmitDeepResearcherJobResponse>;
565
+ /** GetDeepResearcherJob retrieves the status and results of a deep researcher job. */
566
+ getDeepResearcherJob: handleUnaryCall<GetDeepResearcherJobRequest, GetDeepResearcherJobResponse>;
567
+ /** GetChatSessions retrieves a user's chats */
568
+ getChatSessions: handleUnaryCall<Empty, GetChatSessionsResponse>;
569
+ /** UpdateChatAttribute updates attribute after asking LLM for one */
570
+ updateChatAttribute: handleUnaryCall<UpdateChatAttributeRequest, UpdateChatAttributeResponse>;
438
571
  }
439
572
  export interface ApexServiceClient extends Client {
440
573
  /** ChatCompletion generates a completion for a given request. */
@@ -448,6 +581,22 @@ export interface ApexServiceClient extends Client {
448
581
  webRetrieval(request: WebRetrievalRequest, callback: (error: ServiceError | null, response: WebRetrievalResponse) => void): ClientUnaryCall;
449
582
  webRetrieval(request: WebRetrievalRequest, metadata: Metadata, callback: (error: ServiceError | null, response: WebRetrievalResponse) => void): ClientUnaryCall;
450
583
  webRetrieval(request: WebRetrievalRequest, metadata: Metadata, options: Partial<CallOptions>, callback: (error: ServiceError | null, response: WebRetrievalResponse) => void): ClientUnaryCall;
584
+ /** SubmitDeepResearcherJob submits a new deep researcher job for processing. */
585
+ submitDeepResearcherJob(request: ChatCompletionRequest, callback: (error: ServiceError | null, response: SubmitDeepResearcherJobResponse) => void): ClientUnaryCall;
586
+ submitDeepResearcherJob(request: ChatCompletionRequest, metadata: Metadata, callback: (error: ServiceError | null, response: SubmitDeepResearcherJobResponse) => void): ClientUnaryCall;
587
+ submitDeepResearcherJob(request: ChatCompletionRequest, metadata: Metadata, options: Partial<CallOptions>, callback: (error: ServiceError | null, response: SubmitDeepResearcherJobResponse) => void): ClientUnaryCall;
588
+ /** GetDeepResearcherJob retrieves the status and results of a deep researcher job. */
589
+ getDeepResearcherJob(request: GetDeepResearcherJobRequest, callback: (error: ServiceError | null, response: GetDeepResearcherJobResponse) => void): ClientUnaryCall;
590
+ getDeepResearcherJob(request: GetDeepResearcherJobRequest, metadata: Metadata, callback: (error: ServiceError | null, response: GetDeepResearcherJobResponse) => void): ClientUnaryCall;
591
+ getDeepResearcherJob(request: GetDeepResearcherJobRequest, metadata: Metadata, options: Partial<CallOptions>, callback: (error: ServiceError | null, response: GetDeepResearcherJobResponse) => void): ClientUnaryCall;
592
+ /** GetChatSessions retrieves a user's chats */
593
+ getChatSessions(request: Empty, callback: (error: ServiceError | null, response: GetChatSessionsResponse) => void): ClientUnaryCall;
594
+ getChatSessions(request: Empty, metadata: Metadata, callback: (error: ServiceError | null, response: GetChatSessionsResponse) => void): ClientUnaryCall;
595
+ getChatSessions(request: Empty, metadata: Metadata, options: Partial<CallOptions>, callback: (error: ServiceError | null, response: GetChatSessionsResponse) => void): ClientUnaryCall;
596
+ /** UpdateChatAttribute updates attribute after asking LLM for one */
597
+ updateChatAttribute(request: UpdateChatAttributeRequest, callback: (error: ServiceError | null, response: UpdateChatAttributeResponse) => void): ClientUnaryCall;
598
+ updateChatAttribute(request: UpdateChatAttributeRequest, metadata: Metadata, callback: (error: ServiceError | null, response: UpdateChatAttributeResponse) => void): ClientUnaryCall;
599
+ updateChatAttribute(request: UpdateChatAttributeRequest, metadata: Metadata, options: Partial<CallOptions>, callback: (error: ServiceError | null, response: UpdateChatAttributeResponse) => void): ClientUnaryCall;
451
600
  }
452
601
  export declare const ApexServiceClient: {
453
602
  new (address: string, credentials: ChannelCredentials, options?: Partial<ClientOptions>): ApexServiceClient;