openAIAssistantRunnable

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddMessageResponse

type AddMessageResponse struct {
	ID string `json:"id"`
}

type AgentExecutor

type AgentExecutor struct {
	Agent *Assistant
	Tools []tools.Tool
	// contains filtered or unexported fields
}

AgentExecutor is responsible for executing the agent with the provided tools

func NewAgentExecutor

func NewAgentExecutor(agent *Assistant, tools []tools.Tool) *AgentExecutor

NewAgentExecutor creates a new instance of AgentExecutor

func (*AgentExecutor) HandleToolsExecution

func (ae *AgentExecutor) HandleToolsExecution(threadID, runID string, toolCalls []ToolCall) error

HandleToolsExecution handles the execution of tools when required

func (*AgentExecutor) Run

func (ae *AgentExecutor) Run(input map[string]string) (string, error)

Run executes the agent with the provided input and returns the response

type Assistant

type Assistant struct {
	ID     string
	Name   string
	APIKey string
	Model  string
	Tools  []tools.Tool
}

func NewAssistant

func NewAssistant(name, instructions, model string, tools []tools.Tool, opts ...Option) (*Assistant, error)

NewAssistant inicializa um novo assistente, opcionalmente com um ID de assistente existente.

func (*Assistant) AddMessage

func (a *Assistant) AddMessage(threadID, role, content string) (string, error)

func (*Assistant) CreateRun

func (a *Assistant) CreateRun(threadID string) (string, error)

func (*Assistant) CreateThread

func (a *Assistant) CreateThread() (string, error)

func (*Assistant) CreateThreadAndRun

func (a *Assistant) CreateThreadAndRun(messages []Message) (string, error)

func (*Assistant) HandleRequiresAction

func (a *Assistant) HandleRequiresAction(threadID, runID string, toolCalls []ToolCall) error

func (*Assistant) RetrieveThreadMessages

func (a *Assistant) RetrieveThreadMessages(runID, threadID string) (string, error)

type CreateAssistantRequest

type CreateAssistantRequest struct {
	Instructions string      `json:"instructions"`
	Name         string      `json:"name"`
	Tools        []llms.Tool `json:"tools"`
	Model        string      `json:"model"`
}

type CreateAssistantResponse

type CreateAssistantResponse struct {
	ID           string      `json:"id"`
	Name         string      `json:"name"`
	Model        string      `json:"model"`
	Instructions string      `json:"instructions"`
	Tools        []llms.Tool `json:"tools"`
}

type CreateRunRequest

type CreateRunRequest struct {
	AssistantID  string `json:"assistant_id"`
	Instructions string `json:"instructions"`
}

type CreateRunResponse

type CreateRunResponse struct {
	ID             string `json:"id"`
	Status         string `json:"status"`
	RequiredAction struct {
		SubmitToolOutputs struct {
			ToolCalls []ToolCall `json:"tool_calls"`
		} `json:"submit_tool_outputs"`
	} `json:"required_action"`
}

type CreateThreadAndRunRequest added in v0.0.4

type CreateThreadAndRunRequest struct {
	AssistantID string `json:"assistant_id"`
	Thread      Thread `json:"thread"`
}

type CreateThreadResponse

type CreateThreadResponse struct {
	ID string `json:"id"`
}

type EchoTool

type EchoTool struct{}

func (EchoTool) Call

func (e EchoTool) Call(ctx context.Context, input string) (string, error)

func (EchoTool) Description

func (e EchoTool) Description() string

func (EchoTool) Name

func (e EchoTool) Name() string

type GetTheradAndRunResponse added in v0.0.5

type GetTheradAndRunResponse struct {
	ID             string        `json:"id"`
	Object         string        `json:"object"`
	CreatedAt      int           `json:"created_at"`
	AssistantId    string        `json:"assistant_id"`
	ThreadId       string        `json:"thread_id"`
	Status         string        `json:"status"`
	StartedAt      interface{}   `json:"started_at"`
	ExpiresAt      int           `json:"expires_at"`
	CancelledAt    interface{}   `json:"cancelled_at"`
	FailedAt       interface{}   `json:"failed_at"`
	CompletedAt    interface{}   `json:"completed_at"`
	RequiredAction interface{}   `json:"required_action"`
	LastError      interface{}   `json:"last_error"`
	Model          string        `json:"model"`
	Instructions   string        `json:"instructions"`
	Tools          []interface{} `json:"tools"`
	ToolResources  struct {
	} `json:"tool_resources"`
	Metadata struct {
	} `json:"metadata"`
	Temperature         float64     `json:"temperature"`
	TopP                float64     `json:"top_p"`
	MaxCompletionTokens interface{} `json:"max_completion_tokens"`
	MaxPromptTokens     interface{} `json:"max_prompt_tokens"`
	TruncationStrategy  struct {
		Type         string      `json:"type"`
		LastMessages interface{} `json:"last_messages"`
	} `json:"truncation_strategy"`
	IncompleteDetails interface{} `json:"incomplete_details"`
	Usage             interface{} `json:"usage"`
	ResponseFormat    struct {
		Type string `json:"type"`
	} `json:"response_format"`
	ToolChoice        string `json:"tool_choice"`
	ParallelToolCalls bool   `json:"parallel_tool_calls"`
}

type GetThreadMessagesResponse

type GetThreadMessagesResponse struct {
	Object string `json:"object"`
	Data   []struct {
		Id          string  `json:"id"`
		Object      string  `json:"object"`
		CreatedAt   int     `json:"created_at"`
		AssistantId *string `json:"assistant_id"`
		ThreadId    string  `json:"thread_id"`
		RunId       *string `json:"run_id"`
		Role        string  `json:"role"`
		Content     []struct {
			Type string `json:"type"`
			Text struct {
				Value       string        `json:"value"`
				Annotations []interface{} `json:"annotations"`
			} `json:"text"`
		} `json:"content"`
		Attachments []interface{} `json:"attachments"`
		Metadata    struct {
		} `json:"metadata"`
	} `json:"data"`
	FirstId string `json:"first_id"`
	LastId  string `json:"last_id"`
	HasMore bool   `json:"has_more"`
}

type Message added in v0.0.4

type Message struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

type Option

type Option func(*Assistant)

Option defines the type for functional options to configure the assistant.

func WithAssistantID

func WithAssistantID(id string) Option

WithAssistantID configures the assistant with an existing assistant ID.

type Thread added in v0.0.4

type Thread struct {
	Messages []Message `json:"messages"`
}

type ToolCall

type ToolCall struct {
	ID       string `json:"id"`
	Type     string `json:"type"`
	Function struct {
		Name      string `json:"name"`
		Arguments string `json:"arguments"`
	} `json:"function"`
}

type ToolConfig

type ToolConfig struct {
	Type     string                   `json:"type"`
	Function *llms.FunctionDefinition `json:"function,omitempty"`
}

ToolConfig is the configuration for a tool that can be used by the assistant.

Jump to

Keyboard shortcuts

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