2026-04-02 14:45:41 +00:00
|
|
|
package providers
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"cursor-api-proxy/internal/apitypes"
|
|
|
|
|
"cursor-api-proxy/internal/config"
|
|
|
|
|
"cursor-api-proxy/internal/providers/cursor"
|
|
|
|
|
"cursor-api-proxy/internal/providers/geminiweb"
|
|
|
|
|
"fmt"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type Provider interface {
|
|
|
|
|
Name() string
|
|
|
|
|
Close() error
|
|
|
|
|
Generate(ctx context.Context, model string, messages []apitypes.Message, tools []apitypes.Tool, cb func(apitypes.StreamChunk)) error
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NewProvider(cfg config.BridgeConfig) (Provider, error) {
|
|
|
|
|
providerType := cfg.Provider
|
|
|
|
|
if providerType == "" {
|
|
|
|
|
providerType = "cursor"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch providerType {
|
|
|
|
|
case "cursor":
|
|
|
|
|
return cursor.NewProvider(cfg), nil
|
|
|
|
|
case "gemini-web":
|
2026-04-02 17:20:42 +00:00
|
|
|
return geminiweb.NewPlaywrightProvider(cfg)
|
2026-04-02 14:45:41 +00:00
|
|
|
default:
|
|
|
|
|
return nil, fmt.Errorf("unknown provider: %s", providerType)
|
|
|
|
|
}
|
|
|
|
|
}
|