Documentation
¶
Index ¶
- Constants
- Variables
- func AccessAuthorized(next httprouter.Handle, accessKey string) httprouter.Handle
- func GetDocType(s string) int
- func IndexAuthorized(next httprouter.Handle, indexKey string) httprouter.Handle
- type App
- func (a *App) CheckFileExistence(ds *document.Service) func(http.ResponseWriter, *http.Request, httprouter.Params)
- func (a *App) DownloadFile() func(http.ResponseWriter, *http.Request, httprouter.Params)
- func (a *App) Index(ds *document.Service, ss *store.Service) func(http.ResponseWriter, *http.Request, httprouter.Params)
- func (a *App) Search(ds *document.Service, ss *store.Service) func(http.ResponseWriter, *http.Request, httprouter.Params)
- func (a *App) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (a *App) TikaParse(file io.Reader, filename string) (*shared.TikaResponse, error)
- type Cfg
- type ObjectStorageCfg
- type SearchResponse
Constants ¶
const RootFolder = "starship_documents"
RootFolder represents the root folder that documents for starship are stored on object storage TODO - have this configurable in an environment variable
Variables ¶
var MimeToDocType = map[string]int{ "text/plain": document.TypeMarkdown, "application/pdf": document.TypePDF, }
MimeToDocType translates a tika mimeType to a document type
Functions ¶
func AccessAuthorized ¶
func AccessAuthorized(next httprouter.Handle, accessKey string) httprouter.Handle
AccessAuthorized checks to see if an accessKey was supplied at app start and ensures the connecting client has provided it in the proper header
func IndexAuthorized ¶
func IndexAuthorized(next httprouter.Handle, indexKey string) httprouter.Handle
IndexAuthorized checks to see if an indexKey was supplied at app start and ensures the connecting client has provided it in the proper header
Types ¶
type App ¶
type App struct { DB *sqlx.DB HTTPClient *http.Client ObjectStorageEnabled bool Cfg // contains filtered or unexported fields }
App represents the application and configuration
func (*App) CheckFileExistence ¶
func (a *App) CheckFileExistence(ds *document.Service) func(http.ResponseWriter, *http.Request, httprouter.Params)
CheckFileExistence determines whether a file exists at the given path for an account
func (*App) DownloadFile ¶
func (a *App) DownloadFile() func(http.ResponseWriter, *http.Request, httprouter.Params)
DownloadFile handles downloading a file from object storage
func (*App) Index ¶
func (a *App) Index(ds *document.Service, ss *store.Service) func(http.ResponseWriter, *http.Request, httprouter.Params)
Index handles creating word embeddings from a multi-part/file upload and indexing it for search purposes
func (*App) Search ¶
func (a *App) Search(ds *document.Service, ss *store.Service) func(http.ResponseWriter, *http.Request, httprouter.Params)
Search performs a search on all documents with the given text
type Cfg ¶
type Cfg struct { ModelURL string ModelName string ModelVectorDims int TikaURL string StoragePath string IndexKey string AccessKey string ObjectStorageConfig ObjectStorageCfg }
Cfg represents the app config ModelVectorDims represents how many dimensions a spotify/annoy index should be be (size of sentence embedding returned from ml model)
type ObjectStorageCfg ¶
ObjectStorageCfg represents configuration passed for connecting to object storage
func (*ObjectStorageCfg) Enabled ¶
func (o *ObjectStorageCfg) Enabled() bool
Enabled checks if ObjectStorageCfg is configured properly
type SearchResponse ¶
type SearchResponse struct { Distances []float32 `json:"distances"` Documents []document.SearchResult `json:"documents"` }
SearchResponse is the response body from the search endpoint