cloudflareclient

package
v1.0.12 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2024 License: MIT Imports: 8 Imported by: 0

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