Documentation
¶
Index ¶
- Constants
- Variables
- func BuildAuthURL(redirectURI, state, codeChallenge string) string
- func ConvertGeminiSSEToNonStreaming(rawStream io.ReadCloser, modelName string) (io.ReadCloser, error)
- func GeneratePKCE() (verifier, challenge string, err error)
- func GetClientID() string
- func GetClientSecret() string
- func TranslateGeminiSSEToOpenAI(rawStream io.ReadCloser, modelName string) io.ReadCloser
- type Account
- type Provider
- func (p *Provider) ChatCompletion(ctx context.Context, req *providers.ChatRequest) (io.ReadCloser, bool, int, error)
- func (p *Provider) Embeddings(ctx context.Context, req *providers.EmbeddingRequest) (*providers.EmbeddingResponse, error)
- func (p *Provider) ID() string
- func (p *Provider) IsHealthy() bool
- func (p *Provider) Models(ctx context.Context) ([]providers.ModelInfo, error)
- func (p *Provider) NextAccount() (*Account, error)
- func (p *Provider) Type() string
Constants ¶
const ( AuthorizeURL = "https://accounts.google.com/o/oauth2/v2/auth" DefaultTokenURL = "https://oauth2.googleapis.com/token" UserInfoURL = "https://www.googleapis.com/oauth2/v1/userinfo" CloudCodeAPIBaseURL = "https://daily-cloudcode-pa.googleapis.com" FallbackCloudCodeURL = "https://cloudcode-pa.googleapis.com" )
Variables ¶
var Scopes = []string{
"https://www.googleapis.com/auth/cloud-platform",
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/userinfo.profile",
"https://www.googleapis.com/auth/cclog",
"https://www.googleapis.com/auth/experimentsandconfigs",
}
Functions ¶
func BuildAuthURL ¶
BuildAuthURL creates the Google OAuth authorization URL with PKCE
func ConvertGeminiSSEToNonStreaming ¶ added in v0.2.2
func ConvertGeminiSSEToNonStreaming(rawStream io.ReadCloser, modelName string) (io.ReadCloser, error)
ConvertGeminiSSEToNonStreaming aggregates a Gemini SSE stream into a standard OpenAI non-streaming JSON
func GeneratePKCE ¶
GeneratePKCE returns a random code verifier and its S256 code challenge
func GetClientID ¶
func GetClientID() string
func GetClientSecret ¶
func GetClientSecret() string
func TranslateGeminiSSEToOpenAI ¶
func TranslateGeminiSSEToOpenAI(rawStream io.ReadCloser, modelName string) io.ReadCloser
TranslateGeminiSSEToOpenAI wraps a raw Gemini SSE stream and emits standard OpenAI SSE lines
Types ¶
type Account ¶
type Account struct {
ID string `json:"id"`
Email string `json:"email"`
RefreshToken string `json:"refresh_token"`
AccessToken string `json:"access_token"`
ExpiresAt time.Time `json:"expires_at"`
ProjectID string `json:"project_id"`
TokenURL string `json:"token_url,omitempty"`
// contains filtered or unexported fields
}
func ExchangeCode ¶
ExchangeCode exchanges an authorization code for refresh & access tokens
func (*Account) DiscoverProjectID ¶
func (*Account) FetchUserInfo ¶
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
func NewProvider ¶
func (*Provider) ChatCompletion ¶
func (p *Provider) ChatCompletion(ctx context.Context, req *providers.ChatRequest) (io.ReadCloser, bool, int, error)
func (*Provider) Embeddings ¶ added in v0.2.0
func (p *Provider) Embeddings(ctx context.Context, req *providers.EmbeddingRequest) (*providers.EmbeddingResponse, error)