Skip to content

Latest commit

 

History

History
239 lines (167 loc) · 12.1 KB

File metadata and controls

239 lines (167 loc) · 12.1 KB

Agents

Overview

Available Operations

search

Search agents available to the authenticated user by agent name.

Example Usage

package hello.world;

import com.glean.api_client.glean_api_client.Glean;
import com.glean.api_client.glean_api_client.models.components.PlatformAgentsSearchRequest;
import com.glean.api_client.glean_api_client.models.errors.PlatformProblemDetailException;
import com.glean.api_client.glean_api_client.models.operations.PlatformAgentsSearchResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws PlatformProblemDetailException, Exception {

        Glean sdk = Glean.builder()
                .apiToken(System.getenv().getOrDefault("GLEAN_API_TOKEN", ""))
            .build();

        PlatformAgentsSearchRequest req = PlatformAgentsSearchRequest.builder()
                .name("HR Policy Agent")
                .build();

        PlatformAgentsSearchResponse res = sdk.agents().search()
                .request(req)
                .call();

        if (res.platformAgentsSearchResponse().isPresent()) {
            System.out.println(res.platformAgentsSearchResponse().get());
        }
    }
}

Parameters

Parameter Type Required Description
request PlatformAgentsSearchRequest ✔️ The request object to use for the request.

Response

PlatformAgentsSearchResponse

Errors

Error Type Status Code Content Type
models/errors/PlatformProblemDetailException 400, 401, 403, 404, 408, 413, 429 application/problem+json
models/errors/PlatformProblemDetailException 500, 503 application/problem+json
models/errors/APIException 4XX, 5XX */*

get

Retrieve details for an agent available to the authenticated user.

Example Usage

package hello.world;

import com.glean.api_client.glean_api_client.Glean;
import com.glean.api_client.glean_api_client.models.errors.PlatformProblemDetailException;
import com.glean.api_client.glean_api_client.models.operations.PlatformAgentsGetResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws PlatformProblemDetailException, Exception {

        Glean sdk = Glean.builder()
                .apiToken(System.getenv().getOrDefault("GLEAN_API_TOKEN", ""))
            .build();

        PlatformAgentsGetResponse res = sdk.agents().get()
                .agentId("<id>")
                .call();

        if (res.platformAgentGetResponse().isPresent()) {
            System.out.println(res.platformAgentGetResponse().get());
        }
    }
}

Parameters

Parameter Type Required Description
agentId String ✔️ ID of the agent to retrieve.

Response

PlatformAgentsGetResponse

Errors

Error Type Status Code Content Type
models/errors/PlatformProblemDetailException 400, 401, 403, 404, 408, 429 application/problem+json
models/errors/PlatformProblemDetailException 500, 503 application/problem+json
models/errors/APIException 4XX, 5XX */*

getSchemas

Retrieve an agent's input and output JSON schemas.

Example Usage

package hello.world;

import com.glean.api_client.glean_api_client.Glean;
import com.glean.api_client.glean_api_client.models.errors.PlatformProblemDetailException;
import com.glean.api_client.glean_api_client.models.operations.PlatformAgentsGetSchemasResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws PlatformProblemDetailException, Exception {

        Glean sdk = Glean.builder()
                .apiToken(System.getenv().getOrDefault("GLEAN_API_TOKEN", ""))
            .build();

        PlatformAgentsGetSchemasResponse res = sdk.agents().getSchemas()
                .agentId("<id>")
                .includeTools(false)
                .call();

        if (res.platformAgentSchemasResponse().isPresent()) {
            System.out.println(res.platformAgentSchemasResponse().get());
        }
    }
}

Parameters

Parameter Type Required Description
agentId String ✔️ ID of the agent whose schemas should be retrieved.
includeTools Optional<Boolean> Whether to include tool metadata in the response.

Response

PlatformAgentsGetSchemasResponse

Errors

Error Type Status Code Content Type
models/errors/PlatformProblemDetailException 400, 401, 403, 404, 408, 429 application/problem+json
models/errors/PlatformProblemDetailException 500, 503 application/problem+json
models/errors/APIException 4XX, 5XX */*

createRun

Execute an agent run. Set stream to true to receive server-sent events; otherwise the response contains the final agent messages.

Example Usage

package hello.world;

import com.glean.api_client.glean_api_client.Glean;
import com.glean.api_client.glean_api_client.models.components.*;
import com.glean.api_client.glean_api_client.models.errors.PlatformProblemDetailException;
import com.glean.api_client.glean_api_client.models.operations.PlatformAgentsCreateRunResponse;
import java.lang.Exception;
import java.util.List;

public class Application {

    public static void main(String[] args) throws PlatformProblemDetailException, Exception {

        Glean sdk = Glean.builder()
                .apiToken(System.getenv().getOrDefault("GLEAN_API_TOKEN", ""))
            .build();

        PlatformAgentsCreateRunResponse res = sdk.agents().createRun()
                .agentId("<id>")
                .platformAgentRunCreateRequest(PlatformAgentRunCreateRequest.builder()
                    .messages(List.of(
                        PlatformMessage.builder()
                            .role(PlatformMessageRole.USER)
                            .content(List.of())
                            .build()))
                    .build())
                .call();

        if (res.platformAgentRunWaitResponse().isPresent()) {
            System.out.println(res.platformAgentRunWaitResponse().get());
        }
    }
}

Parameters

Parameter Type Required Description
agentId String ✔️ ID of the agent to run.
platformAgentRunCreateRequest PlatformAgentRunCreateRequest ✔️ N/A

Response

PlatformAgentsCreateRunResponse

Errors

Error Type Status Code Content Type
models/errors/PlatformProblemDetailException 400, 401, 403, 404, 408, 409, 413, 429 application/problem+json
models/errors/PlatformProblemDetailException 500, 503 application/problem+json
models/errors/APIException 4XX, 5XX */*