(client.agents)
Returns details of an agent created in the Agent Builder.
from glean.api_client import Glean
import os
with Glean(
api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as g_client:
res = g_client.client.agents.retrieve(agent_id="<id>")
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
agent_id |
str |
✔️ |
The ID of the agent. |
timezone_offset |
Optional[int] |
➖ |
The offset of the client's timezone in minutes from UTC. e.g. PDT is -420 because it's 7 hours behind UTC. |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.Agent
| Error Type |
Status Code |
Content Type |
| errors.GleanError |
4XX, 5XX |
*/* |
Return agent's input and output schemas. You can use these schemas to detect changes to an agent's input or output structure.
from glean.api_client import Glean
import os
with Glean(
api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as g_client:
res = g_client.client.agents.retrieve_schemas(agent_id="<id>")
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
agent_id |
str |
✔️ |
The ID of the agent. |
timezone_offset |
Optional[int] |
➖ |
The offset of the client's timezone in minutes from UTC. e.g. PDT is -420 because it's 7 hours behind UTC. |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.AgentSchemas
| Error Type |
Status Code |
Content Type |
| errors.GleanError |
4XX, 5XX |
*/* |
Search for agents by agent name.
from glean.api_client import Glean
import os
with Glean(
api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as g_client:
res = g_client.client.agents.list(name="HR Policy Agent")
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
Example |
name |
Optional[str] |
➖ |
Filters on the name of the agent. The keyword search is case-insensitive. If search string is ommited or empty, acts as no filter. |
HR Policy Agent |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
|
models.SearchAgentsResponse
| Error Type |
Status Code |
Content Type |
| errors.GleanError |
4XX, 5XX |
*/* |
Executes an agent run and returns the result as a stream of server-sent events (SSE).
from glean.api_client import Glean
import os
with Glean(
api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as g_client:
res = g_client.client.agents.run_stream(agent_id="<id>")
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
agent_id |
str |
✔️ |
The ID of the agent to run. |
input |
Dict[str, Any] |
➖ |
The input to the agent. |
messages |
List[models.Message] |
➖ |
The messages to pass an input to the agent. |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
str
| Error Type |
Status Code |
Content Type |
| errors.GleanError |
4XX, 5XX |
*/* |
Executes an agent run and returns the final response.
from glean.api_client import Glean
import os
with Glean(
api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as g_client:
res = g_client.client.agents.run(agent_id="<id>")
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
agent_id |
str |
✔️ |
The ID of the agent to run. |
input |
Dict[str, Any] |
➖ |
The input to the agent. |
messages |
List[models.Message] |
➖ |
The messages to pass an input to the agent. |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.AgentRunWaitResponse
| Error Type |
Status Code |
Content Type |
| errors.GleanError |
4XX, 5XX |
*/* |