bhlquest

command module
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2023 License: MIT Imports: 4 Imported by: 0

README

BHLquest

BHLquest is an AI application designed to query the content of the Biodiversity Heritage Library. The application is local and does not depend on external services.

Installation

Ensure that your computer's Go version is up to date.

  1. Install and Run llmutil RESTful Interface

Follow instructions at llmutil documentation.

  1. Install Go Tools for bhlquest

Navigate to the root of the bhlquest project and execute:

make tools
go mod tidy
  1. Install bhlquest
make install

Usage

  1. Install Prerequisits and Create Database
  • Create bhlnames and bhlquest databases in PostgreSQL.
  • Download the bhlnames database dump.
  • Restore the bhlnames database:
zstd -dc bhlnames-xxxx-xx-xx.zst|pg_restore -d bhlnames
  • Install the BHL text corpus.
  • Install pgvector extension, which is necessary for storing vector data.
  1. Initial Run

First run wil create a configuration file, typically located at $HOME/.config/bhlquest.yaml:

bhlquest -V
  1. Edit bhlquest.yaml

Ensure that database settings, llmutil URL, directory which points to the BHL corpus settings accurately reflect their real values.

  1. Import and Embed a Subset of BHL data into Vectors
bhlquest init --classes 'Aves,Mammalia' --rebuild-db

# if init process was interrupted, it can be continued from the place it
# stopped. Make sure the `--classes` values are the same as before.
# Remove `--rebuild-db` flag to keep alreday saved data.

bhlquest init --classes 'Aves,Mammalia'

If no clases are specified, the process will include all BHL data.

It will take a while!

  1. Use bhlquest via Command Line or RESTful API
Command line Usage
bhlquest ask "What are the ecological niches of the Indigo Bunting?"
Starting RESTful API
bhlquest serve

With the default settings, the API description should be accessible.

Development

Auto-generating API Documentation

Install swag from the root of the project:

make tools

To update the documentation, execute:

swag init -g server.go -d ./internal/io/web

Run this command each time the docs are updated.

Generating a Client for a Specific Language

You can use the openapi-generator to create an API client in a language of your choice. For instance, to generate a Ruby client, run the following command from the project's root:

openapi-generator generate -i ./docs/swagger.yaml -g ruby -o ~/tmp/bhlquest --additional-properties gemName=bhlquest

Documentation

Overview

Copyright © 2023 Dmitry Mozzherin <dmozzherin@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Directories

Path Synopsis
Package docs Code generated by swaggo/swag.
Package docs Code generated by swaggo/swag.
internal
pkg

Jump to

Keyboard shortcuts

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