New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

genai-agent

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

genai-agent

Multi-provider GenAI wrapper (Google, OpenAI, Anthropic) with builtin function-calling support.

latest
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

genai-agent

genai-agent is a TypeScript-based Node.js package that provides an easy interface for interacting with different generative AI providers like Google, OpenAI, and Anthropic. This package allows you to use pre-configured agents for AI-powered tasks such as chat, content generation, and function calls.

Features

  • Supports Google GenAI (Google Cloud).
  • Placeholder implementations for OpenAI and Anthropic agents (to be added later).
  • Easily extensible to add more AI providers in the future.

Installation

To install the package, run the following command:

npm install genai-agent

Usage

Here’s how you can use the package to interact with the available agents (Google for now):

1.Google Agent

import { GoogleAgent } from "genai-agent";

// Initialize the agent with your API key
const agent = new GoogleAgent({ apiKey: "YOUR_GOOGLE_API_KEY" });

// Call the chat method to interact with the AI
const response = await agent.chat({
  model: "gemini-1.5-flash",
  text: "Hello, AI!",
  functionDeclarations: [],
  functions: {},
  systemInstruction: "your-instruction",
});

console.log(response); // The response from the AI

2. OpenAI Agent (Coming Soon)

import { OpenAIAgent } from "genai-agent";

// Placeholder for OpenAIAgent usage
const openAI = new OpenAIAgent({ apiKey: "YOUR_OPENAI_API_KEY" });

3. Anthropic Agent (Coming Soon)

import { AnthropicAgent } from "genai-agent";

// Placeholder for AnthropicAgent usage
const anthropic = new AnthropicAgent({ apiKey: "YOUR_ANTHROPIC_API_KEY" });

API Reference

  • Google Agent (Current Implementation)
    • constructor({ apiKey: string }): Initialize with your API key.
    • chat({ model: string, text: string, functionDeclarations: any[], functions: Record<string, Function>, systemInstruction: string }): The main method to interact with the agent and get AI responses.

Development

To contribute or develop locally, follow these steps:

  • Clone the repository
git clone https://github.com/yourusername/genai-agent.git
  • Install dependencies:
npm install
  • Build typescript code
npm run build

License

This project is licensed under the MIT License.

Notices and Attributions

This project includes third-party software components:

See the NOTICE file for additional details.

Examples

Checkout some examples with function calls and response here

Notes

  • OpenAI and Anthropic: These are placeholders right now. You’ll be able to add their logic in the future, and users will be able to interact with them in the same way as GoogleAgent.
  • API Keys: For security reasons, don't hardcode your API keys in the codebase. Use environment variables or secret managers for production applications.

Keywords

genai

FAQs

Package last updated on 13 May 2025

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