npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@oliverlessa/gemini-agent-lib

v1.1.0

Published

Uma biblioteca NodeJS para criar agentes de IA com Gemini LLM

Readme

GeminiAgentLib

Uma biblioteca Node.js flexível para construir, gerenciar e orquestrar agentes de Inteligência Artificial. Integre facilmente os modelos Gemini do Google (incluindo Generative AI e Vertex AI) em suas aplicações, criando desde assistentes simples até sistemas multi-agentes complexos com memória e ferramentas personalizadas.

Instalação

A paritir do repositório NPM:

npm install @oliverlessa/gemini-agent-lib

A partir de um diretório/pasta local:

npm install /caminho/gemini-agent-lib --install-links

Configuração Essencial (.env)

Esta biblioteca requer um arquivo .env na raiz do projeto para funcionar corretamente. Este arquivo contém as chaves de API e configurações necessárias para acessar os serviços do Google AI e Vertex AI.

Configuração Rápida

  1. Instale o pacote dotenv:

    npm install dotenv
  2. Crie um arquivo .env na raiz do seu projeto

  3. Adicione suas variáveis de ambiente (no mínimo a chave do Gemini):

    GEMINI_API_KEY=sua_chave_api_gemini
  4. Carregue o dotenv no início do seu aplicativo:

    require('dotenv').config();
  5. Adicione o arquivo .env ao seu .gitignore

Exemplo Completo do .env

# Chave de API do Gemini
GEMINI_API_KEY=sua_chave_api_gemini

# Configurações do Google Cloud e Vertex AI
VERTEX_API_KEY=sua_chave_api_vertex
GOOGLE_CLOUD_PROJECT_ID=seu_id_projeto_gcp
VERTEX_PROJECT_ID=seu_id_projeto_vertex
VERTEX_LOCATION=regiao_vertex
GOOGLE_APPLICATION_CREDENTIALS=./caminho_para_arquivo_credenciais.json

⚠️ IMPORTANTE: O arquivo .env é essencial para o funcionamento da biblioteca. Sem ele, você não conseguirá se conectar aos modelos de IA.

Para uma explicação detalhada de cada variável e como obtê-las, consulte a documentação de configuração.

Uso Básico

const { Agent, GenerativeAILLM } = require('gemini-agent-lib');

// Configurar o LLM
const llm = new GenerativeAILLM({
    apiKey: process.env.GEMINI_API_KEY,
    modelName: "gemini-2.0-flash-001"
});

// Criar um agente
const agent = new Agent({
    role: "Assistente",
    objective: "Ajudar o usuário",
    context: "Você é um assistente útil",
    task: "Responda à pergunta do usuário",
    llm: llm
});

// Executar o agente
const resposta = await agent.executeTask();
console.log(resposta);

Componentes Principais

  • Agent: Agente básico para executar tarefas
  • ChatAgent: Agente com capacidade de manter conversas
  • ThinkingAgent: Agente com capacidade de "pensar" antes de responder
  • SequentialAgentChain: Executa uma cadeia de agentes em sequência
  • HierarchicalAgentOrchestrator: Orquestra múltiplos agentes de forma hierárquica
  • AutoGenOrchestrator: Orquestra autonomamente múltiplos agentes para resolver tarefas complexas (requer Vertex AI)
  • ToolBuilder: Facilita a criação de ferramentas para os agentes
  • Sistema de Memória: Inclui memória de conversação, fatos e Memória Semântica (com adaptador ChromaDBMemoryAdapter flexível para diferentes embeddings, além de SQLite e MongoDB). Essencial para RAG (Retrieval-Augmented Generation), permitindo que agentes acessem conhecimento externo e possuam memória de longo prazo.

Documentação

Para documentação detalhada sobre cada componente, consulte os links abaixo (apontando para o repositório GitHub):

Debug e Logs

A biblioteca utiliza o pacote debug para gerenciar mensagens de depuração. Por padrão, nenhuma mensagem de debug é exibida. Para ativar:

# Ativar todos os logs da biblioteca
DEBUG=gemini-agent-lib:* node seu-script.js

# Ativar apenas logs específicos
DEBUG=gemini-agent-lib:agent,gemini-agent-lib:chat-agent node seu-script.js

Para mais detalhes, consulte a documentação do sistema de debug.

Exemplos

Veja exemplos de uso na pasta examples.

Licença

MIT