cloudflareclient

package
v0.1.14 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2025 License: MIT Imports: 8 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 (
	RoleSystem    = "system"
	RoleTypeUser  = "user"
	RoleAssistant = "assistant"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Message string `json:"message"`
}

type Client

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

func NewClient

func NewClient(client httpClient, accountID, baseURL, token, modelName, embeddingModelName string) *Client

func (*Client) CreateEmbedding

func (c *Client) CreateEmbedding(ctx context.Context, texts *CreateEmbeddingRequest) (*CreateEmbeddingResponse, error)

CreateEmbedding creates an embedding from the given texts.

func (*Client) GenerateContent

func (c *Client) GenerateContent(ctx context.Context, request *GenerateContentRequest) (*GenerateContentResponse, error)

GenerateContent generates text based on the given prompts.

func (*Client) Summarize

func (c *Client) Summarize(ctx context.Context, inputText string, maxLength int) (*SummarizeResponse, error)

Summarize summarizes the given input text.

type CreateEmbeddingRequest

type CreateEmbeddingRequest struct {
	Text []string `json:"text"`
}

type CreateEmbeddingResponse

type CreateEmbeddingResponse struct {
	Result struct {
		Shape []int       `json:"shape"`
		Data  [][]float32 `json:"data"`
	} `json:"result"`
}

type GenerateContentRequest

type GenerateContentRequest struct {
	Messages []Message `json:"messages"`
	Stream   bool      `json:"stream"`

	// StreamingFunc is a function to be called for each chunk of a streaming response.
	// Return an error to stop streaming early.
	StreamingFunc func(ctx context.Context, chunk []byte) error `json:"-"`
}

type GenerateContentResponse

type GenerateContentResponse struct {
	Errors   []APIError `json:"errors"`
	Messages []string   `json:"messages"`
	Result   struct {
		Response string `json:"response"`
	} `json:"result"`
	Success bool `json:"success"`
}

type Message

type Message struct {
	Role    Role   `json:"role"`
	Content string `json:"content"`
}

type Role

type Role string

type StreamingResponse

type StreamingResponse struct {
	Response string `json:"response"`
	P        string `json:"p"`
}

type SummarizeRequest

type SummarizeRequest struct {
	InputText string `json:"input_text"`
	MaxLength int    `json:"max_length"`
}

type SummarizeResponse

type SummarizeResponse struct {
	Result struct {
		Summary string `json:"summary"`
	} `json:"result"`
	Success bool `json:"success"`
}

Jump to

Keyboard shortcuts

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