client

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2025 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	RequestMutex sync.Mutex
	// contains filtered or unexported fields
}

Client is the main client for interacting with the CLI API.

func NewClient

func NewClient(httpClient *http.Client, ts *auth.TokenStorage, cfg *config.Config) *Client

NewClient creates a new CLI API client.

func (*Client) CheckCloudAPIIsEnabled added in v1.3.0

func (c *Client) CheckCloudAPIIsEnabled() (bool, error)

func (*Client) GetEmail added in v1.3.1

func (c *Client) GetEmail() string

func (*Client) GetProjectID added in v1.3.1

func (c *Client) GetProjectID() string

func (*Client) GetProjectList

func (c *Client) GetProjectList(ctx context.Context) (*GCPProject, error)

func (*Client) IsAuto added in v1.3.0

func (c *Client) IsAuto() bool

func (*Client) IsChecked added in v1.3.0

func (c *Client) IsChecked() bool

func (*Client) SaveTokenToFile added in v1.3.0

func (c *Client) SaveTokenToFile() error

func (*Client) SendMessageStream

func (c *Client) SendMessageStream(ctx context.Context, rawJson []byte, model string, contents []Content, tools []ToolDeclaration) (<-chan []byte, <-chan *ErrorMessage)

SendMessageStream handles a single conversational turn, including tool calls.

func (*Client) SetIsAuto added in v1.3.0

func (c *Client) SetIsAuto(auto bool)

func (*Client) SetIsChecked added in v1.3.0

func (c *Client) SetIsChecked(checked bool)

func (*Client) SetProjectID added in v1.3.0

func (c *Client) SetProjectID(projectID string)

func (*Client) SetupUser

func (c *Client) SetupUser(ctx context.Context, email, projectID string) error

SetupUser performs the initial user onboarding and setup.

func (*Client) StreamAPIRequest

func (c *Client) StreamAPIRequest(ctx context.Context, endpoint string, body interface{}) (io.ReadCloser, *ErrorMessage)

StreamAPIRequest handles making streaming requests to the CLI API endpoints.

type Content

type Content struct {
	Role  string `json:"role"`
	Parts []Part `json:"parts"`
}

type ErrorMessage added in v1.2.0

type ErrorMessage struct {
	StatusCode int
	Error      error
}

type FunctionCall

type FunctionCall struct {
	Name string                 `json:"name"`
	Args map[string]interface{} `json:"args"`
}

FunctionCall represents a tool call requested by the model.

type FunctionResponse

type FunctionResponse struct {
	Name     string                 `json:"name"`
	Response map[string]interface{} `json:"response"`
}

FunctionResponse represents the result of a tool execution.

type GCPProject

type GCPProject struct {
	Projects []GCPProjectProjects `json:"projects"`
}

type GCPProjectLabels

type GCPProjectLabels struct {
	GenerativeLanguage string `json:"generative-language"`
}

type GCPProjectProjects

type GCPProjectProjects struct {
	ProjectNumber  string           `json:"projectNumber"`
	ProjectID      string           `json:"projectId"`
	LifecycleState string           `json:"lifecycleState"`
	Name           string           `json:"name"`
	Labels         GCPProjectLabels `json:"labels"`
	CreateTime     time.Time        `json:"createTime"`
}

type GenerateContentRequest

type GenerateContentRequest struct {
	Contents         []Content         `json:"contents"`
	Tools            []ToolDeclaration `json:"tools,omitempty"`
	GenerationConfig `json:"generationConfig"`
}

GenerateContentRequest is the request payload for the streamGenerateContent endpoint.

type GenerationConfig

type GenerationConfig struct {
	ThinkingConfig GenerationConfigThinkingConfig `json:"thinkingConfig,omitempty"`
	Temperature    float64                        `json:"temperature,omitempty"`
	TopP           float64                        `json:"topP,omitempty"`
	TopK           float64                        `json:"topK,omitempty"`
}

GenerationConfig defines model generation parameters.

type GenerationConfigThinkingConfig

type GenerationConfigThinkingConfig struct {
	IncludeThoughts bool `json:"include_thoughts,omitempty"`
}

type InlineData

type InlineData struct {
	MimeType string `json:"mime_type,omitempty"`
	Data     string `json:"data,omitempty"`
}

type Part

type Part struct {
	Text             string            `json:"text,omitempty"`
	InlineData       *InlineData       `json:"inlineData,omitempty"`
	FunctionCall     *FunctionCall     `json:"functionCall,omitempty"`
	FunctionResponse *FunctionResponse `json:"functionResponse,omitempty"`
}

Part represents a single part of a message's content.

type ToolDeclaration

type ToolDeclaration struct {
	FunctionDeclarations []interface{} `json:"functionDeclarations"`
}

ToolDeclaration is the structure for declaring tools to the API. For now, we'll assume a simple structure. A more complete implementation would mirror the OpenAPI schema definition.

Jump to

Keyboard shortcuts

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