@pwshub/aisdk 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.d.ts +73 -0
  2. package/package.json +5 -4
package/index.d.ts ADDED
@@ -0,0 +1,73 @@
1
+ /**
2
+ * @fileoverview Type declarations for @pwshub/aisdk
3
+ */
4
+
5
+ export interface AiOptions {
6
+ gatewayUrl?: string;
7
+ }
8
+
9
+ export interface AskParams {
10
+ model: string;
11
+ apikey: string;
12
+ prompt: string;
13
+ system?: string;
14
+ fallbacks?: string[];
15
+ providerOptions?: Record<string, unknown>;
16
+ temperature?: number;
17
+ maxTokens?: number;
18
+ topP?: number;
19
+ topK?: number;
20
+ frequencyPenalty?: number;
21
+ presencePenalty?: number;
22
+ }
23
+
24
+ export interface Usage {
25
+ inputTokens: number;
26
+ outputTokens: number;
27
+ cacheTokens: number;
28
+ estimatedCost: number;
29
+ }
30
+
31
+ export interface AskResult {
32
+ text: string;
33
+ model: string;
34
+ usage: Usage;
35
+ }
36
+
37
+ export interface ModelRecord {
38
+ id: string;
39
+ name: string;
40
+ provider: string;
41
+ input_price: number;
42
+ output_price: number;
43
+ cache_price: number;
44
+ max_in: number;
45
+ max_out: number;
46
+ enable: boolean;
47
+ supportedParams?: string[];
48
+ }
49
+
50
+ export class ProviderError extends Error {
51
+ status: number;
52
+ provider: string;
53
+ model: string;
54
+ raw?: unknown;
55
+ constructor(message: string, options: { status: number; provider: string; model: string; raw?: unknown });
56
+ }
57
+
58
+ export class InputError extends Error {
59
+ status: number;
60
+ provider: string;
61
+ model: string;
62
+ raw?: unknown;
63
+ constructor(message: string, options: { status: number; provider: string; model: string; raw?: unknown });
64
+ }
65
+
66
+ export interface AiClient {
67
+ ask: (params: AskParams) => Promise<AskResult>;
68
+ listModels: () => ModelRecord[];
69
+ }
70
+
71
+ export function createAi(opts?: AiOptions): AiClient;
72
+ export function setModels(models: ModelRecord[]): void;
73
+ export function listModels(): ModelRecord[];
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@pwshub/aisdk",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "A thin, unified AI client for OpenAI, Anthropic, Google, DashScope, and DeepSeek with automatic param normalization and fallback support",
5
5
  "repository": {
6
6
  "type": "git",
7
- "url": "https://github.com/ndaidong/aisdk"
7
+ "url": "https://github.com/pwshub/aisdk"
8
8
  },
9
9
  "engines": {
10
10
  "node": ">=22.0.0",
@@ -15,9 +15,10 @@
15
15
  "exports": {
16
16
  ".": "./src/index.js"
17
17
  },
18
- "types": "./src/index.js",
18
+ "types": "./index.d.ts",
19
19
  "files": [
20
- "src"
20
+ "src",
21
+ "index.d.ts"
21
22
  ],
22
23
  "scripts": {
23
24
  "test": "node --test test/*.test.js",