Skip to content

vineethkuttan/napi-deviceinfo-ai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

NAPI Device Info AI

πŸ€– Ask questions about your machine in natural language!

An AI-powered Node.js package that lets you query your Windows device information using natural language. Powered by Azure OpenAI and native Windows APIs through N-API.

Features

  • πŸ’¬ Natural Language Interface: Ask questions like "What's my computer name?" or "How busy is my machine?"
  • πŸš€ Native Performance: Uses N-API for fast, direct access to Windows system information
  • πŸ€– AI-Powered: Integrates with Azure OpenAI to understand and respond to your queries
  • πŸ”§ Easy to Use: Simple API with sensible defaults
  • πŸ“Š System Information: Get device name, process count, and memory information
  • πŸ—‚οΈ Multi-Drive Support: Comprehensive storage information across all drives
  • πŸ“ Full TypeScript Support: Complete type definitions included

Installation

npm install napi-deviceinfo-ai

Note: This package is Windows-only and requires Node.js 16+.

Prerequisites

You'll need an Azure OpenAI API key to use this package. Get one from the Azure OpenAI Service.

Quick Start

import { askAboutDevice } from 'napi-deviceinfo-ai';

// Ask a question about your device
const response = await askAboutDevice("What is my computer name?", {
  apiKey: "your-azure-openai-api-key"
});

console.log(response);
// Output: "Your computer name is DESKTOP-ABC123."

API Reference

askAboutDevice(query, options)

Main function to ask questions about your device using AI.

Parameters:

  • query (string): Your question in natural language
  • options (object): Configuration options
    • apiKey (string, required): Your Azure OpenAI API key
    • endpoint (string, optional): Azure OpenAI endpoint (default: uses built-in endpoint)
    • modelName (string, optional): Model to use (default: "gpt-4")
    • deployment (string, optional): Deployment name (default: "gpt-4")
    • apiVersion (string, optional): API version (default: "2024-04-01-preview")
    • verbose (boolean, optional): Enable detailed logging (default: false)

Returns: Promise - AI response about your device

Native Functions

You can also access the underlying system information directly:

import { getDeviceName, getProcessCount, getTotalPhysicalMemory } from 'napi-deviceinfo-ai';

const deviceName = getDeviceName();           // "DESKTOP-ABC123"
const processCount = getProcessCount();       // 156
const totalMemory = getTotalPhysicalMemory(); // 17179869184 (bytes)

Example Queries

The AI can understand various types of questions:

const examples = [
  "What is my machine name?",
  "How many processes are running?",
  "How much RAM does my computer have?", 
  "Give me a summary of my device",
  "Is my computer busy right now?",
  "What's the total memory in GB?",
  "Show me my device information"
];

for (const query of examples) {
  const response = await askAboutDevice(query, { apiKey: "your-key" });
  console.log(`Q: ${query}`);
  console.log(`A: ${response}\n`);
}

TypeScript Support

Full TypeScript definitions are included with proper typing for all functions:

import { 
  askAboutDevice, 
  getCompleteDeviceInfo, 
  type CompleteDeviceInfo,
  type DeviceInfoOptions 
} from 'napi-deviceinfo-ai';

// Get complete device info with full typing
const deviceInfo: CompleteDeviceInfo = getCompleteDeviceInfo();
console.log('Device:', deviceInfo.deviceName);
console.log('Memory GB:', deviceInfo.totalMemoryBytes / (1024**3));
console.log('Drives:', deviceInfo.availableDrives);

// AI query with typed options
const options: DeviceInfoOptions = {
  apiKey: "your-api-key",
  verbose: true
};
const response = await askAboutDevice("What's my computer?", options);

Environment Variables

You can set your API key as an environment variable:

# Windows Command Prompt
set AZURE_OPENAI_API_KEY=your-api-key-here

# PowerShell
$env:AZURE_OPENAI_API_KEY="your-api-key-here"

# Then in your code:
const response = await askAboutDevice("What's my computer name?", {
  apiKey: process.env.AZURE_OPENAI_API_KEY
});

Error Handling

try {
  const response = await askAboutDevice("What's my device name?", {
    apiKey: "your-api-key"
  });
  console.log(response);
} catch (error) {
  if (error.message.includes("API key")) {
    console.error("Please provide a valid API key");
  } else {
    console.error("Error:", error.message);
  }
}

Building from Source

If you want to build the native components:

# Install dependencies
npm install

# Build the native addon
npm run build

# Run demo
npm run demo

System Requirements

  • OS: Windows only (win32)
  • Node.js: 16.0.0 or higher
  • Azure OpenAI: API key required

Contributing

Contributions welcome! This package uses:

  • N-API for native Windows system calls
  • Azure OpenAI for natural language processing
  • node-gyp for building native addons

License

MIT


Ask your computer anything! πŸš€

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors