### Installing GroundX TypeScript Library Source: https://github.com/eyelevelai/groundx-typescript/blob/main/README.md Use npm to install the GroundX TypeScript library as a dependency in your project. ```sh npm i -s groundx ``` -------------------------------- ### Customizing Fetch Client - TypeScript Source: https://github.com/eyelevelai/groundx-typescript/blob/main/README.md Provides an example of how to inject a custom fetch implementation into the GroundXClient constructor, useful for unsupported environments. ```typescript import { GroundXClient } from "groundx"; const client = new GroundXClient({ ... fetcher: // provide your implementation here }); ``` -------------------------------- ### Getting List of Ingest Processes - GroundX TypeScript Source: https://github.com/eyelevelai/groundx-typescript/blob/main/reference.md Get a list of ingest process requests, sorted from most recent to least. ```typescript await client.documents.getProcesses(); ``` -------------------------------- ### Accessing Raw API Responses - TypeScript Source: https://github.com/eyelevelai/groundx-typescript/blob/main/README.md Shows how to use the `.asRaw()` method to get the full response object, including headers and the parsed body, after an API call. ```typescript const response = await client.ingest(...).asRaw(); console.log(response.headers['X-My-Header']); console.log(response.body); ``` -------------------------------- ### Getting Document by ID - GroundX TypeScript Source: https://github.com/eyelevelai/groundx-typescript/blob/main/reference.md Look up an existing document by documentId. ```typescript await client.documents.get("documentId"); ``` -------------------------------- ### Getting a Bucket by ID with GroundX Typescript Client Source: https://github.com/eyelevelai/groundx-typescript/blob/main/reference.md Look up a specific bucket by its bucketId. This operation requires the `bucketId` (number) and optional `Buckets.RequestOptions`. ```typescript await client.buckets.get(1); ``` -------------------------------- ### Getting Ingest Status by ID - GroundX TypeScript Source: https://github.com/eyelevelai/groundx-typescript/blob/main/reference.md Get the current status of an ingest process, initiated with documents.ingest_remote, documents.ingest_local, or documents.crawl_website, by specifying the processId. The processId is included in the response of the documents.ingest functions. ```typescript await client.documents.getProcessingStatusById("processId"); ``` -------------------------------- ### Getting Service Health Status in TypeScript Source: https://github.com/eyelevelai/groundx-typescript/blob/main/reference.md Looks up the current health status for a specified service using the client's health module. The status information is updated every 5 minutes. Requires the service name as a string and optional request options. ```typescript await client.health.get("search"); ``` -------------------------------- ### Instantiating Client and Ingesting Documents - TypeScript Source: https://github.com/eyelevelai/groundx-typescript/blob/main/README.md Demonstrates how to create a new GroundXClient instance using an API key and perform a basic document ingestion request. ```typescript import { GroundXClient } from "groundx"; const client = new GroundXClient({ apiKey: "YOUR_API_KEY" }); await client.ingest( [ { bucketId: 1234, fileName: "my_file1.txt", filePath: "https://my.source.url.com/file1.txt", fileType: "txt", }, ], ); ``` -------------------------------- ### Listing Buckets with GroundX Typescript Client Source: https://github.com/eyelevelai/groundx-typescript/blob/main/reference.md List all buckets within your GroundX account. This operation requires optional `GroundX.BucketsListRequest` and `Buckets.RequestOptions` parameters. ```typescript await client.buckets.list(); ``` -------------------------------- ### Creating a Bucket with GroundX Typescript Client Source: https://github.com/eyelevelai/groundx-typescript/blob/main/reference.md Create a new bucket. This operation requires a `GroundX.BucketCreateRequest` object, typically including the bucket name, and optional `Buckets.RequestOptions`. ```typescript await client.buckets.create({ name: "your_bucket_name" }); ``` -------------------------------- ### Creating a Group with GroundX Client (TypeScript) Source: https://github.com/eyelevelai/groundx-typescript/blob/main/reference.md Creates a new group using the GroundX client. Requires a group name in the request body. Optionally accepts request options. ```typescript await client.groups.create({ name: "your_group_name" }); ``` -------------------------------- ### Listing Groups with GroundX Typescript Client Source: https://github.com/eyelevelai/groundx-typescript/blob/main/reference.md List all groups within your GroundX account. This operation requires optional `GroundX.GroupsListRequest` and `Groups.RequestOptions` parameters. ```typescript await client.groups.list(); ``` -------------------------------- ### Importing GroundX Types - TypeScript Source: https://github.com/eyelevelai/groundx-typescript/blob/main/README.md Shows how to import the GroundX namespace to access request and response types as TypeScript interfaces. ```typescript import { GroundX } from "groundx"; const request: GroundX.Document = { ... }; ``` -------------------------------- ### Creating a Group with GroundX Typescript Client Source: https://github.com/eyelevelai/groundx-typescript/blob/main/reference.md Create a new group, a group being a collection of buckets which can be searched. This operation requires a `GroundX.GroupCreateRequest` object, typically including the group name, and optional `Groups.RequestOptions`. ```typescript await client.groups.create({}); ``` -------------------------------- ### Crawling Website Content with GroundX TypeScript Client Source: https://github.com/eyelevelai/groundx-typescript/blob/main/reference.md Crawl a publicly accessible website and ingest its content into a GroundX bucket. The process follows links recursively up to a specified depth or page cap. Requires a `GroundX.WebsiteCrawlRequest` object with website details like `bucketId`, `cap`, `depth`, `searchData`, and `sourceUrl`. The `sourceUrl` must include the protocol (http:// or https://). This endpoint is not supported for on-prem deployments. Optional `requestOptions` can be provided. ```typescript await client.documents.crawlWebsite({ websites: [ { bucketId: 1234, cap: 10, depth: 2, searchData: { key: "value" }, sourceUrl: "https://my.website.com" } ] }); ``` -------------------------------- ### Retrieving Customer Account Info with GroundX Client (TypeScript) Source: https://github.com/eyelevelai/groundx-typescript/blob/main/reference.md Fetches the account details linked to the API key used for authentication. This method requires no specific parameters other than optional request options. ```typescript await client.customer.get(); ``` -------------------------------- ### Aborting API Requests - TypeScript Source: https://github.com/eyelevelai/groundx-typescript/blob/main/README.md Illustrates how to use an `AbortController` and its signal to cancel an ongoing API request. ```typescript const controller = new AbortController(); const response = await client.ingest(..., { abortSignal: controller.signal }); controller.abort(); // aborts the request ``` -------------------------------- ### Ingesting Local Documents with GroundX TypeScript Client Source: https://github.com/eyelevelai/groundx-typescript/blob/main/reference.md Upload documents from a local file system into a GroundX bucket. Requires a `GroundX.DocumentLocalIngestRequest` object containing document `blob` and `metadata` including `bucketId`, `fileName`, and `fileType`. Optional `requestOptions` can be provided. Refer to the documentation for supported document types and ingest capacities. ```typescript await client.documents.ingestLocal([ { blob: "blob", metadata: { bucketId: 1234, fileName: "my_file1.txt", fileType: "txt" } } ]); ``` -------------------------------- ### Adding Custom Request Headers - TypeScript Source: https://github.com/eyelevelai/groundx-typescript/blob/main/README.md Demonstrates how to include additional custom headers in an API request using the `headers` option. ```typescript const response = await client.ingest(..., { headers: { 'X-Custom-Header': 'custom value' } }); ``` -------------------------------- ### Listing Documents with GroundX TypeScript Client Source: https://github.com/eyelevelai/groundx-typescript/blob/main/reference.md Retrieve a list of all documents currently stored on GroundX across all resources. Accepts an optional `GroundX.DocumentsListRequest` object for filtering or pagination, and optional `requestOptions`. ```typescript await client.documents.list(); ``` -------------------------------- ### Setting Request Timeout - TypeScript Source: https://github.com/eyelevelai/groundx-typescript/blob/main/README.md Shows how to configure the timeout duration for an API request using the `timeoutInSeconds` option. ```typescript const response = await client.ingest(..., { timeoutInSeconds: 30 // override timeout to 30s }); ``` -------------------------------- ### Ingesting Remote Documents with GroundX TypeScript Client Source: https://github.com/eyelevelai/groundx-typescript/blob/main/reference.md Ingest documents hosted on public URLs into a GroundX bucket. Requires a `GroundX.DocumentRemoteIngestRequest` object specifying document details like `bucketId`, `fileName`, `fileType`, and `sourceUrl`. Optional `requestOptions` can be provided. Refer to the documentation for supported document types and ingest capacities. ```typescript await client.documents.ingestRemote({ documents: [ { bucketId: 1234, fileName: "my_file1.txt", fileType: "txt", sourceUrl: "https://my.source.url.com/file1.txt" } ] }); ``` -------------------------------- ### Handling GroundX API Errors - TypeScript Source: https://github.com/eyelevelai/groundx-typescript/blob/main/README.md Illustrates how to catch and handle errors thrown by the GroundX client, specifically checking for instances of GroundXError to access status code, message, and body. ```typescript import { GroundXError } from "groundx"; try { await client.ingest(...); } catch (err) { if (err instanceof GroundXError) { console.log(err.statusCode); console.log(err.message); console.log(err.body); } } ``` -------------------------------- ### Adding a Bucket to a Group with GroundX Client (TypeScript) Source: https://github.com/eyelevelai/groundx-typescript/blob/main/reference.md Associates an existing bucket with an existing group. Requires both the groupId and bucketId. This creates a many-to-many relationship. Optionally accepts request options. ```typescript await client.groups.addBucket(1, 1); ``` -------------------------------- ### Listing Service Health Status with GroundX Client (TypeScript) Source: https://github.com/eyelevelai/groundx-typescript/blob/main/reference.md Retrieves the current health status for all services provided by the API. The status information is updated periodically. This method requires no parameters. ```typescript await client.health.list(); ``` -------------------------------- ### Searching Documents with GroundX Typescript Client Source: https://github.com/eyelevelai/groundx-typescript/blob/main/reference.md Search documents on GroundX for the most relevant information to a given query by documentId(s). The result of this query is typically used in one of two ways; `result.search.text` can be used to provide context to a language model, facilitating RAG, or `result.search.results` can be used to observe chunks of text which are relevant to the query, facilitating citation. Requires a `GroundX.SearchDocumentsRequest` object and optional `Search.RequestOptions`. ```typescript await client.search.documents({ nextToken: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9", query: "my search query", documentIds: ["docUUID1", "docUUID2"] }); ``` -------------------------------- ### Looking Up Documents by ID - GroundX TypeScript Source: https://github.com/eyelevelai/groundx-typescript/blob/main/reference.md Lookup the document(s) associated with a processId, bucketId, or groupId. ```typescript await client.documents.lookup(1); ``` -------------------------------- ### Configuring Request Retries - TypeScript Source: https://github.com/eyelevelai/groundx-typescript/blob/main/README.md Explains how to override the default retry behavior for a specific request by setting the `maxRetries` option. ```typescript const response = await client.ingest(..., { maxRetries: 0 // override maxRetries at the request level }); ``` -------------------------------- ### Searching Document Content - GroundX TypeScript Source: https://github.com/eyelevelai/groundx-typescript/blob/main/reference.md Search documents on GroundX for the most relevant information to a given query. The result can be used to provide context to a language model (RAG) or to observe relevant text chunks for citation. ```typescript await client.search.content(1, { nextToken: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9", query: "my search query" }); ``` -------------------------------- ### Updating a Bucket with GroundX Typescript Client Source: https://github.com/eyelevelai/groundx-typescript/blob/main/reference.md Rename a bucket. This operation requires the `bucketId` (number), a `GroundX.BucketUpdateRequest` object (including the new name), and optional `Buckets.RequestOptions`. ```typescript await client.buckets.update(1, { newName: "your_bucket_name" }); ``` -------------------------------- ### Updating a Group with GroundX Client (TypeScript) Source: https://github.com/eyelevelai/groundx-typescript/blob/main/reference.md Updates an existing group, primarily used for renaming. Requires the groupId and an update request object containing the new name. Optionally accepts request options. ```typescript await client.groups.update(1, { newName: "your_group_name" }); ``` -------------------------------- ### Deleting Document by ID - GroundX TypeScript Source: https://github.com/eyelevelai/groundx-typescript/blob/main/reference.md Delete a single document hosted on GroundX. ```typescript await client.documents.deleteById("documentId"); ``` -------------------------------- ### Retrieving a Group by ID with GroundX Client (TypeScript) Source: https://github.com/eyelevelai/groundx-typescript/blob/main/reference.md Retrieves a specific group by its unique identifier. The groupId parameter is required. Optionally accepts request options. ```typescript await client.groups.get(1); ``` -------------------------------- ### Deleting a Bucket by ID with GroundX Typescript Client Source: https://github.com/eyelevelai/groundx-typescript/blob/main/reference.md Delete a bucket. This operation requires the `bucketId` (number) of the bucket being deleted and optional `Buckets.RequestOptions`. ```typescript await client.buckets.delete(1); ``` -------------------------------- ### Deleting Documents with GroundX TypeScript Client Source: https://github.com/eyelevelai/groundx-typescript/blob/main/reference.md Delete multiple documents from GroundX. Requires a `GroundX.DocumentsDeleteRequest` object containing the `documentIds` to be deleted, typically as a comma-separated string or an array. Optional `requestOptions` can be provided. ```typescript await client.documents.delete({ documentIds: "123e4567-e89b-12d3-a456-426614174000,9f7c11a6-24b8-4d52-a9f3-90a7e70a9e49" }); ``` -------------------------------- ### Deleting a Group with GroundX Client (TypeScript) Source: https://github.com/eyelevelai/groundx-typescript/blob/main/reference.md Deletes a specific group using its unique identifier. The groupId parameter is required. Optionally accepts request options. ```typescript await client.groups.delete(1); ``` -------------------------------- ### Removing a Bucket from a Group with GroundX Client (TypeScript) Source: https://github.com/eyelevelai/groundx-typescript/blob/main/reference.md Removes the association between a specific bucket and a group. Requires both the groupId and bucketId. This operation does not delete the bucket or the group, only the link between them. Optionally accepts request options. ```typescript await client.groups.removeBucket(1, 1); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.