New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@tavily/core

Package Overview
Dependencies
Maintainers
0
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tavily/core - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

12

dist/index.d.ts
type TavilySearchFuncton = (query: string, options: TavilySearchOptions) => Promise<TavilySearchResponse>;
type TavilyQNASearchFuncton = (query: string, options: TavilySearchOptions) => Promise<string>;
type TavilyContextSearchFuncton = (query: string, options: TavilySearchOptions) => Promise<string>;
type TavilyExtractFunction = (urls: Array<string>) => Promise<TavilyExtractResponse>;
type TavilyExtractFunction = (urls: Array<string>, options: TavilyExtractOptions) => Promise<TavilyExtractResponse>;
type TavilyClient = {

@@ -26,2 +26,4 @@ search: TavilySearchFuncton;

maxTokens?: undefined | number;
timeRange?: "year" | "month" | "week" | "day" | "y" | "m" | "w" | "d";
[key: string]: any;
};

@@ -47,5 +49,11 @@ type TavilyImage = {

};
type TavilyExtractOptions = {
includeImages?: boolean;
extractDepth?: "basic" | "advanced";
[key: string]: any;
};
type TavilyExtractResult = {
url: string;
rawContent: string;
images?: Array<string>;
};

@@ -64,2 +72,2 @@ type TavilyExtractFailedResult = {

export { tavily };
export { type TavilyClient, type TavilyClientOptions, type TavilyContextSearchFuncton, type TavilyExtractFunction, type TavilyExtractOptions, type TavilyExtractResponse, type TavilyQNASearchFuncton, type TavilySearchFuncton, type TavilySearchOptions, type TavilySearchResponse, tavily };

110

dist/index.js

@@ -6,4 +6,30 @@ "use strict";

var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __objRest = (source, exclude) => {
var target = {};
for (var prop in source)
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
target[prop] = source[prop];
if (source != null && __getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(source)) {
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
target[prop] = source[prop];
}
return target;
};
var __export = (target, all) => {

@@ -52,7 +78,7 @@ for (var name in all)

// src/index.ts
var src_exports = {};
__export(src_exports, {
var index_exports = {};
__export(index_exports, {
tavily: () => tavily
});
module.exports = __toCommonJS(src_exports);
module.exports = __toCommonJS(index_exports);

@@ -104,18 +130,45 @@ // src/utils.ts

excludeDomains: void 0,
maxTokens: void 0
maxTokens: void 0,
timeRange: void 0
}) {
const response = yield post("search", {
const _a = options, {
searchDepth,
topic,
days,
maxResults,
includeImages,
includeImageDescriptions,
includeAnswer,
includeRawContent,
includeDomains,
excludeDomains,
timeRange
} = _a, kwargs = __objRest(_a, [
"searchDepth",
"topic",
"days",
"maxResults",
"includeImages",
"includeImageDescriptions",
"includeAnswer",
"includeRawContent",
"includeDomains",
"excludeDomains",
"timeRange"
]);
const response = yield post("search", __spreadValues({
api_key: apiKey,
query,
search_depth: options.searchDepth,
topic: options.topic,
days: options.days,
max_results: options.maxResults,
include_images: options.includeImages,
include_image_descriptions: options.includeImageDescriptions,
include_answer: options.includeAnswer,
include_raw_content: options.includeRawContent,
include_domains: options.includeDomains,
exclude_domains: options.excludeDomains
});
search_depth: searchDepth,
topic,
days,
max_results: maxResults,
include_images: includeImages,
include_image_descriptions: includeImageDescriptions,
include_answer: includeAnswer,
include_raw_content: includeRawContent,
include_domains: includeDomains,
exclude_domains: excludeDomains,
time_range: timeRange
}, kwargs));
return {

@@ -224,8 +277,20 @@ query,

function _extract(apiKey) {
return function extract(urls) {
return __async(this, null, function* () {
const response = yield post("extract", {
return function extract(_0) {
return __async(this, arguments, function* (urls, options = {
includeImages: false,
extractDepth: "basic"
}) {
const _a = options, {
includeImages,
extractDepth
} = _a, kwargs = __objRest(_a, [
"includeImages",
"extractDepth"
]);
const response = yield post("extract", __spreadValues({
api_key: apiKey,
urls
});
urls,
include_images: includeImages,
extract_depth: extractDepth
}, kwargs));
return {

@@ -236,3 +301,4 @@ responseTime: response.data.response_time,

url: result.url,
rawContent: result.raw_content
rawContent: result.raw_content,
images: result.images
};

@@ -239,0 +305,0 @@ }),

{
"name": "@tavily/core",
"version": "0.0.2",
"version": "0.0.3",
"description": "Official JavaScript library for Tavily.",

@@ -8,2 +8,8 @@ "main": "./dist/index.js",

"types": "./dist/index.d.ts",
"exports": {
".": {
"import": "./dist/index.mjs",
"require": "./dist/index.js"
}
},
"homepage": "https://tavily.com",

@@ -30,3 +36,3 @@ "repository": {

"@types/node": "^22.7.4",
"tsup": "^8.3.0",
"tsup": "^8.3.6",
"typescript": "^5.6.2"

@@ -33,0 +39,0 @@ },

# Tavily JavaScript SDK
> We're excited to announce the release of our JavaScript SDK! Please keep in mind that this package is still in Beta, and is therefore subject to change in the future. Please report any bugs and send all feedback to [support@tavily.com](mailto:support@tavily.com) or our [Developer Community](https://community.tavily.com). We're excited to see what you build with Tavily!
Tavily's JavaScript SDK allows for easy interaction with the Tavily API, offering the full range of our search and extract functionalities directly from your JavaScript and TypeScript programs. Easily integrate smart search and content extraction capabilities into your applications, harnessing the powerful Tavily Search and Tavily Extract APIs.
Tavily.js allows for easy interaction with the Tavily API, offering the full range of our search and extract functionalities directly from your JavaScript and TypeScript programs. Easily integrate smart search and content extraction capabilities into your applications, harnessing Tavily's powerful search and extract features.
## Installing

@@ -13,9 +11,7 @@ ```bash

# Tavily Search
Connect your LLM to the web using the Tavily Search API.
Connect your LLM to the web using the Tavily Search API. Tavily Search is a powerful search engine tailored for use by LLMs in agentic applications.
## Usage
Below are some code snippets that show you how to interact with our search API. The different steps and components of this code are explained in more detail on the JavaScript [API Reference](https://docs.tavily.com/docs/javascript-sdk/tavily-search/api-reference) page.
Below is a simple code snippet that shows you how to use Tavily Search. The different steps and components of this code are explained in more detail on the JavaScript [API Reference](https://docs.tavily.com/sdk/get-started/javascript) page.
### Getting and printing the full Search API response
```javascript

@@ -33,50 +29,13 @@ const { tavily } = require("@tavily/core");

```
This is equivalent to directly querying our REST API.
> To learn more about the different parameters, head to our [JavaScript API Reference](https://docs.tavily.com/sdk/reference/javascript).
### Generating context for a RAG Application
```javascript
const { tavily } = require("@tavily/core");
// Step 1. Instantiating your Tavily client
const tvly = tavily({ apiKey: "tvly-YOUR_API_KEY" });
// Step 2. Executing a context search query
const context = tvly.searchContext("What happened during the Burning Man floods?");
// Step 3. That's it! You now have a context string that you can feed directly into your RAG Application
console.log(response);
```
This is how you can generate precise and fact-based context for your RAG application in one line of code.
### Getting a quick answer to a question
```javascript
const { tavily } = require("@tavily/core");
// Step 1. Instantiating your Tavily client
const tvly = tavily({ apiKey: "tvly-YOUR_API_KEY" });
// Step 2. Executing a Q&A search query
const answer = tvly.searchQNA("Who is Leo Messi?");
// Step 3. That's it! Your question has been answered!
console.log(answer);
```
This is how you get accurate and concise answers to questions, in one line of code. Perfect for usage by LLMs!
# Tavily Extract
> We’re excited to announce the release of the Tavily Extract feature! This feature is still in beta, so please report any bugs or send feedback to [support@tavily.com](mailto:support@tavily.com).
The Tavily Extract API allows you to effortlessly retrieve raw content from a list of websites, making it ideal for data collection, content analysis, and research. You can also combine Tavily Extract with our Search method: first, obtain a list of relevant documents, then perform further processing on selected links to gather additional information and use it as context for your research tasks.
Please note that for every 5 successful URL extractions, 1 API credit is deducted from your account. We look forward to seeing what you build with it!
## Usage
Below are some code snippets demonstrating how to interact with the Tavily Extract API. The different steps and components of this code are explained in more detail on the JavaScript [API Reference](https://docs.tavily.com/docs/javascript-sdk/tavily-extract/api-reference) page.
Below is a simple code snippet demonstrating how to use Tavily Extract. The different steps and components of this code are explained in more detail on the JavaScript [API Reference](https://docs.tavily.com/docs/javascript-sdk/tavily-extract/api-reference) page.
### Extracting Raw Content from Multiple URLs using Tavily Extract API
```javascript

@@ -108,7 +67,12 @@ const { tavily } = require("@tavily/core");

## 📝 License
> To learn more about the different parameters, head to our [JavaScript API Reference](https://docs.tavily.com/sdk/reference/javascript).
## Cost
Head to the [API Credits Overview](https://docs.tavily.com/guides/api-credits) in our documentation to learn more about how many API Credits each request costs.
## License
This project is licensed under the terms of the MIT license.
## 💌 Contact
## Contact

@@ -115,0 +79,0 @@ If you are encountering issues while using Tavily, please email us at [support@tavily.com](mailto:support@tavily.com). We'll be happy to help you.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc