@qwanyx/stack 0.2.75 → 0.2.76
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/client/LLMClient.d.ts +86 -0
- package/dist/index.cjs.js +36 -36
- package/dist/index.d.ts +2 -0
- package/dist/index.esm.js +2493 -2355
- package/package.json +1 -1
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LLMClient - AI/LLM Communication Layer
|
|
3
|
+
*
|
|
4
|
+
* Provides a type-safe interface to the qwanyx-brain LLM coprocessor.
|
|
5
|
+
* All operations communicate through the unified `/spu/invoke` endpoint.
|
|
6
|
+
*/
|
|
7
|
+
export type QwanyxModel = 'xlm' | 'mlm' | 'nlm';
|
|
8
|
+
export interface LLMClientConfig {
|
|
9
|
+
baseUrl: string;
|
|
10
|
+
system_id: string;
|
|
11
|
+
}
|
|
12
|
+
export interface ChatMessage {
|
|
13
|
+
role: 'system' | 'user' | 'assistant';
|
|
14
|
+
content: string;
|
|
15
|
+
}
|
|
16
|
+
export interface AnalyzeDocumentFile {
|
|
17
|
+
filename: string;
|
|
18
|
+
data: string;
|
|
19
|
+
content_type: string;
|
|
20
|
+
}
|
|
21
|
+
export declare class LLMClient {
|
|
22
|
+
private config;
|
|
23
|
+
constructor(config: LLMClientConfig);
|
|
24
|
+
/**
|
|
25
|
+
* Call the LLM coprocessor
|
|
26
|
+
*/
|
|
27
|
+
private callLLM;
|
|
28
|
+
/**
|
|
29
|
+
* Get auth token from localStorage (browser) or return empty string
|
|
30
|
+
*/
|
|
31
|
+
private getToken;
|
|
32
|
+
/**
|
|
33
|
+
* Simple text completion
|
|
34
|
+
*/
|
|
35
|
+
complete(prompt: string, options?: {
|
|
36
|
+
model?: QwanyxModel;
|
|
37
|
+
systemPrompt?: string;
|
|
38
|
+
temperature?: number;
|
|
39
|
+
maxTokens?: number;
|
|
40
|
+
}): Promise<string>;
|
|
41
|
+
/**
|
|
42
|
+
* Chat completion with messages
|
|
43
|
+
*/
|
|
44
|
+
chat(messages: ChatMessage[], options?: {
|
|
45
|
+
model?: QwanyxModel;
|
|
46
|
+
temperature?: number;
|
|
47
|
+
maxTokens?: number;
|
|
48
|
+
}): Promise<string>;
|
|
49
|
+
/**
|
|
50
|
+
* Chat completion with JSON response
|
|
51
|
+
* Automatically parses the response and strips markdown code blocks
|
|
52
|
+
*/
|
|
53
|
+
chatJson<T>(systemPrompt: string, userPrompt: string, options?: {
|
|
54
|
+
model?: QwanyxModel;
|
|
55
|
+
temperature?: number;
|
|
56
|
+
}): Promise<T>;
|
|
57
|
+
/**
|
|
58
|
+
* Analyze documents (PDF, images, text files) via base64 encoding
|
|
59
|
+
*/
|
|
60
|
+
analyzeDocuments(prompt: string, files: AnalyzeDocumentFile[], options?: {
|
|
61
|
+
model?: QwanyxModel;
|
|
62
|
+
temperature?: number;
|
|
63
|
+
maxTokens?: number;
|
|
64
|
+
}): Promise<string>;
|
|
65
|
+
/**
|
|
66
|
+
* Transcribe audio to text
|
|
67
|
+
*/
|
|
68
|
+
transcribe(audioData: string, // base64 encoded
|
|
69
|
+
options?: {
|
|
70
|
+
filename?: string;
|
|
71
|
+
language?: string;
|
|
72
|
+
}): Promise<string>;
|
|
73
|
+
private promptCache;
|
|
74
|
+
/**
|
|
75
|
+
* Get a prompt template from the server
|
|
76
|
+
*/
|
|
77
|
+
getPrompt(name: string): Promise<string>;
|
|
78
|
+
/**
|
|
79
|
+
* Clear prompt cache (useful when prompts are updated)
|
|
80
|
+
*/
|
|
81
|
+
clearPromptCache(): void;
|
|
82
|
+
/**
|
|
83
|
+
* Replace {{placeholders}} in a prompt template
|
|
84
|
+
*/
|
|
85
|
+
buildPrompt(template: string, context: Record<string, string>): string;
|
|
86
|
+
}
|