genai

package
v0.0.0-...-239384d Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: BSD-3-Clause, CC-BY-4.0 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 interface {
	GenerateText(context.Context, string) ([]string, error)
}

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) ReadJSON

func (es *Examples) ReadJSON(r io.Reader) error

func (Examples) WriteFiles

func (es Examples) WriteFiles(folder string) error

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 GeminiClient

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

func NewGeminiClient

func NewGeminiClient(ctx context.Context) (*GeminiClient, error)

func (*GeminiClient) GenerateText

func (c *GeminiClient) GenerateText(ctx context.Context, prompt string) ([]string, error)

type Input

type Input struct {
	// The path of the affected module to include in the summary.
	Module string
	// The original description (can be copied from a GHSA or CVE)
	// of the vulnerability.
	Description string
}

type Suggestion

type Suggestion struct {
	// A short summary of the vulnerability.
	Summary string
	// A re-written description of the vulnerability.
	Description string
}

func Suggest

func Suggest(ctx context.Context, c Client, in *Input) ([]*Suggestion, error)

Suggest uses generative AI to generate suggestions for vulnerability reports based on the input.

Directories

Path Synopsis
Command gen_examples generates and stores examples that can be used to create prompts / training inputs for Google's Generative AI APIs.
Command gen_examples generates and stores examples that can be used to create prompts / training inputs for Google's Generative AI APIs.

Jump to

Keyboard shortcuts

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