Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
62 changes: 62 additions & 0 deletions v1/endpoints/agents.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package endpoints

import (
"github.com/metorial/metorial-go/v1/internal/endpoint"
"github.com/metorial/metorial-go/v1/resources/agents"
)

// AgentsEndpoint provides access to inspect agents and their linked clients and instances.
type AgentsEndpoint struct {
client *endpoint.Client
}

// NewAgentsEndpoint creates a new AgentsEndpoint.
func NewAgentsEndpoint(client *endpoint.Client) *AgentsEndpoint {
return &AgentsEndpoint{client: client}
}

// AgentsEndpointListParams contains optional query parameters for List.
type AgentsEndpointListParams struct {
Limit *float64 `json:"limit,omitempty"`
After *string `json:"after,omitempty"`
Before *string `json:"before,omitempty"`
Cursor *string `json:"cursor,omitempty"`
Order *string `json:"order,omitempty"`
Search *string `json:"search,omitempty"`
Status *any `json:"status,omitempty"`
Type *any `json:"type,omitempty"`
Id *any `json:"id,omitempty"`
// CreatedAt - Filter agent creation time by date range
CreatedAt *map[string]any `json:"created_at,omitempty"`
// UpdatedAt - Filter agent last update time by date range
UpdatedAt *map[string]any `json:"updated_at,omitempty"`
}

// List returns a paginated list of agents for the instance.
func (e *AgentsEndpoint) List(params *AgentsEndpointListParams) (*agents.AgentsListOutput, error) {
var query map[string]any
if params != nil {
query = endpoint.StructToQuery(params)
}
req := &endpoint.Request{
Path: []string{"agents"},
Query: query,
}
var result agents.AgentsListOutput
if err := e.client.Get(req, &result); err != nil {
return nil, err
}
return &result, nil
}

// Get retrieves a specific agent by ID.
func (e *AgentsEndpoint) Get(agentId string) (*agents.AgentsGetOutput, error) {
req := &endpoint.Request{
Path: []string{"agents", agentId},
}
var result agents.AgentsGetOutput
if err := e.client.Get(req, &result); err != nil {
return nil, err
}
return &result, nil
}
61 changes: 61 additions & 0 deletions v1/endpoints/agents_instances.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package endpoints

import (
"github.com/metorial/metorial-go/v1/internal/endpoint"
"github.com/metorial/metorial-go/v1/resources/agents/instances"
)

// AgentsInstancesEndpoint provides access to inspect agents and their linked clients and instances.
type AgentsInstancesEndpoint struct {
client *endpoint.Client
}

// NewAgentsInstancesEndpoint creates a new AgentsInstancesEndpoint.
func NewAgentsInstancesEndpoint(client *endpoint.Client) *AgentsInstancesEndpoint {
return &AgentsInstancesEndpoint{client: client}
}

// AgentsInstancesEndpointListParams contains optional query parameters for List.
type AgentsInstancesEndpointListParams struct {
Limit *float64 `json:"limit,omitempty"`
After *string `json:"after,omitempty"`
Before *string `json:"before,omitempty"`
Cursor *string `json:"cursor,omitempty"`
Order *string `json:"order,omitempty"`
Type *any `json:"type,omitempty"`
Id *any `json:"id,omitempty"`
AgentClientId *any `json:"agent_client_id,omitempty"`
// CreatedAt - Filter agent instance creation time by date range
CreatedAt *map[string]any `json:"created_at,omitempty"`
// UpdatedAt - Filter agent instance last update time by date range
UpdatedAt *map[string]any `json:"updated_at,omitempty"`
}

// List returns a paginated list of instances for an agent.
func (e *AgentsInstancesEndpoint) List(agentId string, params *AgentsInstancesEndpointListParams) (*instances.AgentsInstancesListOutput, error) {
var query map[string]any
if params != nil {
query = endpoint.StructToQuery(params)
}
req := &endpoint.Request{
Path: []string{"agents", agentId, "instances"},
Query: query,
}
var result instances.AgentsInstancesListOutput
if err := e.client.Get(req, &result); err != nil {
return nil, err
}
return &result, nil
}

// Get retrieves a specific agent instance by ID.
func (e *AgentsInstancesEndpoint) Get(agentId string, agentInstanceId string) (*instances.AgentsInstancesGetOutput, error) {
req := &endpoint.Request{
Path: []string{"agents", agentId, "instances", agentInstanceId},
}
var result instances.AgentsInstancesGetOutput
if err := e.client.Get(req, &result); err != nil {
return nil, err
}
return &result, nil
}
54 changes: 54 additions & 0 deletions v1/endpoints/assistants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package endpoints

