Skip to content

Latest commit

 

History

History
198 lines (131 loc) · 17 KB

File metadata and controls

198 lines (131 loc) · 17 KB

Agents

Overview

Available Operations

search

Search agents available to the authenticated user by agent name.

Example Usage

from glean.api_client import Glean
import os


with Glean(
    api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as glean:

    res = glean.agents.search(name="HR Policy Agent")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
name Optional[str] Case-insensitive substring to match against agent names. If omitted or empty, no name filter is applied. HR Policy Agent
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.PlatformAgentsSearchResponse

Errors

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

get

Retrieve details for an agent available to the authenticated user.

Example Usage

from glean.api_client import Glean
import os


with Glean(
    api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as glean:

    res = glean.agents.get(agent_id="{agent_id}")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
agent_id str ✔️ ID of the agent to retrieve. {agent_id}
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.PlatformAgentGetResponse

Errors

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

get_schemas

Retrieve an agent's input and output JSON schemas.

Example Usage

from glean.api_client import Glean
import os


with Glean(
    api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as glean:

    res = glean.agents.get_schemas(agent_id="{agent_id}", include_tools=False)

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
agent_id str ✔️ ID of the agent whose schemas should be retrieved. {agent_id}
include_tools Optional[bool] Whether to include tool metadata in the response.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.PlatformAgentSchemasResponse

Errors

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

create_run

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

Example Usage

from glean.api_client import Glean, models
import os


with Glean(
    api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as glean:

    res = glean.agents.create_run(agent_id="{agent_id}", messages=[
        {
            "role": models.PlatformMessageRole.USER,
            "content": [
                {
                    "text": "What is our parental leave policy?",
                    "type": models.PlatformContentType.TEXT,
                },
            ],
        },
    ], stream=False)

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
agent_id str ✔️ ID of the agent to run. {agent_id}
input Dict[str, Any] Input fields for an input-form triggered agent.
messages List[models.PlatformMessage] Messages to pass to the agent. When provided, the array MUST contain at least one message and each message MUST specify a valid role and non-empty content.
metadata Dict[str, Any] Metadata to pass to the agent.
stream Optional[bool] Whether to stream the run response as server-sent events.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.PlatformAgentsCreateRunResponse

Errors

Error Type Status Code Content Type
errors.PlatformUnauthorizedAgentToolsProblemError 422 application/problem+json
errors.PlatformProblemDetailError 400, 401, 403, 404, 408, 409, 413, 429 application/problem+json
errors.PlatformProblemDetailError 500, 503 application/problem+json
errors.GleanError 4XX, 5XX */*