The WetroCloud SDK provides an easy way to interact with the WetroCloud API, allowing developers to create collections, insert resources, and query data effortlessly.
npm install wetrocloud-sdk
import Wetrocloud from "wetrocloud-sdk";
const wetrocloud = new Wetrocloud({ apiKey: "your-api-key" });Creates a new collection.
collection_id: string- (Optional) The unique ID of the collection.
Promise<ICreateCollection | IErrorMessage>;import Wetrocloud from "wetrocloud-sdk";
const wetrocloud = new Wetrocloud();
const collection_id = 'unique_id'; //this is optional if not specified one would be generated for you.
const response = await wetrocloud.createCollection({ collection_id });
console.log("Creating Collection", response);Retrieves a list of available collections.
Promise<IListCollection[] | IErrorMessage>;import Wetrocloud from "wetrocloud-sdk";
const wetrocloud = new Wetrocloud();
const response = await wetrocloud.listCollections();
console.log("Lisiting Collections", response);Inserts a resource into a collection.
-
collection_id: string- The ID of the collection. -
resource: string- The resource to insert. -
type: string- The type of resource.
Promise<IInsertResourceCollection | IErrorMessage>;import Wetrocloud from "wetrocloud-sdk";
const wetrocloud = new Wetrocloud();
const response = await wetrocloud.insertResource({
collection_id: "<collection_id>",
resource: "https://medium.com/@AlexanderObregon/a-brief-history-of-artificial-intelligence-1656693721f9#:~:text=In%20this%20article%2C%20we%20explore,learning%20are%20breaking%20new%20ground.",
type: "web"
});
console.log("insert a resource", response);Queries resources from a collection.
-
collection_id: string- The ID of the collection. -
request_query: string- The query string. -
json_schema?: T | T[]- Optional JSON schema. -
json_schema_rules?: string- Optional JSON schema rules. -
model?: string- Optional model parameter. -
stream?: boolean- Optional. Determines whether the response should be streamed. Defaults tofalse.
Promise<IErrorMessage | IQueryResourceCollectionDynamic<T>>;import Wetrocloud from "wetrocloud-sdk";
const wetrocloud = new Wetrocloud();
const collectionId = '<collection_id>';
const query = 'What are the sales trends for Q1?';
const response = await wetrocloud.queryCollection({
collection_id: collectionId,
request_query: query,
});
console.log("Querying resource", response);Chat with a collection using message history.
-
collection_id: string- The ID of the collection. -
message: string- The message to send. -
chat_history: { "role": "user" | "system", "content": string }[]- Chat history. -
stream?: boolean- Optional. Determines whether the response should be streamed. Defaults tofalse.
Promise<IErrorMessage | IQueryResourceCollectionDynamic<T>>;import Wetrocloud from "wetrocloud-sdk";
const wetrocloud = new Wetrocloud();
const response = await wetrocloud.chat({
collection_id:"<collection_id>",
message:"Tell me more",
chat_history:[
{"role":"user", "content":"What is this all about?"},
{"role":"system","content":"This is about Queen Elizabeth_II of England"}
]
});
console.log("Chat with collection", response);Deletes a resource from a collection.
-
collection_id: string- The ID of the collection. -
resource_id: string- The ID of the resource to delete.
Promise<IGenericResponse | IErrorMessage>;import Wetrocloud from "wetrocloud-sdk";
const wetrocloud = new Wetrocloud();
const response = await wetrocloud.deleteResource({
collection_id: '<collection_id>',
resource_id: '<resource_id>'
});
console.log("Deleting resource", response);Deletes an entire collection.
collection_id: string- The ID of the collection.
Promise<IGenericResponse | IErrorMessage>;import Wetrocloud from "wetrocloud-sdk";
const wetrocloud = new Wetrocloud();
const response = await wetrocloud.deleteCollection({
collection_id:'<collection_id>',
});
console.log("Deleting collection", response);Categorizes a resource using predefined categories.
-
resource: string- The resource to categorize. -
type: string- The type of resource. -
json_schema: T | T[]- JSON schema of the resource. -
categories: string[]- List of categories. -
prompt: string- An overall command of your request.
Promise<ICatergorizeResource<T> | IErrorMessage>;import Wetrocloud from "wetrocloud-sdk";
const wetrocloud = new Wetrocloud();
//Categorize content
const response = await wetrocloud.categorize({
resource: "match review: John Cena vs. The Rock",
type: "text",
json_schema: { 'label': '' },
categories: ["football", "coding", "entertainment", "basketball", "wrestling", "information"],
prompt: "Where does this fall under?"
});
console.log("Categorizing resource", result);Generates text without retrieval-augmented generation (RAG).
-
model: string- The model to use. -
messages: { role: "user" | "system" | "assistant", content: string }[]- Message history. -
stream?: boolean- Optional. Determines whether the response should be streamed. Defaults tofalse.
Promise<IGenericResponse | IErrorMessage>;import Wetrocloud from "wetrocloud-sdk";
const wetrocloud = new Wetrocloud();
// Text Generation
const response = await wetrocloud.textGeneration({
messages: [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Write a short poem about technology."}
],
model: "llama-3.3-70b"
})
console.log("Generation without RAG", result);Extracts text from an image.
-
image_url: string- The URL of the image. -
request_query: string- The query to process the image.
Promise<IGenericResponse | IErrorMessage>;import Wetrocloud from "wetrocloud-sdk";
const wetrocloud = new Wetrocloud();
const imageUrl = 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTQBQcwHfud1w3RN25Wgys6Btt_Y-4mPrD2kg&s';
const query = 'What animal is this?';
// Extract text from an image and answer questions about it
const response = await wetrocloud.imageToText({
image_url: imageUrl,
request_query: query
})
console.log("Image to text", response);Extracts structured data from a website.
-
website_url: string- The URL of the website. -
json_schema: T | T[]- The JSON schema defining the expected structure.
Promise<IDataExtraction<T> | IErrorMessage>;import Wetrocloud from "wetrocloud-sdk";
const wetrocloud = new Wetrocloud();
const website = "https://www.forbes.com/real-time-billionaires/#7583ee253d78"
const json_schema = [{ "name": "<name of rich man>", "networth": "<amount worth>" }]
// Extract structured data from a website
const response = await wetrocloud.extract({
website,
json_schema:
});
console.log("Data extraction", result);Here are the markdown-formatted documentation sections for both markDownConverter() and transcript() methods, following the format of your extract<T>() example:
Converts a markdown resource (URL or local file) into structured markdown content using WetroCloud.
resource: stringβ The markdown file path or URL.resource_type: stringβ Type of resource, e.g.,"file"or"web".
Promise<IMarkDown>import Wetrocloud from "wetro-sdk";
const wetrocloud = new Wetrocloud();
const resource = "https://www.forbes.com/real-time-billionaires/#7583ee253d78";
const resource_type = "web";
// Convert markdown file to structured markdown
const result = await wetrocloud.markDownConverter({
resource,
resource_type
});
console.log("Converted Markdown", result);Retrieves transcript data from a YouTube video via WetroCloud.
resource: stringβ The YouTube video URL.resource_type: 'youtube'β Must be set to"youtube".
Promise<ITrancript>import Wetrocloud from "wetro-sdk";
const wetrocloud = new Wetrocloud();
const resource = "https://www.youtube.com/watch?v=m4qBwGnubew&pp=ygURZ29vZ2xlIGFpIHJlbGVhc2U%3D";
const resource_type = "youtube";
// Retrieve transcript from YouTube video
const result = await wetrocloud.transcript({
resource,
resource_type
});
console.log("Transcript result", result);Let me know if you want these grouped in a table of contents or need this output styled for a README or documentation website.
For additional support, please contact [email protected] or visit our website WetroCloud Docs.