0.1.1 • Published 8 months ago

@dfinity/llm v0.1.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
8 months ago

@dfinity/llm

A library for making requests to the LLM canister on the Internet Computer.

Install

npm install @dfinity/llm

Usage

Prompting (single message)

import { IDL, update } from "azle";
import * as llm from "@dfinity/llm";

export default class {
  @update([IDL.Text], IDL.Text)
  async prompt(prompt: string): Promise<string> {
    return await llm.prompt(llm.Model.Llama3_1_8B, prompt);
  }
}

Chatting (multiple messages)

import { IDL, update } from "azle";
import { chat_message as ChatMessageIDL } from "azle/canisters/llm/idl";
import * as llm from "@dfinity/llm";

export default class {
  @update([IDL.Vec(ChatMessageIDL)], IDL.Text)
  async chat(messages: llm.ChatMessage[]): Promise<string> {
    return await llm.chat(llm.Model.Llama3_1_8B, messages);
  }
}
0.1.1

8 months ago

0.1.0

8 months ago