internal

package
v0.0.0-...-cbb887f Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Copyright 2025 Google LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecuteGcloudCommand

func ExecuteGcloudCommand(command string) (string, error)

ExecuteGcloudCommand executes a gcloud command and returns the output or an error.

func ExecuteKubectlCommand

func ExecuteKubectlCommand(command string) (string, error)

ExecuteKubectlCommand executes a kubectl command and returns the output or an error.

func Render

func Render(block Block) string

Render formats a Block for display in the terminal. It applies different styles based on the type of block (e.g., error, agent, user, tool).

func Repl

func Repl(ctx context.Context, client gollm.Client) error

Repl starts the REPL (Read-Eval-Print Loop) for the BubbleChat application. It initializes the chat client, sets up the conversation history, and starts the BubbleTea program to handle user input and display the conversation. It's expected that outside of initializing the client you will not need to do anything to have an interactive session.

Types

type Block

type Block struct {
	Text string
	Type BlockType
}

Block represents a single message block in the conversation. It can be a user message, an AI response, an error message, or a tool response.

func (*Block) String

func (b *Block) String() string

type BlockType

type BlockType int

BlockType defines the type of a block in the conversation.

const (
	// ErrorBlock indicates an error message.
	ErrorBlock BlockType = iota
	// AgentBlock indicates a message from the AI agent.
	AgentBlock
	// UserBlock indicates a message from the user.
	UserBlock
	// ToolBlock indicates a message from a tool.
	ToolBlock
)

type Document

type Document struct {
	History
	// contains filtered or unexported fields
}

Document also contains visual elements in addition to the conversation history datamodel.

func NewDoc

func NewDoc(context context.Context, client gollm.Client) *Document

func (*Document) HandleSend

func (doc *Document) HandleSend()

HandleSend processes the user input when the Enter key is pressed. It adds the user input as a new block in the conversation history and sends the message to the chat service.

func (*Document) Init

func (doc *Document) Init() tea.Cmd

Init initializes the text input model and returns a command to start blinking the cursor. This function is called by BubbleTea when the program starts.

func (*Document) Update

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

Update processes incoming messages and user input. This function is called by BubbleTea whenever there is a new message or user input.

func (*Document) View

func (doc *Document) View() string

View renders the current state of the document, including the conversation history. This function is called by BubbleTea to display the UI.

type History

type History struct {
	Blocks  []Block
	Chat    gollm.Chat
	Context context.Context
}

History represents the conversation history, which is a collection of blocks.

func NewHistory

func NewHistory(ctx context.Context, client gollm.Client, model string) *History

NewHistory creates a new conversation history with the given chat client and context.

func (*History) AddBlock

func (h *History) AddBlock(block Block)

func (*History) ChatLoop

func (h *History) ChatLoop(query string)

func (*History) ExecuteFunctionCall

func (h *History) ExecuteFunctionCall(fnCall gollm.FunctionCall) (string, error)

Jump to

Keyboard shortcuts

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