Request


To interact with the Cloud4.ai system, the SDK offers a convenient wrapper around all C4AI Services. Serving as the primary entry point, the Elastic Endpoint Service (EES) streamlines the process of defining Command Requests, complete with options and scheduling capabilities, thereby facilitating control over throttling, retries, and other critical integration aspects.

Note: Delve deeper into EES configurations, options, and features in the EES (Elastic Endpoint) section.

Configurations

Simple Request

Using the SDK's EES class, you can seamlessly dispatch any executable command for execution. Here's an example:

const command = new C4AI_EES.Commands.EXECUTE({
    service: new C4AI_EES(eesSic),
    command: new C4AI_AAC.Commands.EXECUTE({
        service: new C4AI_AAC(aacSic),
        parameters: new C4AI_RequestParameters(
            new C4AI_RequestParameter('prompt', 'Say Hello!')
        )
    })
});

Nested Injections

By leveraging the request syntax, you can define additional strategies for parameter retrieval. This allows you to specify parameters at various depths within the commands included in the original request. Consider the following example:

const command = new C4AI_EES.Commands.EXECUTE({
    service: new C4AI_EES(eesSic),
    command: new C4AI_AAC.Commands.EXECUTE({
        service: new C4AI_AAC(aacSic),
        parameters: new C4AI_RequestParameters(
            new C4AI_RequestParameter('foo', 'bar'),
            new C4AI_RequestParameter('foo2', 'bar2'),
            new C4AI_RequestParameter(
                'prompt',
                new C4AI_PLPrompt.Commands.COMPILE({
                    service: new C4AI_PLPrompt(promptSic),
                    parameters: new C4AI_RequestParameters(
                        new C4AI_RequestParameter('foo', 'bar'),
                        new C4AI_RequestParameter('foo2', 'bar2')
                    )
                })
            )
        )
    })
});

Upon making a request, the response will always return a Command Request Type. For instance:

C4AI_CommandRequest {
  rawResult: {
    id: 'c4ai-cr::04b3735e-22ec-4de2-b5fa-ff9cc1f40048',
    status: 'COMPLETED',
    mode: 'play',
    command: 'EXECUTE',
    service: 'sic@0000000001:aac-instance:0000000119',
    result: {
      result: 'My neck can be up to 6 feet long, making it the longest neck of any land animal!',
      payload: [Object]
    },
    api: 'sic@0000000001:api-credentials:0000000019',
    organization: 'sic@0000000000:organization:0000000001',
    duration: 1,
    start: '2024-04-30T23:16:54.746Z',
    end: '2024-04-30T23:16:56.264Z',
    createdAt: 'Tue Apr 30 2024 23:16:56 GMT+0000'
  }
}

This version maintains the original information while adding clarification and detail for better understanding.

Last updated