@hilbras/sdk 0.26.0 → 0.26.6
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 +1 -1
- package/dist/catalog/provider-catalog.json +92 -57
- package/dist/features/agent/index.d.ts +13 -0
- package/dist/features/agent/index.d.ts.map +1 -0
- package/dist/features/agent/index.js +12 -0
- package/dist/features/agent/index.js.map +1 -0
- package/dist/features/agent/plan-and-execute.d.ts +49 -0
- package/dist/features/agent/plan-and-execute.d.ts.map +1 -0
- package/dist/features/agent/plan-and-execute.js +184 -0
- package/dist/features/agent/plan-and-execute.js.map +1 -0
- package/dist/features/agent/react.d.ts +49 -0
- package/dist/features/agent/react.d.ts.map +1 -0
- package/dist/features/agent/react.js +165 -0
- package/dist/features/agent/react.js.map +1 -0
- package/dist/features/agent/tool-loop.d.ts +58 -0
- package/dist/features/agent/tool-loop.d.ts.map +1 -0
- package/dist/features/agent/tool-loop.js +217 -0
- package/dist/features/agent/tool-loop.js.map +1 -0
- package/dist/features/agent/types.d.ts +136 -0
- package/dist/features/agent/types.d.ts.map +1 -0
- package/dist/features/agent/types.js +7 -0
- package/dist/features/agent/types.js.map +1 -0
- package/dist/features/eval/evaluate.d.ts +39 -0
- package/dist/features/eval/evaluate.d.ts.map +1 -0
- package/dist/features/eval/evaluate.js +153 -0
- package/dist/features/eval/evaluate.js.map +1 -0
- package/dist/features/eval/index.d.ts +9 -0
- package/dist/features/eval/index.d.ts.map +1 -0
- package/dist/features/eval/index.js +8 -0
- package/dist/features/eval/index.js.map +1 -0
- package/dist/features/eval/metrics.d.ts +38 -0
- package/dist/features/eval/metrics.d.ts.map +1 -0
- package/dist/features/eval/metrics.js +133 -0
- package/dist/features/eval/metrics.js.map +1 -0
- package/dist/features/eval/types.d.ts +116 -0
- package/dist/features/eval/types.d.ts.map +1 -0
- package/dist/features/eval/types.js +7 -0
- package/dist/features/eval/types.js.map +1 -0
- package/dist/features/fine-tune/formatters.d.ts +11 -0
- package/dist/features/fine-tune/formatters.d.ts.map +1 -0
- package/dist/features/fine-tune/formatters.js +155 -0
- package/dist/features/fine-tune/formatters.js.map +1 -0
- package/dist/features/fine-tune/index.d.ts +10 -0
- package/dist/features/fine-tune/index.d.ts.map +1 -0
- package/dist/features/fine-tune/index.js +9 -0
- package/dist/features/fine-tune/index.js.map +1 -0
- package/dist/features/fine-tune/quality.d.ts +37 -0
- package/dist/features/fine-tune/quality.d.ts.map +1 -0
- package/dist/features/fine-tune/quality.js +97 -0
- package/dist/features/fine-tune/quality.js.map +1 -0
- package/dist/features/fine-tune/split.d.ts +23 -0
- package/dist/features/fine-tune/split.d.ts.map +1 -0
- package/dist/features/fine-tune/split.js +43 -0
- package/dist/features/fine-tune/split.js.map +1 -0
- package/dist/features/fine-tune/types.d.ts +85 -0
- package/dist/features/fine-tune/types.d.ts.map +1 -0
- package/dist/features/fine-tune/types.js +5 -0
- package/dist/features/fine-tune/types.js.map +1 -0
- package/dist/features/rag/chunker.d.ts +42 -0
- package/dist/features/rag/chunker.d.ts.map +1 -0
- package/dist/features/rag/chunker.js +115 -0
- package/dist/features/rag/chunker.js.map +1 -0
- package/dist/features/rag/in-memory-store.d.ts +21 -0
- package/dist/features/rag/in-memory-store.d.ts.map +1 -0
- package/dist/features/rag/in-memory-store.js +81 -0
- package/dist/features/rag/in-memory-store.js.map +1 -0
- package/dist/features/rag/index.d.ts +15 -0
- package/dist/features/rag/index.d.ts.map +1 -0
- package/dist/features/rag/index.js +14 -0
- package/dist/features/rag/index.js.map +1 -0
- package/dist/features/rag/pipeline.d.ts +92 -0
- package/dist/features/rag/pipeline.d.ts.map +1 -0
- package/dist/features/rag/pipeline.js +102 -0
- package/dist/features/rag/pipeline.js.map +1 -0
- package/dist/features/rag/retriever.d.ts +71 -0
- package/dist/features/rag/retriever.d.ts.map +1 -0
- package/dist/features/rag/retriever.js +99 -0
- package/dist/features/rag/retriever.js.map +1 -0
- package/dist/features/rag/vector-store.d.ts +43 -0
- package/dist/features/rag/vector-store.d.ts.map +1 -0
- package/dist/features/rag/vector-store.js +8 -0
- package/dist/features/rag/vector-store.js.map +1 -0
- package/dist/frameworks/angular/angular-shim.d.ts +19 -0
- package/dist/frameworks/angular/angular-shim.d.ts.map +1 -0
- package/dist/frameworks/angular/angular-shim.js +22 -0
- package/dist/frameworks/angular/angular-shim.js.map +1 -0
- package/dist/frameworks/angular/chat.service.d.ts +53 -0
- package/dist/frameworks/angular/chat.service.d.ts.map +1 -0
- package/dist/frameworks/angular/chat.service.js +154 -0
- package/dist/frameworks/angular/chat.service.js.map +1 -0
- package/dist/frameworks/angular/completion.service.d.ts +34 -0
- package/dist/frameworks/angular/completion.service.d.ts.map +1 -0
- package/dist/frameworks/angular/completion.service.js +114 -0
- package/dist/frameworks/angular/completion.service.js.map +1 -0
- package/dist/frameworks/angular/index.d.ts +12 -0
- package/dist/frameworks/angular/index.d.ts.map +1 -0
- package/dist/frameworks/angular/index.js +9 -0
- package/dist/frameworks/angular/index.js.map +1 -0
- package/dist/frameworks/angular/object.service.d.ts +34 -0
- package/dist/frameworks/angular/object.service.d.ts.map +1 -0
- package/dist/frameworks/angular/object.service.js +119 -0
- package/dist/frameworks/angular/object.service.js.map +1 -0
- package/dist/frameworks/astro/endpoints.d.ts +42 -0
- package/dist/frameworks/astro/endpoints.d.ts.map +1 -0
- package/dist/frameworks/astro/endpoints.js +75 -0
- package/dist/frameworks/astro/endpoints.js.map +1 -0
- package/dist/frameworks/astro/hooks.d.ts +29 -0
- package/dist/frameworks/astro/hooks.d.ts.map +1 -0
- package/dist/frameworks/astro/hooks.js +80 -0
- package/dist/frameworks/astro/hooks.js.map +1 -0
- package/dist/frameworks/astro/index.d.ts +8 -0
- package/dist/frameworks/astro/index.d.ts.map +1 -0
- package/dist/frameworks/astro/index.js +8 -0
- package/dist/frameworks/astro/index.js.map +1 -0
- package/dist/frameworks/nextjs/client.d.ts +13 -0
- package/dist/frameworks/nextjs/client.d.ts.map +1 -0
- package/dist/frameworks/nextjs/client.js +8 -0
- package/dist/frameworks/nextjs/client.js.map +1 -0
- package/dist/frameworks/nextjs/index.d.ts +21 -0
- package/dist/frameworks/nextjs/index.d.ts.map +1 -0
- package/dist/frameworks/nextjs/index.js +20 -0
- package/dist/frameworks/nextjs/index.js.map +1 -0
- package/dist/frameworks/nextjs/route-handlers.d.ts +62 -0
- package/dist/frameworks/nextjs/route-handlers.d.ts.map +1 -0
- package/dist/frameworks/nextjs/route-handlers.js +74 -0
- package/dist/frameworks/nextjs/route-handlers.js.map +1 -0
- package/dist/frameworks/nextjs/server.d.ts +78 -0
- package/dist/frameworks/nextjs/server.d.ts.map +1 -0
- package/dist/frameworks/nextjs/server.js +89 -0
- package/dist/frameworks/nextjs/server.js.map +1 -0
- package/dist/frameworks/nextjs/signal-shim.d.ts +9 -0
- package/dist/frameworks/nextjs/signal-shim.d.ts.map +1 -0
- package/dist/frameworks/nextjs/signal-shim.js +14 -0
- package/dist/frameworks/nextjs/signal-shim.js.map +1 -0
- package/dist/frameworks/nextjs/use-chat.d.ts +22 -0
- package/dist/frameworks/nextjs/use-chat.d.ts.map +1 -0
- package/dist/frameworks/nextjs/use-chat.js +89 -0
- package/dist/frameworks/nextjs/use-chat.js.map +1 -0
- package/dist/frameworks/nextjs/use-completion.d.ts +18 -0
- package/dist/frameworks/nextjs/use-completion.d.ts.map +1 -0
- package/dist/frameworks/nextjs/use-completion.js +67 -0
- package/dist/frameworks/nextjs/use-completion.js.map +1 -0
- package/dist/frameworks/qwik/index.d.ts +11 -0
- package/dist/frameworks/qwik/index.d.ts.map +1 -0
- package/dist/frameworks/qwik/index.js +11 -0
- package/dist/frameworks/qwik/index.js.map +1 -0
- package/dist/frameworks/qwik/signal-shim.d.ts +11 -0
- package/dist/frameworks/qwik/signal-shim.d.ts.map +1 -0
- package/dist/frameworks/qwik/signal-shim.js +15 -0
- package/dist/frameworks/qwik/signal-shim.js.map +1 -0
- package/dist/frameworks/qwik/use-chat.d.ts +28 -0
- package/dist/frameworks/qwik/use-chat.d.ts.map +1 -0
- package/dist/frameworks/qwik/use-chat.js +91 -0
- package/dist/frameworks/qwik/use-chat.js.map +1 -0
- package/dist/frameworks/qwik/use-completion.d.ts +20 -0
- package/dist/frameworks/qwik/use-completion.d.ts.map +1 -0
- package/dist/frameworks/qwik/use-completion.js +69 -0
- package/dist/frameworks/qwik/use-completion.js.map +1 -0
- package/dist/frameworks/react/index.d.ts +14 -0
- package/dist/frameworks/react/index.d.ts.map +1 -0
- package/dist/frameworks/react/index.js +10 -0
- package/dist/frameworks/react/index.js.map +1 -0
- package/dist/frameworks/react/stream-parser.d.ts +8 -0
- package/dist/frameworks/react/stream-parser.d.ts.map +1 -0
- package/dist/frameworks/react/stream-parser.js +42 -0
- package/dist/frameworks/react/stream-parser.js.map +1 -0
- package/dist/frameworks/react/use-chat.d.ts +19 -0
- package/dist/frameworks/react/use-chat.d.ts.map +1 -0
- package/dist/frameworks/react/use-chat.js +173 -0
- package/dist/frameworks/react/use-chat.js.map +1 -0
- package/dist/frameworks/react/use-completion.d.ts +11 -0
- package/dist/frameworks/react/use-completion.d.ts.map +1 -0
- package/dist/frameworks/react/use-completion.js +91 -0
- package/dist/frameworks/react/use-completion.js.map +1 -0
- package/dist/frameworks/react/use-object.d.ts +45 -0
- package/dist/frameworks/react/use-object.d.ts.map +1 -0
- package/dist/frameworks/react/use-object.js +100 -0
- package/dist/frameworks/react/use-object.js.map +1 -0
- package/dist/frameworks/remix/actions.d.ts +38 -0
- package/dist/frameworks/remix/actions.d.ts.map +1 -0
- package/dist/frameworks/remix/actions.js +72 -0
- package/dist/frameworks/remix/actions.js.map +1 -0
- package/dist/frameworks/remix/hooks.d.ts +40 -0
- package/dist/frameworks/remix/hooks.d.ts.map +1 -0
- package/dist/frameworks/remix/hooks.js +97 -0
- package/dist/frameworks/remix/hooks.js.map +1 -0
- package/dist/frameworks/remix/index.d.ts +8 -0
- package/dist/frameworks/remix/index.d.ts.map +1 -0
- package/dist/frameworks/remix/index.js +8 -0
- package/dist/frameworks/remix/index.js.map +1 -0
- package/dist/frameworks/solid/index.d.ts +13 -0
- package/dist/frameworks/solid/index.d.ts.map +1 -0
- package/dist/frameworks/solid/index.js +13 -0
- package/dist/frameworks/solid/index.js.map +1 -0
- package/dist/frameworks/solid/solid-shim.d.ts +13 -0
- package/dist/frameworks/solid/solid-shim.d.ts.map +1 -0
- package/dist/frameworks/solid/solid-shim.js +15 -0
- package/dist/frameworks/solid/solid-shim.js.map +1 -0
- package/dist/frameworks/solid/use-chat.d.ts +28 -0
- package/dist/frameworks/solid/use-chat.d.ts.map +1 -0
- package/dist/frameworks/solid/use-chat.js +91 -0
- package/dist/frameworks/solid/use-chat.js.map +1 -0
- package/dist/frameworks/solid/use-completion.d.ts +20 -0
- package/dist/frameworks/solid/use-completion.d.ts.map +1 -0
- package/dist/frameworks/solid/use-completion.js +66 -0
- package/dist/frameworks/solid/use-completion.js.map +1 -0
- package/dist/frameworks/solid/use-object.d.ts +19 -0
- package/dist/frameworks/solid/use-object.d.ts.map +1 -0
- package/dist/frameworks/solid/use-object.js +70 -0
- package/dist/frameworks/solid/use-object.js.map +1 -0
- package/dist/frameworks/svelte/index.d.ts +15 -0
- package/dist/frameworks/svelte/index.d.ts.map +1 -0
- package/dist/frameworks/svelte/index.js +11 -0
- package/dist/frameworks/svelte/index.js.map +1 -0
- package/dist/frameworks/svelte/stream-parser.d.ts +8 -0
- package/dist/frameworks/svelte/stream-parser.d.ts.map +1 -0
- package/dist/frameworks/svelte/stream-parser.js +42 -0
- package/dist/frameworks/svelte/stream-parser.js.map +1 -0
- package/dist/frameworks/svelte/use-chat.d.ts +31 -0
- package/dist/frameworks/svelte/use-chat.d.ts.map +1 -0
- package/dist/frameworks/svelte/use-chat.js +146 -0
- package/dist/frameworks/svelte/use-chat.js.map +1 -0
- package/dist/frameworks/svelte/use-completion.d.ts +25 -0
- package/dist/frameworks/svelte/use-completion.d.ts.map +1 -0
- package/dist/frameworks/svelte/use-completion.js +108 -0
- package/dist/frameworks/svelte/use-completion.js.map +1 -0
- package/dist/frameworks/svelte/use-object.d.ts +28 -0
- package/dist/frameworks/svelte/use-object.d.ts.map +1 -0
- package/dist/frameworks/svelte/use-object.js +122 -0
- package/dist/frameworks/svelte/use-object.js.map +1 -0
- package/dist/frameworks/vue/index.d.ts +12 -0
- package/dist/frameworks/vue/index.d.ts.map +1 -0
- package/dist/frameworks/vue/index.js +10 -0
- package/dist/frameworks/vue/index.js.map +1 -0
- package/dist/frameworks/vue/stream-parser.d.ts +8 -0
- package/dist/frameworks/vue/stream-parser.d.ts.map +1 -0
- package/dist/frameworks/vue/stream-parser.js +42 -0
- package/dist/frameworks/vue/stream-parser.js.map +1 -0
- package/dist/frameworks/vue/use-chat.d.ts +64 -0
- package/dist/frameworks/vue/use-chat.d.ts.map +1 -0
- package/dist/frameworks/vue/use-chat.js +119 -0
- package/dist/frameworks/vue/use-chat.js.map +1 -0
- package/dist/frameworks/vue/use-completion.d.ts +18 -0
- package/dist/frameworks/vue/use-completion.d.ts.map +1 -0
- package/dist/frameworks/vue/use-completion.js +87 -0
- package/dist/frameworks/vue/use-completion.js.map +1 -0
- package/dist/frameworks/vue/use-object.d.ts +22 -0
- package/dist/frameworks/vue/use-object.d.ts.map +1 -0
- package/dist/frameworks/vue/use-object.js +101 -0
- package/dist/frameworks/vue/use-object.js.map +1 -0
- package/package.json +97 -1
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @hilbras/rag — Retriever
|
|
3
|
+
*
|
|
4
|
+
* Hybrid retriever that combines vector similarity search with keyword matching.
|
|
5
|
+
* Supports optional reranking for improved relevance.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Hybrid retriever combining vector search with optional reranking.
|
|
9
|
+
*/
|
|
10
|
+
export class Retriever {
|
|
11
|
+
_store;
|
|
12
|
+
_embedder;
|
|
13
|
+
_topK;
|
|
14
|
+
_reranker;
|
|
15
|
+
_minScore;
|
|
16
|
+
constructor(config) {
|
|
17
|
+
this._store = config.store;
|
|
18
|
+
this._embedder = config.embedder;
|
|
19
|
+
this._topK = config.topK ?? 5;
|
|
20
|
+
this._reranker = config.reranker;
|
|
21
|
+
this._minScore = config.minScore ?? 0;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Retrieve relevant documents for a query.
|
|
25
|
+
*/
|
|
26
|
+
async retrieve(query, options) {
|
|
27
|
+
const topK = options?.topK ?? this._topK;
|
|
28
|
+
const queryEmbedding = await this._embedder(query);
|
|
29
|
+
// Vector similarity search
|
|
30
|
+
let results = await this._store.search(queryEmbedding, topK * 2); // Fetch extra for reranking
|
|
31
|
+
// Apply metadata filter
|
|
32
|
+
if (options?.filter) {
|
|
33
|
+
results = results.filter((r) => {
|
|
34
|
+
const meta = r.document.metadata ?? {};
|
|
35
|
+
return options.filter(meta);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
// Apply min score threshold
|
|
39
|
+
if (this._minScore > 0) {
|
|
40
|
+
results = results.filter((r) => r.score >= this._minScore);
|
|
41
|
+
}
|
|
42
|
+
// Take top K
|
|
43
|
+
results = results.slice(0, topK);
|
|
44
|
+
// Rerank if available and requested
|
|
45
|
+
if (this._reranker && options?.rerank !== false) {
|
|
46
|
+
const docs = results.map((r) => r.document.content);
|
|
47
|
+
const reranked = await this._reranker(query, docs);
|
|
48
|
+
if (reranked.length > 0) {
|
|
49
|
+
results = reranked.map((r) => ({
|
|
50
|
+
...results[r.index],
|
|
51
|
+
score: r.score,
|
|
52
|
+
}));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return results.map((r) => ({
|
|
56
|
+
content: r.document.content,
|
|
57
|
+
documentId: r.document.id,
|
|
58
|
+
score: r.score,
|
|
59
|
+
metadata: r.document.metadata,
|
|
60
|
+
}));
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Build a context string from retrieved documents.
|
|
64
|
+
*/
|
|
65
|
+
async getContext(query, options) {
|
|
66
|
+
const results = await this.retrieve(query, options);
|
|
67
|
+
const maxLen = options?.maxContextLength ?? 4000;
|
|
68
|
+
let context = "";
|
|
69
|
+
for (const r of results) {
|
|
70
|
+
const addition = `${r.content}\n\n`;
|
|
71
|
+
if (context.length + addition.length > maxLen)
|
|
72
|
+
break;
|
|
73
|
+
context += addition;
|
|
74
|
+
}
|
|
75
|
+
return context.trim();
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Build RAG prompt messages for chat completion.
|
|
79
|
+
*/
|
|
80
|
+
async buildMessages(query, systemPrompt, options) {
|
|
81
|
+
const context = await this.getContext(query, options);
|
|
82
|
+
const messages = [];
|
|
83
|
+
if (systemPrompt) {
|
|
84
|
+
messages.push({ role: "system", content: systemPrompt });
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
messages.push({
|
|
88
|
+
role: "system",
|
|
89
|
+
content: "Answer the user's question based on the provided context. If the context doesn't contain enough information, say so.",
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
messages.push({
|
|
93
|
+
role: "user",
|
|
94
|
+
content: `Context:\n${context}\n\nQuestion: ${query}`,
|
|
95
|
+
});
|
|
96
|
+
return messages;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=retriever.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retriever.js","sourceRoot":"","sources":["../../../src/features/rag/retriever.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAqCH;;GAEG;AACH,MAAM,OAAO,SAAS;IACZ,MAAM,CAAc;IACpB,SAAS,CAAuC;IAChD,KAAK,CAAS;IACd,SAAS,CAA+B;IACxC,SAAS,CAAS;IAE1B,YAAY,MAAuB;QACjC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC;QAC3B,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC;QACjC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,IAAI,IAA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ACxB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,aAAa,CACjB,KAAa,EACb,YAAqB,EACrB,OAA0D;QAE1D,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAEtD,MAAM,QAAQ,GAA6C,EAAE,CAAC;QAE9D,IAAI,YAAY,EAAE,CAAC;YACjB,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC,CAAC;QAC3D,CAAC;aAAM,CAAC;YACN,QAAQ,CAAC,IAAI,CAAC;gBACZ,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,sHAAsH;aAChI,CAAC,CAAC;QACL,CAAC;QAED,QAAQ,CAAC,IAAI,CAAC;YACZ,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE,aAAa,OAAO,iBAAiB,KAAK,EAAE;SACtD,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @hilbras/rag — VectorStore Interface
|
|
3
|
+
*
|
|
4
|
+
* Abstract interface for vector storage backends.
|
|
5
|
+
* Implementations can be in-memory, Pinecone, Weaviate, Chroma, etc.
|
|
6
|
+
*/
|
|
7
|
+
export interface VectorDocument {
|
|
8
|
+
/** Unique document ID */
|
|
9
|
+
id: string;
|
|
10
|
+
/** Document content/text */
|
|
11
|
+
content: string;
|
|
12
|
+
/** Vector embedding */
|
|
13
|
+
embedding: number[];
|
|
14
|
+
/** Optional metadata */
|
|
15
|
+
metadata?: Record<string, unknown>;
|
|
16
|
+
}
|
|
17
|
+
export interface SearchResult {
|
|
18
|
+
/** The matched document */
|
|
19
|
+
document: VectorDocument;
|
|
20
|
+
/** Similarity score (0-1, higher = more similar) */
|
|
21
|
+
score: number;
|
|
22
|
+
}
|
|
23
|
+
export interface VectorStoreConfig {
|
|
24
|
+
/** Dimension of the embeddings */
|
|
25
|
+
dimension: number;
|
|
26
|
+
/** Distance metric: cosine (default), dot, l2 */
|
|
27
|
+
metric?: "cosine" | "dot" | "l2";
|
|
28
|
+
}
|
|
29
|
+
export interface VectorStore {
|
|
30
|
+
/** Add documents to the store */
|
|
31
|
+
add(documents: VectorDocument[]): Promise<void>;
|
|
32
|
+
/** Remove documents by ID */
|
|
33
|
+
remove(ids: string[]): Promise<void>;
|
|
34
|
+
/** Search for similar documents */
|
|
35
|
+
search(embedding: number[], topK: number): Promise<SearchResult[]>;
|
|
36
|
+
/** Get document by ID */
|
|
37
|
+
get(id: string): Promise<VectorDocument | null>;
|
|
38
|
+
/** Get total number of documents */
|
|
39
|
+
size(): number;
|
|
40
|
+
/** Clear all documents */
|
|
41
|
+
clear(): Promise<void>;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=vector-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vector-store.d.ts","sourceRoot":"","sources":["../../../src/features/rag/vector-store.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,cAAc;IAC7B,yBAAyB;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,4BAA4B;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,uBAAuB;IACvB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,wBAAwB;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,YAAY;IAC3B,2BAA2B;IAC3B,QAAQ,EAAE,cAAc,CAAC;IACzB,oDAAoD;IACpD,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,iBAAiB;IAChC,kCAAkC;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,iDAAiD;IACjD,MAAM,CAAC,EAAE,QAAQ,GAAG,KAAK,GAAG,IAAI,CAAC;CAClC;AAED,MAAM,WAAW,WAAW;IAC1B,iCAAiC;IACjC,GAAG,CAAC,SAAS,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD,6BAA6B;IAC7B,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrC,mCAAmC;IACnC,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC;IACnE,yBAAyB;IACzB,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IAChD,oCAAoC;IACpC,IAAI,IAAI,MAAM,CAAC;IACf,0BAA0B;IAC1B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vector-store.js","sourceRoot":"","sources":["../../../src/features/rag/vector-store.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @hilbras/angular — Minimal Angular-compatible signal types
|
|
3
|
+
*
|
|
4
|
+
* These are minimal type definitions that match Angular's signal API.
|
|
5
|
+
* When used with real Angular, the actual @angular/core provides these.
|
|
6
|
+
*/
|
|
7
|
+
export interface WritableSignal<T> {
|
|
8
|
+
(): T;
|
|
9
|
+
set(value: T): void;
|
|
10
|
+
update(fn: (value: T) => T): void;
|
|
11
|
+
asReadonly(): Signal<T>;
|
|
12
|
+
}
|
|
13
|
+
export interface Signal<T> {
|
|
14
|
+
(): T;
|
|
15
|
+
}
|
|
16
|
+
export declare function signal<T>(initialValue: T): WritableSignal<T>;
|
|
17
|
+
export declare function computed<T>(fn: () => T): Signal<T>;
|
|
18
|
+
export declare function Injectable(options?: any): ClassDecorator;
|
|
19
|
+
//# sourceMappingURL=angular-shim.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"angular-shim.d.ts","sourceRoot":"","sources":["../../../src/frameworks/angular/angular-shim.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,IAAI,CAAC,CAAC;IACN,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IACpB,MAAM,CAAC,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;IAClC,UAAU,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC;CACzB;AAED,MAAM,WAAW,MAAM,CAAC,CAAC;IACvB,IAAI,CAAC,CAAC;CACP;AAED,wBAAgB,MAAM,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAO5D;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAElD;AAGD,wBAAgB,UAAU,CAAC,OAAO,CAAC,EAAE,GAAG,GAAG,cAAc,CAExD"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @hilbras/angular — Minimal Angular-compatible signal types
|
|
3
|
+
*
|
|
4
|
+
* These are minimal type definitions that match Angular's signal API.
|
|
5
|
+
* When used with real Angular, the actual @angular/core provides these.
|
|
6
|
+
*/
|
|
7
|
+
export function signal(initialValue) {
|
|
8
|
+
let value = initialValue;
|
|
9
|
+
const fn = () => value;
|
|
10
|
+
fn.set = (v) => { value = v; };
|
|
11
|
+
fn.update = (upd) => { value = upd(value); };
|
|
12
|
+
fn.asReadonly = () => fn;
|
|
13
|
+
return fn;
|
|
14
|
+
}
|
|
15
|
+
export function computed(fn) {
|
|
16
|
+
return fn;
|
|
17
|
+
}
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
|
+
export function Injectable(options) {
|
|
20
|
+
return () => { };
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=angular-shim.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"angular-shim.js","sourceRoot":"","sources":["../../../src/frameworks/angular/angular-shim.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAaH,MAAM,UAAU,MAAM,CAAI,YAAe;IACvC,IAAI,KAAK,GAAG,YAAY,CAAC;IACzB,MAAM,EAAE,GAAG,GAAG,EAAE,CAAC,KAAK,CAAC;IACvB,EAAE,CAAC,GAAG,GAAG,CAAC,CAAI,EAAE,EAAE,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAClC,EAAE,CAAC,MAAM,GAAG,CAAC,GAAgB,EAAE,EAAE,GAAG,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1D,EAAE,CAAC,UAAU,GAAG,GAAG,EAAE,CAAC,EAAe,CAAC;IACtC,OAAO,EAAuB,CAAC;AACjC,CAAC;AAED,MAAM,UAAU,QAAQ,CAAI,EAAW;IACrC,OAAO,EAAe,CAAC;AACzB,CAAC;AAED,8DAA8D;AAC9D,MAAM,UAAU,UAAU,CAAC,OAAa;IACtC,OAAO,GAAG,EAAE,GAAE,CAAC,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @hilbras/angular — Chat Service
|
|
3
|
+
*
|
|
4
|
+
* Angular service for streaming chat conversations with an LLM backend.
|
|
5
|
+
* Uses Angular signals for reactive state management.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* @Component({ ... })
|
|
9
|
+
* export class ChatComponent {
|
|
10
|
+
* chat = inject(HilbrasChatService);
|
|
11
|
+
* messages = this.chat.messages;
|
|
12
|
+
* isLoading = this.chat.isLoading;
|
|
13
|
+
*
|
|
14
|
+
* send() {
|
|
15
|
+
* this.chat.submit({ api: '/api/chat', body: { model: 'gpt-4o' } });
|
|
16
|
+
* }
|
|
17
|
+
* }
|
|
18
|
+
*/
|
|
19
|
+
export interface UIMessage {
|
|
20
|
+
id: string;
|
|
21
|
+
role: "user" | "assistant" | "system" | "tool";
|
|
22
|
+
content: string;
|
|
23
|
+
createdAt?: number;
|
|
24
|
+
provider?: string;
|
|
25
|
+
model?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface ChatOptions {
|
|
28
|
+
api: string;
|
|
29
|
+
initialMessages?: UIMessage[];
|
|
30
|
+
provider?: string;
|
|
31
|
+
model?: string;
|
|
32
|
+
onFinish?: (messages: UIMessage[]) => void;
|
|
33
|
+
onError?: (error: Error) => void;
|
|
34
|
+
headers?: Record<string, string>;
|
|
35
|
+
body?: Record<string, unknown>;
|
|
36
|
+
}
|
|
37
|
+
export declare class HilbrasChatService {
|
|
38
|
+
private _messages;
|
|
39
|
+
private _input;
|
|
40
|
+
private _isLoading;
|
|
41
|
+
private _error;
|
|
42
|
+
private _abortController;
|
|
43
|
+
readonly messages: import("./angular-shim.js").Signal<UIMessage[]>;
|
|
44
|
+
readonly input: import("./angular-shim.js").Signal<string>;
|
|
45
|
+
readonly isLoading: import("./angular-shim.js").Signal<boolean>;
|
|
46
|
+
readonly error: import("./angular-shim.js").Signal<Error | null>;
|
|
47
|
+
readonly hasMessages: import("./angular-shim.js").Signal<boolean>;
|
|
48
|
+
setInput(value: string): void;
|
|
49
|
+
stop(): void;
|
|
50
|
+
clear(): void;
|
|
51
|
+
submit(options: ChatOptions): Promise<void>;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=chat.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.service.d.ts","sourceRoot":"","sources":["../../../src/frameworks/angular/chat.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,GAAG,WAAW,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
+
* @hilbras/angular — Chat Service
|
|
3
|
+
*
|
|
4
|
+
* Angular service for streaming chat conversations with an LLM backend.
|
|
5
|
+
* Uses Angular signals for reactive state management.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* @Component({ ... })
|
|
9
|
+
* export class ChatComponent {
|
|
10
|
+
* chat = inject(HilbrasChatService);
|
|
11
|
+
* messages = this.chat.messages;
|
|
12
|
+
* isLoading = this.chat.isLoading;
|
|
13
|
+
*
|
|
14
|
+
* send() {
|
|
15
|
+
* this.chat.submit({ api: '/api/chat', body: { model: 'gpt-4o' } });
|
|
16
|
+
* }
|
|
17
|
+
* }
|
|
18
|
+
*/
|
|
19
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
20
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
21
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
22
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
23
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
24
|
+
};
|
|
25
|
+
import { Injectable, signal, computed } from "./angular-shim.js";
|
|
26
|
+
let _idCounter = 0;
|
|
27
|
+
function generateId() {
|
|
28
|
+
return `msg_${Date.now()}_${_idCounter++}`;
|
|
29
|
+
}
|
|
30
|
+
let HilbrasChatService = class HilbrasChatService {
|
|
31
|
+
_messages = signal([]);
|
|
32
|
+
_input = signal("");
|
|
33
|
+
_isLoading = signal(false);
|
|
34
|
+
_error = signal(null);
|
|
35
|
+
_abortController = null;
|
|
36
|
+
messages = this._messages.asReadonly();
|
|
37
|
+
input = this._input.asReadonly();
|
|
38
|
+
isLoading = this._isLoading.asReadonly();
|
|
39
|
+
error = this._error.asReadonly();
|
|
40
|
+
hasMessages = computed(() => this._messages().length > 0);
|
|
41
|
+
setInput(value) {
|
|
42
|
+
this._input.set(value);
|
|
43
|
+
}
|
|
44
|
+
stop() {
|
|
45
|
+
this._abortController?.abort();
|
|
46
|
+
this._abortController = null;
|
|
47
|
+
this._isLoading.set(false);
|
|
48
|
+
}
|
|
49
|
+
clear() {
|
|
50
|
+
this._messages.set([]);
|
|
51
|
+
this._input.set("");
|
|
52
|
+
this._error.set(null);
|
|
53
|
+
this.stop();
|
|
54
|
+
}
|
|
55
|
+
async submit(options) {
|
|
56
|
+
const trimmed = this._input().trim();
|
|
57
|
+
if (!trimmed || this._isLoading())
|
|
58
|
+
return;
|
|
59
|
+
const userMessage = {
|
|
60
|
+
id: generateId(),
|
|
61
|
+
role: "user",
|
|
62
|
+
content: trimmed,
|
|
63
|
+
createdAt: Date.now(),
|
|
64
|
+
};
|
|
65
|
+
const assistantMessage = {
|
|
66
|
+
id: generateId(),
|
|
67
|
+
role: "assistant",
|
|
68
|
+
content: "",
|
|
69
|
+
createdAt: Date.now(),
|
|
70
|
+
provider: options.provider,
|
|
71
|
+
model: options.model,
|
|
72
|
+
};
|
|
73
|
+
this._messages.update((msgs) => [...msgs, userMessage, assistantMessage]);
|
|
74
|
+
this._input.set("");
|
|
75
|
+
this._isLoading.set(true);
|
|
76
|
+
this._error.set(null);
|
|
77
|
+
const controller = new AbortController();
|
|
78
|
+
this._abortController = controller;
|
|
79
|
+
try {
|
|
80
|
+
const res = await fetch(options.api, {
|
|
81
|
+
method: "POST",
|
|
82
|
+
headers: { "Content-Type": "application/json", ...options.headers },
|
|
83
|
+
body: JSON.stringify({
|
|
84
|
+
messages: this._messages().slice(0, -1).map((m) => ({
|
|
85
|
+
role: m.role,
|
|
86
|
+
content: m.content,
|
|
87
|
+
})),
|
|
88
|
+
stream: true,
|
|
89
|
+
...options.body,
|
|
90
|
+
}),
|
|
91
|
+
signal: controller.signal,
|
|
92
|
+
});
|
|
93
|
+
if (!res.ok)
|
|
94
|
+
throw new Error(`HTTP ${res.status}: ${res.statusText}`);
|
|
95
|
+
if (!res.body)
|
|
96
|
+
throw new Error("Response body is null");
|
|
97
|
+
const reader = res.body.getReader();
|
|
98
|
+
const decoder = new TextDecoder();
|
|
99
|
+
let buffer = "";
|
|
100
|
+
while (true) {
|
|
101
|
+
const { done, value } = await reader.read();
|
|
102
|
+
if (done)
|
|
103
|
+
break;
|
|
104
|
+
buffer += decoder.decode(value, { stream: true });
|
|
105
|
+
const parts = buffer.split("\n\n");
|
|
106
|
+
buffer = parts.pop() ?? "";
|
|
107
|
+
for (const part of parts) {
|
|
108
|
+
const lines = part.split("\n");
|
|
109
|
+
let rawData = "";
|
|
110
|
+
for (const line of lines) {
|
|
111
|
+
if (line.startsWith("data: "))
|
|
112
|
+
rawData = line.slice(6).trim();
|
|
113
|
+
}
|
|
114
|
+
if (!rawData || rawData === "[DONE]")
|
|
115
|
+
continue;
|
|
116
|
+
let data;
|
|
117
|
+
try {
|
|
118
|
+
data = JSON.parse(rawData);
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
if (data.type === "text" && typeof data.text === "string") {
|
|
124
|
+
this._messages.update((msgs) => {
|
|
125
|
+
const updated = [...msgs];
|
|
126
|
+
const last = updated[updated.length - 1];
|
|
127
|
+
if (last)
|
|
128
|
+
updated[updated.length - 1] = { ...last, content: last.content + data.text };
|
|
129
|
+
return updated;
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
const finalMessages = this._messages();
|
|
135
|
+
options.onFinish?.(finalMessages);
|
|
136
|
+
}
|
|
137
|
+
catch (err) {
|
|
138
|
+
if (err.name === "AbortError")
|
|
139
|
+
return;
|
|
140
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
141
|
+
this._error.set(error);
|
|
142
|
+
options.onError?.(error);
|
|
143
|
+
}
|
|
144
|
+
finally {
|
|
145
|
+
this._abortController = null;
|
|
146
|
+
this._isLoading.set(false);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
HilbrasChatService = __decorate([
|
|
151
|
+
Injectable({ providedIn: "root" })
|
|
152
|
+
], HilbrasChatService);
|
|
153
|
+
export { HilbrasChatService };
|
|
154
|
+
//# sourceMappingURL=chat.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.service.js","sourceRoot":"","sources":["../../../src/frameworks/angular/chat.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;;;;;;;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAWjE,IAAI,UAAU,GAAG,CAAC,CAAC;AACnB,SAAS,UAAU;IACjB,OAAO,OAAO,IAAI,CAAC,GAAG,EAAE,IAAI,UAAU,EAAE,EAAE,CAAC;AAC7C,CAAC;AAcM,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IACrB,SAAS,GAAG,MAAM,CAAc,EAAE,CAAC,CAAC;IACpC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC;IACpB,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC3B,MAAM,GAAG,MAAM,CAAe,IAAI,CAAC,CAAC;IACpC,gBAAgB,GAA2B,IAAI,CAAC;IAE/C,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,CAAC;IACvC,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;IACjC,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC;IACzC,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;IACjC,WAAW,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAEnE,QAAQ,CAAC,KAAa;QACpB,IAAI,C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IAAI,IAAI;gCAAE,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;4BACvF,OAAO,OAAO,CAAC;wBACjB,CAAC,CAAC,CAAC;oBACL,CAAC;gBACH,CAAC;YACH,CAAC;YAED,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;YACvC,OAAO,CAAC,QAAQ,EAAE,CAAC,aAAa,CAAC,CAAC;QACpC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAK,GAAa,CAAC,IAAI,KAAK,YAAY;gBAAE,OAAO;YACjD,MAAM,KAAK,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;YAClE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACvB,OAAO,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;QAC3B,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;YAC7B,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;CACF,CAAA;AA1HY,kBAAkB;IAD9B,UAAU,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC;GACtB,kBAAkB,CA0H9B"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @hilbras/angular — Completion Service
|
|
3
|
+
*
|
|
4
|
+
* Angular service for streaming text completions from an LLM backend.
|
|
5
|
+
* Uses Angular signals for reactive state management.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* @Component({ ... })
|
|
9
|
+
* export class CompletionComponent {
|
|
10
|
+
* completion = inject(HilbrasCompletionService);
|
|
11
|
+
* text = this.completion.text;
|
|
12
|
+
* }
|
|
13
|
+
*/
|
|
14
|
+
export interface CompletionOptions {
|
|
15
|
+
api: string;
|
|
16
|
+
prompt?: string;
|
|
17
|
+
onFinish?: (text: string) => void;
|
|
18
|
+
onError?: (error: Error) => void;
|
|
19
|
+
headers?: Record<string, string>;
|
|
20
|
+
body?: Record<string, unknown>;
|
|
21
|
+
}
|
|
22
|
+
export declare class HilbrasCompletionService {
|
|
23
|
+
private _text;
|
|
24
|
+
private _isLoading;
|
|
25
|
+
private _error;
|
|
26
|
+
private _abortController;
|
|
27
|
+
readonly text: import("./angular-shim.js").Signal<string>;
|
|
28
|
+
readonly isLoading: import("./angular-shim.js").Signal<boolean>;
|
|
29
|
+
readonly error: import("./angular-shim.js").Signal<Error | null>;
|
|
30
|
+
stop(): void;
|
|
31
|
+
clear(): void;
|
|
32
|
+
submit(options: CompletionOptions): Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=completion.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"completion.service.d.ts","sourceRoot":"","sources":["../../../src/frameworks/angular/completion.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED,qBACa,wBAAwB;IACnC,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,UAAU,CAAiB;IACnC,OAAO,CAAC,MAAM,CAA8B;IAC5C,OAAO,CAAC,gBAAgB,CAAgC;IAExD,QAAQ,CAAC,IAAI,6CAA2B;IACxC,QAAQ,CAAC,SAAS,8CAAgC;IAClD,QAAQ,CAAC,KAAK,mDAA4B;IAE1C,IAAI,IAAI,IAAI,CAIX;IAED,KAAK,IAAI,IAAI,CAIZ;IAEK,MAAM,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAkEtD;CACF"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @hilbras/angular — Completion Service
|
|
3
|
+
*
|
|
4
|
+
* Angular service for streaming text completions from an LLM backend.
|
|
5
|
+
* Uses Angular signals for reactive state management.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* @Component({ ... })
|
|
9
|
+
* export class CompletionComponent {
|
|
10
|
+
* completion = inject(HilbrasCompletionService);
|
|
11
|
+
* text = this.completion.text;
|
|
12
|
+
* }
|
|
13
|
+
*/
|
|
14
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
15
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
16
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
17
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
18
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
19
|
+
};
|
|
20
|
+
import { Injectable, signal } from "./angular-shim.js";
|
|
21
|
+
let HilbrasCompletionService = class HilbrasCompletionService {
|
|
22
|
+
_text = signal("");
|
|
23
|
+
_isLoading = signal(false);
|
|
24
|
+
_error = signal(null);
|
|
25
|
+
_abortController = null;
|
|
26
|
+
text = this._text.asReadonly();
|
|
27
|
+
isLoading = this._isLoading.asReadonly();
|
|
28
|
+
error = this._error.asReadonly();
|
|
29
|
+
stop() {
|
|
30
|
+
this._abortController?.abort();
|
|
31
|
+
this._abortController = null;
|
|
32
|
+
this._isLoading.set(false);
|
|
33
|
+
}
|
|
34
|
+
clear() {
|
|
35
|
+
this._text.set("");
|
|
36
|
+
this._error.set(null);
|
|
37
|
+
this.stop();
|
|
38
|
+
}
|
|
39
|
+
async submit(options) {
|
|
40
|
+
if (this._isLoading())
|
|
41
|
+
return;
|
|
42
|
+
this._text.set("");
|
|
43
|
+
this._isLoading.set(true);
|
|
44
|
+
this._error.set(null);
|
|
45
|
+
const controller = new AbortController();
|
|
46
|
+
this._abortController = controller;
|
|
47
|
+
try {
|
|
48
|
+
const res = await fetch(options.api, {
|
|
49
|
+
method: "POST",
|
|
50
|
+
headers: { "Content-Type": "application/json", ...options.headers },
|
|
51
|
+
body: JSON.stringify({
|
|
52
|
+
prompt: options.prompt ?? "",
|
|
53
|
+
stream: true,
|
|
54
|
+
...options.body,
|
|
55
|
+
}),
|
|
56
|
+
signal: controller.signal,
|
|
57
|
+
});
|
|
58
|
+
if (!res.ok)
|
|
59
|
+
throw new Error(`HTTP ${res.status}: ${res.statusText}`);
|
|
60
|
+
if (!res.body)
|
|
61
|
+
throw new Error("Response body is null");
|
|
62
|
+
const reader = res.body.getReader();
|
|
63
|
+
const decoder = new TextDecoder();
|
|
64
|
+
let buffer = "";
|
|
65
|
+
let fullText = "";
|
|
66
|
+
while (true) {
|
|
67
|
+
const { done, value } = await reader.read();
|
|
68
|
+
if (done)
|
|
69
|
+
break;
|
|
70
|
+
buffer += decoder.decode(value, { stream: true });
|
|
71
|
+
const parts = buffer.split("\n\n");
|
|
72
|
+
buffer = parts.pop() ?? "";
|
|
73
|
+
for (const part of parts) {
|
|
74
|
+
const lines = part.split("\n");
|
|
75
|
+
let rawData = "";
|
|
76
|
+
for (const line of lines) {
|
|
77
|
+
if (line.startsWith("data: "))
|
|
78
|
+
rawData = line.slice(6).trim();
|
|
79
|
+
}
|
|
80
|
+
if (!rawData || rawData === "[DONE]")
|
|
81
|
+
continue;
|
|
82
|
+
let data;
|
|
83
|
+
try {
|
|
84
|
+
data = JSON.parse(rawData);
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
if (data.type === "text" && typeof data.text === "string") {
|
|
90
|
+
fullText += data.text;
|
|
91
|
+
this._text.set(fullText);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
options.onFinish?.(fullText);
|
|
96
|
+
}
|
|
97
|
+
catch (err) {
|
|
98
|
+
if (err.name === "AbortError")
|
|
99
|
+
return;
|
|
100
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
101
|
+
this._error.set(error);
|
|
102
|
+
options.onError?.(error);
|
|
103
|
+
}
|
|
104
|
+
finally {
|
|
105
|
+
this._abortController = null;
|
|
106
|
+
this._isLoading.set(false);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
HilbrasCompletionService = __decorate([
|
|
111
|
+
Injectable({ providedIn: "root" })
|
|
112
|
+
], HilbrasCompletionService);
|
|
113
|
+
export { HilbrasCompletionService };
|
|
114
|
+
//# sourceMappingURL=completion.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"completion.service.js","sourceRoot":"","sources":["../../../src/frameworks/angular/completion.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;;;;;;;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAYhD,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IAC3B,KAAK,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC;IACnB,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC3B,MAAM,GAAG,MAAM,CAAe,IAAI,CAAC,CAAC;IACpC,gBAAgB,GAA2B,IAAI,CAAC;IAE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LLM UIs with @hilbras/sdk.
|
|
5
|
+
*/
|
|
6
|
+
export { HilbrasChatService } from "./chat.service.js";
|
|
7
|
+
export type { ChatOptions } from "./chat.service.js";
|
|
8
|
+
export { HilbrasCompletionService } from "./completion.service.js";
|
|
9
|
+
export type { CompletionOptions } from "./completion.service.js";
|
|
10
|
+
export { HilbrasObjectService } from "./object.service.js";
|
|
11
|
+
export type { ObjectOptions } from "./object.service.js";
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/frameworks/angular/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AACnE,YAAY,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @hilbras/angular — Public API
|
|
3
|
+
*
|
|
4
|
+
* Angular services for building streaming LLM UIs with @hilbras/sdk.
|
|
5
|
+
*/
|
|
6
|
+
export { HilbrasChatService } from "./chat.service.js";
|
|
7
|
+
export { HilbrasCompletionService } from "./completion.service.js";
|
|
8
|
+
export { HilbrasObjectService } from "./object.service.js";
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/frameworks/angular/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAGvD,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAGnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC"}
|