Skip to content

Commit

Permalink
feat: add o3-mini
Browse files Browse the repository at this point in the history
  • Loading branch information
mumu-lhl committed Feb 6, 2025
1 parent d6b8aeb commit b8c1e7c
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 16 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"deno.enable": true
}
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

English | [中文](./README_CN.md)

duckduckgo-ai-chat provides the [Duckduckgo AI Chat](https://duckduckgo.com/aichat) API for JavaScript/TypeScript, which can use gpt-4o-mini for free.
duckduckgo-ai-chat provides the [Duckduckgo AI Chat](https://duckduckgo.com/aichat) API for JavaScript/TypeScript, which can use o3-mini for free.

## Install

Expand All @@ -23,8 +23,8 @@ deno add jsr:@mumulhl/duckduckgo-ai-chat
```javascript
import { initChat } from "@mumulhl/duckduckgo-ai-chat";

// Initialize, optional models are gpt-4o-mini, claude-3-haiku, llama, mixtral
const chat = await initChat("gpt-4o-mini");
// Initialize, optional models are gpt-4o-mini, claude-3-haiku, llama, mixtral, o3-mini
const chat = await initChat("o3-mini");

// Fetch the full reply in one go
let message = await chat.fetchFull("Hello");
Expand Down
6 changes: 3 additions & 3 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

[English](./README.md) | 中文

duckduckgo-ai-chat 为 JavaScript/TypeScript 提供 [Duckduckgo AI Chat](https://duckduckgo.com/aichat) API,可以免费使用 gpt-4o-mini。
duckduckgo-ai-chat 为 JavaScript/TypeScript 提供 [Duckduckgo AI Chat](https://duckduckgo.com/aichat) API,可以免费使用 o3-mini。

## 安装

Expand All @@ -23,8 +23,8 @@ deno add jsr:@mumulhl/duckduckgo-ai-chat
```javascript
import { initChat } from "@mumulhl/duckduckgo-ai-chat";

// 初始化,可选模型有 gpt-4o-mini, claude-3-haiku, llama, mixtral
const chat = await initChat("gpt-4o-mini");
// 初始化,可选模型有 gpt-4o-mini, claude-3-haiku, llama, mixtral, o3-mini
const chat = await initChat("o3-mini");

// 一次性获取完整的回复
let message = await chat.fetchFull("Hello");
Expand Down
7 changes: 5 additions & 2 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ type Model =
| "gpt-4o-mini"
| "claude-3-haiku-20240307"
| "meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo"
| "mistralai/Mixtral-8x7B-Instruct-v0.1";
| "mistralai/Mixtral-8x7B-Instruct-v0.1"
| "o3-mini";

type ModelAlias =
| "gpt-4o-mini"
| "claude-3-haiku"
| "llama"
| "mixtral";
| "mixtral"
| "o3-mini";

type Messages = { content: string; role: "user" | "assistant" }[];

Expand All @@ -28,6 +30,7 @@ const _model: { [property: string]: Model } = {
"claude-3-haiku": "claude-3-haiku-20240307",
"llama": "meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo",
"mixtral": "mistralai/Mixtral-8x7B-Instruct-v0.1",
"o3-mini": "o3-mini",
};

class Chat {
Expand Down
16 changes: 8 additions & 8 deletions test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@ async function test(name: string, fn: any) {
}

await test("Init chat", async () => {
await initChat("gpt-4o-mini");
await initChat("o3-mini");
});

await test("fetchFull", async () => {
const chat = await initChat("gpt-4o-mini");
const message = await chat.fetchFull("Hello");
const chat = await initChat("o3-mini");
const message = await chat.fetchFull("Who are you?");
console.log(message);
});

await test("fetchStream", async () => {
const chat = await initChat("gpt-4o-mini");
const stream = chat.fetchStream("Hello");
let text = "Hello";
const chat = await initChat("o3-mini");
const stream = chat.fetchStream("Who are you?");
let text = "";
for await (const data of stream) {
text += data;
}
console.log(text);
});

await test("redo", async () => {
const chat = await initChat("gpt-4o-mini");
const chat = await initChat("o3-mini");
await chat.fetchFull("Hello");

let message = await chat.fetchFull(
Expand All @@ -42,7 +42,7 @@ await test("redo", async () => {
});

await test("Chat", async () => {
const chat = await initChat("gpt-4o-mini");
const chat = await initChat("o3-mini");

let message = await chat.fetchFull("Hello");
console.log(message);
Expand Down

0 comments on commit b8c1e7c

Please sign in to comment.