Refactor: modularize and streamline LLM providers and utility functions

- Migrate `compress_image.go` to `internal/imageutil` for better encapsulation.
- Reorganize LLM provider implementations into distinct packages (`google`, `openai`, and `anthropic`).
- Replace `go_llm` package name with `llm`.
- Refactor internal APIs for improved clarity, including renaming `anthropic` to `anthropicImpl` and `google` to `googleImpl`.
- Add helper methods and restructure message handling for better separation of concerns.
This commit is contained in:
2026-01-24 15:40:38 -05:00
parent be99af3597
commit bf7c86ab2a
18 changed files with 411 additions and 350 deletions

View File

@@ -1,17 +1,20 @@
package go_llm
import (
"github.com/openai/openai-go"
)
type rawAble interface {
toRaw() map[string]any
fromRaw(raw map[string]any) Input
}
package llm
// Input is the interface for conversation inputs.
// Types that implement this interface can be part of a conversation:
// Message, ToolCall, ToolCallResponse, and ResponseChoice.
type Input interface {
toChatCompletionMessages(model string) []openai.ChatCompletionMessageParamUnion
// isInput is a marker method to ensure only valid types implement this interface.
isInput()
}
// Implement Input interface for all valid input types.
func (Message) isInput() {}
func (ToolCall) isInput() {}
func (ToolCallResponse) isInput() {}
func (ResponseChoice) isInput() {}
// Request represents a request to a language model.
type Request struct {
Conversation []Input
Messages []Message