Documentation
¶
Index ¶
- Constants
- Variables
- func GetModels() tea.Cmd
- func ProcessError(err error, modelID string)
- func SendChat(prompt string, chatContext string) tea.Cmd
- type ChatErrorMsg
- type ChatModel
- type ChatRequest
- type ChatResponse
- type ChatResponseMsg
- type ChatService
- type FoundationModelsMsg
- type InferenceConfig
- type Message
- type Model
- type TextContent
Constants ¶
const ( MinWidth = 80 MinHeight = 24 )
Variables ¶
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 ProcessError ¶
ProcessError is a helper function to handle errors from Bedrock invocation.
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.
type TextContent ¶
type TextContent struct {
Text string `json:"text"`
}
TextContent represents the structure of each content object.