import (
"github.com/metorial/metorial-go/v1/internal/endpoint"
"github.com/metorial/metorial-go/v1/resources/assistants"
)

// AssistantsEndpoint provides access to assistant and conversation endpoints
type AssistantsEndpoint struct {
client *endpoint.Client
}

// NewAssistantsEndpoint creates a new AssistantsEndpoint.
func NewAssistantsEndpoint(client *endpoint.Client) *AssistantsEndpoint {
return &AssistantsEndpoint{client: client}
}

// AssistantsEndpointListParams contains optional query parameters for List.
type AssistantsEndpointListParams struct {
Limit *float64 `json:"limit,omitempty"`
After *string `json:"after,omitempty"`
Before *string `json:"before,omitempty"`
Cursor *string `json:"cursor,omitempty"`
Order *string `json:"order,omitempty"`
}

// List list assistants available in an instance.
func (e *AssistantsEndpoint) List(params *AssistantsEndpointListParams) (*assistants.AssistantsListOutput, error) {
var query map[string]any
if params != nil {
query = endpoint.StructToQuery(params)
}
req := &endpoint.Request{
Path: []string{"assistants"},
Query: query,
}
var result assistants.AssistantsListOutput
if err := e.client.Get(req, &result); err != nil {
return nil, err
}
return &result, nil
}

// Get get an assistant available in an instance.
func (e *AssistantsEndpoint) Get(assistantId string) (*assistants.AssistantsGetOutput, error) {
req := &endpoint.Request{
Path: []string{"assistants", assistantId},
}
var result assistants.AssistantsGetOutput
if err := e.client.Get(req, &result); err != nil {
return nil, err
}
return &result, nil
}
12 changes: 12 additions & 0 deletions v1/endpoints/callbacks_instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@ func (e *CallbacksInstancesEndpoint) List(callbackId string, params *CallbacksIn
return &result, nil
}

// Get retrieves a specific callback instance by ID.
func (e *CallbacksInstancesEndpoint) Get(callbackId string, callbackInstanceId string) (*instances.CallbacksInstancesGetOutput, error) {
req := &endpoint.Request{
Path: []string{"callbacks", callbackId, "instances", callbackInstanceId},
}
var result instances.CallbacksInstancesGetOutput
if err := e.client.Get(req, &result); err != nil {
return nil, err
}
return &result, nil
}

// Create attaches a callback to a config and optional auth config.
func (e *CallbacksInstancesEndpoint) Create(callbackId string, body *CallbacksInstancesEndpointCreateBody) (*instances.CallbacksInstancesCreateOutput, error) {
req := &endpoint.Request{
Expand Down
92 changes: 92 additions & 0 deletions v1/endpoints/conversations.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package endpoints

import (
"github.com/metorial/metorial-go/v1/internal/endpoint"
"github.com/metorial/metorial-go/v1/resources/conversations"
)

// ConversationsEndpoint provides access to assistant and conversation endpoints
type ConversationsEndpoint struct {
client *endpoint.Client
}

// NewConversationsEndpoint creates a new ConversationsEndpoint.
func NewConversationsEndpoint(client *endpoint.Client) *ConversationsEndpoint {
return &ConversationsEndpoint{client: client}
}

// ConversationsEndpointListParams contains optional query parameters for List.
type ConversationsEndpointListParams struct {
Limit *float64 `json:"limit,omitempty"`
After *string `json:"after,omitempty"`
Before *string `json:"before,omitempty"`
Cursor *string `json:"cursor,omitempty"`
Order *string `json:"order,omitempty"`
AssistantId *any `json:"assistant_id,omitempty"`
}

// ConversationsEndpointCreateBody contains the request body for Create.
type ConversationsEndpointCreateBody struct {
AssistantId string `json:"assistant_id"`
Title *string `json:"title,omitempty"`
}

// ConversationsEndpointUpdateBody contains the request body for Update.
type ConversationsEndpointUpdateBody struct {
Title *string `json:"title,omitempty"`
}

// List list assistant conversations in an instance.
func (e *ConversationsEndpoint) List(params *ConversationsEndpointListParams) (*conversations.ConversationsListOutput, error) {
var query map[string]any
if params != nil {
query = endpoint.StructToQuery(params)
}
req := &endpoint.Request{
Path: []string{"conversations"},
Query: query,
}
var result conversations.ConversationsListOutput
if err := e.client.Get(req, &result); err != nil {
return nil, err
}
return &result, nil
}

// Create create a new assistant conversation in an instance.
func (e *ConversationsEndpoint) Create(body *ConversationsEndpointCreateBody) (*conversations.ConversationsCreateOutput, error) {
req := &endpoint.Request{
Path: []string{"conversations"},
Body: body,
}
var result conversations.ConversationsCreateOutput
if err := e.client.Post(req, &result); err != nil {
return nil, err
}
return &result, nil
}

// Get get a specific assistant conversation.
func (e *ConversationsEndpoint) Get(assistantConversationId string) (*conversations.ConversationsGetOutput, error) {
req := &endpoint.Request{
Path: []string{"conversations", assistantConversationId},
}
var result conversations.ConversationsGetOutput
if err := e.client.Get(req, &result); err != nil {
return nil, err
}
return &result, nil
}

// Update update a specific assistant conversation.
func (e *ConversationsEndpoint) Update(assistantConversationId string, body *ConversationsEndpointUpdateBody) (*conversations.ConversationsUpdateOutput, error) {
req := &endpoint.Request{
Path: []string{"conversations", assistantConversationId},
Body: body,
}
var result conversations.ConversationsUpdateOutput
if err := e.client.Patch(req, &result); err != nil {
return nil, err
}
return &result, nil
}
74 changes: 74 additions & 0 deletions v1/endpoints/conversations_messages.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package endpoints

import (
"github.com/metorial/metorial-go/v1/internal/endpoint"
"github.com/metorial/metorial-go/v1/resources/conversations/messages"
)

// ConversationsMessagesEndpoint provides access to assistant and conversation endpoints
type ConversationsMessagesEndpoint struct {
client *endpoint.Client
}

// NewConversationsMessagesEndpoint creates a new ConversationsMessagesEndpoint.
func NewConversationsMessagesEndpoint(client *endpoint.Client) *ConversationsMessagesEndpoint {
return &ConversationsMessagesEndpoint{client: client}
}

// ConversationsMessagesEndpointListParams contains optional query parameters for List.
type ConversationsMessagesEndpointListParams struct {
Limit *float64 `json:"limit,omitempty"`
After *string `json:"after,omitempty"`
Before *string `json:"before,omitempty"`
Cursor *string `json:"cursor,omitempty"`
Order *string `json:"order,omitempty"`
}

// ConversationsMessagesEndpointCreateBody contains the request body for Create.
type ConversationsMessagesEndpointCreateBody struct {
Message map[string]any `json:"message"`
ParentMessageId *string `json:"parent_message_id,omitempty"`
ModelId *string `json:"model_id,omitempty"`
}

// List list messages in a specific assistant conversation.
func (e *ConversationsMessagesEndpoint) List(assistantConversationId string, params *ConversationsMessagesEndpointListParams) (*messages.ConversationsMessagesListOutput, error) {
var query map[string]any
if params != nil {
query = endpoint.StructToQuery(params)
}
req := &endpoint.Request{
Path: []string{"conversations", assistantConversationId, "messages"},
Query: query,
}
var result messages.ConversationsMessagesListOutput
if err := e.client.Get(req, &result); err != nil {
return nil, err
}
return &result, nil
}

// Create create a user message and assistant request in a specific conversation.
func (e *ConversationsMessagesEndpoint) Create(assistantConversationId string, body *ConversationsMessagesEndpointCreateBody) (*messages.ConversationsMessagesCreateOutput, error) {
req := &endpoint.Request{
Path: []string{"conversations", assistantConversationId, "messages"},
Body: body,
}
var result messages.ConversationsMessagesCreateOutput
if err := e.client.Post(req, &result); err != nil {
return nil, err
}
return &result, nil
}

// Get get a specific assistant message.
func (e *ConversationsMessagesEndpoint) Get(assistantConversationId string, assistantMessageId string) (*messages.ConversationsMessagesGetOutput, error) {
req := &endpoint.Request{
Path: []string{"conversations", assistantConversationId, "messages", assistantMessageId},
}
var result messages.ConversationsMessagesGetOutput
if err := e.client.Get(req, &result); err != nil {
return nil, err
}
return &result, nil
}
Loading
Loading