hazo_llm_api 1.0.3 → 1.0.4
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/README.md +4 -4
- package/package.json +1 -1
- package/techdoc.md +2 -2
- package/dist/components/hazo_llm_prompt_config/hazo_llm_prompt_config.d.ts +0 -16
- package/dist/components/hazo_llm_prompt_config/hazo_llm_prompt_config.d.ts.map +0 -1
- package/dist/components/hazo_llm_prompt_config/hazo_llm_prompt_config.js +0 -258
- package/dist/components/hazo_llm_prompt_config/hazo_llm_prompt_config.js.map +0 -1
- package/dist/components/hazo_llm_prompt_config/index.d.ts +0 -8
- package/dist/components/hazo_llm_prompt_config/index.d.ts.map +0 -1
- package/dist/components/hazo_llm_prompt_config/index.js +0 -7
- package/dist/components/hazo_llm_prompt_config/index.js.map +0 -1
- package/dist/components/hazo_llm_prompt_config/types.d.ts +0 -74
- package/dist/components/hazo_llm_prompt_config/types.d.ts.map +0 -1
- package/dist/components/hazo_llm_prompt_config/types.js +0 -8
- package/dist/components/hazo_llm_prompt_config/types.js.map +0 -1
- package/dist/components/index.d.ts +0 -7
- package/dist/components/index.d.ts.map +0 -1
- package/dist/components/index.js +0 -7
- package/dist/components/index.js.map +0 -1
- package/dist/components/layout/index.d.ts +0 -7
- package/dist/components/layout/index.d.ts.map +0 -1
- package/dist/components/layout/index.js +0 -7
- package/dist/components/layout/index.js.map +0 -1
- package/dist/components/layout/layout.d.ts +0 -21
- package/dist/components/layout/layout.d.ts.map +0 -1
- package/dist/components/layout/layout.js +0 -18
- package/dist/components/layout/layout.js.map +0 -1
- package/dist/index.d.ts +0 -15
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -21
- package/dist/index.js.map +0 -1
- package/dist/lib/config/config_parser.d.ts +0 -131
- package/dist/lib/config/config_parser.d.ts.map +0 -1
- package/dist/lib/config/config_parser.js +0 -297
- package/dist/lib/config/config_parser.js.map +0 -1
- package/dist/lib/config/index.d.ts +0 -8
- package/dist/lib/config/index.d.ts.map +0 -1
- package/dist/lib/config/index.js +0 -22
- package/dist/lib/config/index.js.map +0 -1
- package/dist/lib/config/provider_loader.d.ts +0 -113
- package/dist/lib/config/provider_loader.d.ts.map +0 -1
- package/dist/lib/config/provider_loader.js +0 -169
- package/dist/lib/config/provider_loader.js.map +0 -1
- package/dist/lib/database/index.d.ts +0 -8
- package/dist/lib/database/index.d.ts.map +0 -1
- package/dist/lib/database/index.js +0 -10
- package/dist/lib/database/index.js.map +0 -1
- package/dist/lib/database/init_database.d.ts +0 -118
- package/dist/lib/database/init_database.d.ts.map +0 -1
- package/dist/lib/database/init_database.js +0 -524
- package/dist/lib/database/init_database.js.map +0 -1
- package/dist/lib/database/utils.d.ts +0 -50
- package/dist/lib/database/utils.d.ts.map +0 -1
- package/dist/lib/database/utils.js +0 -78
- package/dist/lib/database/utils.js.map +0 -1
- package/dist/lib/index.d.ts +0 -14
- package/dist/lib/index.d.ts.map +0 -1
- package/dist/lib/index.js +0 -17
- package/dist/lib/index.js.map +0 -1
- package/dist/lib/llm_api/hazo_llm_image_image.d.ts +0 -26
- package/dist/lib/llm_api/hazo_llm_image_image.d.ts.map +0 -1
- package/dist/lib/llm_api/hazo_llm_image_image.js +0 -94
- package/dist/lib/llm_api/hazo_llm_image_image.js.map +0 -1
- package/dist/lib/llm_api/hazo_llm_image_image_text.d.ts +0 -26
- package/dist/lib/llm_api/hazo_llm_image_image_text.d.ts.map +0 -1
- package/dist/lib/llm_api/hazo_llm_image_image_text.js +0 -222
- package/dist/lib/llm_api/hazo_llm_image_image_text.js.map +0 -1
- package/dist/lib/llm_api/hazo_llm_image_text.d.ts +0 -20
- package/dist/lib/llm_api/hazo_llm_image_text.d.ts.map +0 -1
- package/dist/lib/llm_api/hazo_llm_image_text.js +0 -78
- package/dist/lib/llm_api/hazo_llm_image_text.js.map +0 -1
- package/dist/lib/llm_api/hazo_llm_text_image.d.ts +0 -20
- package/dist/lib/llm_api/hazo_llm_text_image.d.ts.map +0 -1
- package/dist/lib/llm_api/hazo_llm_text_image.js +0 -69
- package/dist/lib/llm_api/hazo_llm_text_image.js.map +0 -1
- package/dist/lib/llm_api/hazo_llm_text_image_text.d.ts +0 -26
- package/dist/lib/llm_api/hazo_llm_text_image_text.d.ts.map +0 -1
- package/dist/lib/llm_api/hazo_llm_text_image_text.js +0 -154
- package/dist/lib/llm_api/hazo_llm_text_image_text.js.map +0 -1
- package/dist/lib/llm_api/hazo_llm_text_text.d.ts +0 -20
- package/dist/lib/llm_api/hazo_llm_text_text.d.ts.map +0 -1
- package/dist/lib/llm_api/hazo_llm_text_text.js +0 -91
- package/dist/lib/llm_api/hazo_llm_text_text.js.map +0 -1
- package/dist/lib/llm_api/index.d.ts +0 -191
- package/dist/lib/llm_api/index.d.ts.map +0 -1
- package/dist/lib/llm_api/index.js +0 -1168
- package/dist/lib/llm_api/index.js.map +0 -1
- package/dist/lib/llm_api/provider_helper.d.ts +0 -163
- package/dist/lib/llm_api/provider_helper.d.ts.map +0 -1
- package/dist/lib/llm_api/provider_helper.js +0 -346
- package/dist/lib/llm_api/provider_helper.js.map +0 -1
- package/dist/lib/llm_api/types.d.ts +0 -525
- package/dist/lib/llm_api/types.d.ts.map +0 -1
- package/dist/lib/llm_api/types.js +0 -49
- package/dist/lib/llm_api/types.js.map +0 -1
- package/dist/lib/prompts/get_prompt.d.ts +0 -50
- package/dist/lib/prompts/get_prompt.d.ts.map +0 -1
- package/dist/lib/prompts/get_prompt.js +0 -232
- package/dist/lib/prompts/get_prompt.js.map +0 -1
- package/dist/lib/prompts/index.d.ts +0 -9
- package/dist/lib/prompts/index.d.ts.map +0 -1
- package/dist/lib/prompts/index.js +0 -9
- package/dist/lib/prompts/index.js.map +0 -1
- package/dist/lib/prompts/prompt_cache.d.ts +0 -151
- package/dist/lib/prompts/prompt_cache.d.ts.map +0 -1
- package/dist/lib/prompts/prompt_cache.js +0 -276
- package/dist/lib/prompts/prompt_cache.js.map +0 -1
- package/dist/lib/prompts/substitute_variables.d.ts +0 -38
- package/dist/lib/prompts/substitute_variables.d.ts.map +0 -1
- package/dist/lib/prompts/substitute_variables.js +0 -175
- package/dist/lib/prompts/substitute_variables.js.map +0 -1
- package/dist/lib/providers/gemini/gemini_client.d.ts +0 -25
- package/dist/lib/providers/gemini/gemini_client.d.ts.map +0 -1
- package/dist/lib/providers/gemini/gemini_client.js +0 -235
- package/dist/lib/providers/gemini/gemini_client.js.map +0 -1
- package/dist/lib/providers/gemini/gemini_provider.d.ts +0 -111
- package/dist/lib/providers/gemini/gemini_provider.d.ts.map +0 -1
- package/dist/lib/providers/gemini/gemini_provider.js +0 -431
- package/dist/lib/providers/gemini/gemini_provider.js.map +0 -1
- package/dist/lib/providers/gemini/index.d.ts +0 -8
- package/dist/lib/providers/gemini/index.d.ts.map +0 -1
- package/dist/lib/providers/gemini/index.js +0 -8
- package/dist/lib/providers/gemini/index.js.map +0 -1
- package/dist/lib/providers/index.d.ts +0 -8
- package/dist/lib/providers/index.d.ts.map +0 -1
- package/dist/lib/providers/index.js +0 -8
- package/dist/lib/providers/index.js.map +0 -1
- package/dist/lib/providers/qwen/index.d.ts +0 -8
- package/dist/lib/providers/qwen/index.d.ts.map +0 -1
- package/dist/lib/providers/qwen/index.js +0 -8
- package/dist/lib/providers/qwen/index.js.map +0 -1
- package/dist/lib/providers/qwen/qwen_client.d.ts +0 -154
- package/dist/lib/providers/qwen/qwen_client.d.ts.map +0 -1
- package/dist/lib/providers/qwen/qwen_client.js +0 -1002
- package/dist/lib/providers/qwen/qwen_client.js.map +0 -1
- package/dist/lib/providers/qwen/qwen_provider.d.ts +0 -139
- package/dist/lib/providers/qwen/qwen_provider.d.ts.map +0 -1
- package/dist/lib/providers/qwen/qwen_provider.js +0 -304
- package/dist/lib/providers/qwen/qwen_provider.js.map +0 -1
- package/dist/lib/providers/registry.d.ts +0 -66
- package/dist/lib/providers/registry.d.ts.map +0 -1
- package/dist/lib/providers/registry.js +0 -158
- package/dist/lib/providers/registry.js.map +0 -1
- package/dist/lib/providers/types.d.ts +0 -145
- package/dist/lib/providers/types.d.ts.map +0 -1
- package/dist/lib/providers/types.js +0 -37
- package/dist/lib/providers/types.js.map +0 -1
- package/dist/server.d.ts +0 -26
- package/dist/server.d.ts.map +0 -1
- package/dist/server.js +0 -49
- package/dist/server.js.map +0 -1
|
@@ -1,525 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LLM API Types
|
|
3
|
-
*
|
|
4
|
-
* TypeScript interfaces and types for the LLM API module.
|
|
5
|
-
* Includes configuration, function parameters, and response types.
|
|
6
|
-
*/
|
|
7
|
-
import type { ServiceType, ProviderName } from '../providers/types.js';
|
|
8
|
-
/**
|
|
9
|
-
* Logger interface matching Winston logger methods
|
|
10
|
-
* Parent application provides this logger instance
|
|
11
|
-
*/
|
|
12
|
-
export interface Logger {
|
|
13
|
-
error: (message: string, meta?: Record<string, unknown>) => void;
|
|
14
|
-
info: (message: string, meta?: Record<string, unknown>) => void;
|
|
15
|
-
warn: (message: string, meta?: Record<string, unknown>) => void;
|
|
16
|
-
debug: (message: string, meta?: Record<string, unknown>) => void;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Gemini API generation configuration parameters
|
|
20
|
-
* All parameters are optional - only include in API calls if explicitly set
|
|
21
|
-
*
|
|
22
|
-
* Note: This is used internally by the Gemini provider.
|
|
23
|
-
* Configure via hazo_llm_api_config.ini [llm_gemini] section instead of passing directly.
|
|
24
|
-
*/
|
|
25
|
-
export interface GeminiGenerationConfig {
|
|
26
|
-
/** Controls randomness in output (0.0-2.0). Lower = more deterministic */
|
|
27
|
-
temperature?: number;
|
|
28
|
-
/** Maximum number of tokens in the response */
|
|
29
|
-
max_output_tokens?: number;
|
|
30
|
-
/** Nucleus sampling probability (0.0-1.0). Considers tokens up to cumulative probability */
|
|
31
|
-
top_p?: number;
|
|
32
|
-
/** Top-k sampling. Considers only the top K most probable tokens */
|
|
33
|
-
top_k?: number;
|
|
34
|
-
/** Number of response candidates to generate (1-8) */
|
|
35
|
-
candidate_count?: number;
|
|
36
|
-
/** Sequences that stop generation when encountered */
|
|
37
|
-
stop_sequences?: string[];
|
|
38
|
-
/** Format of the response: "text/plain" or "application/json" */
|
|
39
|
-
response_mime_type?: string;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Context passed to beforeRequest hook
|
|
43
|
-
*/
|
|
44
|
-
export interface LLMRequestContext {
|
|
45
|
-
/** Service type being called */
|
|
46
|
-
service_type: ServiceType;
|
|
47
|
-
/** Provider name */
|
|
48
|
-
provider: string;
|
|
49
|
-
/** Request parameters (type varies by service) */
|
|
50
|
-
params: Record<string, unknown>;
|
|
51
|
-
/** Timestamp when request started */
|
|
52
|
-
timestamp: Date;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Context passed to afterResponse hook
|
|
56
|
-
*/
|
|
57
|
-
export interface LLMResponseContext extends LLMRequestContext {
|
|
58
|
-
/** The response from the LLM */
|
|
59
|
-
response: LLMResponse;
|
|
60
|
-
/** Duration of the request in milliseconds */
|
|
61
|
-
duration_ms: number;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Context passed to onError hook
|
|
65
|
-
*/
|
|
66
|
-
export interface LLMErrorContext extends LLMRequestContext {
|
|
67
|
-
/** The error that occurred */
|
|
68
|
-
error: LLMError;
|
|
69
|
-
/** Duration until error in milliseconds */
|
|
70
|
-
duration_ms: number;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Hook function called before each LLM request
|
|
74
|
-
* Can be async for logging to external services
|
|
75
|
-
*/
|
|
76
|
-
export type BeforeRequestHook = (context: LLMRequestContext) => void | Promise<void>;
|
|
77
|
-
/**
|
|
78
|
-
* Hook function called after each successful LLM response
|
|
79
|
-
* Can be async for logging/analytics
|
|
80
|
-
*/
|
|
81
|
-
export type AfterResponseHook = (context: LLMResponseContext) => void | Promise<void>;
|
|
82
|
-
/**
|
|
83
|
-
* Hook function called when an error occurs
|
|
84
|
-
* Can be async for error reporting
|
|
85
|
-
*/
|
|
86
|
-
export type OnErrorHook = (context: LLMErrorContext) => void | Promise<void>;
|
|
87
|
-
/**
|
|
88
|
-
* Lifecycle hooks for LLM API calls
|
|
89
|
-
* All hooks are optional and can be async
|
|
90
|
-
*
|
|
91
|
-
* @example
|
|
92
|
-
* ```typescript
|
|
93
|
-
* await initialize_llm_api({
|
|
94
|
-
* hooks: {
|
|
95
|
-
* beforeRequest: (ctx) => {
|
|
96
|
-
* console.log(`Calling ${ctx.provider}.${ctx.service_type}`);
|
|
97
|
-
* },
|
|
98
|
-
* afterResponse: (ctx) => {
|
|
99
|
-
* console.log(`Response in ${ctx.duration_ms}ms`);
|
|
100
|
-
* },
|
|
101
|
-
* onError: (ctx) => {
|
|
102
|
-
* console.error(`Error: ${ctx.error.code}`);
|
|
103
|
-
* },
|
|
104
|
-
* },
|
|
105
|
-
* });
|
|
106
|
-
* ```
|
|
107
|
-
*/
|
|
108
|
-
export interface LLMHooks {
|
|
109
|
-
/** Called before each LLM request */
|
|
110
|
-
beforeRequest?: BeforeRequestHook;
|
|
111
|
-
/** Called after each successful LLM response */
|
|
112
|
-
afterResponse?: AfterResponseHook;
|
|
113
|
-
/** Called when an error occurs */
|
|
114
|
-
onError?: OnErrorHook;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Configuration options for initializing the LLM API
|
|
118
|
-
* Supports provider-based architecture where providers are loaded from config file
|
|
119
|
-
*
|
|
120
|
-
* All configuration fields are optional - the API will use sensible defaults:
|
|
121
|
-
* - logger: Default console logger
|
|
122
|
-
* - sqlite_path: From config file or "prompt_library.sqlite" in cwd
|
|
123
|
-
* - hooks: None
|
|
124
|
-
*
|
|
125
|
-
* @example
|
|
126
|
-
* ```typescript
|
|
127
|
-
* // Minimal initialization
|
|
128
|
-
* await initialize_llm_api({});
|
|
129
|
-
*
|
|
130
|
-
* // With custom logger and hooks
|
|
131
|
-
* await initialize_llm_api({
|
|
132
|
-
* logger: myLogger,
|
|
133
|
-
* hooks: {
|
|
134
|
-
* beforeRequest: (ctx) => console.log(`Calling ${ctx.provider}`),
|
|
135
|
-
* },
|
|
136
|
-
* });
|
|
137
|
-
* ```
|
|
138
|
-
*/
|
|
139
|
-
export interface LLMApiConfig {
|
|
140
|
-
/**
|
|
141
|
-
* Logger instance from parent application
|
|
142
|
-
* Optional - if not provided, uses default console logger
|
|
143
|
-
*/
|
|
144
|
-
logger?: Logger;
|
|
145
|
-
/**
|
|
146
|
-
* Path to SQLite database file
|
|
147
|
-
* Supports: relative paths, absolute paths, ~ expansion, environment variables
|
|
148
|
-
* Default: "prompt_library.sqlite" (relative to process.cwd())
|
|
149
|
-
*/
|
|
150
|
-
sqlite_path?: string;
|
|
151
|
-
/**
|
|
152
|
-
* Lifecycle hooks for monitoring, logging, and analytics
|
|
153
|
-
* Optional - hooks are called at various points during LLM API calls
|
|
154
|
-
*/
|
|
155
|
-
hooks?: LLMHooks;
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Single prompt variable key-value pair
|
|
159
|
-
*/
|
|
160
|
-
export interface PromptVariable {
|
|
161
|
-
[key: string]: string;
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Array of prompt variables for substitution
|
|
165
|
-
* Format: [{ "variable1": "value1", "variable2": "value2" }]
|
|
166
|
-
*/
|
|
167
|
-
export type PromptVariables = PromptVariable[];
|
|
168
|
-
/**
|
|
169
|
-
* Base64 encoded data with MIME type
|
|
170
|
-
* Used for sending images/files to LLM APIs
|
|
171
|
-
*/
|
|
172
|
-
export interface Base64Data {
|
|
173
|
-
/** MIME type of the data (e.g., "image/jpeg", "image/png") */
|
|
174
|
-
mime_type: string;
|
|
175
|
-
/** Base64 encoded string of the data */
|
|
176
|
-
data: string;
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* Prompt text mode - determines how prompt text is obtained
|
|
180
|
-
*/
|
|
181
|
-
export type PromptTextMode = 'static' | 'dynamic';
|
|
182
|
-
/**
|
|
183
|
-
* Parameters for the call_llm function
|
|
184
|
-
*/
|
|
185
|
-
export interface CallLLMParams {
|
|
186
|
-
/** Area/category of the prompt (required for dynamic mode) */
|
|
187
|
-
prompt_area?: string;
|
|
188
|
-
/** Key identifier for the prompt (required for dynamic mode) */
|
|
189
|
-
prompt_key?: string;
|
|
190
|
-
/** Variables to substitute in the prompt text */
|
|
191
|
-
prompt_variables?: PromptVariables;
|
|
192
|
-
/** Base64 encoded data to include in the prompt (images, etc.) */
|
|
193
|
-
prompt_b64_data?: Base64Data[];
|
|
194
|
-
/** Static prompt text (required for static mode) */
|
|
195
|
-
static_prompt?: string;
|
|
196
|
-
/** Mode for obtaining prompt text: "static" uses static_prompt, "dynamic" fetches from database */
|
|
197
|
-
prompt_text_mode: PromptTextMode;
|
|
198
|
-
}
|
|
199
|
-
/**
|
|
200
|
-
* Prompt record from the prompts_library table
|
|
201
|
-
*/
|
|
202
|
-
export interface PromptRecord {
|
|
203
|
-
/** Unique identifier for the prompt */
|
|
204
|
-
uuid: string;
|
|
205
|
-
/** Area/category of the prompt */
|
|
206
|
-
prompt_area: string;
|
|
207
|
-
/** Key identifier for the prompt */
|
|
208
|
-
prompt_key: string;
|
|
209
|
-
/** The actual prompt text */
|
|
210
|
-
prompt_text: string;
|
|
211
|
-
/** JSON string of variables used in the prompt */
|
|
212
|
-
prompt_variables: string;
|
|
213
|
-
/** Additional notes about the prompt */
|
|
214
|
-
prompt_notes: string;
|
|
215
|
-
/** Timestamp when the record was created */
|
|
216
|
-
created_at: string;
|
|
217
|
-
/** Timestamp when the record was last changed */
|
|
218
|
-
changed_by: string;
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
|
-
* Error codes for LLM API errors
|
|
222
|
-
* Use these codes for programmatic error handling
|
|
223
|
-
*
|
|
224
|
-
* @example
|
|
225
|
-
* ```typescript
|
|
226
|
-
* import { LLM_ERROR_CODES } from 'hazo_llm_api/server';
|
|
227
|
-
*
|
|
228
|
-
* if (response.error_info?.code === LLM_ERROR_CODES.RATE_LIMITED) {
|
|
229
|
-
* // Implement retry logic
|
|
230
|
-
* }
|
|
231
|
-
* ```
|
|
232
|
-
*/
|
|
233
|
-
export declare const LLM_ERROR_CODES: {
|
|
234
|
-
/** Provider not found in registry */
|
|
235
|
-
readonly PROVIDER_NOT_FOUND: "PROVIDER_NOT_FOUND";
|
|
236
|
-
/** Provider is not enabled in configuration */
|
|
237
|
-
readonly PROVIDER_NOT_ENABLED: "PROVIDER_NOT_ENABLED";
|
|
238
|
-
/** Provider does not support the requested service type */
|
|
239
|
-
readonly CAPABILITY_NOT_SUPPORTED: "CAPABILITY_NOT_SUPPORTED";
|
|
240
|
-
/** API key is missing or invalid */
|
|
241
|
-
readonly API_KEY_MISSING: "API_KEY_MISSING";
|
|
242
|
-
/** Rate limit exceeded */
|
|
243
|
-
readonly RATE_LIMITED: "RATE_LIMITED";
|
|
244
|
-
/** Network error (connection failed, timeout, etc.) */
|
|
245
|
-
readonly NETWORK_ERROR: "NETWORK_ERROR";
|
|
246
|
-
/** Invalid request parameters */
|
|
247
|
-
readonly INVALID_REQUEST: "INVALID_REQUEST";
|
|
248
|
-
/** API returned an error */
|
|
249
|
-
readonly API_ERROR: "API_ERROR";
|
|
250
|
-
/** Request timed out */
|
|
251
|
-
readonly TIMEOUT: "TIMEOUT";
|
|
252
|
-
/** Database error */
|
|
253
|
-
readonly DATABASE_ERROR: "DATABASE_ERROR";
|
|
254
|
-
/** Prompt not found */
|
|
255
|
-
readonly PROMPT_NOT_FOUND: "PROMPT_NOT_FOUND";
|
|
256
|
-
/** Unknown/unexpected error */
|
|
257
|
-
readonly UNKNOWN: "UNKNOWN";
|
|
258
|
-
};
|
|
259
|
-
/**
|
|
260
|
-
* Type for LLM error codes
|
|
261
|
-
*/
|
|
262
|
-
export type LLMErrorCode = typeof LLM_ERROR_CODES[keyof typeof LLM_ERROR_CODES];
|
|
263
|
-
/**
|
|
264
|
-
* Structured error information for LLM API responses
|
|
265
|
-
* Provides detailed error information for programmatic handling
|
|
266
|
-
*/
|
|
267
|
-
export interface LLMError {
|
|
268
|
-
/** Error code for programmatic handling */
|
|
269
|
-
code: LLMErrorCode;
|
|
270
|
-
/** Human-readable error message */
|
|
271
|
-
message: string;
|
|
272
|
-
/** Whether this error is potentially retryable */
|
|
273
|
-
retryable: boolean;
|
|
274
|
-
/** Original error details (if applicable) */
|
|
275
|
-
details?: Record<string, unknown>;
|
|
276
|
-
}
|
|
277
|
-
/**
|
|
278
|
-
* Generic LLM API response
|
|
279
|
-
*/
|
|
280
|
-
export interface LLMResponse {
|
|
281
|
-
/** Whether the API call was successful */
|
|
282
|
-
success: boolean;
|
|
283
|
-
/** The generated text response from the LLM */
|
|
284
|
-
text?: string;
|
|
285
|
-
/**
|
|
286
|
-
* Error message if the call failed
|
|
287
|
-
* @deprecated Use error_info for structured error data
|
|
288
|
-
*/
|
|
289
|
-
error?: string;
|
|
290
|
-
/** Structured error information (new in v2.0) */
|
|
291
|
-
error_info?: LLMError;
|
|
292
|
-
/** Raw response from the API */
|
|
293
|
-
raw_response?: unknown;
|
|
294
|
-
/** Base64 encoded image data (for image output functions) */
|
|
295
|
-
image_b64?: string;
|
|
296
|
-
/** MIME type of the generated image */
|
|
297
|
-
image_mime_type?: string;
|
|
298
|
-
}
|
|
299
|
-
/**
|
|
300
|
-
* A single chunk from a streaming LLM response
|
|
301
|
-
*/
|
|
302
|
-
export interface LLMStreamChunk {
|
|
303
|
-
/** The text content of this chunk */
|
|
304
|
-
text: string;
|
|
305
|
-
/** Whether this is the final chunk */
|
|
306
|
-
done: boolean;
|
|
307
|
-
/**
|
|
308
|
-
* Error message if streaming failed
|
|
309
|
-
* @deprecated Use error_info for structured error data
|
|
310
|
-
*/
|
|
311
|
-
error?: string;
|
|
312
|
-
/** Structured error information if streaming failed */
|
|
313
|
-
error_info?: LLMError;
|
|
314
|
-
}
|
|
315
|
-
/**
|
|
316
|
-
* Async iterator for streaming LLM responses
|
|
317
|
-
*
|
|
318
|
-
* @example
|
|
319
|
-
* ```typescript
|
|
320
|
-
* const stream = await hazo_llm_text_text_stream({ prompt: 'Hello' });
|
|
321
|
-
*
|
|
322
|
-
* for await (const chunk of stream) {
|
|
323
|
-
* if (chunk.error) {
|
|
324
|
-
* console.error(chunk.error);
|
|
325
|
-
* break;
|
|
326
|
-
* }
|
|
327
|
-
* process.stdout.write(chunk.text);
|
|
328
|
-
* if (chunk.done) break;
|
|
329
|
-
* }
|
|
330
|
-
* ```
|
|
331
|
-
*/
|
|
332
|
-
export type LLMStreamResponse = AsyncGenerator<LLMStreamChunk, void, unknown>;
|
|
333
|
-
/**
|
|
334
|
-
* Parameters for hazo_llm_text_text (text input → text output)
|
|
335
|
-
*/
|
|
336
|
-
export interface TextTextParams {
|
|
337
|
-
/** Static prompt text */
|
|
338
|
-
prompt: string;
|
|
339
|
-
/** Variables to substitute in the prompt text */
|
|
340
|
-
prompt_variables?: PromptVariables;
|
|
341
|
-
/** Area/category for dynamic prompt (optional) */
|
|
342
|
-
prompt_area?: string;
|
|
343
|
-
/** Key for dynamic prompt (optional) */
|
|
344
|
-
prompt_key?: string;
|
|
345
|
-
}
|
|
346
|
-
/**
|
|
347
|
-
* Parameters for hazo_llm_image_text (image input → text output)
|
|
348
|
-
*/
|
|
349
|
-
export interface ImageTextParams {
|
|
350
|
-
/** Prompt/instruction for analyzing the image */
|
|
351
|
-
prompt: string;
|
|
352
|
-
/** Base64 encoded image data */
|
|
353
|
-
image_b64: string;
|
|
354
|
-
/** MIME type of the image (e.g., "image/jpeg", "image/png") */
|
|
355
|
-
image_mime_type: string;
|
|
356
|
-
/** Variables to substitute in the prompt text */
|
|
357
|
-
prompt_variables?: PromptVariables;
|
|
358
|
-
}
|
|
359
|
-
/**
|
|
360
|
-
* Parameters for hazo_llm_text_image (text input → image output)
|
|
361
|
-
*/
|
|
362
|
-
export interface TextImageParams {
|
|
363
|
-
/** Text prompt describing the image to generate */
|
|
364
|
-
prompt: string;
|
|
365
|
-
/** Variables to substitute in the prompt text */
|
|
366
|
-
prompt_variables?: PromptVariables;
|
|
367
|
-
}
|
|
368
|
-
/**
|
|
369
|
-
* Parameters for hazo_llm_image_image (image input → image output)
|
|
370
|
-
*/
|
|
371
|
-
export interface ImageImageParams {
|
|
372
|
-
/** Prompt/instruction for transforming the image(s) */
|
|
373
|
-
prompt: string;
|
|
374
|
-
/** Base64 encoded input image data (for single image, use this OR images array) */
|
|
375
|
-
image_b64?: string;
|
|
376
|
-
/** MIME type of the input image (for single image) */
|
|
377
|
-
image_mime_type?: string;
|
|
378
|
-
/** Array of input images (for multiple images) */
|
|
379
|
-
images?: Base64Data[];
|
|
380
|
-
/** Variables to substitute in the prompt text */
|
|
381
|
-
prompt_variables?: PromptVariables;
|
|
382
|
-
}
|
|
383
|
-
/**
|
|
384
|
-
* Parameters for hazo_llm_text_image_text (text → image → text)
|
|
385
|
-
* Generates an image from prompt_image, then analyzes it with prompt_text
|
|
386
|
-
*/
|
|
387
|
-
export interface TextImageTextParams {
|
|
388
|
-
/** Prompt for image generation (step 1) */
|
|
389
|
-
prompt_image: string;
|
|
390
|
-
/** Prompt for analyzing the generated image (step 2) */
|
|
391
|
-
prompt_text: string;
|
|
392
|
-
/** Variables to substitute in the image generation prompt */
|
|
393
|
-
prompt_image_variables?: PromptVariables;
|
|
394
|
-
/** Variables to substitute in the text analysis prompt */
|
|
395
|
-
prompt_text_variables?: PromptVariables;
|
|
396
|
-
}
|
|
397
|
-
/**
|
|
398
|
-
* Base64 image data for chained operations
|
|
399
|
-
*/
|
|
400
|
-
export interface ChainImage {
|
|
401
|
-
/** Base64 encoded image data */
|
|
402
|
-
image_b64: string;
|
|
403
|
-
/** MIME type of the image */
|
|
404
|
-
image_mime_type: string;
|
|
405
|
-
}
|
|
406
|
-
/**
|
|
407
|
-
* Parameters for hazo_llm_image_image_text (images → image → text)
|
|
408
|
-
* Chain multiple image transformations, then describe the final result
|
|
409
|
-
*
|
|
410
|
-
* Flow:
|
|
411
|
-
* 1. Combine images[0] + images[1] using prompts[0] → result_1
|
|
412
|
-
* 2. Combine result_1 + images[2] using prompts[1] → result_2
|
|
413
|
-
* 3. Continue chaining through all images
|
|
414
|
-
* 4. Analyze final result with description_prompt → text output
|
|
415
|
-
*
|
|
416
|
-
* Requirements:
|
|
417
|
-
* - Minimum 2 images required
|
|
418
|
-
* - Number of prompts = number of images - 1
|
|
419
|
-
*/
|
|
420
|
-
export interface ImageImageTextParams {
|
|
421
|
-
/** Array of images to chain (minimum 2) */
|
|
422
|
-
images: ChainImage[];
|
|
423
|
-
/** Array of transformation prompts (length = images.length - 1) */
|
|
424
|
-
prompts: string[];
|
|
425
|
-
/** Final prompt for describing the last generated image */
|
|
426
|
-
description_prompt: string;
|
|
427
|
-
/** Variables to substitute in the description prompt */
|
|
428
|
-
description_prompt_variables?: PromptVariables;
|
|
429
|
-
}
|
|
430
|
-
/**
|
|
431
|
-
* Gemini API text part
|
|
432
|
-
*/
|
|
433
|
-
export interface GeminiTextPart {
|
|
434
|
-
text: string;
|
|
435
|
-
}
|
|
436
|
-
/**
|
|
437
|
-
* Gemini API inline data part (for images)
|
|
438
|
-
*/
|
|
439
|
-
export interface GeminiInlineDataPart {
|
|
440
|
-
inline_data: {
|
|
441
|
-
mime_type: string;
|
|
442
|
-
data: string;
|
|
443
|
-
};
|
|
444
|
-
}
|
|
445
|
-
/**
|
|
446
|
-
* Gemini API part (either text or inline data)
|
|
447
|
-
*/
|
|
448
|
-
export type GeminiPart = GeminiTextPart | GeminiInlineDataPart;
|
|
449
|
-
/**
|
|
450
|
-
* Gemini API content structure
|
|
451
|
-
*/
|
|
452
|
-
export interface GeminiContent {
|
|
453
|
-
parts: GeminiPart[];
|
|
454
|
-
}
|
|
455
|
-
/**
|
|
456
|
-
* Gemini API generation config in request format (camelCase for API)
|
|
457
|
-
*/
|
|
458
|
-
export interface GeminiApiGenerationConfig {
|
|
459
|
-
temperature?: number;
|
|
460
|
-
maxOutputTokens?: number;
|
|
461
|
-
topP?: number;
|
|
462
|
-
topK?: number;
|
|
463
|
-
candidateCount?: number;
|
|
464
|
-
stopSequences?: string[];
|
|
465
|
-
responseMimeType?: string;
|
|
466
|
-
}
|
|
467
|
-
/**
|
|
468
|
-
* Gemini API request body
|
|
469
|
-
*/
|
|
470
|
-
export interface GeminiRequestBody {
|
|
471
|
-
contents: GeminiContent[];
|
|
472
|
-
generationConfig?: GeminiApiGenerationConfig;
|
|
473
|
-
}
|
|
474
|
-
/**
|
|
475
|
-
* Gemini API response candidate
|
|
476
|
-
*/
|
|
477
|
-
export interface GeminiCandidate {
|
|
478
|
-
content: {
|
|
479
|
-
parts: Array<{
|
|
480
|
-
text: string;
|
|
481
|
-
}>;
|
|
482
|
-
role: string;
|
|
483
|
-
};
|
|
484
|
-
finishReason: string;
|
|
485
|
-
index: number;
|
|
486
|
-
}
|
|
487
|
-
/**
|
|
488
|
-
* Gemini API response structure
|
|
489
|
-
*/
|
|
490
|
-
export interface GeminiApiResponse {
|
|
491
|
-
candidates?: GeminiCandidate[];
|
|
492
|
-
promptFeedback?: {
|
|
493
|
-
safetyRatings: Array<{
|
|
494
|
-
category: string;
|
|
495
|
-
probability: string;
|
|
496
|
-
}>;
|
|
497
|
-
};
|
|
498
|
-
error?: {
|
|
499
|
-
code: number;
|
|
500
|
-
message: string;
|
|
501
|
-
status: string;
|
|
502
|
-
};
|
|
503
|
-
}
|
|
504
|
-
/**
|
|
505
|
-
* Initialized LLM API client instance
|
|
506
|
-
*/
|
|
507
|
-
export interface LLMApiClient {
|
|
508
|
-
/** Configuration used to initialize the client */
|
|
509
|
-
config: LLMApiConfig;
|
|
510
|
-
/** Whether the database has been initialized */
|
|
511
|
-
db_initialized: boolean;
|
|
512
|
-
/** Text input → Text output */
|
|
513
|
-
hazo_llm_text_text: (params: TextTextParams, llm?: ProviderName) => Promise<LLMResponse>;
|
|
514
|
-
/** Image input → Text output (image analysis) */
|
|
515
|
-
hazo_llm_image_text: (params: ImageTextParams, llm?: ProviderName) => Promise<LLMResponse>;
|
|
516
|
-
/** Text input → Image output (image generation) */
|
|
517
|
-
hazo_llm_text_image: (params: TextImageParams, llm?: ProviderName) => Promise<LLMResponse>;
|
|
518
|
-
/** Image input → Image output (image transformation) */
|
|
519
|
-
hazo_llm_image_image: (params: ImageImageParams, llm?: ProviderName) => Promise<LLMResponse>;
|
|
520
|
-
/** Text → Image → Text (generate image then analyze it) */
|
|
521
|
-
hazo_llm_text_image_text: (params: TextImageTextParams, llm?: ProviderName) => Promise<LLMResponse>;
|
|
522
|
-
/** Images → Image → Text (chain image transformations then describe) */
|
|
523
|
-
hazo_llm_image_image_text: (params: ImageImageTextParams, llm?: ProviderName) => Promise<LLMResponse>;
|
|
524
|
-
}
|
|
525
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/llm_api/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAMvE;;;GAGG;AACH,MAAM,WAAW,MAAM;IACrB,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;IACjE,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;IAChE,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;IAChE,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;CAClE;AAMD;;;;;;GAMG;AACH,MAAM,WA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C,WAAW,CAAC,CAAC;IAEzF,iDAAiD;IACjD,mBAAmB,EAAE,CAAC,MAAM,EAAE,eAAe,EAAE,GAAG,CAAC,EAAE,YAAY,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;IAE3F,mDAAmD;IACnD,mBAAmB,EAAE,CAAC,MAAM,EAAE,eAAe,EAAE,GAAG,CAAC,EAAE,YAAY,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;IAE3F,wDAAwD;IACxD,oBAAoB,EAAE,CAAC,MAAM,EAAE,gBAAgB,EAAE,GAAG,CAAC,EAAE,YAAY,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;IAE7F,2DAA2D;IAC3D,wBAAwB,EAAE,CAAC,MAAM,EAAE,mBAAmB,EAAE,GAAG,CAAC,EAAE,YAAY,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;IAEpG,wEAAwE;IACxE,yBAAyB,EAAE,CAAC,MAAM,EAAE,oBAAoB,EAAE,GAAG,CAAC,EAAE,YAAY,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;CACvG"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LLM API Types
|
|
3
|
-
*
|
|
4
|
-
* TypeScript interfaces and types for the LLM API module.
|
|
5
|
-
* Includes configuration, function parameters, and response types.
|
|
6
|
-
*/
|
|
7
|
-
// =============================================================================
|
|
8
|
-
// LLM Error Types
|
|
9
|
-
// =============================================================================
|
|
10
|
-
/**
|
|
11
|
-
* Error codes for LLM API errors
|
|
12
|
-
* Use these codes for programmatic error handling
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```typescript
|
|
16
|
-
* import { LLM_ERROR_CODES } from 'hazo_llm_api/server';
|
|
17
|
-
*
|
|
18
|
-
* if (response.error_info?.code === LLM_ERROR_CODES.RATE_LIMITED) {
|
|
19
|
-
* // Implement retry logic
|
|
20
|
-
* }
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
export const LLM_ERROR_CODES = {
|
|
24
|
-
/** Provider not found in registry */
|
|
25
|
-
PROVIDER_NOT_FOUND: 'PROVIDER_NOT_FOUND',
|
|
26
|
-
/** Provider is not enabled in configuration */
|
|
27
|
-
PROVIDER_NOT_ENABLED: 'PROVIDER_NOT_ENABLED',
|
|
28
|
-
/** Provider does not support the requested service type */
|
|
29
|
-
CAPABILITY_NOT_SUPPORTED: 'CAPABILITY_NOT_SUPPORTED',
|
|
30
|
-
/** API key is missing or invalid */
|
|
31
|
-
API_KEY_MISSING: 'API_KEY_MISSING',
|
|
32
|
-
/** Rate limit exceeded */
|
|
33
|
-
RATE_LIMITED: 'RATE_LIMITED',
|
|
34
|
-
/** Network error (connection failed, timeout, etc.) */
|
|
35
|
-
NETWORK_ERROR: 'NETWORK_ERROR',
|
|
36
|
-
/** Invalid request parameters */
|
|
37
|
-
INVALID_REQUEST: 'INVALID_REQUEST',
|
|
38
|
-
/** API returned an error */
|
|
39
|
-
API_ERROR: 'API_ERROR',
|
|
40
|
-
/** Request timed out */
|
|
41
|
-
TIMEOUT: 'TIMEOUT',
|
|
42
|
-
/** Database error */
|
|
43
|
-
DATABASE_ERROR: 'DATABASE_ERROR',
|
|
44
|
-
/** Prompt not found */
|
|
45
|
-
PROMPT_NOT_FOUND: 'PROMPT_NOT_FOUND',
|
|
46
|
-
/** Unknown/unexpected error */
|
|
47
|
-
UNKNOWN: 'UNKNOWN',
|
|
48
|
-
};
|
|
49
|
-
//# sourceMappingURL=types.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/lib/llm_api/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAoSH,gFAAgF;AAChF,kBAAkB;AAClB,gFAAgF;AAEhF;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,qCAAqC;IACrC,kBAAkB,EAAE,oBAAoB;IACxC,+CAA+C;IAC/C,oBAAoB,EAAE,sBAAsB;IAC5C,2DAA2D;IAC3D,wBAAwB,EAAE,0BAA0B;IACpD,oCAAoC;IACpC,eAAe,EAAE,iBAAiB;IAClC,0BAA0B;IAC1B,YAAY,EAAE,cAAc;IAC5B,uDAAuD;IACvD,aAAa,EAAE,eAAe;IAC9B,iCAAiC;IACjC,eAAe,EAAE,iBAAiB;IAClC,4BAA4B;IAC5B,SAAS,EAAE,WAAW;IACtB,wBAAwB;IACxB,OAAO,EAAE,SAAS;IAClB,qBAAqB;IACrB,cAAc,EAAE,gBAAgB;IAChC,uBAAuB;IACvB,gBAAgB,EAAE,kBAAkB;IACpC,+BAA+B;IAC/B,OAAO,EAAE,SAAS;CACV,CAAC"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Prompt Retrieval Module
|
|
3
|
-
*
|
|
4
|
-
* Functions to retrieve prompts from the prompts_library database table.
|
|
5
|
-
* Searches by prompt_area and prompt_key to find the prompt_text.
|
|
6
|
-
*/
|
|
7
|
-
import type { Database as SqlJsDatabase } from 'sql.js';
|
|
8
|
-
import type { Logger, PromptRecord } from '../llm_api/types.js';
|
|
9
|
-
/**
|
|
10
|
-
* Retrieve a prompt from the database by prompt_area and prompt_key
|
|
11
|
-
* @param db - Database instance
|
|
12
|
-
* @param prompt_area - Area/category of the prompt
|
|
13
|
-
* @param prompt_key - Key identifier for the prompt
|
|
14
|
-
* @param logger - Logger instance
|
|
15
|
-
* @returns The prompt record if found, null otherwise
|
|
16
|
-
*/
|
|
17
|
-
export declare function get_prompt_by_area_and_key(db: SqlJsDatabase, prompt_area: string, prompt_key: string, logger: Logger): PromptRecord | null;
|
|
18
|
-
/**
|
|
19
|
-
* Retrieve the prompt text only by prompt_area and prompt_key
|
|
20
|
-
* @param db - Database instance
|
|
21
|
-
* @param prompt_area - Area/category of the prompt
|
|
22
|
-
* @param prompt_key - Key identifier for the prompt
|
|
23
|
-
* @param logger - Logger instance
|
|
24
|
-
* @returns The prompt text if found, null otherwise
|
|
25
|
-
*/
|
|
26
|
-
export declare function get_prompt_text(db: SqlJsDatabase, prompt_area: string, prompt_key: string, logger: Logger): string | null;
|
|
27
|
-
/**
|
|
28
|
-
* Get all prompts by prompt_area
|
|
29
|
-
* @param db - Database instance
|
|
30
|
-
* @param prompt_area - Area/category of the prompts
|
|
31
|
-
* @param logger - Logger instance
|
|
32
|
-
* @returns Array of prompt records
|
|
33
|
-
*/
|
|
34
|
-
export declare function get_prompts_by_area(db: SqlJsDatabase, prompt_area: string, logger: Logger): PromptRecord[];
|
|
35
|
-
/**
|
|
36
|
-
* Get a prompt by its UUID
|
|
37
|
-
* @param db - Database instance
|
|
38
|
-
* @param uuid - UUID of the prompt
|
|
39
|
-
* @param logger - Logger instance
|
|
40
|
-
* @returns The prompt record if found, null otherwise
|
|
41
|
-
*/
|
|
42
|
-
export declare function get_prompt_by_uuid(db: SqlJsDatabase, uuid: string, logger: Logger): PromptRecord | null;
|
|
43
|
-
/**
|
|
44
|
-
* Get all prompts from the library
|
|
45
|
-
* @param db - Database instance
|
|
46
|
-
* @param logger - Logger instance
|
|
47
|
-
* @returns Array of all prompt records
|
|
48
|
-
*/
|
|
49
|
-
export declare function get_all_prompts(db: SqlJsDatabase, logger: Logger): PromptRecord[];
|
|
50
|
-
//# sourceMappingURL=get_prompt.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get_prompt.d.ts","sourceRoot":"","sources":["../../../src/lib/prompts/get_prompt.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,QAAQ,IAAI,aAAa,EAAE,MAAM,QAAQ,CAAC;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAOhE;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CACxC,EAAE,EAAE,aAAa,EACjB,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,GACb,YAAY,GAAG,IAAI,CAmDrB;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,EAAE,EAAE,aAAa,EACjB,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,GACb,MAAM,GAAG,IAAI,CAmBf;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,EAAE,EAAE,aAAa,EACjB,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,GACb,YAAY,EAAE,CA8ChB;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,EAAE,EAAE,aAAa,EACjB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,GACb,YAAY,GAAG,IAAI,CA8CrB;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,EAAE,EAAE,aAAa,EACjB,MAAM,EAAE,MAAM,GACb,YAAY,EAAE,CA6ChB"}
|