bard

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2023 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const ModelBard = "bard"

Variables

This section is empty.

Functions

func ListModels

func ListModels() []string

Types

type Answer

type Answer struct {
	Content           string
	ConversationID    string
	ResponseID        string
	FactualityQueries []any
	TextQuery         string
	Choices           []Choice
	Links             []string
	Images            []any
	ProgramLang       string
	Code              string
	StatusCode        int
}

Answer represents the response from the Bard AI service. It contains the generated text content, conversation ID, response ID, factuality queries, original text query, and any choices provided.

func (*Answer) ToChatCompletionResponse

func (a *Answer) ToChatCompletionResponse() llm.ChatCompletionResponse

func (*Answer) ToChatCompletionStreamResponse

func (a *Answer) ToChatCompletionStreamResponse() llm.ChatCompletionStreamResponse

type Bard

type Bard struct {
	*llm.LLM
	// contains filtered or unexported fields
}

func New

func New(token string, dao llm.Dao, opts ...ClientOption) (*Bard, error)

func (*Bard) CreateConversation

func (b *Bard) CreateConversation(ctx context.Context, name string) (llm.Conversation, error)

func (*Bard) CreateMessage

func (b *Bard) CreateMessage(ctx context.Context, conversationId string, req llm.ChatCompletionRequest) (llm.Message, error)

func (*Bard) CreateMessageStream

func (b *Bard) CreateMessageStream(ctx context.Context, conversationId string, req llm.ChatCompletionRequest, respChan chan llm.ChatCompletionStreamResponse, errChan chan error)

type Choice

type Choice struct {
	// ID is a unique identifier for the choice.
	ID string
	// Content is the text content of the choice.
	Content string
}

Choice represents an alternative response option provided by Bard.

type Client

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

func NewClient

func NewClient(token string, opts ...ClientOption) (*Client, error)

func (*Client) Ask

func (c *Client) Ask(prompt, conversationID, responseID, choiceID string, reqID int) (*Answer, error)

func (*Client) CreateChatCompletion

func (c *Client) CreateChatCompletion(ctx context.Context, req llm.ChatCompletionRequest) (llm.ChatCompletionResponse, error)

func (*Client) CreateChatCompletionStream

func (c *Client) CreateChatCompletionStream(ctx context.Context, req llm.ChatCompletionRequest, dataChan chan llm.ChatCompletionStreamResponse, errChan chan error)

func (*Client) FirstAsk

func (c *Client) FirstAsk(prompt string) (*Answer, error)

func (*Client) ListModels

func (c *Client) ListModels() []string

type ClientOption

type ClientOption func(*Client)

func WithCookies

func WithCookies(cookies map[string]string) ClientOption

func WithTimeout

func WithTimeout(timeout time.Duration) ClientOption

Jump to

Keyboard shortcuts

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