mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-27 07:16:19 +09:00
refactor: unify SDK model factories into internal/models
Move CreateModel, BuildReasoningOptions, ReasoningBudgetTokens and related types from internal/agent to internal/models as NewSDKChatModel, SDKModelConfig, etc. This eliminates duplicate ClientType constants and centralises all Twilight AI SDK instance creation in a single package. NewSDKEmbeddingModel now accepts a clientType parameter and dispatches to the native Google embedding provider for google-generative-ai, instead of always using the OpenAI-compatible endpoint.
This commit is contained in:
@@ -35,6 +35,7 @@ type denseRuntime struct {
|
||||
|
||||
type denseModelSpec struct {
|
||||
modelID string
|
||||
clientType string
|
||||
baseURL string
|
||||
apiKey string
|
||||
dimensions int
|
||||
@@ -74,7 +75,7 @@ func newDenseRuntime(providerConfig map[string]any, queries *dbsqlc.Queries, cfg
|
||||
return nil, fmt.Errorf("dense runtime: %w", err)
|
||||
}
|
||||
|
||||
embedModel := models.NewSDKEmbeddingModel(spec.baseURL, spec.apiKey, spec.modelID, denseEmbedTimeout)
|
||||
embedModel := models.NewSDKEmbeddingModel(spec.clientType, spec.baseURL, spec.apiKey, spec.modelID, denseEmbedTimeout)
|
||||
|
||||
return &denseRuntime{
|
||||
qdrant: qClient,
|
||||
@@ -565,6 +566,7 @@ func resolveDenseEmbeddingModel(ctx context.Context, queries *dbsqlc.Queries, mo
|
||||
}
|
||||
return denseModelSpec{
|
||||
modelID: strings.TrimSpace(row.ModelID),
|
||||
clientType: strings.TrimSpace(provider.ClientType),
|
||||
baseURL: strings.TrimSpace(provider.BaseUrl),
|
||||
apiKey: strings.TrimSpace(provider.ApiKey),
|
||||
dimensions: *cfg.Dimensions,
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
|
||||
"github.com/memohai/memoh/internal/agent"
|
||||
adapters "github.com/memohai/memoh/internal/memory/adapters"
|
||||
"github.com/memohai/memoh/internal/models"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -42,7 +43,7 @@ func New(cfg Config) *Client {
|
||||
}
|
||||
|
||||
func (c *Client) model() *sdk.Model {
|
||||
return agent.CreateModel(agent.ModelConfig{
|
||||
return models.NewSDKChatModel(models.SDKModelConfig{
|
||||
ModelID: c.cfg.ModelID,
|
||||
ClientType: c.cfg.ClientType,
|
||||
APIKey: c.cfg.APIKey,
|
||||
|
||||
Reference in New Issue
Block a user