ai

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AIModel

type AIModel interface {
	// GetName returns the name of the AI model.
	GetName() string

	// GetAPIKey returns the API key for the AI model.
	GetAPIKey() string

	// GetCommand generates a command based on user input.
	GetCommand(prompt string) (*AIResponse, error)

	// SetContext sets the context for the AI model.
	SetContext(context string)

	// GetContext returns the context for the AI model.
	GetContext() string

	// SetCommandType sets the command type for the AI model.
	SetCommandType(commandType string)

	// GetCommandType returns the command type for the AI model.
	GetCommandType() string
}

AIModel defines the interface for different AI providers.

type AIResponse

type AIResponse struct {
	// Prompt is the user prompt that is sent to the AI.
	Prompt string

	// Command is the command that is suggested by the AI.
	Command string

	// Answer is the answer that is provided by the AI.
	Answer string

	// NextSteps are the suggested next steps that are provided by the AI.
	NextSteps []string
}

AIResponse holds the parsed command and suggested next steps.

type OpenAIModel

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

OpenAIModel is the OpenAI implementation of the AIModel interface.

func NewOpenAIModel

func NewOpenAIModel(commandType, context string) (*OpenAIModel, error)

func (*OpenAIModel) GetAPIKey

func (o *OpenAIModel) GetAPIKey() string

func (*OpenAIModel) GetAnswer

func (o *OpenAIModel) GetAnswer(prompt string) (*AIResponse, error)

func (*OpenAIModel) GetChatModel

func (o *OpenAIModel) GetChatModel() openai.ChatModel

func (*OpenAIModel) GetCommand

func (o *OpenAIModel) GetCommand(prompt string) (*AIResponse, error)

GetCommand calls the OpenAI API with tool calling (if supported), then falls back to text parsing if no tool call is made.

func (*OpenAIModel) GetCommandType

func (o *OpenAIModel) GetCommandType() string

func (*OpenAIModel) GetContext

func (o *OpenAIModel) GetContext() string

func (*OpenAIModel) GetName

func (o *OpenAIModel) GetName() string

func (*OpenAIModel) SetChatModel

func (o *OpenAIModel) SetChatModel(chatModel openai.ChatModel)

func (*OpenAIModel) SetCommandType

func (o *OpenAIModel) SetCommandType(commandType string)

func (*OpenAIModel) SetContext

func (o *OpenAIModel) SetContext(context string)

Jump to

Keyboard shortcuts

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