mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-25 07:00:48 +09:00
64378d29ed
* feat(web): add provider oauth management ui * feat: add OAuth callback support on port 1455 * feat: enhance reasoning effort options and support for OpenAI Codex OAuth * feat: update twilight-ai dependency to v0.3.4 * refactor: promote openai-codex to first-class client_type, remove auth_type Replace the previous openai-responses + metadata auth_type=openai-codex-oauth combo with a dedicated openai-codex client_type. OAuth requirement is now determined solely by client_type, eliminating the auth_type concept from the LLM provider domain entirely. - Add openai-codex to DB CHECK constraint (migration 0047) with data migration - Add ClientTypeOpenAICodex constant and dedicated SDK/probe branches - Remove AuthType from SDKModelConfig, ModelCredentials, TriggerConfig, etc. - Simplify supportsOAuth to check client_type == openai-codex - Add conf/providers/codex.yaml preset with Codex catalog models - Frontend: replace auth_type selector with client_type-driven OAuth UI --------- Co-authored-by: Acbox <acbox0328@gmail.com>
47 lines
1.4 KiB
Go
47 lines
1.4 KiB
Go
package models
|
|
|
|
import (
|
|
"net/http"
|
|
"time"
|
|
|
|
googleembedding "github.com/memohai/twilight-ai/provider/google/embedding"
|
|
openaiembedding "github.com/memohai/twilight-ai/provider/openai/embedding"
|
|
sdk "github.com/memohai/twilight-ai/sdk"
|
|
)
|
|
|
|
// NewSDKEmbeddingModel creates a Twilight AI SDK EmbeddingModel for the given
|
|
// provider configuration. It dispatches to the native Google embedding provider
|
|
// when clientType is "google-generative-ai", and falls back to the
|
|
// OpenAI-compatible /embeddings endpoint for all other provider types.
|
|
func NewSDKEmbeddingModel(clientType, baseURL, apiKey, modelID string, timeout time.Duration, httpClient *http.Client) *sdk.EmbeddingModel {
|
|
if timeout <= 0 {
|
|
timeout = 30 * time.Second
|
|
}
|
|
if httpClient == nil {
|
|
httpClient = &http.Client{Timeout: timeout}
|
|
}
|
|
|
|
switch ClientType(clientType) {
|
|
case ClientTypeGoogleGenerativeAI:
|
|
opts := []googleembedding.Option{
|
|
googleembedding.WithAPIKey(apiKey),
|
|
googleembedding.WithHTTPClient(httpClient),
|
|
}
|
|
if baseURL != "" {
|
|
opts = append(opts, googleembedding.WithBaseURL(baseURL))
|
|
}
|
|
p := googleembedding.New(opts...)
|
|
return p.EmbeddingModel(modelID)
|
|
default:
|
|
opts := []openaiembedding.Option{
|
|
openaiembedding.WithAPIKey(apiKey),
|
|
openaiembedding.WithHTTPClient(httpClient),
|
|
}
|
|
if baseURL != "" {
|
|
opts = append(opts, openaiembedding.WithBaseURL(baseURL))
|
|
}
|
|
p := openaiembedding.New(opts...)
|
|
return p.EmbeddingModel(modelID)
|
|
}
|
|
}
|