@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/sashabaranov/go-openai"
|
||||
@@ -17,6 +18,11 @@ type OpenAIAdapter struct {
|
||||
|
||||
// NewOpenAIAdapter creates a new OpenAI LLM adapter
|
||||
func NewOpenAIAdapter(cfg Config) *OpenAIAdapter {
|
||||
if cfg.BaseURL != "" {
|
||||
clientConfig := openai.DefaultConfig(cfg.APIKey)
|
||||
clientConfig.BaseURL = strings.TrimRight(cfg.BaseURL, "/") + "/v1"
|
||||
return &OpenAIAdapter{client: openai.NewClientWithConfig(clientConfig), config: cfg}
|
||||
}
|
||||
return &OpenAIAdapter{
|
||||
client: openai.NewClient(cfg.APIKey),
|
||||
config: cfg,
|
||||
|
||||
Reference in New Issue
Block a user