wikipedia

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: 12 Imported by: 0

Documentation

Overview

Package wikipedia contains an implementation of the tool interface with the wikipedia api.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnexpectedAPIResult = errors.New("unexpected result from wikipedia api")

ErrUnexpectedAPIResult is returned if the result form the wikipedia api is unexpected.

Functions

This section is empty.

Types

type Tool

type Tool struct {
	CallbacksHandler callbacks.Handler
	// The number of wikipedia pages to include in the result.
	TopK int
	// The number of characters to take from each page.
	DocMaxChars int
	// The language code to use.
	LanguageCode string
	// The user agent sent in the heder. See https://www.mediawiki.org/wiki/API:Etiquette.
	UserAgent string
}

Tool is an implementation of the tool interface that finds information using the wikipedia api.

func New

func New(userAgent string) Tool

New creates a new wikipedia tool to find wikipedia pages using the wikipedia api. TopK is set to 2, DocMaxChars is set to 2000 and the language code is set to "en".

func (Tool) Call

func (t Tool) Call(ctx context.Context, input string) (string, error)

Call uses the wikipedia api to find the top search results for the input and returns the first part of the documents combined.

func (Tool) Description

func (t Tool) Description() string

func (Tool) Name

func (t Tool) Name() string

Jump to

Keyboard shortcuts

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