Documentation
¶
Index ¶
- type Client
- func (c *Client) APIRequest(ctx context.Context, endpoint string, body interface{}, stream bool) (io.ReadCloser, *ErrorMessage)
- func (c *Client) CheckCloudAPIIsEnabled() (bool, error)
- func (c *Client) GetEmail() string
- func (c *Client) GetGenerativeLanguageAPIKey() string
- func (c *Client) GetProjectID() string
- func (c *Client) GetProjectList(ctx context.Context) (*GCPProject, error)
- func (c *Client) IsAuto() bool
- func (c *Client) IsChecked() bool
- func (c *Client) IsModelQuotaExceeded(model string) bool
- func (c *Client) SaveTokenToFile() error
- func (c *Client) SendMessage(ctx context.Context, rawJson []byte, model string, systemInstruction *Content, ...) ([]byte, *ErrorMessage)
- func (c *Client) SendMessageStream(ctx context.Context, rawJson []byte, model string, systemInstruction *Content, ...) (<-chan []byte, <-chan *ErrorMessage)
- func (c *Client) SendRawMessage(ctx context.Context, rawJson []byte) ([]byte, *ErrorMessage)
- func (c *Client) SendRawMessageStream(ctx context.Context, rawJson []byte) (<-chan []byte, <-chan *ErrorMessage)
- func (c *Client) SetIsAuto(auto bool)
- func (c *Client) SetIsChecked(checked bool)
- func (c *Client) SetProjectID(projectID string)
- func (c *Client) SetupUser(ctx context.Context, email, projectID string) error
- type Content
- type ErrorMessage
- type FunctionCall
- type FunctionResponse
- type GCPProject
- type GCPProjectLabels
- type GCPProjectProjects
- type GenerateContentRequest
- type GenerationConfig
- type GenerationConfigThinkingConfig
- type InlineData
- type Part
- type ToolDeclaration
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client is the main client for interacting with the CLI API.
func NewClient ¶
func NewClient(httpClient *http.Client, ts *auth.TokenStorage, cfg *config.Config, glAPIKey ...string) *Client
NewClient creates a new CLI API client.
func (*Client) APIRequest ¶ added in v1.5.0
func (c *Client) APIRequest(ctx context.Context, endpoint string, body interface{}, stream bool) (io.ReadCloser, *ErrorMessage)
APIRequest handles making requests to the CLI API endpoints.
func (*Client) CheckCloudAPIIsEnabled ¶ added in v1.3.0
CheckCloudAPIIsEnabled sends a simple test request to the API to verify that the Cloud AI API is enabled for the user's project. It provides an activation URL if the API is disabled.
func (*Client) GetGenerativeLanguageAPIKey ¶ added in v1.7.0
func (*Client) GetProjectID ¶ added in v1.3.1
func (*Client) GetProjectList ¶
func (c *Client) GetProjectList(ctx context.Context) (*GCPProject, error)
GetProjectList fetches a list of Google Cloud projects accessible by the user.
func (*Client) IsModelQuotaExceeded ¶ added in v1.6.0
func (*Client) SaveTokenToFile ¶ added in v1.3.0
SaveTokenToFile serializes the client's current token storage to a JSON file. The filename is constructed from the user's email and project ID.
func (*Client) SendMessage ¶ added in v1.5.0
func (c *Client) SendMessage(ctx context.Context, rawJson []byte, model string, systemInstruction *Content, contents []Content, tools []ToolDeclaration) ([]byte, *ErrorMessage)
SendMessage handles a single conversational turn, including tool calls.
func (*Client) SendMessageStream ¶
func (c *Client) SendMessageStream(ctx context.Context, rawJson []byte, model string, systemInstruction *Content, contents []Content, tools []ToolDeclaration) (<-chan []byte, <-chan *ErrorMessage)
SendMessageStream handles a single conversational turn, including tool calls.
func (*Client) SendRawMessage ¶ added in v1.8.0
SendRawMessage handles a single conversational turn, including tool calls.
func (*Client) SendRawMessageStream ¶ added in v1.8.0
func (c *Client) SendRawMessageStream(ctx context.Context, rawJson []byte) (<-chan []byte, <-chan *ErrorMessage)
SendRawMessageStream handles a single conversational turn, including tool calls.
func (*Client) SetIsChecked ¶ added in v1.3.0
func (*Client) SetProjectID ¶ added in v1.3.0
type ErrorMessage ¶ added in v1.2.0
ErrorMessage encapsulates an error with an associated HTTP status code.
type FunctionCall ¶
FunctionCall represents a tool call requested by the model, including the function name and its arguments.
type FunctionResponse ¶
type FunctionResponse struct { Name string `json:"name"` Response map[string]interface{} `json:"response"` }
FunctionResponse represents the result of a tool execution, sent back to the model.
type GCPProject ¶
type GCPProject struct {
Projects []GCPProjectProjects `json:"projects"`
}
GCPProject represents the response structure for a Google Cloud project list request.
type GCPProjectLabels ¶
type GCPProjectLabels struct {
GenerativeLanguage string `json:"generative-language"`
}
GCPProjectLabels defines the labels associated with a GCP project.
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"` }
GCPProjectProjects contains details about a single Google Cloud project.
type GenerateContentRequest ¶
type GenerateContentRequest struct { SystemInstruction *Content `json:"systemInstruction,omitempty"` Contents []Content `json:"contents"` Tools []ToolDeclaration `json:"tools,omitempty"` GenerationConfig `json:"generationConfig"` }
GenerateContentRequest is the top-level request structure 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 parameters that control the model's generation behavior.
type GenerationConfigThinkingConfig ¶
type GenerationConfigThinkingConfig struct { // IncludeThoughts determines whether the model should output its reasoning process. IncludeThoughts bool `json:"include_thoughts,omitempty"` }
GenerationConfigThinkingConfig specifies configuration for the model's "thinking" process.
type InlineData ¶
type InlineData struct { MimeType string `json:"mime_type,omitempty"` Data string `json:"data,omitempty"` }
InlineData represents base64-encoded data with its MIME type.
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 distinct piece of content within a message, which can be text, inline data (like an image), a function call, or a function response.
type ToolDeclaration ¶
type ToolDeclaration struct {
FunctionDeclarations []interface{} `json:"functionDeclarations"`
}
ToolDeclaration defines the structure for declaring tools (like functions) that the model can call.