1.0.0 • Published 11 months ago

duckduckgo-ai-chat v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

duckduckgo-ai-chat

English | 中文

duckduckgo-ai-chat provides the Duckduckgo AI Chat API for JavaScript/TypeScript, which can use gpt-4o-mini for free.

Install

npm install duckduckgo-ai-chat
# or
pnpm install duckduckgo-ai-chat
# or
yarn add duckduckgo-ai-chat
# or
bun add duckduckgo-ai-chat

Usage example

import { initChat } from "duckduckgo-ai-chat";

// Initialize, optional models are gpt-4o-mini, claude-3-haiku-20240307, meta-llama/Llama-3-70b-chat-hf, mistralai/Mixtral-8x7B-Instruct-v0.1
const chat = await initChat("gpt-4o-mini");

// Fetch the full reply in one go
let message = await chat.fetchFull("Hello");
console.log(message)

// Redo
chat.redo()
message = await chat.fetchFull("Hello");
console.log(message)

// Fetch the streamed reply
const stream = chat.fetchStream("Hello");
for await (let data of stream) {
  console.log(data)
}
1.0.0

11 months ago