gemini

package
v0.0.0-...-17cbd25 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 23 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const GeminiPayloadSize = 102

Variables

This section is empty.

Functions

func AccountPrefix

func AccountPrefix(authUser string) string

func BuildBody

func BuildBody(prompt string, modelID, thinkMode int, fileRefs []string, extra map[int]any, cfg config.Config) string

func BuildURL

func BuildURL(cfg config.Config, blOverride string) string

func CleanText

func CleanText(text string, strip bool) string

func ExtractResponseModel

func ExtractResponseModel(raw string) string

ExtractResponseModel reads the upstream UI model label at payload index 42. It does not inspect generated text or infer identity from a requested selector.

func ExtractResponseText

func ExtractResponseText(raw string) (string, error)

func ExtractTextsFromLine

func ExtractTextsFromLine(line string) []string

func FetchLatestBL

func FetchLatestBL(client Requester) (string, error)

func IsBardError

func IsBardError(raw string) (string, bool)

func SAPISIDHash

func SAPISIDHash(sapisid string) string

func SniffImageMime

func SniffImageMime(b []byte) string

Types

type Client

type Client struct {
	Cfg     config.Config
	HTTP    Requester
	Cookies *CookieCache
	Logf    func(format string, args ...any)
	// contains filtered or unexported fields
}

func NewClient

func NewClient(cfg config.Config) *Client

func (*Client) CurrentBL

func (c *Client) CurrentBL() string

func (*Client) Generate

func (c *Client) Generate(prompt string, modelID, thinkMode int, fileRefs []string, extra map[int]any) (string, error)

func (*Client) GenerateImage

func (c *Client) GenerateImage(prompt string, modelID, thinkMode int, fileRefs []string, extra map[int]any) ([]ImageData, error)

func (*Client) GenerateStream

func (c *Client) GenerateStream(prompt string, modelID, thinkMode int, fileRefs []string, extra map[int]any, emit func(string) error) error

func (*Client) GenerateStreamWithModel

func (c *Client) GenerateStreamWithModel(prompt string, modelID, thinkMode int, fileRefs []string, extra map[int]any, emit func(string, string) error) (string, error)

func (*Client) GenerateWithModel

func (c *Client) GenerateWithModel(prompt string, modelID, thinkMode int, fileRefs []string, extra map[int]any) (string, string, error)

func (*Client) SetBL

func (c *Client) SetBL(bl string)

func (*Client) UpdateBLIfNeeded

func (c *Client) UpdateBLIfNeeded() (string, bool, error)

type CookieCache

type CookieCache struct {
	// contains filtered or unexported fields
}

func NewCookieCache

func NewCookieCache(file string) *CookieCache

func (*CookieCache) Load

func (c *CookieCache) Load() (CookieInfo, error)

type CookieInfo

type CookieInfo struct {
	Cookie  string
	SAPISID string
}

type ImageData

type ImageData struct {
	Mime string
	Data []byte
}

func ExtractImagesFromResponse

func ExtractImagesFromResponse(raw string) []ImageData

type Requester

type Requester interface {
	Do(req *http.Request) (*http.Response, error)
}

type StreamParser

type StreamParser struct {
	// contains filtered or unexported fields
}

func NewStreamParser

func NewStreamParser() *StreamParser

func (*StreamParser) Feed

func (p *StreamParser) Feed(chunk string) ([]string, error)

func (*StreamParser) Model

func (p *StreamParser) Model() string

func (*StreamParser) ResetBuffer

func (p *StreamParser) ResetBuffer()

type UpstreamError

type UpstreamError struct {
	Status int
	Kind   string
	Msg    string
}

func (*UpstreamError) Error

func (e *UpstreamError) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL