- Retrieve - Retrieve an agent
- RetrieveSchemas - List an agent's schemas
- List - Search agents
- RunStream - Create an agent run and stream the response
- Run - Create an agent run and wait for the response
Returns details of an agent created in the Agent Builder.
package main
import(
"context"
"os"
apiclientgo "github.com/gleanwork/api-client-go"
"log"
)
func main() {
ctx := context.Background()
s := apiclientgo.New(
apiclientgo.WithSecurity(os.Getenv("GLEAN_API_TOKEN")),
)
res, err := s.Client.Agents.Retrieve(ctx, "<id>", nil, nil)
if err != nil {
log.Fatal(err)
}
if res.Agent != nil {
// handle response
}
}| Parameter | Type | Required | Description |
|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
agentID |
string |
✔️ | The ID of the agent. |
locale |
*string |
➖ | The client's preferred locale in rfc5646 format (e.g. en, ja, pt-BR). If omitted, the Accept-Language will be used. If not present or not supported, defaults to the closest match or en. |
timezoneOffset |
*int64 |
➖ | The offset of the client's timezone in minutes from UTC. e.g. PDT is -420 because it's 7 hours behind UTC. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.GetAgentResponse, error
| Error Type | Status Code | Content Type |
|---|---|---|
| apierrors.ErrorResponse | 404 | application/json |
| apierrors.APIError | 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.
package main
import(
"context"
"os"
apiclientgo "github.com/gleanwork/api-client-go"
"log"
)
func main() {
ctx := context.Background()
s := apiclientgo.New(
apiclientgo.WithSecurity(os.Getenv("GLEAN_API_TOKEN")),
)
res, err := s.Client.Agents.RetrieveSchemas(ctx, "<id>", nil, nil)
if err != nil {
log.Fatal(err)
}
if res.AgentSchemas != nil {
// handle response
}
}| Parameter | Type | Required | Description |
|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
agentID |
string |
✔️ | The ID of the agent. |
locale |
*string |
➖ | The client's preferred locale in rfc5646 format (e.g. en, ja, pt-BR). If omitted, the Accept-Language will be used. If not present or not supported, defaults to the closest match or en. |
timezoneOffset |
*int64 |
➖ | The offset of the client's timezone in minutes from UTC. e.g. PDT is -420 because it's 7 hours behind UTC. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.GetAgentSchemasResponse, error
| Error Type | Status Code | Content Type |
|---|---|---|
| apierrors.ErrorResponse | 404, 422 | application/json |
| apierrors.APIError | 4XX, 5XX | */* |
Search for agents by agent name.
package main
import(
"context"
"os"
apiclientgo "github.com/gleanwork/api-client-go"
"github.com/gleanwork/api-client-go/models/components"
"log"
)
func main() {
ctx := context.Background()
s := apiclientgo.New(
apiclientgo.WithSecurity(os.Getenv("GLEAN_API_TOKEN")),
)
res, err := s.Client.Agents.List(ctx, components.SearchAgentsRequest{
Name: apiclientgo.Pointer("HR Policy Agent"),
})
if err != nil {
log.Fatal(err)
}
if res.SearchAgentsResponse != nil {
// handle response
}
}| Parameter | Type | Required | Description |
|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
components.SearchAgentsRequest | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.SearchAgentsResponse, error
| Error Type | Status Code | Content Type |
|---|---|---|
| apierrors.ErrorResponse | 404, 422 | application/json |
| apierrors.APIError | 4XX, 5XX | */* |
Executes an agent run and returns the result as a stream of server-sent events (SSE). Note: If the agent uses an input form trigger, all form fields (including optional fields) must be included in the input object.
package main
import(
"context"
"os"
apiclientgo "github.com/gleanwork/api-client-go"
"github.com/gleanwork/api-client-go/models/components"
"log"
)
func main() {
ctx := context.Background()
s := apiclientgo.New(
apiclientgo.WithSecurity(os.Getenv("GLEAN_API_TOKEN")),
)
res, err := s.Client.Agents.RunStream(ctx, components.AgentRunCreate{
AgentID: "<id>",
Messages: []components.Message{
components.Message{
Role: apiclientgo.Pointer("USER"),
},
},
})
if err != nil {
log.Fatal(err)
}
if res.Res != nil {
// handle response
}
}| Parameter | Type | Required | Description |
|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
components.AgentRunCreate | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.CreateAndStreamRunResponse, error
| Error Type | Status Code | Content Type |
|---|---|---|
| apierrors.ErrorResponse | 404, 409, 422 | application/json |
| apierrors.APIError | 4XX, 5XX | */* |
Executes an agent run and returns the final response. Note: If the agent uses an input form trigger, all form fields (including optional fields) must be included in the input object.
package main
import(
"context"
"os"
apiclientgo "github.com/gleanwork/api-client-go"
"github.com/gleanwork/api-client-go/models/components"
"log"
)
func main() {
ctx := context.Background()
s := apiclientgo.New(
apiclientgo.WithSecurity(os.Getenv("GLEAN_API_TOKEN")),
)
res, err := s.Client.Agents.Run(ctx, components.AgentRunCreate{
AgentID: "<id>",
Messages: []components.Message{
components.Message{
Role: apiclientgo.Pointer("USER"),
},
},
})
if err != nil {
log.Fatal(err)
}
if res.AgentRunWaitResponse != nil {
// handle response
}
}| Parameter | Type | Required | Description |
|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
components.AgentRunCreate | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.CreateAndWaitRunResponse, error
| Error Type | Status Code | Content Type |
|---|---|---|
| apierrors.APIError | 4XX, 5XX | */* |