app

package
v0.0.0-...-6e2f12f Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2025 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinWidth  = 80
	MinHeight = 24
)

Variables

View Source
var (
	TitleStyle = lipgloss.NewStyle().
				Bold(true).
				Foreground(lipgloss.Color("205"))

	BorderStyle = lipgloss.NewStyle().
				Border(lipgloss.ThickBorder()).
				BorderForeground(lipgloss.Color("240")).
				Padding(0, 1)

	FocusedBorderStyle = lipgloss.NewStyle().
						Border(lipgloss.ThickBorder()).
						BorderForeground(lipgloss.Color("205")).
						Padding(0, 1)

	HelpStyle = lipgloss.NewStyle().
				Foreground(lipgloss.Color("241")).
				Italic(true)

	NoItemsStyle = lipgloss.NewStyle().Margin(1, 0)

	SpinnerStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("205"))

	// New Style for Focused "LoamIIIF" Title
	FocusedTitleStyle = lipgloss.NewStyle().
						Bold(true).
						Foreground(lipgloss.Color("206")).
						Underline(true) // Optional: Adds underline to indicate focus

	// AssistantStyle for Assistant messages
	AssistantStyle = lipgloss.NewStyle().
					Bold(true).
					Foreground(lipgloss.Color("42")) // Choose a distinct color for Assistant
)

Functions

func GetModels

func GetModels() tea.Cmd

GetModels sends a command to fetch foundation models.

func ProcessError

func ProcessError(err error, modelID string)

ProcessError is a helper function to handle errors from Bedrock invocation.

func SendChat

func SendChat(prompt string, chatContext string) tea.Cmd

SendChat sends a chat message with context and returns a command to handle it.

Types

type ChatErrorMsg

type ChatErrorMsg struct {
	Error error
}

ChatErrorMsg represents an error that occurred during chat invocation.

type ChatModel

type ChatModel struct {
	Viewport    viewport.Model
	Messages    []string
	TextArea    textarea.Model
	SenderStyle lipgloss.Style
	Err         error

	// New Field for Context
	Context string
}

ChatModel holds data for the chat feature.

func InitialChatModel

func InitialChatModel() ChatModel

InitialChatModel creates an initialized ChatModel.

type ChatRequest

type ChatRequest struct {
	InferenceConfig InferenceConfig `json:"inferenceConfig"`
	Messages        []Message       `json:"messages"`
}

ChatRequest represents the request payload for AWS Bedrock's chat model.

type ChatResponse

type ChatResponse struct {
	Output struct {
		Message struct {
			Content []struct {
				Text string `json:"text"`
			} `json:"content"`
			Role string `json:"role"`
		} `json:"message"`
	} `json:"output"`
}

ChatResponse represents the response from AWS Bedrock's chat model.

type ChatResponseMsg

type ChatResponseMsg struct {
	Response string
}

ChatResponseMsg represents a successful response from the chat model.

type ChatService

type ChatService struct {
	BedrockClient      *bedrockruntime.Client
	BedrockModelClient *bedrock.Client
}

ChatService encapsulates the AWS Bedrock Runtime and Bedrock clients.

func NewChatService

func NewChatService(profileName string) (*ChatService, error)

NewChatService initializes the ChatService with the Bedrock Runtime and Bedrock clients. It accepts an optional profile name. If profileName is empty, the default profile is used.

func (*ChatService) GetFoundationModels

func (cs *ChatService) GetFoundationModels() tea.Cmd

GetFoundationModels fetches the list of available foundation models.

func (*ChatService) SendChatCommand

func (cs *ChatService) SendChatCommand(prompt string, chatContext string) tea.Cmd

SendChatCommand creates a Bubble Tea command that sends the prompt and context to Bedrock's Claude and returns the response.

func (*ChatService) SendChatSync

func (cs *ChatService) SendChatSync(prompt string, chatContext string) (string, error)

SendChatSync sends a prompt with context to the chat model synchronously

type FoundationModelsMsg

type FoundationModelsMsg struct {
	Models []string
}

FoundationModelsMsg represents the list of foundation models retrieved.

type InferenceConfig

type InferenceConfig struct {
	MaxNewTokens int `json:"max_new_tokens"`
}

InferenceConfig represents the configuration for the inference.

type Message

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

Message represents a single message in the chat.

type Model

type Model struct {
	// Existing fields
	TextArea     textarea.Model
	List         list.Model
	Status       string
	Spinner      spinner.Model
	Loading      bool
	Mutex        sync.Mutex
	InList       bool
	Width        int
	ShowDetail   bool
	SelectedItem ui.Item

	// Stack for item slices (so you can go back)
	PrevItemsStack [][]list.Item

	// --- New Chat Fields ---
	ShowChat        bool // Are we currently showing the chat panel?
	Chat            ChatModel
	AvailableModels []string       // List of foundation models
	ModelViewport   viewport.Model // Scrollable viewport for foundation models
	Err             error
}

Model is the main application model.

func InitialModel

func InitialModel() *Model

InitialModel initializes the main Model.

func (*Model) Init

func (m *Model) Init() tea.Cmd

Init sets up any initial commands for the Bubble Tea program.

func (*Model) Update

func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update is the main update loop for the Bubble Tea program.

func (*Model) View

func (m *Model) View() string

type TextContent

type TextContent struct {
	Text string `json:"text"`
}

TextContent represents the structure of each content object.

Jump to

Keyboard shortcuts

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