File size: 2,500 Bytes
584926e 3e5ab39 584926e 3e5ab39 584926e f3f3cbf 584926e 3e5ab39 584926e f3f3cbf 3e5ab39 584926e a64baa3 3e5ab39 584926e a64baa3 3e5ab39 a64baa3 9cc01d9 3e5ab39 649ddcc 9cc01d9 409fbf7 3e5ab39 649ddcc 9cc01d9 649ddcc 3e5ab39 649ddcc f3f3cbf 3e5ab39 c37b7ba | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | package executor
import (
"context"
"net/http"
"github.com/router-for-me/CLIProxyAPI/v6/internal/config"
cliproxyauth "github.com/router-for-me/CLIProxyAPI/v6/sdk/cliproxy/auth"
cliproxyexecutor "github.com/router-for-me/CLIProxyAPI/v6/sdk/cliproxy/executor"
)
// GeminiVertexExecutor is a compatibility wrapper over the refactored Vertex executor.
// Behavior is preserved while provider-specific logic lives in gemini_vertex_provider.go.
type GeminiVertexExecutor struct {
ref *GeminiVertexExecutorRefactored
}
// NewGeminiVertexExecutor creates a new Vertex AI Gemini executor instance.
func NewGeminiVertexExecutor(cfg *config.Config) *GeminiVertexExecutor {
return &GeminiVertexExecutor{ref: NewGeminiVertexExecutorRefactored(cfg)}
}
// Identifier returns the executor identifier.
func (e *GeminiVertexExecutor) Identifier() string { return e.ref.Identifier() }
// PrepareRequest injects Vertex credentials into the outgoing HTTP request.
func (e *GeminiVertexExecutor) PrepareRequest(req *http.Request, auth *cliproxyauth.Auth) error {
return e.ref.PrepareRequest(req, auth)
}
// HttpRequest injects Vertex credentials into the request and executes it.
func (e *GeminiVertexExecutor) HttpRequest(ctx context.Context, auth *cliproxyauth.Auth, req *http.Request) (*http.Response, error) {
return e.ref.HttpRequest(ctx, auth, req)
}
// Execute performs a non-streaming request to the Vertex AI API.
func (e *GeminiVertexExecutor) Execute(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, opts cliproxyexecutor.Options) (cliproxyexecutor.Response, error) {
return e.ref.Execute(ctx, auth, req, opts)
}
// ExecuteStream performs a streaming request to the Vertex AI API.
func (e *GeminiVertexExecutor) ExecuteStream(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, opts cliproxyexecutor.Options) (*cliproxyexecutor.StreamResult, error) {
return e.ref.ExecuteStream(ctx, auth, req, opts)
}
// CountTokens counts tokens for the given request using the Vertex AI API.
func (e *GeminiVertexExecutor) CountTokens(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, opts cliproxyexecutor.Options) (cliproxyexecutor.Response, error) {
return e.ref.CountTokens(ctx, auth, req, opts)
}
// Refresh refreshes the authentication credentials (no-op for Vertex).
func (e *GeminiVertexExecutor) Refresh(ctx context.Context, auth *cliproxyauth.Auth) (*cliproxyauth.Auth, error) {
return e.ref.Refresh(ctx, auth)
}
|