hazo_llm_api 1.0.4 → 1.0.5
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/dist/components/index.d.ts +7 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +7 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/layout/index.d.ts +7 -0
- package/dist/components/layout/index.d.ts.map +1 -0
- package/dist/components/layout/index.js +7 -0
- package/dist/components/layout/index.js.map +1 -0
- package/dist/components/layout/layout.d.ts +21 -0
- package/dist/components/layout/layout.d.ts.map +1 -0
- package/dist/components/layout/layout.js +18 -0
- package/dist/components/layout/layout.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/config/config_parser.d.ts +131 -0
- package/dist/lib/config/config_parser.d.ts.map +1 -0
- package/dist/lib/config/config_parser.js +297 -0
- package/dist/lib/config/config_parser.js.map +1 -0
- package/dist/lib/config/index.d.ts +8 -0
- package/dist/lib/config/index.d.ts.map +1 -0
- package/dist/lib/config/index.js +22 -0
- package/dist/lib/config/index.js.map +1 -0
- package/dist/lib/config/provider_loader.d.ts +113 -0
- package/dist/lib/config/provider_loader.d.ts.map +1 -0
- package/dist/lib/config/provider_loader.js +169 -0
- package/dist/lib/config/provider_loader.js.map +1 -0
- package/dist/lib/database/index.d.ts +8 -0
- package/dist/lib/database/index.d.ts.map +1 -0
- package/dist/lib/database/index.js +10 -0
- package/dist/lib/database/index.js.map +1 -0
- package/dist/lib/database/init_database.d.ts +118 -0
- package/dist/lib/database/init_database.d.ts.map +1 -0
- package/dist/lib/database/init_database.js +591 -0
- package/dist/lib/database/init_database.js.map +1 -0
- package/dist/lib/database/utils.d.ts +53 -0
- package/dist/lib/database/utils.d.ts.map +1 -0
- package/dist/lib/database/utils.js +87 -0
- package/dist/lib/database/utils.js.map +1 -0
- package/dist/lib/index.d.ts +14 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +17 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/llm_api/chain_helpers.d.ts +117 -0
- package/dist/lib/llm_api/chain_helpers.d.ts.map +1 -0
- package/dist/lib/llm_api/chain_helpers.js +445 -0
- package/dist/lib/llm_api/chain_helpers.js.map +1 -0
- package/dist/lib/llm_api/hazo_llm_image_image.d.ts +26 -0
- package/dist/lib/llm_api/hazo_llm_image_image.d.ts.map +1 -0
- package/dist/lib/llm_api/hazo_llm_image_image.js +94 -0
- package/dist/lib/llm_api/hazo_llm_image_image.js.map +1 -0
- package/dist/lib/llm_api/hazo_llm_image_image_text.d.ts +26 -0
- package/dist/lib/llm_api/hazo_llm_image_image_text.d.ts.map +1 -0
- package/dist/lib/llm_api/hazo_llm_image_image_text.js +222 -0
- package/dist/lib/llm_api/hazo_llm_image_image_text.js.map +1 -0
- package/dist/lib/llm_api/hazo_llm_image_text.d.ts +20 -0
- package/dist/lib/llm_api/hazo_llm_image_text.d.ts.map +1 -0
- package/dist/lib/llm_api/hazo_llm_image_text.js +78 -0
- package/dist/lib/llm_api/hazo_llm_image_text.js.map +1 -0
- package/dist/lib/llm_api/hazo_llm_prompt_chain.d.ts +20 -0
- package/dist/lib/llm_api/hazo_llm_prompt_chain.d.ts.map +1 -0
- package/dist/lib/llm_api/hazo_llm_prompt_chain.js +368 -0
- package/dist/lib/llm_api/hazo_llm_prompt_chain.js.map +1 -0
- package/dist/lib/llm_api/hazo_llm_text_image.d.ts +20 -0
- package/dist/lib/llm_api/hazo_llm_text_image.d.ts.map +1 -0
- package/dist/lib/llm_api/hazo_llm_text_image.js +69 -0
- package/dist/lib/llm_api/hazo_llm_text_image.js.map +1 -0
- package/dist/lib/llm_api/hazo_llm_text_image_text.d.ts +26 -0
- package/dist/lib/llm_api/hazo_llm_text_image_text.d.ts.map +1 -0
- package/dist/lib/llm_api/hazo_llm_text_image_text.js +154 -0
- package/dist/lib/llm_api/hazo_llm_text_image_text.js.map +1 -0
- package/dist/lib/llm_api/hazo_llm_text_text.d.ts +20 -0
- package/dist/lib/llm_api/hazo_llm_text_text.d.ts.map +1 -0
- package/dist/lib/llm_api/hazo_llm_text_text.js +91 -0
- package/dist/lib/llm_api/hazo_llm_text_text.js.map +1 -0
- package/dist/lib/llm_api/index.d.ts +223 -0
- package/dist/lib/llm_api/index.d.ts.map +1 -0
- package/dist/lib/llm_api/index.js +1220 -0
- package/dist/lib/llm_api/index.js.map +1 -0
- package/dist/lib/llm_api/provider_helper.d.ts +163 -0
- package/dist/lib/llm_api/provider_helper.d.ts.map +1 -0
- package/dist/lib/llm_api/provider_helper.js +346 -0
- package/dist/lib/llm_api/provider_helper.js.map +1 -0
- package/dist/lib/llm_api/types.d.ts +667 -0
- package/dist/lib/llm_api/types.d.ts.map +1 -0
- package/dist/lib/llm_api/types.js +49 -0
- package/dist/lib/llm_api/types.js.map +1 -0
- package/dist/lib/prompts/get_prompt.d.ts +76 -0
- package/dist/lib/prompts/get_prompt.d.ts.map +1 -0
- package/dist/lib/prompts/get_prompt.js +342 -0
- package/dist/lib/prompts/get_prompt.js.map +1 -0
- package/dist/lib/prompts/index.d.ts +9 -0
- package/dist/lib/prompts/index.d.ts.map +1 -0
- package/dist/lib/prompts/index.js +9 -0
- package/dist/lib/prompts/index.js.map +1 -0
- package/dist/lib/prompts/prompt_cache.d.ts +151 -0
- package/dist/lib/prompts/prompt_cache.d.ts.map +1 -0
- package/dist/lib/prompts/prompt_cache.js +276 -0
- package/dist/lib/prompts/prompt_cache.js.map +1 -0
- package/dist/lib/prompts/substitute_variables.d.ts +38 -0
- package/dist/lib/prompts/substitute_variables.d.ts.map +1 -0
- package/dist/lib/prompts/substitute_variables.js +171 -0
- package/dist/lib/prompts/substitute_variables.js.map +1 -0
- package/dist/lib/providers/gemini/gemini_client.d.ts +25 -0
- package/dist/lib/providers/gemini/gemini_client.d.ts.map +1 -0
- package/dist/lib/providers/gemini/gemini_client.js +235 -0
- package/dist/lib/providers/gemini/gemini_client.js.map +1 -0
- package/dist/lib/providers/gemini/gemini_provider.d.ts +111 -0
- package/dist/lib/providers/gemini/gemini_provider.d.ts.map +1 -0
- package/dist/lib/providers/gemini/gemini_provider.js +431 -0
- package/dist/lib/providers/gemini/gemini_provider.js.map +1 -0
- package/dist/lib/providers/gemini/index.d.ts +8 -0
- package/dist/lib/providers/gemini/index.d.ts.map +1 -0
- package/dist/lib/providers/gemini/index.js +8 -0
- package/dist/lib/providers/gemini/index.js.map +1 -0
- package/dist/lib/providers/index.d.ts +8 -0
- package/dist/lib/providers/index.d.ts.map +1 -0
- package/dist/lib/providers/index.js +8 -0
- package/dist/lib/providers/index.js.map +1 -0
- package/dist/lib/providers/qwen/index.d.ts +8 -0
- package/dist/lib/providers/qwen/index.d.ts.map +1 -0
- package/dist/lib/providers/qwen/index.js +8 -0
- package/dist/lib/providers/qwen/index.js.map +1 -0
- package/dist/lib/providers/qwen/qwen_client.d.ts +154 -0
- package/dist/lib/providers/qwen/qwen_client.d.ts.map +1 -0
- package/dist/lib/providers/qwen/qwen_client.js +1002 -0
- package/dist/lib/providers/qwen/qwen_client.js.map +1 -0
- package/dist/lib/providers/qwen/qwen_provider.d.ts +139 -0
- package/dist/lib/providers/qwen/qwen_provider.d.ts.map +1 -0
- package/dist/lib/providers/qwen/qwen_provider.js +304 -0
- package/dist/lib/providers/qwen/qwen_provider.js.map +1 -0
- package/dist/lib/providers/registry.d.ts +66 -0
- package/dist/lib/providers/registry.d.ts.map +1 -0
- package/dist/lib/providers/registry.js +158 -0
- package/dist/lib/providers/registry.js.map +1 -0
- package/dist/lib/providers/types.d.ts +145 -0
- package/dist/lib/providers/types.d.ts.map +1 -0
- package/dist/lib/providers/types.js +37 -0
- package/dist/lib/providers/types.js.map +1 -0
- package/dist/server.d.ts +27 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +50 -0
- package/dist/server.js.map +1 -0
- package/package.json +12 -1
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Database Utilities
|
|
3
|
+
*
|
|
4
|
+
* Shared utility functions for database operations.
|
|
5
|
+
* Single source of truth for common database helpers.
|
|
6
|
+
*/
|
|
7
|
+
// =============================================================================
|
|
8
|
+
// Row Conversion Utilities
|
|
9
|
+
// =============================================================================
|
|
10
|
+
/**
|
|
11
|
+
* Convert a database row to a PromptRecord object using column names
|
|
12
|
+
*
|
|
13
|
+
* This is the single source of truth for row-to-record conversion.
|
|
14
|
+
* Used by both database initialization and prompt retrieval functions.
|
|
15
|
+
*
|
|
16
|
+
* @param row - Raw database row as array of values
|
|
17
|
+
* @param columns - Array of column names from the query result
|
|
18
|
+
* @returns PromptRecord object
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const result = db.exec('SELECT * FROM prompts_library WHERE uuid = ?', [uuid]);
|
|
23
|
+
* if (result.length > 0 && result[0].values.length > 0) {
|
|
24
|
+
* const record = row_to_prompt_record(result[0].values[0], result[0].columns);
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export function row_to_prompt_record(row, columns) {
|
|
29
|
+
const record = {};
|
|
30
|
+
for (let i = 0; i < columns.length; i++) {
|
|
31
|
+
record[columns[i]] = row[i];
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
uuid: String(record.uuid || ''),
|
|
35
|
+
prompt_area: String(record.prompt_area || ''),
|
|
36
|
+
prompt_key: String(record.prompt_key || ''),
|
|
37
|
+
local_1: record.local_1 != null ? String(record.local_1) : null,
|
|
38
|
+
local_2: record.local_2 != null ? String(record.local_2) : null,
|
|
39
|
+
local_3: record.local_3 != null ? String(record.local_3) : null,
|
|
40
|
+
prompt_text: String(record.prompt_text || ''),
|
|
41
|
+
prompt_variables: String(record.prompt_variables || '[]'),
|
|
42
|
+
prompt_notes: String(record.prompt_notes || ''),
|
|
43
|
+
created_at: String(record.created_at || ''),
|
|
44
|
+
changed_by: String(record.changed_by || ''),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Column indices for prompts_library table
|
|
49
|
+
* Use these constants when building queries to ensure consistency
|
|
50
|
+
*/
|
|
51
|
+
export const PROMPT_COLUMNS = {
|
|
52
|
+
UUID: 0,
|
|
53
|
+
PROMPT_AREA: 1,
|
|
54
|
+
PROMPT_KEY: 2,
|
|
55
|
+
LOCAL_1: 3,
|
|
56
|
+
LOCAL_2: 4,
|
|
57
|
+
LOCAL_3: 5,
|
|
58
|
+
PROMPT_TEXT: 6,
|
|
59
|
+
PROMPT_VARIABLES: 7,
|
|
60
|
+
PROMPT_NOTES: 8,
|
|
61
|
+
CREATED_AT: 9,
|
|
62
|
+
CHANGED_BY: 10,
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* SQL column names for prompts_library table
|
|
66
|
+
*/
|
|
67
|
+
export const PROMPT_COLUMN_NAMES = [
|
|
68
|
+
'uuid',
|
|
69
|
+
'prompt_area',
|
|
70
|
+
'prompt_key',
|
|
71
|
+
'local_1',
|
|
72
|
+
'local_2',
|
|
73
|
+
'local_3',
|
|
74
|
+
'prompt_text',
|
|
75
|
+
'prompt_variables',
|
|
76
|
+
'prompt_notes',
|
|
77
|
+
'created_at',
|
|
78
|
+
'changed_by',
|
|
79
|
+
];
|
|
80
|
+
/**
|
|
81
|
+
* Get the SELECT clause for all prompt columns
|
|
82
|
+
* @returns SQL SELECT clause string
|
|
83
|
+
*/
|
|
84
|
+
export function get_prompt_select_clause() {
|
|
85
|
+
return PROMPT_COLUMN_NAMES.join(', ');
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/lib/database/utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,gFAAgF;AAChF,2BAA2B;AAC3B,gFAAgF;AAEhF;;;;;;;;;;;;;;;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KAC5C,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,CAAC;IACP,WAAW,EAAE,CAAC;IACd,UAAU,EAAE,CAAC;IACb,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,CAAC;IACV,WAAW,EAAE,CAAC;IACd,gBAAgB,EAAE,CAAC;IACnB,YAAY,EAAE,CAAC;IACf,UAAU,EAAE,CAAC;IACb,UAAU,EAAE,EAAE;CACN,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,MAAM;IACN,aAAa;IACb,YAAY;IACZ,SAAS;IACT,SAAS;IACT,SAAS;IACT,aAAa;IACb,kBAAkB;IAClB,cAAc;IACd,YAAY;IACZ,YAAY;CACJ,CAAC;AAEX;;;GAGG;AACH,MAAM,UAAU,wBAAwB;IACtC,OAAO,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Library Module Exports
|
|
3
|
+
*
|
|
4
|
+
* Export all library functions from this module
|
|
5
|
+
*/
|
|
6
|
+
export { initialize_llm_api, hazo_llm_text_text, hazo_llm_image_text, hazo_llm_text_image, hazo_llm_image_image, hazo_llm_text_image_text, hazo_llm_image_image_text, is_initialized, get_current_config, } from './llm_api/index.js';
|
|
7
|
+
export type { LLMApiConfig, LLMApiClient, LLMResponse, TextTextParams, ImageTextParams, TextImageParams, ImageImageParams, TextImageTextParams, ImageImageTextParams, ChainImage, Logger, PromptVariable, PromptVariables, Base64Data, PromptTextMode, PromptRecord, CallLLMParams, } from './llm_api/types.js';
|
|
8
|
+
export { initialize_database, get_database, close_database, insert_prompt, update_prompt, } from './database/index.js';
|
|
9
|
+
export { get_prompt_by_area_and_key, get_prompt_text, get_prompts_by_area, get_prompt_by_uuid, substitute_variables, parse_prompt_variables, validate_variables, } from './prompts/index.js';
|
|
10
|
+
export { call_gemini_api, get_gemini_api_url, GeminiProvider, type GeminiProviderConfig, QwenProvider, type QwenProviderConfig, call_qwen_api, get_qwen_api_url, type QwenGenerationConfig, } from './providers/index.js';
|
|
11
|
+
export type { LLMProvider, LLMProviderConfig, ServiceType, LLMCapabilities, } from './providers/types.js';
|
|
12
|
+
export { SERVICE_TYPES, } from './providers/types.js';
|
|
13
|
+
export { register_provider, set_enabled_llms, set_primary_llm, get_primary_llm, get_provider, get_registered_providers, is_llm_enabled, } from './providers/registry.js';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,wBAAwB,EACxB,yBAAyB,EACzB,cAAc,EACd,kBAAkB,GACnB,MAAM,oBAAoB,CAAC;AAG5B,YAAY,EACV,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,cAAc,EACd,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,EACpB,UAAU,EACV,MAAM,EACN,cAAc,EACd,eAAe,EACf,UAAU,EACV,cAAc,EACd,YAAY,EACZ,aAAa,GACd,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,mBAAmB,EACnB,YAAY,EACZ,cAAc,EACd,aAAa,EACb,aAAa,GACd,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,0BAA0B,EAC1B,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,KAAK,oBAAoB,EACzB,YAAY,EACZ,KAAK,kBAAkB,EACvB,aAAa,EACb,gBAAgB,EAChB,KAAK,oBAAoB,GAC1B,MAAM,sBAAsB,CAAC;AAG9B,YAAY,EACV,WAAW,EACX,iBAAiB,EACjB,WAAW,EACX,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,aAAa,GACd,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,YAAY,EACZ,wBAAwB,EACxB,cAAc,GACf,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Library Module Exports
|
|
3
|
+
*
|
|
4
|
+
* Export all library functions from this module
|
|
5
|
+
*/
|
|
6
|
+
// LLM API exports
|
|
7
|
+
export { initialize_llm_api, hazo_llm_text_text, hazo_llm_image_text, hazo_llm_text_image, hazo_llm_image_image, hazo_llm_text_image_text, hazo_llm_image_image_text, is_initialized, get_current_config, } from './llm_api/index.js';
|
|
8
|
+
// Database exports
|
|
9
|
+
export { initialize_database, get_database, close_database, insert_prompt, update_prompt, } from './database/index.js';
|
|
10
|
+
// Prompts exports
|
|
11
|
+
export { get_prompt_by_area_and_key, get_prompt_text, get_prompts_by_area, get_prompt_by_uuid, substitute_variables, parse_prompt_variables, validate_variables, } from './prompts/index.js';
|
|
12
|
+
// Provider exports
|
|
13
|
+
export { call_gemini_api, get_gemini_api_url, GeminiProvider, QwenProvider, call_qwen_api, get_qwen_api_url, } from './providers/index.js';
|
|
14
|
+
export { SERVICE_TYPES, } from './providers/types.js';
|
|
15
|
+
// Provider registry exports
|
|
16
|
+
export { register_provider, set_enabled_llms, set_primary_llm, get_primary_llm, get_provider, get_registered_providers, is_llm_enabled, } from './providers/registry.js';
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,kBAAkB;AAClB,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,wBAAwB,EACxB,yBAAyB,EACzB,cAAc,EACd,kBAAkB,GACnB,MAAM,oBAAoB,CAAC;AAuB5B,mBAAmB;AACnB,OAAO,EACL,mBAAmB,EACnB,YAAY,EACZ,cAAc,EACd,aAAa,EACb,aAAa,GACd,MAAM,qBAAqB,CAAC;AAE7B,kBAAkB;AAClB,OAAO,EACL,0BAA0B,EAC1B,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,oBAAoB,CAAC;AAE5B,mBAAmB;AACnB,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,cAAc,EAEd,YAAY,EAEZ,aAAa,EACb,gBAAgB,GAEjB,MAAM,sBAAsB,CAAC;AAU9B,OAAO,EACL,aAAa,GACd,MAAM,sBAAsB,CAAC;AAE9B,4BAA4B;AAC5B,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,YAAY,EACZ,wBAAwB,EACxB,cAAc,GACf,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chain Helper Functions
|
|
3
|
+
*
|
|
4
|
+
* Utility functions for parsing call_chain paths, resolving values,
|
|
5
|
+
* and deep merging results in prompt chains.
|
|
6
|
+
*/
|
|
7
|
+
import type { Logger, ChainFieldDefinition, ChainVariableDefinition, ChainImageDefinition, ChainCallResult, PromptVariables } from './types.js';
|
|
8
|
+
interface ParsedPath {
|
|
9
|
+
call_index: number;
|
|
10
|
+
property_path: string[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Parse a call_chain path expression like "call[0].tax_category" or "call[2].data.nested.value"
|
|
14
|
+
*
|
|
15
|
+
* @param path_expr - The path expression to parse
|
|
16
|
+
* @param logger - Logger instance
|
|
17
|
+
* @returns Parsed path with call index and property path array, or null if invalid
|
|
18
|
+
*/
|
|
19
|
+
export declare function parse_call_chain_path(path_expr: string, logger: Logger): ParsedPath | null;
|
|
20
|
+
/**
|
|
21
|
+
* Extract a value from a nested object using a property path array
|
|
22
|
+
*
|
|
23
|
+
* @param obj - The object to extract from
|
|
24
|
+
* @param path - Array of property names to traverse
|
|
25
|
+
* @param logger - Logger instance
|
|
26
|
+
* @returns The extracted value as a string, or null if not found
|
|
27
|
+
*/
|
|
28
|
+
export declare function extract_value_from_path(obj: Record<string, unknown>, path: string[], logger: Logger): string | null;
|
|
29
|
+
/**
|
|
30
|
+
* Extract a value from a ChainCallResult using a property path
|
|
31
|
+
* Supports both parsed_result fields and top-level image/text fields
|
|
32
|
+
*
|
|
33
|
+
* Examples:
|
|
34
|
+
* - "image_b64" -> returns result.image_b64
|
|
35
|
+
* - "image_mime_type" -> returns result.image_mime_type
|
|
36
|
+
* - "raw_text" -> returns result.raw_text
|
|
37
|
+
* - "country" -> traverses result.parsed_result.country
|
|
38
|
+
* - "data.nested.value" -> traverses result.parsed_result.data.nested.value
|
|
39
|
+
*
|
|
40
|
+
* @param result - The ChainCallResult to extract from
|
|
41
|
+
* @param property_path - Array of property names to traverse
|
|
42
|
+
* @param logger - Logger instance
|
|
43
|
+
* @returns The extracted value as a string, or null if not found
|
|
44
|
+
*/
|
|
45
|
+
export declare function extract_value_from_result(result: ChainCallResult, property_path: string[], logger: Logger): string | null;
|
|
46
|
+
/**
|
|
47
|
+
* Resolve a chain field definition to its actual value
|
|
48
|
+
* Supports both parsed_result fields and top-level image/text fields
|
|
49
|
+
*
|
|
50
|
+
* @param field - The field definition to resolve
|
|
51
|
+
* @param previous_results - Array of previous call results
|
|
52
|
+
* @param logger - Logger instance
|
|
53
|
+
* @returns Resolved string value, or null if resolution failed
|
|
54
|
+
*/
|
|
55
|
+
export declare function resolve_chain_field(field: ChainFieldDefinition, previous_results: ChainCallResult[], logger: Logger): string | null;
|
|
56
|
+
/**
|
|
57
|
+
* Resolve a chain variable definition to its actual value
|
|
58
|
+
* Supports both parsed_result fields and top-level image/text fields
|
|
59
|
+
*
|
|
60
|
+
* @param variable - The variable definition to resolve
|
|
61
|
+
* @param previous_results - Array of previous call results
|
|
62
|
+
* @param logger - Logger instance
|
|
63
|
+
* @returns Resolved string value, or null if resolution failed
|
|
64
|
+
*/
|
|
65
|
+
export declare function resolve_chain_variable(variable: ChainVariableDefinition, previous_results: ChainCallResult[], logger: Logger): string | null;
|
|
66
|
+
/**
|
|
67
|
+
* Build prompt variables from a variables array in a chain call definition
|
|
68
|
+
*
|
|
69
|
+
* @param variables_array - Array of variable definitions
|
|
70
|
+
* @param previous_results - Array of previous call results
|
|
71
|
+
* @param logger - Logger instance
|
|
72
|
+
* @returns PromptVariables array for substitution
|
|
73
|
+
*/
|
|
74
|
+
export declare function build_prompt_variables(variables_array: ChainVariableDefinition[] | undefined, previous_results: ChainCallResult[], logger: Logger): PromptVariables;
|
|
75
|
+
/**
|
|
76
|
+
* Resolved image data from a ChainImageDefinition
|
|
77
|
+
*/
|
|
78
|
+
export interface ResolvedImage {
|
|
79
|
+
image_b64: string;
|
|
80
|
+
image_mime_type: string;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Resolve a ChainImageDefinition to actual image data
|
|
84
|
+
*
|
|
85
|
+
* @param image_def - The image definition to resolve
|
|
86
|
+
* @param previous_results - Array of previous call results
|
|
87
|
+
* @param logger - Logger instance
|
|
88
|
+
* @returns Resolved image data or null if resolution failed
|
|
89
|
+
*/
|
|
90
|
+
export declare function resolve_chain_image_definition(image_def: ChainImageDefinition, previous_results: ChainCallResult[], logger: Logger): ResolvedImage | null;
|
|
91
|
+
/**
|
|
92
|
+
* Deep merge two objects, with source values overwriting target values
|
|
93
|
+
*
|
|
94
|
+
* @param target - Target object
|
|
95
|
+
* @param source - Source object to merge in
|
|
96
|
+
* @returns New merged object
|
|
97
|
+
*/
|
|
98
|
+
export declare function deep_merge(target: Record<string, unknown>, source: Record<string, unknown>): Record<string, unknown>;
|
|
99
|
+
/**
|
|
100
|
+
* Merge multiple call results into a single object
|
|
101
|
+
*
|
|
102
|
+
* @param results - Array of chain call results
|
|
103
|
+
* @param logger - Logger instance
|
|
104
|
+
* @returns Deep-merged object from all successful calls
|
|
105
|
+
*/
|
|
106
|
+
export declare function merge_chain_results(results: ChainCallResult[], logger: Logger): Record<string, unknown>;
|
|
107
|
+
/**
|
|
108
|
+
* Attempt to parse LLM response text as JSON
|
|
109
|
+
* Handles common LLM output formats (with markdown code blocks, etc.)
|
|
110
|
+
*
|
|
111
|
+
* @param text - Raw text response from LLM
|
|
112
|
+
* @param logger - Logger instance
|
|
113
|
+
* @returns Parsed JSON object or null if parsing fails
|
|
114
|
+
*/
|
|
115
|
+
export declare function parse_llm_json_response(text: string, logger: Logger): Record<string, unknown> | null;
|
|
116
|
+
export {};
|
|
117
|
+
//# sourceMappingURL=chain_helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chain_helpers.d.ts","sourceRoot":"","sources":["../../../src/lib/llm_api/chain_helpers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,MAAM,EACN,oBAAoB,EACpB,uBAAuB,EACvB,oBAAoB,EACpB,eAAe,EACf,eAAe,EAChB,MAAM,YAAY,CAAC;AAQpB,UAAU,UAAU;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB;AAMD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,GACb,UAAU,GAAG,IAAI,CAqBnB;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,IAAI,EAAE,MAAM,EAAE,EACd,MAAM,E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