Jev API

Jev API クイックスタート

公式 JavaScript SDK をサーバーで使い、TypeSafe API key を設定して最初の型付きリクエストを送ります。

1. 始める前に

Node.js 20 以上と TypeSafe API key が必要です。API key はブラウザーではなくサーバーから使います。

2. 公式 SDK をインストール

npm install @typesafe-ai/sdk

Node.js 20 以上と TypeSafe API key が必要です。API key はブラウザーではなくサーバーから使います。

3. 最初の判断を送る

import { choice, TypeSafeClient } from "@typesafe-ai/sdk";

const client = new TypeSafeClient();
const response = await client.systemOne({
  state: { document: "I was charged twice. Please fix this ASAP." },
  questions: {
    category: choice("What is this ticket about?", {
      billing: null, technical: null, other: null,
    }),
  },
});

console.log(response.answers.category.choice);

この例では固定されたカテゴリーから問い合わせを分類します。

4. State とは?

State はモデルが判断する情報です。既知の事実は明示的なフィールドで渡します。

5. 質問の設計

Choice は選択肢、Noul は yes の確率、Score は定義済みの尺度を返します。

import { choice, noul, score, TypeSafeClient } from "@typesafe-ai/sdk";

const client = new TypeSafeClient();
const response = await client.systemOne({
  state: { message: "Our checkout failed twice and launch is tomorrow." },
  questions: {
    route: choice("Which queue should own this?", {
      billing: "Payment and charge issues",
      technical: "Product or integration failures",
      other: "Everything else",
    }),
    urgent: noul("Is this time-sensitive?"),
    severity: score("How severe is the impact?", [
      "Low", "Moderate", "High", "Critical",
    ]),
  },
});

よくある間違い

答えを事前に定義できない課題で長文を生成させないでください。API key をブラウザーに置かないでください。

公式ソース

公式 TypeSafe 料金ソース ↗

Playground、テンプレート、コスト計算機、Jev と ChatGPT の比較も確認できます。 Jev Playgroundテンプレート料金