client

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2025 License: MIT Imports: 15 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
	Email        string
	// contains filtered or unexported fields
}

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

func NewClient

func NewClient(httpClient *http.Client) *Client

NewClient creates a new CLI API client.

func (*Client) GetProjectList

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

func (*Client) SendMessageStream

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

SendMessageStream handles a single conversational turn, including tool calls.

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, error)

StreamAPIRequest handles making streaming requests to the CLI API endpoints.

type Content

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

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