@qianxude/ai 0.2.1
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.
- package/LICENSE +21 -0
- package/README.md +599 -0
- package/dist/client/client.d.ts +56 -0
- package/dist/client/client.d.ts.map +1 -0
- package/dist/client/client.js +285 -0
- package/dist/client/client.js.map +1 -0
- package/dist/client/config.d.ts +34 -0
- package/dist/client/config.d.ts.map +1 -0
- package/dist/client/config.js +141 -0
- package/dist/client/config.js.map +1 -0
- package/dist/client/index.d.ts +9 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +13 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/providers.d.ts +27 -0
- package/dist/client/providers.d.ts.map +1 -0
- package/dist/client/providers.js +235 -0
- package/dist/client/providers.js.map +1 -0
- package/dist/client/task.d.ts +59 -0
- package/dist/client/task.d.ts.map +1 -0
- package/dist/client/task.js +179 -0
- package/dist/client/task.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/types/base.d.ts +38 -0
- package/dist/types/base.d.ts.map +1 -0
- package/dist/types/base.js +6 -0
- package/dist/types/base.js.map +1 -0
- package/dist/types/client.d.ts +47 -0
- package/dist/types/client.d.ts.map +1 -0
- package/dist/types/client.js +2 -0
- package/dist/types/client.js.map +1 -0
- package/dist/types/common.d.ts +19 -0
- package/dist/types/common.d.ts.map +1 -0
- package/dist/types/common.js +31 -0
- package/dist/types/common.js.map +1 -0
- package/dist/types/config.d.ts +26 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +2 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/index.d.ts +14 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +7 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/message.d.ts +25 -0
- package/dist/types/message.d.ts.map +1 -0
- package/dist/types/message.js +2 -0
- package/dist/types/message.js.map +1 -0
- package/dist/types/mod.d.ts +2 -0
- package/dist/types/mod.d.ts.map +1 -0
- package/dist/types/mod.js +2 -0
- package/dist/types/mod.js.map +1 -0
- package/dist/types/options.d.ts +31 -0
- package/dist/types/options.d.ts.map +1 -0
- package/dist/types/options.js +5 -0
- package/dist/types/options.js.map +1 -0
- package/dist/types/provider.d.ts +22 -0
- package/dist/types/provider.d.ts.map +1 -0
- package/dist/types/provider.js +2 -0
- package/dist/types/provider.js.map +1 -0
- package/dist/types/response.d.ts +19 -0
- package/dist/types/response.d.ts.map +1 -0
- package/dist/types/response.js +5 -0
- package/dist/types/response.js.map +1 -0
- package/dist/types/task.d.ts +28 -0
- package/dist/types/task.d.ts.map +1 -0
- package/dist/types/task.js +2 -0
- package/dist/types/task.js.map +1 -0
- package/package.json +42 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/types/common.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,qBAAqB;AACrB,qBAAa,QAAS,SAAQ,KAAK;aAGf,IAAI,EAAE,MAAM;aACH,KAAK,CAAC,EAAE,OAAO;gBAFxC,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,MAAM,EACH,KAAK,CAAC,EAAE,OAAO,YAAA;CAK3C;AAED,mCAAmC;AACnC,qBAAa,kBAAmB,SAAQ,QAAQ;gBAClC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAI7C;AAED,0BAA0B;AAC1B,qBAAa,aAAc,SAAQ,QAAQ;aAGvB,QAAQ,EAAE,MAAM;gBADhC,OAAO,EAAE,MAAM,EACC,QAAQ,EAAE,MAAM,EAChC,KAAK,CAAC,EAAE,OAAO;CAKlB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Common types and error classes for LLM package
|
|
3
|
+
*/
|
|
4
|
+
/** Base LLM error */
|
|
5
|
+
export class LLMError extends Error {
|
|
6
|
+
code;
|
|
7
|
+
cause;
|
|
8
|
+
constructor(message, code, cause) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.code = code;
|
|
11
|
+
this.cause = cause;
|
|
12
|
+
this.name = 'LLMError';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/** Configuration-related errors */
|
|
16
|
+
export class ConfigurationError extends LLMError {
|
|
17
|
+
constructor(message, cause) {
|
|
18
|
+
super(message, 'CONFIGURATION_ERROR', cause);
|
|
19
|
+
this.name = 'ConfigurationError';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/** Provider API errors */
|
|
23
|
+
export class ProviderError extends LLMError {
|
|
24
|
+
provider;
|
|
25
|
+
constructor(message, provider, cause) {
|
|
26
|
+
super(message, 'PROVIDER_ERROR', cause);
|
|
27
|
+
this.provider = provider;
|
|
28
|
+
this.name = 'ProviderError';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/types/common.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,qBAAqB;AACrB,MAAM,OAAO,QAAS,SAAQ,KAAK;IAGf;IACS;IAH3B,YACE,OAAe,EACC,IAAY,EACH,KAAe;QAExC,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,SAAI,GAAJ,IAAI,CAAQ;QACH,UAAK,GAAL,KAAK,CAAU;QAGxC,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;IACzB,CAAC;CACF;AAED,mCAAmC;AACnC,MAAM,OAAO,kBAAmB,SAAQ,QAAQ;IAC9C,YAAY,OAAe,EAAE,KAAe;QAC1C,KAAK,CAAC,OAAO,EAAE,qBAAqB,EAAE,KAAK,CAAC,CAAC;QAC7C,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AAED,0BAA0B;AAC1B,MAAM,OAAO,aAAc,SAAQ,QAAQ;IAGvB;IAFlB,YACE,OAAe,EACC,QAAgB,EAChC,KAAe;QAEf,KAAK,CAAC,OAAO,EAAE,gBAAgB,EAAE,KAAK,CAAC,CAAC;QAHxB,aAAQ,GAAR,QAAQ,CAAQ;QAIhC,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration types for LLM package
|
|
3
|
+
*/
|
|
4
|
+
import type { LLMApiOptions } from './options.js';
|
|
5
|
+
import type { LLMProvider } from './provider.js';
|
|
6
|
+
/** Model configuration */
|
|
7
|
+
export interface LLMModel extends LLMApiOptions {
|
|
8
|
+
provider: string;
|
|
9
|
+
model: string;
|
|
10
|
+
}
|
|
11
|
+
/** Complete llm.manifest.json structure */
|
|
12
|
+
export interface LLMConfig {
|
|
13
|
+
version: string;
|
|
14
|
+
providers: Record<string, LLMProvider>;
|
|
15
|
+
models: Record<string, LLMModel>;
|
|
16
|
+
tasks: Record<string, string>;
|
|
17
|
+
}
|
|
18
|
+
/** Runtime resolved configuration with API keys */
|
|
19
|
+
export interface ResolvedModelConfig extends LLMApiOptions {
|
|
20
|
+
provider: string;
|
|
21
|
+
model: string;
|
|
22
|
+
apiKey: string;
|
|
23
|
+
baseUrl: string;
|
|
24
|
+
excludeCaps?: string[];
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,0BAA0B;AAC1B,MAAM,WAAW,QAAS,SAAQ,aAAa;IAC7C,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,2CAA2C;AAC3C,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACvC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACjC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/B;AAED,mDAAmD;AACnD,MAAM,WAAW,mBAAoB,SAAQ,aAAa;IACxD,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface exports for LLM package
|
|
3
|
+
* All domain-based types are re-exported from here
|
|
4
|
+
*/
|
|
5
|
+
export { LLMError, ConfigurationError, ProviderError } from './common.js';
|
|
6
|
+
export type { LLMProvider, ProviderClient } from './provider.js';
|
|
7
|
+
export type { LLMModel, LLMConfig, ResolvedModelConfig } from './config.js';
|
|
8
|
+
export type { LLMMessage, LLMInputPrompt, LLMInputMessages, LLMInput, LLMRequest } from './message.js';
|
|
9
|
+
export type { LLMApiOptions, LLMCallOptions, LLMTaskOptions, CompletionOptions } from './options.js';
|
|
10
|
+
export type { LLMResponse, LLMStreamChunk } from './response.js';
|
|
11
|
+
export type { OpenAIMessage, OpenAIChoice, OpenAIUsage, OpenAIResponse, OpenAIDelta, OpenAIStreamChoice, OpenAIStreamChunk } from './base.js';
|
|
12
|
+
export type { LLMTask, LLMTaskCall } from './task.js';
|
|
13
|
+
export type { TaskBasedLLMClient, LLMClientOptions } from './client.js';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG1E,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAGjE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAG5E,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,gBAAgB,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAGvG,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGrG,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAGjE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAG9I,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAGtD,YAAY,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,iCAAiC;AACjC,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Message and request types for LLM package
|
|
3
|
+
*/
|
|
4
|
+
import type { LLMApiOptions, LLMCallOptions } from './options.js';
|
|
5
|
+
/** Message format for chat completions */
|
|
6
|
+
export interface LLMMessage {
|
|
7
|
+
role: 'system' | 'user' | 'assistant';
|
|
8
|
+
content: string;
|
|
9
|
+
}
|
|
10
|
+
/** Prompt call input for LLM completion requests */
|
|
11
|
+
export interface LLMInputPrompt {
|
|
12
|
+
systemPrompt?: string;
|
|
13
|
+
prompt?: string;
|
|
14
|
+
}
|
|
15
|
+
/** Messages call input for LLM completion requests */
|
|
16
|
+
export interface LLMInputMessages {
|
|
17
|
+
messages?: LLMMessage[];
|
|
18
|
+
}
|
|
19
|
+
/** Combined input type */
|
|
20
|
+
export interface LLMInput extends LLMInputPrompt, LLMInputMessages {
|
|
21
|
+
}
|
|
22
|
+
/** Complete call with messages - unified as LLMRequest */
|
|
23
|
+
export interface LLMRequest extends LLMApiOptions, LLMCallOptions, LLMInputPrompt, LLMInputMessages {
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=message.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../src/types/message.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAElE,0CAA0C;AAC1C,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,oDAAoD;AACpD,MAAM,WAAW,cAAc;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,sDAAsD;AACtD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,UAAU,EAAE,CAAC;CACzB;AAED,0BAA0B;AAC1B,MAAM,WAAW,QAAS,SAAQ,cAAc,EAAE,gBAAgB;CAAG;AAErE,0DAA0D;AAC1D,MAAM,WAAW,UAAW,SAAQ,aAAa,EAAE,cAAc,EAAE,cAAc,EAAE,gBAAgB;CAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../src/types/message.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/types/mod.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../../src/types/mod.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options types for LLM package
|
|
3
|
+
*/
|
|
4
|
+
/** Options for the LLM API */
|
|
5
|
+
export interface LLMApiOptions {
|
|
6
|
+
temperature?: number;
|
|
7
|
+
topK?: number;
|
|
8
|
+
topP?: number;
|
|
9
|
+
maxTokens?: number;
|
|
10
|
+
}
|
|
11
|
+
/** Call options for timeouts */
|
|
12
|
+
export interface LLMCallOptions {
|
|
13
|
+
timeout?: number;
|
|
14
|
+
}
|
|
15
|
+
/** Task creation options */
|
|
16
|
+
export interface LLMTaskOptions {
|
|
17
|
+
callOptions?: Partial<LLMCallOptions>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Options for completion requests
|
|
21
|
+
* Extended to support both old and new patterns
|
|
22
|
+
*/
|
|
23
|
+
export interface CompletionOptions extends LLMApiOptions, LLMCallOptions {
|
|
24
|
+
/** Task-based model selection (new) */
|
|
25
|
+
task?: string;
|
|
26
|
+
/** Direct model selection */
|
|
27
|
+
model?: string;
|
|
28
|
+
/** System prompt for the completion */
|
|
29
|
+
systemPrompt?: string;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/types/options.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,8BAA8B;AAC9B,MAAM,WAAW,aAAa;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,gCAAgC;AAChC,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,4BAA4B;AAC5B,MAAM,WAAW,cAAc;IAC7B,WAAW,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;CACvC;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAkB,SAAQ,aAAa,EAAE,cAAc;IACtE,uCAAuC;IACvC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6BAA6B;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uCAAuC;IACvC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/types/options.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ResolvedModelConfig } from './config.js';
|
|
2
|
+
/**
|
|
3
|
+
* Provider types for LLM package
|
|
4
|
+
*/
|
|
5
|
+
import type { LLMRequest } from './message.js';
|
|
6
|
+
import type { LLMResponse, LLMStreamChunk } from './response.js';
|
|
7
|
+
/** Provider configuration */
|
|
8
|
+
export interface LLMProvider {
|
|
9
|
+
name: string;
|
|
10
|
+
apiKeyEnv: string;
|
|
11
|
+
baseUrlEnv?: string;
|
|
12
|
+
defaultBaseUrl?: string;
|
|
13
|
+
excludeCaps?: string[];
|
|
14
|
+
}
|
|
15
|
+
/** Provider interface for implementing new providers */
|
|
16
|
+
export interface ProviderClient {
|
|
17
|
+
/** Complete a request with messages array */
|
|
18
|
+
complete(config: ResolvedModelConfig, call: LLMRequest): Promise<LLMResponse>;
|
|
19
|
+
/** Stream a request with messages array */
|
|
20
|
+
stream(config: ResolvedModelConfig, call: LLMRequest): AsyncGenerator<LLMStreamChunk>;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/types/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACvD;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEjE,6BAA6B;AAC7B,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,wDAAwD;AACxD,MAAM,WAAW,cAAc;IAC7B,6CAA6C;IAC7C,QAAQ,CAAC,MAAM,EAAE,mBAAmB,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IAE9E,2CAA2C;IAC3C,MAAM,CAAC,MAAM,EAAE,mBAAmB,EAAE,IAAI,EAAE,UAAU,GAAG,cAAc,CAAC,cAAc,CAAC,CAAC;CACvF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/types/provider.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Response types for LLM package
|
|
3
|
+
*/
|
|
4
|
+
/** LLM response structure */
|
|
5
|
+
export interface LLMResponse {
|
|
6
|
+
content: string;
|
|
7
|
+
usage?: {
|
|
8
|
+
promptTokens: number;
|
|
9
|
+
completionTokens: number;
|
|
10
|
+
totalTokens: number;
|
|
11
|
+
};
|
|
12
|
+
model: string;
|
|
13
|
+
}
|
|
14
|
+
/** Stream chunk from LLM */
|
|
15
|
+
export interface LLMStreamChunk {
|
|
16
|
+
content: string;
|
|
17
|
+
finishReason?: 'stop' | 'length' | 'content_filter';
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=response.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../src/types/response.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,6BAA6B;AAC7B,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE;QACN,YAAY,EAAE,MAAM,CAAC;QACrB,gBAAgB,EAAE,MAAM,CAAC;QACzB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,KAAK,EAAE,MAAM,CAAC;CACf;AAED,4BAA4B;AAC5B,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,gBAAgB,CAAC;CACrD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response.js","sourceRoot":"","sources":["../../src/types/response.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Task types for LLM package
|
|
3
|
+
*/
|
|
4
|
+
import type { ResolvedModelConfig } from './config.js';
|
|
5
|
+
import type { LLMMessage } from './message.js';
|
|
6
|
+
import type { LLMCallOptions } from './options.js';
|
|
7
|
+
import type { LLMResponse, LLMStreamChunk } from './response.js';
|
|
8
|
+
/** Task interface - wraps ResolvedModelConfig */
|
|
9
|
+
export interface LLMTask {
|
|
10
|
+
/** Resolved configuration from ConfigLoader (internal state) */
|
|
11
|
+
readonly config: ResolvedModelConfig;
|
|
12
|
+
/** Task-level call options (can be overridden at call level) */
|
|
13
|
+
readonly callOptions: Required<LLMCallOptions>;
|
|
14
|
+
/** Create a call with optional call-level overrides */
|
|
15
|
+
createCall(overrideOptions?: Partial<LLMCallOptions>): LLMTaskCall;
|
|
16
|
+
}
|
|
17
|
+
/** Task call for execution */
|
|
18
|
+
export interface LLMTaskCall {
|
|
19
|
+
/** Reference to parent task (has access to config via task.config) */
|
|
20
|
+
readonly task: LLMTask;
|
|
21
|
+
/** Merged call options (task-level merged with call-level overrides) */
|
|
22
|
+
readonly callOptions: Required<LLMCallOptions>;
|
|
23
|
+
/** Execute a completion request */
|
|
24
|
+
complete(input: string | LLMMessage[]): Promise<LLMResponse>;
|
|
25
|
+
/** Execute a streaming request */
|
|
26
|
+
stream(input: string | LLMMessage[]): AsyncGenerator<LLMStreamChunk>;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=task.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task.d.ts","sourceRoot":"","sources":["../../src/types/task.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEjE,iDAAiD;AACjD,MAAM,WAAW,OAAO;IACtB,gEAAgE;IAChE,QAAQ,CAAC,MAAM,EAAE,mBAAmB,CAAC;IACrC,gEAAgE;IAChE,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAC;IAE/C,uDAAuD;IACvD,UAAU,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,WAAW,CAAC;CACpE;AAED,8BAA8B;AAC9B,MAAM,WAAW,WAAW;IAC1B,sEAAsE;IACtE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,wEAAwE;IACxE,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAC;IAE/C,mCAAmC;IACnC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IAC7D,kCAAkC;IAClC,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,EAAE,GAAG,cAAc,CAAC,cAAc,CAAC,CAAC;CACtE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task.js","sourceRoot":"","sources":["../../src/types/task.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@qianxude/ai",
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"public": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "bun x tsc -p tsconfig.json",
|
|
16
|
+
"test": "bun test --env-file ../../.env tests",
|
|
17
|
+
"test:real": "bun --env-file ../../.env test tests/unit/client/providers.real.test.ts",
|
|
18
|
+
"test:real:prd": "bun test --env-file ../../.env tests/unit/client/providers.real.test.ts",
|
|
19
|
+
"lint": "oxlint . --ignore-path .gitignore",
|
|
20
|
+
"lint:fix": "oxlint . --fix --ignore-path .gitignore",
|
|
21
|
+
"format": "oxfmt src/**/*.ts tests/**/*.ts",
|
|
22
|
+
"format:check": "oxfmt --check src/**/*.ts tests/**/*.ts",
|
|
23
|
+
"format:diff": "for f in $(oxfmt --check src/**/*.ts tests/**/*.ts 2>&1 | grep -oE 'src/[^ ]+\\.ts'); do echo \"=== $f ===\"; oxfmt --stdin-filepath=\"$f\" < \"$f\" | diff -u \"$f\" -; done",
|
|
24
|
+
"typecheck": "tsc --noEmit",
|
|
25
|
+
"publish:pkg": "bun publish"
|
|
26
|
+
},
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
},
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=18",
|
|
32
|
+
"bun": ">=1.0.0"
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"dist",
|
|
36
|
+
"README.md",
|
|
37
|
+
"LICENSE"
|
|
38
|
+
],
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@qianxude/shared": "~0.2.1"
|
|
41
|
+
}
|
|
42
|
+
}
|