semantic-primitives 0.1.0
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 +201 -0
- package/README.md +449 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25016 -0
- package/dist/llm/client.d.ts +82 -0
- package/dist/llm/client.d.ts.map +1 -0
- package/dist/llm/index.d.ts +11 -0
- package/dist/llm/index.d.ts.map +1 -0
- package/dist/llm/providers/anthropic.d.ts +13 -0
- package/dist/llm/providers/anthropic.d.ts.map +1 -0
- package/dist/llm/providers/google.d.ts +13 -0
- package/dist/llm/providers/google.d.ts.map +1 -0
- package/dist/llm/providers/index.d.ts +7 -0
- package/dist/llm/providers/index.d.ts.map +1 -0
- package/dist/llm/providers/openai.d.ts +13 -0
- package/dist/llm/providers/openai.d.ts.map +1 -0
- package/dist/llm/types.d.ts +91 -0
- package/dist/llm/types.d.ts.map +1 -0
- package/dist/primitives/bigint/bigint.d.ts +197 -0
- package/dist/primitives/bigint/bigint.d.ts.map +1 -0
- package/dist/primitives/bigint/index.d.ts +7 -0
- package/dist/primitives/bigint/index.d.ts.map +1 -0
- package/dist/primitives/bigint/prompts.d.ts +37 -0
- package/dist/primitives/bigint/prompts.d.ts.map +1 -0
- package/dist/primitives/boolean/boolean.d.ts +194 -0
- package/dist/primitives/boolean/boolean.d.ts.map +1 -0
- package/dist/primitives/boolean/evals/from.evals.d.ts +7 -0
- package/dist/primitives/boolean/evals/from.evals.d.ts.map +1 -0
- package/dist/primitives/boolean/evals/index.d.ts +5 -0
- package/dist/primitives/boolean/evals/index.d.ts.map +1 -0
- package/dist/primitives/boolean/index.d.ts +6 -0
- package/dist/primitives/boolean/index.d.ts.map +1 -0
- package/dist/primitives/boolean/prompts.d.ts +29 -0
- package/dist/primitives/boolean/prompts.d.ts.map +1 -0
- package/dist/primitives/index.d.ts +14 -0
- package/dist/primitives/index.d.ts.map +1 -0
- package/dist/primitives/null/index.d.ts +6 -0
- package/dist/primitives/null/index.d.ts.map +1 -0
- package/dist/primitives/null/null.d.ts +181 -0
- package/dist/primitives/null/null.d.ts.map +1 -0
- package/dist/primitives/null/prompts.d.ts +39 -0
- package/dist/primitives/null/prompts.d.ts.map +1 -0
- package/dist/primitives/number/index.d.ts +6 -0
- package/dist/primitives/number/index.d.ts.map +1 -0
- package/dist/primitives/number/number.d.ts +154 -0
- package/dist/primitives/number/number.d.ts.map +1 -0
- package/dist/primitives/number/number.prompts.d.ts +53 -0
- package/dist/primitives/number/number.prompts.d.ts.map +1 -0
- package/dist/primitives/string/evals/classify.evals.d.ts +7 -0
- package/dist/primitives/string/evals/classify.evals.d.ts.map +1 -0
- package/dist/primitives/string/evals/index.d.ts +6 -0
- package/dist/primitives/string/evals/index.d.ts.map +1 -0
- package/dist/primitives/string/evals/semanticallyEquals.evals.d.ts +7 -0
- package/dist/primitives/string/evals/semanticallyEquals.evals.d.ts.map +1 -0
- package/dist/primitives/string/index.d.ts +206 -0
- package/dist/primitives/string/index.d.ts.map +1 -0
- package/dist/primitives/string/string.prompts.d.ts +45 -0
- package/dist/primitives/string/string.prompts.d.ts.map +1 -0
- package/dist/primitives/symbol/index.d.ts +6 -0
- package/dist/primitives/symbol/index.d.ts.map +1 -0
- package/dist/primitives/symbol/symbol.d.ts +176 -0
- package/dist/primitives/symbol/symbol.d.ts.map +1 -0
- package/dist/primitives/symbol/symbol.prompts.d.ts +53 -0
- package/dist/primitives/symbol/symbol.prompts.d.ts.map +1 -0
- package/dist/primitives/undefined/index.d.ts +5 -0
- package/dist/primitives/undefined/index.d.ts.map +1 -0
- package/dist/primitives/undefined/prompts.d.ts +40 -0
- package/dist/primitives/undefined/prompts.d.ts.map +1 -0
- package/dist/primitives/undefined/undefined.d.ts +216 -0
- package/dist/primitives/undefined/undefined.d.ts.map +1 -0
- package/dist/primitives/void/index.d.ts +5 -0
- package/dist/primitives/void/index.d.ts.map +1 -0
- package/dist/primitives/void/prompts.d.ts +37 -0
- package/dist/primitives/void/prompts.d.ts.map +1 -0
- package/dist/primitives/void/void.d.ts +172 -0
- package/dist/primitives/void/void.d.ts.map +1 -0
- package/dist/shared/base-classes.d.ts +331 -0
- package/dist/shared/base-classes.d.ts.map +1 -0
- package/dist/shared/eval-types.d.ts +82 -0
- package/dist/shared/eval-types.d.ts.map +1 -0
- package/dist/shared/index.d.ts +25 -0
- package/dist/shared/index.d.ts.map +1 -0
- package/dist/shared/interfaces.d.ts +799 -0
- package/dist/shared/interfaces.d.ts.map +1 -0
- package/dist/shared/types.d.ts +335 -0
- package/dist/shared/types.d.ts.map +1 -0
- package/dist/types/array/array.d.ts +250 -0
- package/dist/types/array/array.d.ts.map +1 -0
- package/dist/types/array/index.d.ts +6 -0
- package/dist/types/array/index.d.ts.map +1 -0
- package/dist/types/array/prompts.d.ts +63 -0
- package/dist/types/array/prompts.d.ts.map +1 -0
- package/dist/types/blob-file/blob.d.ts +188 -0
- package/dist/types/blob-file/blob.d.ts.map +1 -0
- package/dist/types/blob-file/file.d.ts +144 -0
- package/dist/types/blob-file/file.d.ts.map +1 -0
- package/dist/types/blob-file/index.d.ts +8 -0
- package/dist/types/blob-file/index.d.ts.map +1 -0
- package/dist/types/blob-file/prompts.d.ts +101 -0
- package/dist/types/blob-file/prompts.d.ts.map +1 -0
- package/dist/types/bun/bun.d.ts +266 -0
- package/dist/types/bun/bun.d.ts.map +1 -0
- package/dist/types/bun/index.d.ts +7 -0
- package/dist/types/bun/index.d.ts.map +1 -0
- package/dist/types/bun/prompts.d.ts +93 -0
- package/dist/types/bun/prompts.d.ts.map +1 -0
- package/dist/types/callable/callable.d.ts +200 -0
- package/dist/types/callable/callable.d.ts.map +1 -0
- package/dist/types/callable/index.d.ts +6 -0
- package/dist/types/callable/index.d.ts.map +1 -0
- package/dist/types/callable/prompts.d.ts +45 -0
- package/dist/types/callable/prompts.d.ts.map +1 -0
- package/dist/types/constructable/constructable.d.ts +150 -0
- package/dist/types/constructable/constructable.d.ts.map +1 -0
- package/dist/types/constructable/index.d.ts +5 -0
- package/dist/types/constructable/index.d.ts.map +1 -0
- package/dist/types/constructable/prompts.d.ts +41 -0
- package/dist/types/constructable/prompts.d.ts.map +1 -0
- package/dist/types/date/date.d.ts +258 -0
- package/dist/types/date/date.d.ts.map +1 -0
- package/dist/types/date/index.d.ts +6 -0
- package/dist/types/date/index.d.ts.map +1 -0
- package/dist/types/date/prompts.d.ts +93 -0
- package/dist/types/date/prompts.d.ts.map +1 -0
- package/dist/types/error/error.d.ts +191 -0
- package/dist/types/error/error.d.ts.map +1 -0
- package/dist/types/error/index.d.ts +6 -0
- package/dist/types/error/index.d.ts.map +1 -0
- package/dist/types/error/prompts.d.ts +49 -0
- package/dist/types/error/prompts.d.ts.map +1 -0
- package/dist/types/event-emitter/event-emitter.d.ts +230 -0
- package/dist/types/event-emitter/event-emitter.d.ts.map +1 -0
- package/dist/types/event-emitter/index.d.ts +6 -0
- package/dist/types/event-emitter/index.d.ts.map +1 -0
- package/dist/types/event-emitter/prompts.d.ts +51 -0
- package/dist/types/event-emitter/prompts.d.ts.map +1 -0
- package/dist/types/fetch/headers.d.ts +126 -0
- package/dist/types/fetch/headers.d.ts.map +1 -0
- package/dist/types/fetch/index.d.ts +9 -0
- package/dist/types/fetch/index.d.ts.map +1 -0
- package/dist/types/fetch/prompts.d.ts +139 -0
- package/dist/types/fetch/prompts.d.ts.map +1 -0
- package/dist/types/fetch/request.d.ts +188 -0
- package/dist/types/fetch/request.d.ts.map +1 -0
- package/dist/types/fetch/response.d.ts +155 -0
- package/dist/types/fetch/response.d.ts.map +1 -0
- package/dist/types/form-data/form-data.d.ts +277 -0
- package/dist/types/form-data/form-data.d.ts.map +1 -0
- package/dist/types/form-data/index.d.ts +7 -0
- package/dist/types/form-data/index.d.ts.map +1 -0
- package/dist/types/form-data/prompts.d.ts +80 -0
- package/dist/types/form-data/prompts.d.ts.map +1 -0
- package/dist/types/index.d.ts +29 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/map/index.d.ts +6 -0
- package/dist/types/map/index.d.ts.map +1 -0
- package/dist/types/map/map.d.ts +204 -0
- package/dist/types/map/map.d.ts.map +1 -0
- package/dist/types/map/prompts.d.ts +56 -0
- package/dist/types/map/prompts.d.ts.map +1 -0
- package/dist/types/never/index.d.ts +5 -0
- package/dist/types/never/index.d.ts.map +1 -0
- package/dist/types/never/never.d.ts +220 -0
- package/dist/types/never/never.d.ts.map +1 -0
- package/dist/types/never/prompts.d.ts +50 -0
- package/dist/types/never/prompts.d.ts.map +1 -0
- package/dist/types/object/index.d.ts +6 -0
- package/dist/types/object/index.d.ts.map +1 -0
- package/dist/types/object/object.d.ts +162 -0
- package/dist/types/object/object.d.ts.map +1 -0
- package/dist/types/object/prompts.d.ts +55 -0
- package/dist/types/object/prompts.d.ts.map +1 -0
- package/dist/types/object-literal/index.d.ts +6 -0
- package/dist/types/object-literal/index.d.ts.map +1 -0
- package/dist/types/object-literal/object-literal.d.ts +223 -0
- package/dist/types/object-literal/object-literal.d.ts.map +1 -0
- package/dist/types/object-literal/prompts.d.ts +49 -0
- package/dist/types/object-literal/prompts.d.ts.map +1 -0
- package/dist/types/promise/index.d.ts +6 -0
- package/dist/types/promise/index.d.ts.map +1 -0
- package/dist/types/promise/promise.d.ts +240 -0
- package/dist/types/promise/promise.d.ts.map +1 -0
- package/dist/types/promise/prompts.d.ts +45 -0
- package/dist/types/promise/prompts.d.ts.map +1 -0
- package/dist/types/record/index.d.ts +5 -0
- package/dist/types/record/index.d.ts.map +1 -0
- package/dist/types/record/prompts.d.ts +45 -0
- package/dist/types/record/prompts.d.ts.map +1 -0
- package/dist/types/record/record.d.ts +179 -0
- package/dist/types/record/record.d.ts.map +1 -0
- package/dist/types/regexp/index.d.ts +7 -0
- package/dist/types/regexp/index.d.ts.map +1 -0
- package/dist/types/regexp/prompts.d.ts +56 -0
- package/dist/types/regexp/prompts.d.ts.map +1 -0
- package/dist/types/regexp/regexp.d.ts +160 -0
- package/dist/types/regexp/regexp.d.ts.map +1 -0
- package/dist/types/set/index.d.ts +6 -0
- package/dist/types/set/index.d.ts.map +1 -0
- package/dist/types/set/prompts.d.ts +60 -0
- package/dist/types/set/prompts.d.ts.map +1 -0
- package/dist/types/set/set.d.ts +261 -0
- package/dist/types/set/set.d.ts.map +1 -0
- package/dist/types/streams/index.d.ts +8 -0
- package/dist/types/streams/index.d.ts.map +1 -0
- package/dist/types/streams/prompts.d.ts +53 -0
- package/dist/types/streams/prompts.d.ts.map +1 -0
- package/dist/types/streams/readable-stream.d.ts +148 -0
- package/dist/types/streams/readable-stream.d.ts.map +1 -0
- package/dist/types/streams/transform-stream.d.ts +67 -0
- package/dist/types/streams/transform-stream.d.ts.map +1 -0
- package/dist/types/streams/writable-stream.d.ts +111 -0
- package/dist/types/streams/writable-stream.d.ts.map +1 -0
- package/dist/types/text-codec/index.d.ts +12 -0
- package/dist/types/text-codec/index.d.ts.map +1 -0
- package/dist/types/text-codec/prompts.d.ts +79 -0
- package/dist/types/text-codec/prompts.d.ts.map +1 -0
- package/dist/types/text-codec/text-codec.d.ts +305 -0
- package/dist/types/text-codec/text-codec.d.ts.map +1 -0
- package/dist/types/tuple/index.d.ts +6 -0
- package/dist/types/tuple/index.d.ts.map +1 -0
- package/dist/types/tuple/prompts.d.ts +41 -0
- package/dist/types/tuple/prompts.d.ts.map +1 -0
- package/dist/types/tuple/tuple.d.ts +221 -0
- package/dist/types/tuple/tuple.d.ts.map +1 -0
- package/dist/types/unknown/index.d.ts +5 -0
- package/dist/types/unknown/index.d.ts.map +1 -0
- package/dist/types/unknown/prompts.d.ts +45 -0
- package/dist/types/unknown/prompts.d.ts.map +1 -0
- package/dist/types/unknown/unknown.d.ts +220 -0
- package/dist/types/unknown/unknown.d.ts.map +1 -0
- package/dist/types/url/index.d.ts +7 -0
- package/dist/types/url/index.d.ts.map +1 -0
- package/dist/types/url/prompts.d.ts +93 -0
- package/dist/types/url/prompts.d.ts.map +1 -0
- package/dist/types/url/url.d.ts +270 -0
- package/dist/types/url/url.d.ts.map +1 -0
- package/package.json +73 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified LLM Client
|
|
3
|
+
* Provides a single interface to interact with multiple LLM providers
|
|
4
|
+
*/
|
|
5
|
+
import type { ChatOptions, CompletionOptions, LLMProvider, LLMResponse } from './types.ts';
|
|
6
|
+
/**
|
|
7
|
+
* LLM Client - Unified interface for LLM operations
|
|
8
|
+
*
|
|
9
|
+
* Uses environment variables for configuration:
|
|
10
|
+
* - LLM_PROVIDER: Which provider to use (openai, anthropic, google)
|
|
11
|
+
* - Provider-specific API keys and models
|
|
12
|
+
*/
|
|
13
|
+
export declare class LLMClient {
|
|
14
|
+
private defaultProvider;
|
|
15
|
+
private apiKeys;
|
|
16
|
+
constructor(config?: {
|
|
17
|
+
provider?: LLMProvider;
|
|
18
|
+
apiKeys?: Partial<Record<LLMProvider, string>>;
|
|
19
|
+
});
|
|
20
|
+
/** Get the API key for a provider */
|
|
21
|
+
private getApiKey;
|
|
22
|
+
/** Resolve the provider from options or default */
|
|
23
|
+
private resolveProvider;
|
|
24
|
+
/**
|
|
25
|
+
* Generate a completion from a prompt
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* const client = new LLMClient();
|
|
30
|
+
* const response = await client.complete({
|
|
31
|
+
* prompt: "What is the capital of France?",
|
|
32
|
+
* systemPrompt: "You are a helpful geography assistant."
|
|
33
|
+
* });
|
|
34
|
+
* console.log(response.content);
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
complete(options: CompletionOptions): Promise<LLMResponse>;
|
|
38
|
+
/**
|
|
39
|
+
* Generate a response in a chat conversation
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* const client = new LLMClient();
|
|
44
|
+
* const response = await client.chat({
|
|
45
|
+
* messages: [
|
|
46
|
+
* { role: "user", content: "Hello!" },
|
|
47
|
+
* { role: "assistant", content: "Hi there! How can I help?" },
|
|
48
|
+
* { role: "user", content: "What's the weather like?" }
|
|
49
|
+
* ]
|
|
50
|
+
* });
|
|
51
|
+
* console.log(response.content);
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
chat(options: ChatOptions): Promise<LLMResponse>;
|
|
55
|
+
/**
|
|
56
|
+
* Switch to a different provider
|
|
57
|
+
*/
|
|
58
|
+
withProvider(provider: LLMProvider): LLMClient;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Get the default LLM client (singleton)
|
|
62
|
+
*/
|
|
63
|
+
export declare function getClient(): LLMClient;
|
|
64
|
+
/**
|
|
65
|
+
* Convenience function for simple completions
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```ts
|
|
69
|
+
* const response = await complete("What is 2 + 2?");
|
|
70
|
+
* console.log(response.content); // "4"
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export declare function complete(prompt: string, options?: Omit<CompletionOptions, 'prompt'>): Promise<LLMResponse>;
|
|
74
|
+
/**
|
|
75
|
+
* Convenience function for simple chat completions
|
|
76
|
+
*/
|
|
77
|
+
export declare function chat(options: ChatOptions): Promise<LLMResponse>;
|
|
78
|
+
/**
|
|
79
|
+
* Clear the provider cache (useful for testing or reconfiguration)
|
|
80
|
+
*/
|
|
81
|
+
export declare function clearProviderCache(): void;
|
|
82
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/llm/client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,iBAAiB,EAEjB,WAAW,EAEX,WAAW,EACZ,MAAM,YAAY,CAAC;AAkCpB;;;;;;GAMG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,eAAe,CAAc;IACrC,OAAO,CAAC,OAAO,CAAuC;gBAE1C,MAAM,CAAC,EAAE;QACnB,QAAQ,CAAC,EAAE,WAAW,CAAC;QACvB,OAAO,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC;KAChD;IAMD,qCAAqC;IACrC,OAAO,CAAC,SAAS;IAIjB,mDAAmD;IACnD,OAAO,CAAC,eAAe;IAIvB;;;;;;;;;;;;OAYG;IACG,QAAQ,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,WAAW,CAAC;IAMhE;;;;;;;;;;;;;;;OAeG;IACG,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IAMtD;;OAEG;IACH,YAAY,CAAC,QAAQ,EAAE,WAAW,GAAG,SAAS;CAM/C;AAKD;;GAEG;AACH,wBAAgB,SAAS,IAAI,SAAS,CAKrC;AAED;;;;;;;;GAQG;AACH,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,IAAI,CAAC,iBAAiB,EAAE,QAAQ,CAAC,GAC1C,OAAO,CAAC,WAAW,CAAC,CAEtB;AAED;;GAEG;AACH,wBAAsB,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAErE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,IAAI,CAGzC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LLM Module Exports
|
|
3
|
+
* Unified API for interacting with multiple LLM providers
|
|
4
|
+
*/
|
|
5
|
+
export type { LLMProvider, MessageRole, Message, LLMConfig, CompletionOptions, ChatOptions, LLMResponse, LLMProviderInterface, LLMEnvironment, } from './types.ts';
|
|
6
|
+
export { getEnvConfig } from './types.ts';
|
|
7
|
+
export { LLMClient, getClient, complete, chat, clearProviderCache, } from './client.ts';
|
|
8
|
+
export { OpenAIProvider } from './providers/openai.ts';
|
|
9
|
+
export { AnthropicProvider } from './providers/anthropic.ts';
|
|
10
|
+
export { GoogleProvider } from './providers/google.ts';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/llm/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,YAAY,EACV,WAAW,EACX,WAAW,EACX,OAAO,EACP,SAAS,EACT,iBAAiB,EACjB,WAAW,EACX,WAAW,EACX,oBAAoB,EACpB,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG1C,OAAO,EACL,SAAS,EACT,SAAS,EACT,QAAQ,EACR,IAAI,EACJ,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Anthropic Provider Implementation
|
|
3
|
+
*/
|
|
4
|
+
import type { ChatOptions, CompletionOptions, LLMProviderInterface, LLMResponse } from '../types.ts';
|
|
5
|
+
export declare class AnthropicProvider implements LLMProviderInterface {
|
|
6
|
+
readonly provider: "anthropic";
|
|
7
|
+
private client;
|
|
8
|
+
private defaultModel;
|
|
9
|
+
constructor(apiKey?: string, model?: string);
|
|
10
|
+
complete(options: CompletionOptions): Promise<LLMResponse>;
|
|
11
|
+
chat(options: ChatOptions): Promise<LLMResponse>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=anthropic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anthropic.d.ts","sourceRoot":"","sources":["../../../src/llm/providers/anthropic.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EACV,WAAW,EACX,iBAAiB,EACjB,oBAAoB,EACpB,WAAW,EAEZ,MAAM,aAAa,CAAC;AAuBrB,qBAAa,iBAAkB,YAAW,oBAAoB;IAC5D,QAAQ,CAAC,QAAQ,EAAG,WAAW,CAAU;IACzC,OAAO,CAAC,MAAM,CAAY;IAC1B,OAAO,CAAC,YAAY,CAAS;gBAEjB,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM;IAYrC,QAAQ,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,WAAW,CAAC;IA8B1D,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;CAgCvD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Google Generative AI (Gemini) Provider Implementation
|
|
3
|
+
*/
|
|
4
|
+
import type { ChatOptions, CompletionOptions, LLMProviderInterface, LLMResponse } from '../types.ts';
|
|
5
|
+
export declare class GoogleProvider implements LLMProviderInterface {
|
|
6
|
+
readonly provider: "google";
|
|
7
|
+
private client;
|
|
8
|
+
private defaultModel;
|
|
9
|
+
constructor(apiKey?: string, model?: string);
|
|
10
|
+
complete(options: CompletionOptions): Promise<LLMResponse>;
|
|
11
|
+
chat(options: ChatOptions): Promise<LLMResponse>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=google.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google.d.ts","sourceRoot":"","sources":["../../../src/llm/providers/google.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EACV,WAAW,EACX,iBAAiB,EACjB,oBAAoB,EACpB,WAAW,EAEZ,MAAM,aAAa,CAAC;AAqBrB,qBAAa,cAAe,YAAW,oBAAoB;IACzD,QAAQ,CAAC,QAAQ,EAAG,QAAQ,CAAU;IACtC,OAAO,CAAC,MAAM,CAAqB;IACnC,OAAO,CAAC,YAAY,CAAS;gBAEjB,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM;IAYrC,QAAQ,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,WAAW,CAAC;IAoC1D,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;CAwCvD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/llm/providers/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAI Provider Implementation
|
|
3
|
+
*/
|
|
4
|
+
import type { ChatOptions, CompletionOptions, LLMProviderInterface, LLMResponse } from '../types.ts';
|
|
5
|
+
export declare class OpenAIProvider implements LLMProviderInterface {
|
|
6
|
+
readonly provider: "openai";
|
|
7
|
+
private client;
|
|
8
|
+
private defaultModel;
|
|
9
|
+
constructor(apiKey?: string, model?: string);
|
|
10
|
+
complete(options: CompletionOptions): Promise<LLMResponse>;
|
|
11
|
+
chat(options: ChatOptions): Promise<LLMResponse>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=openai.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../../src/llm/providers/openai.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EACV,WAAW,EACX,iBAAiB,EACjB,oBAAoB,EACpB,WAAW,EAEZ,MAAM,aAAa,CAAC;AAoBrB,qBAAa,cAAe,YAAW,oBAAoB;IACzD,QAAQ,CAAC,QAAQ,EAAG,QAAQ,CAAU;IACtC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,YAAY,CAAS;gBAEjB,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM;IAYrC,QAAQ,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,WAAW,CAAC;IAoC1D,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;CAgCvD"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LLM Provider Types and Interfaces
|
|
3
|
+
* Provides a universal API for interacting with different LLM providers
|
|
4
|
+
*/
|
|
5
|
+
/** Supported LLM providers */
|
|
6
|
+
export type LLMProvider = 'openai' | 'anthropic' | 'google';
|
|
7
|
+
/** Role in a conversation message */
|
|
8
|
+
export type MessageRole = 'system' | 'user' | 'assistant';
|
|
9
|
+
/** A single message in a conversation */
|
|
10
|
+
export interface Message {
|
|
11
|
+
role: MessageRole;
|
|
12
|
+
content: string;
|
|
13
|
+
}
|
|
14
|
+
/** Configuration for LLM requests */
|
|
15
|
+
export interface LLMConfig {
|
|
16
|
+
/** The provider to use (defaults to LLM_PROVIDER env var) */
|
|
17
|
+
provider?: LLMProvider;
|
|
18
|
+
/** Model identifier (uses provider-specific default if not set) */
|
|
19
|
+
model?: string;
|
|
20
|
+
/** Maximum tokens to generate */
|
|
21
|
+
maxTokens?: number;
|
|
22
|
+
/** Temperature for response randomness (0-2) */
|
|
23
|
+
temperature?: number;
|
|
24
|
+
/** Top-p sampling parameter */
|
|
25
|
+
topP?: number;
|
|
26
|
+
/** Stop sequences to end generation */
|
|
27
|
+
stopSequences?: string[];
|
|
28
|
+
}
|
|
29
|
+
/** Options for a completion request */
|
|
30
|
+
export interface CompletionOptions extends LLMConfig {
|
|
31
|
+
/** The prompt to send to the model */
|
|
32
|
+
prompt: string;
|
|
33
|
+
/** Optional system message to set context */
|
|
34
|
+
systemPrompt?: string;
|
|
35
|
+
}
|
|
36
|
+
/** Options for a chat request */
|
|
37
|
+
export interface ChatOptions extends LLMConfig {
|
|
38
|
+
/** Array of messages in the conversation */
|
|
39
|
+
messages: Message[];
|
|
40
|
+
/** Optional system message (prepended to messages) */
|
|
41
|
+
systemPrompt?: string;
|
|
42
|
+
}
|
|
43
|
+
/** Standard response from an LLM request */
|
|
44
|
+
export interface LLMResponse {
|
|
45
|
+
/** The generated text content */
|
|
46
|
+
content: string;
|
|
47
|
+
/** The provider that generated the response */
|
|
48
|
+
provider: LLMProvider;
|
|
49
|
+
/** The model that was used */
|
|
50
|
+
model: string;
|
|
51
|
+
/** Token usage statistics (if available) */
|
|
52
|
+
usage?: {
|
|
53
|
+
promptTokens: number;
|
|
54
|
+
completionTokens: number;
|
|
55
|
+
totalTokens: number;
|
|
56
|
+
};
|
|
57
|
+
/** The raw response from the provider (for advanced use) */
|
|
58
|
+
raw?: unknown;
|
|
59
|
+
}
|
|
60
|
+
/** Interface that all LLM provider implementations must follow */
|
|
61
|
+
export interface LLMProviderInterface {
|
|
62
|
+
/** Provider identifier */
|
|
63
|
+
readonly provider: LLMProvider;
|
|
64
|
+
/** Generate a completion from a prompt */
|
|
65
|
+
complete(options: CompletionOptions): Promise<LLMResponse>;
|
|
66
|
+
/** Generate a response in a chat conversation */
|
|
67
|
+
chat(options: ChatOptions): Promise<LLMResponse>;
|
|
68
|
+
}
|
|
69
|
+
/** Environment configuration for LLM */
|
|
70
|
+
export interface LLMEnvironment {
|
|
71
|
+
provider: LLMProvider;
|
|
72
|
+
openai: {
|
|
73
|
+
apiKey?: string;
|
|
74
|
+
model: string;
|
|
75
|
+
};
|
|
76
|
+
anthropic: {
|
|
77
|
+
apiKey?: string;
|
|
78
|
+
model: string;
|
|
79
|
+
};
|
|
80
|
+
google: {
|
|
81
|
+
apiKey?: string;
|
|
82
|
+
model: string;
|
|
83
|
+
};
|
|
84
|
+
defaults: {
|
|
85
|
+
maxTokens: number;
|
|
86
|
+
temperature: number;
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/** Get environment configuration */
|
|
90
|
+
export declare function getEnvConfig(): LLMEnvironment;
|
|
91
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/llm/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,8BAA8B;AAC9B,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,WAAW,GAAG,QAAQ,CAAC;AAE5D,qCAAqC;AACrC,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAC;AAE1D,yCAAyC;AACzC,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,qCAAqC;AACrC,MAAM,WAAW,SAAS;IACxB,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,WAAW,CAAC;IACvB,mEAAmE;IACnE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iCAAiC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gDAAgD;IAChD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+BAA+B;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uCAAuC;IACvC,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED,uCAAuC;AACvC,MAAM,WAAW,iBAAkB,SAAQ,SAAS;IAClD,sCAAsC;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,iCAAiC;AACjC,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C,4CAA4C;IAC5C,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,sDAAsD;IACtD,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,4CAA4C;AAC5C,MAAM,WAAW,WAAW;IAC1B,iCAAiC;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,+CAA+C;IAC/C,QAAQ,EAAE,WAAW,CAAC;IACtB,8BAA8B;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,4CAA4C;IAC5C,KAAK,CAAC,EAAE;QACN,YAAY,EAAE,MAAM,CAAC;QACrB,gBAAgB,EAAE,MAAM,CAAC;QACzB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,4DAA4D;IAC5D,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED,kEAAkE;AAClE,MAAM,WAAW,oBAAoB;IACnC,0BAA0B;IAC1B,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC;IAE/B,0CAA0C;IAC1C,QAAQ,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IAE3D,iDAAiD;IACjD,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;CAClD;AAED,wCAAwC;AACxC,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,WAAW,CAAC;IACtB,MAAM,EAAE;QACN,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,SAAS,EAAE;QACT,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,MAAM,EAAE;QACN,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,QAAQ,EAAE;QACR,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;CACH;AAED,oCAAoC;AACpC,wBAAgB,YAAY,IAAI,cAAc,CAoB7C"}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SemanticBigInt
|
|
3
|
+
* A BigInt type with LLM-powered semantic understanding
|
|
4
|
+
*
|
|
5
|
+
* Implements shared interfaces:
|
|
6
|
+
* - Semantic<bigint> - Base semantic wrapper
|
|
7
|
+
* - Comparable<bigint | SemanticBigInt> - Semantic equality comparison
|
|
8
|
+
* - ContextValidatable - Domain-specific validation
|
|
9
|
+
* - Describable - Human-readable descriptions
|
|
10
|
+
*/
|
|
11
|
+
import type { LLMClient } from '../../llm/client.ts';
|
|
12
|
+
import type { SemanticEqualsResult, ReasonableResult, InferDomainResult } from '../../shared/types.ts';
|
|
13
|
+
import type { Semantic, Comparable, ContextValidatable, Describable } from '../../shared/interfaces.ts';
|
|
14
|
+
export type { SemanticEqualsResult, ReasonableResult, InferDomainResult } from '../../shared/types.ts';
|
|
15
|
+
/** Format style options for BigInt display */
|
|
16
|
+
export type FormatStyle = 'words' | 'compact' | 'scientific' | 'full';
|
|
17
|
+
/** Options for formatting BigInt values */
|
|
18
|
+
export interface FormatOptions {
|
|
19
|
+
style?: FormatStyle;
|
|
20
|
+
locale?: string;
|
|
21
|
+
}
|
|
22
|
+
/** Result of scale/magnitude analysis */
|
|
23
|
+
export interface ScaleResult {
|
|
24
|
+
magnitude: number;
|
|
25
|
+
name: string;
|
|
26
|
+
scientificNotation: string;
|
|
27
|
+
}
|
|
28
|
+
/** Common mathematical patterns */
|
|
29
|
+
export type MatchPattern = 'power-of-two' | 'prime' | 'perfect-square' | 'factorial' | 'fibonacci' | 'even' | 'odd';
|
|
30
|
+
/**
|
|
31
|
+
* SemanticBigInt - BigInt with LLM-powered semantic understanding
|
|
32
|
+
*
|
|
33
|
+
* Unlike traditional BigInts that are just large integers,
|
|
34
|
+
* semantic BigInts can interpret natural language, understand domain context,
|
|
35
|
+
* and provide human-readable representations.
|
|
36
|
+
*/
|
|
37
|
+
export declare class SemanticBigInt implements Semantic<bigint>, Comparable<bigint | SemanticBigInt>, ContextValidatable, Describable {
|
|
38
|
+
private readonly _value;
|
|
39
|
+
private readonly client;
|
|
40
|
+
private constructor();
|
|
41
|
+
/**
|
|
42
|
+
* Create a SemanticBigInt from a raw bigint value
|
|
43
|
+
*/
|
|
44
|
+
static fromBigInt(value: bigint, client?: LLMClient): SemanticBigInt;
|
|
45
|
+
/**
|
|
46
|
+
* Create a SemanticBigInt from a number
|
|
47
|
+
*/
|
|
48
|
+
static fromNumber(value: number, client?: LLMClient): SemanticBigInt;
|
|
49
|
+
/**
|
|
50
|
+
* Parse a BigInt from natural language or formatted string.
|
|
51
|
+
* Understands scientific notation, word forms, and abbreviations.
|
|
52
|
+
*
|
|
53
|
+
* @param input - Natural language or formatted BigInt string, number, or bigint
|
|
54
|
+
* @param client - Optional LLM client to use
|
|
55
|
+
* @returns Promise resolving to SemanticBigInt instance
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* await SemanticBigInt.from("1 trillion") // 1000000000000n
|
|
59
|
+
* await SemanticBigInt.from("10^18") // 1000000000000000000n
|
|
60
|
+
* await SemanticBigInt.from("5.2e15") // 5200000000000000n
|
|
61
|
+
*/
|
|
62
|
+
static from(input: string | number | bigint, client?: LLMClient): Promise<SemanticBigInt>;
|
|
63
|
+
/**
|
|
64
|
+
* Check if two BigInts are semantically equivalent.
|
|
65
|
+
* Considers approximate values for very large numbers.
|
|
66
|
+
*
|
|
67
|
+
* @param other - BigInt to compare with
|
|
68
|
+
* @param options - Comparison options
|
|
69
|
+
* @returns Promise resolving to equivalence result with confidence
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* const trillion = await SemanticBigInt.from("1 trillion");
|
|
73
|
+
* await trillion.semanticallyEquals(1000000000000n)
|
|
74
|
+
* // { equivalent: true, confidence: 1.0 }
|
|
75
|
+
*/
|
|
76
|
+
semanticallyEquals(other: bigint | SemanticBigInt, options?: {
|
|
77
|
+
tolerance?: 'exact' | 'approximate';
|
|
78
|
+
}): Promise<SemanticEqualsResult>;
|
|
79
|
+
/**
|
|
80
|
+
* Validate if the BigInt is reasonable for a given domain.
|
|
81
|
+
*
|
|
82
|
+
* @param domain - Domain context (e.g., "database-id", "cryptocurrency-amount")
|
|
83
|
+
* @returns Promise resolving to validation result with explanation
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* const negative = SemanticBigInt.fromBigInt(-1n);
|
|
87
|
+
* await negative.isReasonable("database-id")
|
|
88
|
+
* // { reasonable: false, explanation: "Database IDs are typically positive" }
|
|
89
|
+
*/
|
|
90
|
+
isReasonable(domain: string): Promise<ReasonableResult>;
|
|
91
|
+
/**
|
|
92
|
+
* Format the BigInt in a human-readable way.
|
|
93
|
+
*
|
|
94
|
+
* @param options - Formatting options
|
|
95
|
+
* @returns Promise resolving to formatted string
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* const big = SemanticBigInt.fromBigInt(1234567890123n);
|
|
99
|
+
* await big.format({ style: "words" }) // "1.23 trillion"
|
|
100
|
+
* await big.format({ style: "scientific" }) // "1.23 × 10^12"
|
|
101
|
+
*/
|
|
102
|
+
format(options?: FormatOptions): Promise<string>;
|
|
103
|
+
/**
|
|
104
|
+
* Format with thousands separators (full style)
|
|
105
|
+
*/
|
|
106
|
+
private formatFull;
|
|
107
|
+
/**
|
|
108
|
+
* Generate a human-readable explanation of this BigInt.
|
|
109
|
+
* Implements Explainable interface.
|
|
110
|
+
*
|
|
111
|
+
* @param context - Optional context for more relevant explanation
|
|
112
|
+
* @returns Promise resolving to human-readable explanation
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* const big = SemanticBigInt.fromBigInt(1000000000000n);
|
|
116
|
+
* await big.explain() // "A 12-digit number in the trillions"
|
|
117
|
+
*/
|
|
118
|
+
explain(context?: string): Promise<string>;
|
|
119
|
+
/**
|
|
120
|
+
* Get a human-friendly description of the magnitude.
|
|
121
|
+
*
|
|
122
|
+
* @param context - Optional context for more relevant comparison
|
|
123
|
+
* @returns Promise resolving to human-readable description with relatable comparisons
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* const population = SemanticBigInt.fromBigInt(7900000000n);
|
|
127
|
+
* await population.describe("population")
|
|
128
|
+
* // "about 7.9 billion (roughly the world population)"
|
|
129
|
+
*/
|
|
130
|
+
describe(context?: string): Promise<string>;
|
|
131
|
+
/**
|
|
132
|
+
* Infer what domain or type this BigInt likely represents.
|
|
133
|
+
*
|
|
134
|
+
* @returns Promise resolving to inferred domain with confidence
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* const timestamp = SemanticBigInt.fromBigInt(1609459200000n);
|
|
138
|
+
* await timestamp.inferDomain()
|
|
139
|
+
* // { domain: "unix-timestamp-ms", confidence: 0.87 }
|
|
140
|
+
*/
|
|
141
|
+
inferDomain(): Promise<InferDomainResult>;
|
|
142
|
+
/**
|
|
143
|
+
* Check if this BigInt matches common patterns.
|
|
144
|
+
* Uses local computation for efficiency when possible.
|
|
145
|
+
*
|
|
146
|
+
* @param pattern - Pattern to check
|
|
147
|
+
* @returns Promise resolving to whether the BigInt matches the pattern
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* const power = SemanticBigInt.fromBigInt(1024n);
|
|
151
|
+
* await power.matches("power-of-two") // true
|
|
152
|
+
* const prime = SemanticBigInt.fromBigInt(13n);
|
|
153
|
+
* await prime.matches("prime") // true
|
|
154
|
+
*/
|
|
155
|
+
matches(pattern: string): Promise<boolean>;
|
|
156
|
+
/**
|
|
157
|
+
* Check if value is a power of two (local computation)
|
|
158
|
+
*/
|
|
159
|
+
private isPowerOfTwo;
|
|
160
|
+
/**
|
|
161
|
+
* Check if value is a perfect square (local computation)
|
|
162
|
+
*/
|
|
163
|
+
private isPerfectSquare;
|
|
164
|
+
/**
|
|
165
|
+
* Check if value is prime (local computation for small numbers)
|
|
166
|
+
*/
|
|
167
|
+
private isPrimeLocal;
|
|
168
|
+
/**
|
|
169
|
+
* Get the scale/order of magnitude.
|
|
170
|
+
*
|
|
171
|
+
* @returns Scale description with magnitude, name, and scientific notation
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* const trillion = SemanticBigInt.fromBigInt(1000000000000n);
|
|
175
|
+
* trillion.scale()
|
|
176
|
+
* // { magnitude: 12, name: "trillion", scientificNotation: "10^12" }
|
|
177
|
+
*/
|
|
178
|
+
scale(): ScaleResult;
|
|
179
|
+
/**
|
|
180
|
+
* Get the raw BigInt value.
|
|
181
|
+
*
|
|
182
|
+
* @returns The underlying BigInt
|
|
183
|
+
*/
|
|
184
|
+
valueOf(): bigint;
|
|
185
|
+
/**
|
|
186
|
+
* Convert to string representation
|
|
187
|
+
*/
|
|
188
|
+
toString(): string;
|
|
189
|
+
/**
|
|
190
|
+
* Convert to JSON representation
|
|
191
|
+
*/
|
|
192
|
+
toJSON(): {
|
|
193
|
+
value: string;
|
|
194
|
+
scale: ScaleResult;
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
//# sourceMappingURL=bigint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bigint.d.ts","sourceRoot":"","sources":["../../../src/primitives/bigint/bigint.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SemanticBigInt Module
|
|
3
|
+
* Exports all SemanticBigInt types and utilities
|
|
4
|
+
*/
|
|
5
|
+
export { SemanticBigInt, type FormatStyle, type FormatOptions, type ScaleResult, type MatchPattern, } from './bigint.ts';
|
|
6
|
+
export type { SemanticEqualsResult, ReasonableResult, InferDomainResult, } from '../../shared/types.ts';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/primitives/bigint/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,cAAc,EACd,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,YAAY,GAClB,MAAM,aAAa,CAAC;AAErB,YAAY,EACV,oBAAoB,EACpB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompts for SemanticBigInt LLM operations
|
|
3
|
+
* These prompts are used to interpret, analyze, and describe large integers
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* System prompt for BigInt interpretation and analysis tasks
|
|
7
|
+
*/
|
|
8
|
+
export declare const BIGINT_SYSTEM_PROMPT = "You are a semantic BigInt interpreter. Your task is to analyze large integers, understand their context, and provide meaningful interpretations.\n\nYou must respond with valid JSON only, no additional text or explanation.\n\nGuidelines:\n- Interpret natural language representations of large numbers (billions, trillions, scientific notation)\n- Recognize common BigInt domains: timestamps, database IDs, cryptocurrency amounts, cryptographic values\n- Provide confidence scores from 0.0 to 1.0 based on clarity and certainty\n- Consider the magnitude and context when making domain inferences\n- Use appropriate scale names: thousand, million, billion, trillion, quadrillion, etc.";
|
|
9
|
+
/**
|
|
10
|
+
* Prompt template for parsing natural language to BigInt
|
|
11
|
+
*/
|
|
12
|
+
export declare function createFromPrompt(input: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Prompt template for semantic equality comparison
|
|
15
|
+
*/
|
|
16
|
+
export declare function createSemanticallyEqualsPrompt(value1: string, value2: string, tolerance: 'exact' | 'approximate'): string;
|
|
17
|
+
/**
|
|
18
|
+
* Prompt template for domain reasonableness validation
|
|
19
|
+
*/
|
|
20
|
+
export declare function createIsReasonablePrompt(value: string, domain: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Prompt template for human-readable formatting
|
|
23
|
+
*/
|
|
24
|
+
export declare function createFormatPrompt(value: string, style: 'words' | 'compact' | 'scientific' | 'full', locale?: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Prompt template for describing magnitude with context
|
|
27
|
+
*/
|
|
28
|
+
export declare function createDescribePrompt(value: string, context?: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* Prompt template for domain inference
|
|
31
|
+
*/
|
|
32
|
+
export declare function createInferDomainPrompt(value: string): string;
|
|
33
|
+
/**
|
|
34
|
+
* Prompt template for pattern matching
|
|
35
|
+
*/
|
|
36
|
+
export declare function createMatchesPatternPrompt(value: string, pattern: string): string;
|
|
37
|
+
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../src/primitives/bigint/prompts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,eAAO,MAAM,oBAAoB,8qBASsD,CAAC;AAExF;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAgBtD;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,OAAO,GAAG,aAAa,GACjC,MAAM,CAcR;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,MAAM,CAoBR;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,OAAO,GAAG,SAAS,GAAG,YAAY,GAAG,MAAM,EAClD,MAAM,CAAC,EAAE,MAAM,GACd,MAAM,CAiBR;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,MAAM,GACf,MAAM,CAeR;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAoB7D;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,GACd,MAAM,CAsBR"}
|