Documentation ¶
Overview ¶
Package palmapi provides a client and utilities for interacting with the PaLM API (https://developers.generativeai.google/guide/palm_api_overview).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Citation ¶
type Citation struct {
Sources []Source `json:"citationSources,omitempty"`
}
See https://developers.generativeai.google/api/rest/generativelanguage/CitationMetadata
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewDefaultClient ¶
func NewDefaultClient() *Client
NewDefaultClient returns a new default client for the PaLM API that reads an API key from the environment variable "PALM_API_KEY".
func (*Client) GenerateText ¶
func (c *Client) GenerateText(prompt string) (*GenerateTextResponse, error)
GenerateText is a wrapper for the PaLM API "generateText" endpoint. See https://developers.generativeai.google/api/rest/generativelanguage/models/generateText.
type Example ¶
type Example struct { Input `json:"Input"` Suggestion `json:"Suggestion"` }
type Examples ¶
type Examples []*Example
Examples represents a list of input/output pairs to be used as examples to follow by the Suggest function. Can be used to create few-shot prompts or fine-tune a model.
func (Examples) WriteFiles ¶
WriteFiles writes the examples to the given folder in the following formats:
- <folder>/data/examples.json: a JSON array of the examples (used directly by the Suggest function)
- <folder>/data/examples.csv: a CSV-formatted list of each example, where the input and output are comma-separated JSON objects. Can be used as an input to a Makersuite data prompt.
- <folder>/data/prompt.txt: the prompt that will be used by Suggest (with placeholder data for the final input)
type GenerateTextRequest ¶
type GenerateTextRequest struct { Prompt TextPrompt `json:"prompt"` Temperature float32 `json:"temperature,omitempty"` CandidateCount int `json:"candidateCount,omitempty"` TopK int `json:"topK,omitempty"` TopP float32 `json:"topP,omitempty"` MaxOutputTokens int `json:"maxOutputTokens,omitempty"` StopSequences []string `json:"stopSequences,omitempty"` SafetySettings []SafetySetting `json:"safetySettings,omitempty"` }
See https://developers.generativeai.google/api/rest/generativelanguage/models/generateText#request-body
type GenerateTextResponse ¶
type GenerateTextResponse struct {
Candidates []TextCompletion `json:"candidates"`
}
See https://developers.generativeai.google/api/rest/generativelanguage/GenerateTextResponse
type SafetySetting ¶
type SafetySetting struct { Category string `json:"category,omitempty"` Threshold int `json:"threshold,omitempty"` }
See https://developers.generativeai.google/api/rest/generativelanguage/SafetySetting
type Source ¶
type Source struct { StartIndex int `json:"startIndex,omitempty"` EndIndex int `json:"endIndex,omitempty"` URI string `json:"uri,omitempty"` License string `json:"license,omitempty"` }
See https://developers.generativeai.google/api/rest/generativelanguage/CitationMetadata#CitationSource
type Suggestion ¶
type TextCompletion ¶
type TextPrompt ¶
type TextPrompt struct {
Text string `json:"text"`
}
See https://developers.generativeai.google/api/rest/generativelanguage/TextPrompt
Directories ¶
Path | Synopsis |
---|---|
Command gen_examples generates and stores examples that can be used to create prompts / training inputs for the PaLM API.
|
Command gen_examples generates and stores examples that can be used to create prompts / training inputs for the PaLM API. |