gemini

package
v1.18.6 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Overview

/ Package gemini provides the Gemini AI provider

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Candidate

type Candidate struct {
	Content      *CandidateContent `json:"content"`
	FinishReason string            `json:"finishReason"`
	Index        int               `json:"index"`
}

Candidate is the element of Response

type CandidateContent

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

CandidateContent is the content of Candidate

type CandidateSafetyRating

type CandidateSafetyRating struct {
	Category    string `json:"category"`
	Probability string `json:"probability"`
}

CandidateSafetyRating is the safetyRatings of Candidate

type Contents

type Contents struct {
	Role  string `json:"role"`
	Parts Parts  `json:"parts"`
}

Contents is the contents in RequestBody

type FunctionCall

type FunctionCall struct {
	Name string                 `json:"name"`
	Args map[string]interface{} `json:"args"`
}

FunctionCall is the functionCall of Part

type FunctionDeclaration

type FunctionDeclaration struct {
	Name        string              `json:"name"`
	Description string              `json:"description"`
	Parameters  *FunctionParameters `json:"parameters"`
}

FunctionDeclaration is the element of Tool

type FunctionParameters

type FunctionParameters struct {
	Type       string               `json:"type"`
	Properties map[string]*Property `json:"properties"`
	Required   []string             `json:"required"`
}

FunctionParameters is the parameters of FunctionDeclaration

type GeminiProvider

type GeminiProvider struct {
	APIKey string
}

GeminiProvider is the provider for Gemini

func NewProvider

func NewProvider(apiKey string) *GeminiProvider

NewProvider creates a new GeminiProvider

func (*GeminiProvider) GetChatCompletions

func (p *GeminiProvider) GetChatCompletions(userInstruction string, baseSystemMessage string, chainMessage ai.ChainMessage, md metadata.M, withTool bool) (*ai.InvokeResponse, error)

GetChatCompletions get chat completions for ai service

func (*GeminiProvider) Name

func (p *GeminiProvider) Name() string

Name returns the name of the provider

type Part

type Part struct {
	Text         string        `json:"text,omitempty"`
	FunctionCall *FunctionCall `json:"functionCall"`
}

Part is the element of CandidateContent

type Parts

type Parts struct {
	Text string `json:"text"`
}

Parts is the contents.parts in RequestBody

type PromptFeedback

type PromptFeedback struct {
	SafetyRatings []*SafetyRating `json:"safetyRatings"`
}

PromptFeedback is the feedback of Prompt

type Property

type Property struct {
	Type        string `json:"type"`
	Description string `json:"description"`
}

Property is the element of ParameterProperties

type RequestBody

type RequestBody struct {
	Contents Contents `json:"contents"`
	Tools    []Tool   `json:"tools"`
}

RequestBody is the request body

type Response

type Response struct {
	Candidates     []Candidate    `json:"candidates"`
	PromptFeedback PromptFeedback `json:"promptFeedback"`
}

Response is the response of the Gemini API

type SafetyRating

type SafetyRating struct {
	Category    string `json:"category"`
	Probability string `json:"probability"`
}

SafetyRating is the element of PromptFeedback

type Tool

type Tool struct {
	FunctionDeclarations []*FunctionDeclaration `json:"function_declarations"`
}

Tool is the element of tools in RequestBody

type UsageMetadata

type UsageMetadata struct {
	PromptTokenCount int `json:"promptTokenCount"`
	TotalTokenCount  int `json:"totalTokenCount"`
}

UsageMetadata is the token usage in Response

Jump to

Keyboard shortcuts

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