search

package
v0.0.0-...-42283ad Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StripHTML

func StripHTML(s string) string

Helper function to strip html tags from article body

Types

type ArticleWithBody

type ArticleWithBody struct {
	*citygraph.Article
	Body string
}

New struct that embeds graph.Article and adds Body field

type Client

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

Struct for search client that contains OpenAI and Pinecone clients

func NewClient

func NewClient(openAIKey string, pineconeAPIKey string) (*Client, error)

Create Client instance

func (*Client) Generate

func (s *Client) Generate(articles []*citygraph.Article) error

Processes articles from Torontoverse Corpus and Indexes them in Pinecone Generate is method on Client struct defined in search.go

func (*Client) RunQuery

func (s *Client) RunQuery(query string) ([]*SearchResult, error)

RunQuery is a method of Client struct, that returns results using the SearchResult struct

type EmbeddingsRequest

type EmbeddingsRequest struct {
	Input []string `json:"input"`
	Model string   `json:"model"`
}

type FetchVectorsResponse

type FetchVectorsResponse struct {
	Vectors   map[string]*Vector `json:"vectors"`
	Namespace string             `json:"namespace"`
}

type QueryParams

type QueryParams struct {
	IncludeMetadata bool      `json:"includeMetadata"`
	Vector          []float32 `json:"vector"`
	TopK            int64     `json:"topK"`
}

type QueryResponse

type QueryResponse struct {
	Matches   []*QueryVector `json:"matches"`
	Namespace string         `json:"namespace"`
}

Data struct for query response

type QueryVector

type QueryVector struct {
	Vector
	Score float32 `json:"score"`
}

Matches are slices of QueryVector

type SearchResult

type SearchResult struct {
	Name    string
	ID      string
	Path    string
	Slug    string
	Score   float32
	PubDate string
}

Template for search results

type UpsertVectorsParams

type UpsertVectorsParams struct {
	Vectors   []*Vector `json:"vectors"`
	Namespace string    `json:"namespace"`
}

type UpsertVectorsResponse

type UpsertVectorsResponse struct {
	UpsertedCount int `json:"upsertedCount"`
}

type Vector

type Vector struct {
	ID       string
	Values   []float32              `json:"values"`
	Metadata map[string]interface{} `json:"metadata"` // changed "any" to "interface{}"
}

Jump to

Keyboard shortcuts

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