Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

search-gpt-agent

Package Overview
Dependencies
Maintainers
0
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

search-gpt-agent

SearchGPT is a versatile Node.js library that leverages OpenAI's LLMs and Google Search capabilities, allowing for powerful, context-aware query handling and web search functionality. With this library, you can build custom search agents capable of conduc

  • 1.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11
decreased by-93.04%
Maintainers
0
Weekly downloads
 
Created
Source

SearchGPT

SearchGPT is a versatile Node.js library that leverages OpenAI's LLMs and Google Search capabilities, allowing for powerful, context-aware query handling and web search functionality. With this library, you can build custom search agents capable of conducting Google searches and extracting and analyzing content using vector similarities.

Installation

Before using SearchGPT, please ensure you have Node.js and npm installed. Then, create a .env file in your project root and include your OpenAI and Google API keys:

OPENAI_API_KEY=your_openai_api_key
GOOGLE_SEARCH_API_KEY=your_google_search_api_key
GOOGLE_SEARCH_ENGINE_ID=your_search_engine_id

To install, run:

npm install search-gpt

Usage

Below is a brief example of how to use SearchGPT to create a search agent and perform a context-aware search.

import { config } from 'dotenv';
import { searchGpt, googleSearchWithVectorSimilarityTool } from 'search-gpt';

config();

// Create a search agent
async function example() {
    const { createSearchAgent } = searchGpt({
        openaiApiKey: process.env.OPENAI_API_KEY,
    });

    const searchTool = googleSearchWithVectorSimilarityTool({
        googleSearchApiKey: process.env.GOOGLE_SEARCH_API_KEY,
        googleSearchEngineId: process.env.GOOGLE_SEARCH_ENGINE_ID,
        googleSearchApiEntpoint: "https://www.googleapis.com/customsearch/v1",
    });

    const searchAgent = await createSearchAgent("gpt-4o", [], [searchTool]);

    // Perform a context-aware search
    const response = await searchAgent.invoke("What is the current price of bitcoin?");
    console.log(response.output);

    const searchAgentWithContext = await createSearchAgent("gpt-4o", response.outputMessageArray, [searchTool]);
    const response2 = await searchAgentWithContext.invoke("How much is that in Australian dollars?");
    console.log(response2.output);
}

example();

Features

  • Create Custom Agents: Leverage OpenAI's GPT models to create contextually aware search agents.
  • Google Search Integration: Perform searches using Google API and retrieve content.
  • Vector Similarity Search: Use vector embeddings to compare and analyze content contextually.
  • Message History Handling: Maintain conversation state across multiple invocations for interactive applications.

Tools

  • googleSearchTool
  • googleSearchWithVectorSimilarityTool

For further customization, explore additional tools provided in src/tools.


Ensure to replace required API keys and any instance-specific details to utilize SearchGPT effectively. Adjust configurations and refine prompt templates to build agents suited to your domain-specific needs.

Keywords

FAQs

Package last updated on 15 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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