Skip to content

Commit

Permalink
improve docs
Browse files Browse the repository at this point in the history
  • Loading branch information
erik-balfe committed Jul 21, 2024
1 parent e086b3f commit fe4ed6b
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Brave Search API wrapper

A fully typed Brave Search API wrapper, providing easy access to web search, local POI search, and automatic polling for web search summary feature.
A fully typed Brave Search API wrapper, providing easy access to web search, local POI search, and automatic polling for AI generated web search summary feature.

## Installation

Expand Down
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@tyr/brave-search",
"version": "0.6.1",
"version": "0.6.2",
"exports": "./src/braveSearch.ts"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "brave-search",
"version": "0.6.1",
"version": "0.6.2",
"description": "A fully typed Brave Search API wrapper, providing easy access to web search, local POI search, and automatic polling for web search summary feature.",
"scripts": {
"build": "tsc",
Expand Down
14 changes: 2 additions & 12 deletions src/braveSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ const DEFAULT_POLLING_TIMEOUT = 20000;

import {
BraveSearchOptions,
LocalDescriptionsOptions,
LocalDescriptionsSearchApiResponse,
LocalPoiOptions,
LocalPoiSearchApiResponse,
SummarizerOptions,
SummarizerSearchApiResponse,
Expand Down Expand Up @@ -134,13 +132,11 @@ class BraveSearch {
/**
* Searches for local points of interest using the provided IDs and options.
* @param ids The IDs of the local points of interest.
* @param options Optional settings to configure the search behavior.
* @returns A promise that resolves to the search results.
*/
async localPoiSearch(ids: string[], options: LocalPoiOptions = {}): Promise<LocalPoiSearchApiResponse> {
async localPoiSearch(ids: string[]): Promise<LocalPoiSearchApiResponse> {
const params = new URLSearchParams({
ids: ids.join(","),
...this.formatOptions(options),
});

try {
Expand All @@ -159,16 +155,11 @@ class BraveSearch {
/**
* Retrieves descriptions for local points of interest using the provided IDs and options.
* @param ids The IDs of the local points of interest.
* @param options Optional settings to configure the search behavior.
* @returns A promise that resolves to the search results.
*/
async localDescriptionsSearch(
ids: string[],
options: LocalDescriptionsOptions = {},
): Promise<LocalDescriptionsSearchApiResponse> {
async localDescriptionsSearch(ids: string[]): Promise<LocalDescriptionsSearchApiResponse> {
const params = new URLSearchParams({
ids: ids.join(","),
...this.formatOptions(options),
});

try {
Expand Down Expand Up @@ -269,7 +260,6 @@ export {
type BraveSearchOptions,
type LocalDescriptionsOptions,

Check failure on line 261 in src/braveSearch.ts

View workflow job for this annotation

GitHub Actions / publish-to-npm

Cannot find name 'LocalDescriptionsOptions'.
type LocalDescriptionsSearchApiResponse,
type LocalPoiOptions,
type LocalPoiSearchApiResponse,
type SummarizerOptions,
type SummarizerSearchApiResponse,
Expand Down
28 changes: 19 additions & 9 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
*/
export type ResultFilter = string;

/**
* Options for configuring a web search request to the Brave Search API.
*/
export interface BraveSearchOptions {
/**
* The search query country, where the results come from.
Expand Down Expand Up @@ -101,6 +104,9 @@ export interface BraveSearchOptions {
summary?: boolean;
}

/**
* Options for configuring a AI summary answer content.
*/
export interface SummarizerOptions {
/**
* Returns extra entities info with the summary response.
Expand All @@ -110,16 +116,11 @@ export interface SummarizerOptions {
entity_info?: boolean;
}

export interface LocalPoiOptions {
// Add any specific options for Local POI search if needed
}

export interface LocalDescriptionsOptions {
// Add any specific options for Local Descriptions search if needed
}

// Response types

/**
* Response from the Brave Search API with different types of a web search content.
*/
export interface WebSearchApiResponse {
/**
* The type of web search API result. The value is always "search".
Expand Down Expand Up @@ -172,12 +173,15 @@ export interface WebSearchApiResponse {
*/
web?: Search;
/**
* Summary key to get summary results for the query.
* Summary key to get AI generated summary results for the query. (Handled automatically when using getSummarizedAnswer method, that polls for summary right after web search response returned)
* @type {Summarizer}
*/
summarizer?: Summarizer;
}

/**
* Response from the Brave Search API with AI generated summary of search results.
*/
export interface SummarizerSearchApiResponse {
/**
* The type of summarizer search API result. The value is always "summarizer".
Expand Down Expand Up @@ -216,6 +220,9 @@ export interface SummarizerSearchApiResponse {
entities_infos?: { [key: string]: SummaryEntityInfo };
}

/**
* Response from the Brave Search API for a local points of interest (POI) search request.
*/
export interface LocalPoiSearchApiResponse {
/**
* The type of local POI search API result. The value is always "local_pois".
Expand All @@ -229,6 +236,9 @@ export interface LocalPoiSearchApiResponse {
results: LocationResult[];
}

/**
* Response from the Brave Search API with Location descriptions.
*/
export interface LocalDescriptionsSearchApiResponse {
/**
* The type of local description search API result. The value is always "local_descriptions".
Expand Down

0 comments on commit fe4ed6b

Please sign in to comment.