These scripts demonstrate the supported public API. They use the local library checkout, so run them from the repository root after installing the development dependencies:
bundle installbasic_usage.rb— default-provider generation, embeddings, health checks, provider selection, and custom configuration.custom_prompts.rb— system prompts and no-context/with-context templates.custom_contexts.rb— explicit context types, field matching, formatting, and embedding field selection.vector_search.rb—Prescient::Pgvector::StorePostgreSQL/pgvector storage and similarity search.rest_api.ru— a tiny Rack-compatible application that mountsPrescient::APIand lists its endpoints at/, including the bounded agent and search-generation routes.web_search.rb— explicit SearXNG tool invocation with normalized JSON output.
The same web_search capability can use SearchApi instead of SearXNG when the
tool is configured with type: searchapi and SEARCHAPI_API_KEY.
Run the REST API example with a Rack server such as rackup:
BUNDLE_WITH=rack_example bundle install
PRESCIENT_API_TOKEN=change-me BUNDLE_WITH=rack_example \
bundle exec rackup -s puma examples/rest_api.ru
curl http://localhost:9292/The endpoint catalog includes POST /v1/search/generate. With a configured
SearXNG tool and AI provider, call it explicitly to feed search results into
generation:
curl -X POST http://localhost:9292/v1/search/generate \
-H 'Authorization: Bearer change-me' \
-H 'Content-Type: application/json' \
-d '{"query":"Ruby HTTP clients","provider":"openai","limit":5}'Running bundle exec ruby examples/rest_api.ru directly prints the same
endpoint catalog without starting a server.
The example does not add Rack as a Prescient runtime dependency; it only uses
the Rack-compatible call interface provided by Prescient::API.
The first three examples use Ollama by default. Start Ollama and pull the current local models before running them:
docker compose up -d ollama
docker compose run --rm ollama-init
bundle exec ruby examples/basic_usage.rbThe vector-search example additionally requires PostgreSQL with pgvector:
docker compose up -d postgres ollama
docker compose run --rm ollama-init
DB_HOST=localhost bundle exec ruby examples/vector_search.rbCloud-provider examples require the corresponding credentials and provider configuration. The scripts are demonstrations rather than isolated test fixtures; they may make real provider requests when the configured service is available.
The web-search example requires a reachable SearXNG instance:
docker compose up -d searxng
SEARXNG_URL=http://localhost:8080 bundle exec ruby examples/web_search.rb "Ruby HTTP clients"The example returns normalized search results directly by default. Opt in to
feeding those results to the configured AI provider with --generate:
SEARXNG_URL=http://localhost:8080 PRESCIENT_PROVIDER=openai \
bundle exec ruby examples/web_search.rb --generate "Ruby HTTP clients"Omit --generate to keep the search results direct. PRESCIENT_PROVIDER is
only used with --generate and may be omitted when the default provider is
configured.
See the main README for configuration, fallback behavior, prompt templates, context exclusions, embeddings, and the public API. Rails applications can also use the integration guide, and PostgreSQL users should read the pgvector guide.