2026-02-04 11:06:13 +00:00
|
|
|
// PicoClaw - Ultra-lightweight personal AI agent
|
|
|
|
|
// Inspired by and based on nanobot: https://github.com/HKUDS/nanobot
|
|
|
|
|
// License: MIT
|
|
|
|
|
//
|
|
|
|
|
// Copyright (c) 2026 PicoClaw contributors
|
|
|
|
|
|
|
|
|
|
package providers
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
2026-02-18 14:26:35 +00:00
|
|
|
|
2026-02-15 13:04:07 +00:00
|
|
|
"github.com/sipeed/picoclaw/pkg/providers/openai_compat"
|
2026-02-04 11:06:13 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type HTTPProvider struct {
|
2026-02-15 13:04:07 +00:00
|
|
|
delegate *openai_compat.Provider
|
2026-02-04 11:06:13 +00:00
|
|
|
}
|
|
|
|
|
|
2026-02-12 10:27:49 +00:00
|
|
|
func NewHTTPProvider(apiKey, apiBase, proxy string) *HTTPProvider {
|
2026-02-04 11:06:13 +00:00
|
|
|
return &HTTPProvider{
|
2026-02-17 16:13:10 +00:00
|
|
|
delegate: openai_compat.NewProvider(apiKey, apiBase, proxy),
|
2026-02-04 11:06:13 +00:00
|
|
|
}
|
2026-02-18 17:43:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NewHTTPProviderWithMaxTokensField(apiKey, apiBase, proxy, maxTokensField string) *HTTPProvider {
|
2026-02-04 11:06:13 +00:00
|
|
|
return &HTTPProvider{
|
2026-02-19 16:11:46 +00:00
|
|
|
delegate: openai_compat.NewProviderWithMaxTokensField(apiKey, apiBase, proxy, maxTokensField),
|
2026-02-04 11:06:13 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-20 18:03:11 +00:00
|
|
|
func (p *HTTPProvider) Chat(
|
|
|
|
|
ctx context.Context,
|
|
|
|
|
messages []Message,
|
|
|
|
|
tools []ToolDefinition,
|
|
|
|
|
model string,
|
|
|
|
|
options map[string]any,
|
|
|
|
|
) (*LLMResponse, error) {
|
2026-02-17 16:13:10 +00:00
|
|
|
return p.delegate.Chat(ctx, messages, tools, model, options)
|
2026-02-04 11:06:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p *HTTPProvider) GetDefaultModel() string {
|
|
|
|
|
return ""
|
|
|
|
|
}
|