-
Notifications
You must be signed in to change notification settings - Fork 3.3k
feat(google books): Add google books integration #3210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| --- | ||
| title: Google Books | ||
| description: Search and retrieve book information | ||
| --- | ||
|
|
||
| import { BlockInfoCard } from "@/components/ui/block-info-card" | ||
|
|
||
| <BlockInfoCard | ||
| type="google_books" | ||
| color="#FFFFFF" | ||
| /> | ||
|
|
||
| ## Usage Instructions | ||
|
|
||
| Search for books using the Google Books API. Find volumes by title, author, ISBN, or keywords, and retrieve detailed information about specific books including descriptions, ratings, and publication details. | ||
|
|
||
|
|
||
|
|
||
| ## Tools | ||
|
|
||
| ### `google_books_volume_search` | ||
|
|
||
| Search for books using the Google Books API | ||
|
|
||
| #### Input | ||
|
|
||
| | Parameter | Type | Required | Description | | ||
| | --------- | ---- | -------- | ----------- | | ||
| | `apiKey` | string | Yes | Google Books API key | | ||
| | `query` | string | Yes | Search query. Supports special keywords: intitle:, inauthor:, inpublisher:, subject:, isbn: | | ||
| | `filter` | string | No | Filter results by availability \(partial, full, free-ebooks, paid-ebooks, ebooks\) | | ||
| | `printType` | string | No | Restrict to print type \(all, books, magazines\) | | ||
| | `orderBy` | string | No | Sort order \(relevance, newest\) | | ||
| | `startIndex` | number | No | Index of the first result to return \(for pagination\) | | ||
| | `maxResults` | number | No | Maximum number of results to return \(1-40\) | | ||
| | `langRestrict` | string | No | Restrict results to a specific language \(ISO 639-1 code\) | | ||
|
|
||
| #### Output | ||
|
|
||
| | Parameter | Type | Description | | ||
| | --------- | ---- | ----------- | | ||
| | `totalItems` | number | Total number of matching results | | ||
| | `volumes` | array | List of matching volumes | | ||
| | ↳ `id` | string | Volume ID | | ||
| | ↳ `title` | string | Book title | | ||
| | ↳ `subtitle` | string | Book subtitle | | ||
| | ↳ `authors` | array | List of authors | | ||
| | ↳ `publisher` | string | Publisher name | | ||
| | ↳ `publishedDate` | string | Publication date | | ||
| | ↳ `description` | string | Book description | | ||
| | ↳ `pageCount` | number | Number of pages | | ||
| | ↳ `categories` | array | Book categories | | ||
| | ↳ `averageRating` | number | Average rating \(1-5\) | | ||
| | ↳ `ratingsCount` | number | Number of ratings | | ||
| | ↳ `language` | string | Language code | | ||
| | ↳ `previewLink` | string | Link to preview on Google Books | | ||
| | ↳ `infoLink` | string | Link to info page | | ||
| | ↳ `thumbnailUrl` | string | Book cover thumbnail URL | | ||
| | ↳ `isbn10` | string | ISBN-10 identifier | | ||
| | ↳ `isbn13` | string | ISBN-13 identifier | | ||
|
|
||
| ### `google_books_volume_details` | ||
|
|
||
| Get detailed information about a specific book volume | ||
|
|
||
| #### Input | ||
|
|
||
| | Parameter | Type | Required | Description | | ||
| | --------- | ---- | -------- | ----------- | | ||
| | `apiKey` | string | Yes | Google Books API key | | ||
| | `volumeId` | string | Yes | The ID of the volume to retrieve | | ||
| | `projection` | string | No | Projection level \(full, lite\) | | ||
|
|
||
| #### Output | ||
|
|
||
| | Parameter | Type | Description | | ||
| | --------- | ---- | ----------- | | ||
| | `id` | string | Volume ID | | ||
| | `title` | string | Book title | | ||
| | `subtitle` | string | Book subtitle | | ||
| | `authors` | array | List of authors | | ||
| | `publisher` | string | Publisher name | | ||
| | `publishedDate` | string | Publication date | | ||
| | `description` | string | Book description | | ||
| | `pageCount` | number | Number of pages | | ||
| | `categories` | array | Book categories | | ||
| | `averageRating` | number | Average rating \(1-5\) | | ||
| | `ratingsCount` | number | Number of ratings | | ||
| | `language` | string | Language code | | ||
| | `previewLink` | string | Link to preview on Google Books | | ||
| | `infoLink` | string | Link to info page | | ||
| | `thumbnailUrl` | string | Book cover thumbnail URL | | ||
| | `isbn10` | string | ISBN-10 identifier | | ||
| | `isbn13` | string | ISBN-13 identifier | | ||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,6 +33,7 @@ | |
| "github", | ||
| "gitlab", | ||
| "gmail", | ||
| "google_books", | ||
| "google_calendar", | ||
| "google_docs", | ||
| "google_drive", | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,201 @@ | ||
| import { GoogleBooksIcon } from '@/components/icons' | ||
| import type { BlockConfig } from '@/blocks/types' | ||
| import { AuthMode } from '@/blocks/types' | ||
|
|
||
| export const GoogleBooksBlock: BlockConfig = { | ||
| type: 'google_books', | ||
| name: 'Google Books', | ||
| description: 'Search and retrieve book information', | ||
| authMode: AuthMode.ApiKey, | ||
| longDescription: | ||
| 'Search for books using the Google Books API. Find volumes by title, author, ISBN, or keywords, and retrieve detailed information about specific books including descriptions, ratings, and publication details.', | ||
| docsLink: 'https://docs.sim.ai/tools/google_books', | ||
| category: 'tools', | ||
| bgColor: '#E0E0E0', | ||
| icon: GoogleBooksIcon, | ||
|
|
||
| subBlocks: [ | ||
| { | ||
| id: 'operation', | ||
| title: 'Operation', | ||
| type: 'dropdown', | ||
| options: [ | ||
| { label: 'Search Volumes', id: 'volume_search' }, | ||
| { label: 'Get Volume Details', id: 'volume_details' }, | ||
| ], | ||
| value: () => 'volume_search', | ||
| }, | ||
| { | ||
| id: 'apiKey', | ||
| title: 'API Key', | ||
| type: 'short-input', | ||
| password: true, | ||
| placeholder: 'Enter your Google Books API key', | ||
| required: true, | ||
| }, | ||
| { | ||
| id: 'query', | ||
| title: 'Search Query', | ||
| type: 'short-input', | ||
| placeholder: 'e.g., intitle:harry potter inauthor:rowling', | ||
| condition: { field: 'operation', value: 'volume_search' }, | ||
| required: { field: 'operation', value: 'volume_search' }, | ||
| }, | ||
| { | ||
| id: 'filter', | ||
| title: 'Filter', | ||
| type: 'dropdown', | ||
| options: [ | ||
| { label: 'None', id: '' }, | ||
| { label: 'Partial Preview', id: 'partial' }, | ||
| { label: 'Full Preview', id: 'full' }, | ||
| { label: 'Free eBooks', id: 'free-ebooks' }, | ||
| { label: 'Paid eBooks', id: 'paid-ebooks' }, | ||
| { label: 'All eBooks', id: 'ebooks' }, | ||
| ], | ||
| condition: { field: 'operation', value: 'volume_search' }, | ||
| mode: 'advanced', | ||
| }, | ||
| { | ||
| id: 'printType', | ||
| title: 'Print Type', | ||
| type: 'dropdown', | ||
| options: [ | ||
| { label: 'All', id: 'all' }, | ||
| { label: 'Books', id: 'books' }, | ||
| { label: 'Magazines', id: 'magazines' }, | ||
| ], | ||
| value: () => 'all', | ||
| condition: { field: 'operation', value: 'volume_search' }, | ||
| mode: 'advanced', | ||
| }, | ||
| { | ||
| id: 'orderBy', | ||
| title: 'Order By', | ||
| type: 'dropdown', | ||
| options: [ | ||
| { label: 'Relevance', id: 'relevance' }, | ||
| { label: 'Newest', id: 'newest' }, | ||
| ], | ||
| value: () => 'relevance', | ||
| condition: { field: 'operation', value: 'volume_search' }, | ||
| mode: 'advanced', | ||
| }, | ||
| { | ||
| id: 'maxResults', | ||
| title: 'Max Results', | ||
| type: 'short-input', | ||
| placeholder: 'Number of results (1-40)', | ||
| condition: { field: 'operation', value: 'volume_search' }, | ||
| mode: 'advanced', | ||
| }, | ||
| { | ||
| id: 'startIndex', | ||
| title: 'Start Index', | ||
| type: 'short-input', | ||
| placeholder: 'Starting index for pagination', | ||
| condition: { field: 'operation', value: 'volume_search' }, | ||
| mode: 'advanced', | ||
| }, | ||
| { | ||
| id: 'langRestrict', | ||
| title: 'Language', | ||
| type: 'short-input', | ||
| placeholder: 'ISO 639-1 code (e.g., en, es, fr)', | ||
| condition: { field: 'operation', value: 'volume_search' }, | ||
| mode: 'advanced', | ||
| }, | ||
| { | ||
| id: 'volumeId', | ||
| title: 'Volume ID', | ||
| type: 'short-input', | ||
| placeholder: 'Google Books volume ID', | ||
| condition: { field: 'operation', value: 'volume_details' }, | ||
| required: { field: 'operation', value: 'volume_details' }, | ||
| }, | ||
| { | ||
| id: 'projection', | ||
| title: 'Projection', | ||
| type: 'dropdown', | ||
| options: [ | ||
| { label: 'Full', id: 'full' }, | ||
| { label: 'Lite', id: 'lite' }, | ||
| ], | ||
| value: () => 'full', | ||
| condition: { field: 'operation', value: 'volume_details' }, | ||
| mode: 'advanced', | ||
| }, | ||
waleedlatif1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ], | ||
|
|
||
| tools: { | ||
| access: ['google_books_volume_search', 'google_books_volume_details'], | ||
| config: { | ||
| tool: (params) => `google_books_${params.operation}`, | ||
| params: (params) => { | ||
| const { operation, ...rest } = params | ||
|
|
||
| let maxResults: number | undefined | ||
| if (params.maxResults) { | ||
| maxResults = Number.parseInt(params.maxResults, 10) | ||
| if (Number.isNaN(maxResults)) { | ||
| maxResults = undefined | ||
| } | ||
| } | ||
|
|
||
| let startIndex: number | undefined | ||
| if (params.startIndex) { | ||
| startIndex = Number.parseInt(params.startIndex, 10) | ||
| if (Number.isNaN(startIndex)) { | ||
| startIndex = undefined | ||
| } | ||
| } | ||
|
|
||
| return { | ||
| ...rest, | ||
| maxResults, | ||
| startIndex, | ||
| filter: params.filter || undefined, | ||
| printType: params.printType || undefined, | ||
| orderBy: params.orderBy || undefined, | ||
| projection: params.projection || undefined, | ||
| } | ||
| }, | ||
| }, | ||
| }, | ||
|
|
||
| inputs: { | ||
| operation: { type: 'string', description: 'Operation to perform' }, | ||
| apiKey: { type: 'string', description: 'Google Books API key' }, | ||
| query: { type: 'string', description: 'Search query' }, | ||
| filter: { type: 'string', description: 'Filter by availability' }, | ||
| printType: { type: 'string', description: 'Print type filter' }, | ||
| orderBy: { type: 'string', description: 'Sort order' }, | ||
| maxResults: { type: 'string', description: 'Maximum number of results' }, | ||
| startIndex: { type: 'string', description: 'Starting index for pagination' }, | ||
| langRestrict: { type: 'string', description: 'Language restriction' }, | ||
| volumeId: { type: 'string', description: 'Volume ID for details' }, | ||
| projection: { type: 'string', description: 'Projection level' }, | ||
| }, | ||
|
|
||
| outputs: { | ||
| totalItems: { type: 'number', description: 'Total number of matching results' }, | ||
| volumes: { type: 'json', description: 'List of matching volumes' }, | ||
| id: { type: 'string', description: 'Volume ID' }, | ||
| title: { type: 'string', description: 'Book title' }, | ||
| subtitle: { type: 'string', description: 'Book subtitle' }, | ||
| authors: { type: 'json', description: 'List of authors' }, | ||
| publisher: { type: 'string', description: 'Publisher name' }, | ||
| publishedDate: { type: 'string', description: 'Publication date' }, | ||
| description: { type: 'string', description: 'Book description' }, | ||
| pageCount: { type: 'number', description: 'Number of pages' }, | ||
| categories: { type: 'json', description: 'Book categories' }, | ||
| averageRating: { type: 'number', description: 'Average rating (1-5)' }, | ||
| ratingsCount: { type: 'number', description: 'Number of ratings' }, | ||
| language: { type: 'string', description: 'Language code' }, | ||
| previewLink: { type: 'string', description: 'Link to preview on Google Books' }, | ||
| infoLink: { type: 'string', description: 'Link to info page' }, | ||
| thumbnailUrl: { type: 'string', description: 'Book cover thumbnail URL' }, | ||
| isbn10: { type: 'string', description: 'ISBN-10 identifier' }, | ||
| isbn13: { type: 'string', description: 'ISBN-13 identifier' }, | ||
| }, | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export * from './types' | ||
| export { googleBooksVolumeDetailsTool } from './volume_details' | ||
| export { googleBooksVolumeSearchTool } from './volume_search' |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.