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

icp-llm-client

v1.1.0

Published

A TypeScript client for interacting with the LLM canister on the Internet Computer

Downloads

3

Readme

ICP LLM Client

A TypeScript client for interacting with the LLM canister on the Internet Computer.

Installation

npm install icp-llm-client

Usage

import { LLMClient, Model } from "icp-llm-client";

// Create a client instance (connects to IC mainnet by default)
const client = new LLMClient();

// Simple prompt
const response = await client.prompt(
  Model.Llama3_1_8B,
  "What is the Internet Computer?"
);

// Chat with multiple messages
const chatResponse = await client.chat(Model.Llama3_1_8B, [
  {
    role: { system: null },
    content: "You are a helpful assistant",
  },
  {
    role: { user: null },
    content: "What is the Internet Computer?",
  },
]);

Custom Host or Identity

You can specify a custom host or identity:

import { LLMClient, Model } from "icp-llm-client";
import { HttpAgent, Identity } from "@dfinity/agent";

// Create a client with custom host (e.g., local development)
const localClient = new LLMClient({ host: "http://localhost:8000" });

// Create a client with custom identity
const identityClient = new LLMClient({ identity: myIdentity });

// Create a client with both custom host and identity
const customClient = new LLMClient({
  host: "https://custom-ic-host.com",
  identity: myIdentity,
});

Limitations

Model Support

  • Currently only supports Llama 3.1 8B model
  • More models planned based on community feedback

Request Constraints

  • Maximum 10 messages per chat request
  • Prompt length across all messages cannot exceed 10kiB
  • Output is limited to 200 tokens (responses will be truncated)

Privacy Considerations

  • Prompts are not completely private
  • AI Worker operators can theoretically see prompts
  • User identity remains anonymous
  • DFINITY only logs aggregate metrics (request counts, token usage)

Best Practices

  1. Handle Truncated Responses

    const response = await client.prompt(Model.Llama3_1_8B, "Your prompt");
    if (LLMClient.isResponseTruncated(response)) {
      console.log("Response was truncated. Consider breaking up your request.");
    }
  2. Keep Prompts Concise

    // Good - concise prompt
    const response = await client.prompt(
      Model.Llama3_1_8B,
      "What is ICP? Be brief."
    );
    
    // Avoid - too long
    const longResponse = await client.prompt(
      Model.Llama3_1_8B,
      "Write a detailed essay about the Internet Computer..."
    );
  3. Break Up Long Conversations

    // Instead of sending many messages at once
    const messages = [
      { role: { system: null }, content: "You are a helpful assistant" },
      { role: { user: null }, content: "Question 1" },
      { role: { assistant: null }, content: "Answer 1" },
      { role: { user: null }, content: "Question 2" },
      // ... more messages
    ];
    
    // Break into multiple requests
    const firstPart = await client.chat(Model.Llama3_1_8B, messages.slice(0, 5));
    const secondPart = await client.chat(Model.Llama3_1_8B, messages.slice(5));

Error Handling

try {
  const response = await client.prompt(Model.Llama3_1_8B, "Your prompt");
  console.log(response);
} catch (error) {
  if (error.message.includes("10kiB")) {
    console.error("Prompt too long. Please reduce the length.");
  } else if (error.message.includes("10 messages")) {
    console.error("Too many messages. Please reduce the number of messages.");
  } else {
    console.error("An error occurred:", error);
  }
}

License

MIT