composio

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 17, 2024 License: MIT Imports: 12 Imported by: 0

README

composio

Compose AI is a powerful tool for creating complex and high-quality compositions of ai tools. This package provides a client for the composio api easily accessible through the pegwings-go library.

Documentation

Overview

Package composio provides a composio client for pegwings-go.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthOption

type AuthOption func(*url.Values)

AuthOption is an option for the auth request.

func WithShowActiveOnly

func WithShowActiveOnly(showActiveOnly bool) AuthOption

WithShowActiveOnly sets the show active only for the auth request.

func WithUserUUID

func WithUserUUID(userUUID string) AuthOption

WithUserUUID sets the user uuid for the auth request.

type Authorizer

type Authorizer interface {
	GetConnectedAccounts(ctx context.Context, opts ...AuthOption) ([]ConnectedAccount, error)
}

Authorizer is an interface for composio auth.

type Composio

type Composio struct {
	// contains filtered or unexported fields
}

Composio is a composio client.

func NewComposer

func NewComposer(apiKey string, opts ...Option) (*Composio, error)

NewComposer creates a new composio client.

func (*Composio) GetConnectedAccounts

func (c *Composio) GetConnectedAccounts(
	ctx context.Context,
	opts ...AuthOption,
) ([]ConnectedAccount, error)

GetConnectedAccounts returns the connected accounts for the composio client.

func (*Composio) GetTools

func (c *Composio) GetTools(
	ctx context.Context,
	opts ...ToolsOption,
) ([]tools.Tool, error)

GetTools returns the tools for the composio client.

func (*Composio) Run

Run runs the composio client on a chat completion response.

type ConnectedAccount

type ConnectedAccount struct {
	IntegrationID    string `json:"integrationId"`
	ConnectionParams struct {
		Scope            string   `json:"scope"`
		Scopes           []string `json:"scopes"`
		BaseURL          string   `json:"base_url"`
		ClientID         string   `json:"client_id"`
		TokenType        string   `json:"token_type"`
		RedirectURL      string   `json:"redirectUrl"`
		AccessToken      string   `json:"access_token"`
		CallbackURL      string   `json:"callback_url"`
		ClientSecret     string   `json:"client_secret"`
		CodeVerifier     string   `json:"code_verifier"`
		FinalRedirectURI string   `json:"finalRedirectUri"`
	} `json:"connectionParams"`
	IsDisabled         bool      `json:"isDisabled"`
	ID                 string    `json:"id"`
	MemberID           string    `json:"memberId"`
	ClientUniqueUserID string    `json:"clientUniqueUserId"`
	Status             string    `json:"status"`
	Enabled            bool      `json:"enabled"`
	CreatedAt          time.Time `json:"createdAt"`
	UpdatedAt          time.Time `json:"updatedAt"`
	Member             struct {
		ID        string    `json:"id"`
		ClientID  string    `json:"clientId"`
		Email     string    `json:"email"`
		Name      string    `json:"name"`
		Role      string    `json:"role"`
		Metadata  any       `json:"metadata"`
		CreatedAt time.Time `json:"createdAt"`
		UpdatedAt time.Time `json:"updatedAt"`
		DeletedAt any       `json:"deletedAt"`
	} `json:"member"`
	AppUniqueID               string `json:"appUniqueId"`
	AppName                   string `json:"appName"`
	IntegrationIsDisabled     bool   `json:"integrationIsDisabled"`
	IntegrationDisabledReason string `json:"integrationDisabledReason"`
	InvocationCount           string `json:"invocationCount"`
}

ConnectedAccount represents a composio connected account.

Gotten from similar url to: https://backend.composio.dev/api/v1/connectedAccounts?user_uuid=default&showActiveOnly=true

type Integration

type Integration struct {
	Name string `json:"name"`
	ID   int    `json:"id"`
}

Integration represents a composio integration.

type Option

type Option func(*Composio)

Option is an option for the composio client.

WithLogger sets the logger for the composio client.

func WithBaseURL

func WithBaseURL(baseURL string) Option

WithBaseURL sets the base URL for the composio client.

func WithLogger

func WithLogger(logger *slog.Logger) Option

WithLogger sets the logger for the composio client.

type Runner

type Runner interface {
	Run(ctx context.Context,
		user ConnectedAccount,
		response pegwings.ChatCompletionResponse) (
		[]pegwings.ChatCompletionMessage, error)
}

Runner is an interface for composio run.

type Tool

type Tool struct {
	// Name is the name of the tool returned by the composio api.
	Name string `json:"name"`
	// Enum is the enum of the tool returned by the composio api.
	Enum string `json:"enum"`
	// Tags are the tags of the tool returned by the composio api.
	Tags []string `json:"tags"`
	Logo string `json:"logo"`
	// AppID is the app id of the tool returned by the composio api.
	AppID string `json:"appId"`
	// AppName is the app name of the tool returned by the composio
	// api.
	AppName string `json:"appName"`
	// DisplayName is the display name of the tool returned by the
	// composio api.
	DisplayName string `json:"displayName"`
	// Description is the description of the tool returned by the
	// composio api.
	Description string `json:"description"`
	// Parameters are the parameters of the tool returned by the
	// composio api.
	Parameters tools.FunctionParameters `json:"parameters"`
	// Response is the response of the tool returned by the
	// composio api.
	Response struct {
		// Properties are the properties of the response
		// returned by the composio api.
		Properties struct {
			// Data is the data of the response returned by
			// the composio api.
			Data struct {
				// Title is the title of the data in the
				// response returned by the composio
				// api.
				Title string `json:"title"`
				// Type is the type of the data in the
				// response returned by the composio
				// api.
				Type string `json:"type"`
			} `json:"data"`
			// Successful is the successful response of the
			// composio api.
			Successful struct {
				// Description is the description of the
				// successful response of the composio
				// api.
				Description string `json:"description"`
				// Title is the title of the successful
				// response of the composio api.
				Title string `json:"title"`
				// Type is the type of the successful
				// response of the composio api.
				Type string `json:"type"`
			} `json:"successful"`
			Error struct {
				AnyOf []struct {
					Type string `json:"type"`
				} `json:"anyOf"`
				Default     any    `json:"default"`
				Description string `json:"description"`
				Title       string `json:"title"`
			} `json:"error"`
		} `json:"properties"`
		Required []string `json:"required"`
		Title    string   `json:"title"`
		Type     string   `json:"type"`
	} `json:"response"`
	Deprecated   bool   `json:"deprecated"`
	DisplayName0 string `json:"display_name"`
}

Tool represents a composio tool as returned by the api.

type ToolsOption

type ToolsOption func(*url.Values)

ToolsOption is an option for the tools request.

func WithApp

func WithApp(app string) ToolsOption

WithApp sets the app for the tools request.

func WithEntityID

func WithEntityID(entityID string) ToolsOption

WithEntityID sets the entity id for the tools request.

func WithTags

func WithTags(tags ...string) ToolsOption

WithTags sets the tags for the tools request.

func WithUseCase

func WithUseCase(useCase string) ToolsOption

WithUseCase sets the use case for the tools request.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL