@holokai/holo-provider-ollama 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +750 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/manifest.d.ts +3 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +136 -0
- package/dist/manifest.js.map +1 -0
- package/dist/ollama.auditor.d.ts +22 -0
- package/dist/ollama.auditor.d.ts.map +1 -0
- package/dist/ollama.auditor.js +151 -0
- package/dist/ollama.auditor.js.map +1 -0
- package/dist/ollama.provider.d.ts +14 -0
- package/dist/ollama.provider.d.ts.map +1 -0
- package/dist/ollama.provider.js +88 -0
- package/dist/ollama.provider.js.map +1 -0
- package/dist/ollama.response.factory.d.ts +7 -0
- package/dist/ollama.response.factory.d.ts.map +1 -0
- package/dist/ollama.response.factory.js +9 -0
- package/dist/ollama.response.factory.js.map +1 -0
- package/dist/ollama.translator.d.ts +22 -0
- package/dist/ollama.translator.d.ts.map +1 -0
- package/dist/ollama.translator.js +90 -0
- package/dist/ollama.translator.js.map +1 -0
- package/dist/ollama.wire.adapter.d.ts +6 -0
- package/dist/ollama.wire.adapter.d.ts.map +1 -0
- package/dist/ollama.wire.adapter.js +11 -0
- package/dist/ollama.wire.adapter.js.map +1 -0
- package/dist/plugin.d.ts +19 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +57 -0
- package/dist/plugin.js.map +1 -0
- package/dist/translators/index.d.ts +9 -0
- package/dist/translators/index.d.ts.map +1 -0
- package/dist/translators/index.js +9 -0
- package/dist/translators/index.js.map +1 -0
- package/dist/translators/ollama.chat.request.translator.d.ts +20 -0
- package/dist/translators/ollama.chat.request.translator.d.ts.map +1 -0
- package/dist/translators/ollama.chat.request.translator.js +100 -0
- package/dist/translators/ollama.chat.request.translator.js.map +1 -0
- package/dist/translators/ollama.chat.response.translator.d.ts +22 -0
- package/dist/translators/ollama.chat.response.translator.d.ts.map +1 -0
- package/dist/translators/ollama.chat.response.translator.js +127 -0
- package/dist/translators/ollama.chat.response.translator.js.map +1 -0
- package/dist/translators/ollama.generate.request.translator.d.ts +13 -0
- package/dist/translators/ollama.generate.request.translator.d.ts.map +1 -0
- package/dist/translators/ollama.generate.request.translator.js +90 -0
- package/dist/translators/ollama.generate.request.translator.js.map +1 -0
- package/dist/translators/ollama.generate.response.translator.d.ts +20 -0
- package/dist/translators/ollama.generate.response.translator.d.ts.map +1 -0
- package/dist/translators/ollama.generate.response.translator.js +104 -0
- package/dist/translators/ollama.generate.response.translator.js.map +1 -0
- package/dist/translators/ollama.message.translators.d.ts +14 -0
- package/dist/translators/ollama.message.translators.d.ts.map +1 -0
- package/dist/translators/ollama.message.translators.js +117 -0
- package/dist/translators/ollama.message.translators.js.map +1 -0
- package/dist/translators/ollama.options.translators.d.ts +11 -0
- package/dist/translators/ollama.options.translators.d.ts.map +1 -0
- package/dist/translators/ollama.options.translators.js +37 -0
- package/dist/translators/ollama.options.translators.js.map +1 -0
- package/dist/translators/ollama.tool.translators.d.ts +13 -0
- package/dist/translators/ollama.tool.translators.d.ts.map +1 -0
- package/dist/translators/ollama.tool.translators.js +62 -0
- package/dist/translators/ollama.tool.translators.js.map +1 -0
- package/dist/translators/streaming/index.d.ts +5 -0
- package/dist/translators/streaming/index.d.ts.map +1 -0
- package/dist/translators/streaming/index.js +5 -0
- package/dist/translators/streaming/index.js.map +1 -0
- package/dist/translators/streaming/ollama.content.delta.translator.d.ts +14 -0
- package/dist/translators/streaming/ollama.content.delta.translator.d.ts.map +1 -0
- package/dist/translators/streaming/ollama.content.delta.translator.js +76 -0
- package/dist/translators/streaming/ollama.content.delta.translator.js.map +1 -0
- package/dist/translators/streaming/ollama.message.delta.translator.d.ts +15 -0
- package/dist/translators/streaming/ollama.message.delta.translator.d.ts.map +1 -0
- package/dist/translators/streaming/ollama.message.delta.translator.js +116 -0
- package/dist/translators/streaming/ollama.message.delta.translator.js.map +1 -0
- package/dist/translators/streaming/ollama.message.stop.translator.d.ts +16 -0
- package/dist/translators/streaming/ollama.message.stop.translator.d.ts.map +1 -0
- package/dist/translators/streaming/ollama.message.stop.translator.js +87 -0
- package/dist/translators/streaming/ollama.message.stop.translator.js.map +1 -0
- package/dist/translators/streaming/ollama.stream.translator.d.ts +20 -0
- package/dist/translators/streaming/ollama.stream.translator.d.ts.map +1 -0
- package/dist/translators/streaming/ollama.stream.translator.js +82 -0
- package/dist/translators/streaming/ollama.stream.translator.js.map +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +11 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/request.types.d.ts +13 -0
- package/dist/types/request.types.d.ts.map +1 -0
- package/dist/types/request.types.js +8 -0
- package/dist/types/request.types.js.map +1 -0
- package/dist/types/response.types.d.ts +40 -0
- package/dist/types/response.types.d.ts.map +1 -0
- package/dist/types/response.types.js +9 -0
- package/dist/types/response.types.js.map +1 -0
- package/package.json +70 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import 'reflect-metadata';
|
|
11
|
+
import { injectable } from 'tsyringe';
|
|
12
|
+
import { pickDefined } from "@holokai/sdk";
|
|
13
|
+
import { StreamTranslator } from "@holokai/sdk/provider";
|
|
14
|
+
let OllamaMessageDeltaTranslator = class OllamaMessageDeltaTranslator extends StreamTranslator {
|
|
15
|
+
holoDefaults = {};
|
|
16
|
+
providerDefaults = {};
|
|
17
|
+
constructor() {
|
|
18
|
+
super();
|
|
19
|
+
}
|
|
20
|
+
async toHoloManyImpl(source) {
|
|
21
|
+
// Check for tool calls (can appear in any chunk)
|
|
22
|
+
const isChat = 'message' in source;
|
|
23
|
+
const toolCalls = isChat ? source.message?.tool_calls : undefined;
|
|
24
|
+
const hasToolCalls = Array.isArray(toolCalls) && toolCalls.length > 0;
|
|
25
|
+
// For non-final chunks, only emit if there are tool calls
|
|
26
|
+
if (!source.done) {
|
|
27
|
+
if (!hasToolCalls)
|
|
28
|
+
return [];
|
|
29
|
+
return [pickDefined({
|
|
30
|
+
delta: {
|
|
31
|
+
provider: 'ollama',
|
|
32
|
+
type: 'message_delta',
|
|
33
|
+
delta: {
|
|
34
|
+
tool_calls: toolCalls
|
|
35
|
+
},
|
|
36
|
+
provider_delta: source
|
|
37
|
+
}
|
|
38
|
+
})];
|
|
39
|
+
}
|
|
40
|
+
// For done chunks, handle usage and/or tool calls
|
|
41
|
+
const usage = pickDefined({
|
|
42
|
+
input_tokens: source.prompt_eval_count,
|
|
43
|
+
output_tokens: source.eval_count,
|
|
44
|
+
total_tokens: source.prompt_eval_count != null && source.eval_count != null
|
|
45
|
+
? source.prompt_eval_count + source.eval_count
|
|
46
|
+
: undefined
|
|
47
|
+
});
|
|
48
|
+
const hasUsage = Object.keys(usage).length > 0;
|
|
49
|
+
const finish_reason = this.mapOllamaFinishReason(source.done_reason);
|
|
50
|
+
// If there's nothing to report, avoid emitting
|
|
51
|
+
if (!hasUsage && !finish_reason && !hasToolCalls)
|
|
52
|
+
return [];
|
|
53
|
+
return [pickDefined({
|
|
54
|
+
delta: {
|
|
55
|
+
provider: 'ollama',
|
|
56
|
+
type: 'message_delta',
|
|
57
|
+
delta: hasToolCalls ? { tool_calls: toolCalls } : {},
|
|
58
|
+
usage: hasUsage ? usage : undefined,
|
|
59
|
+
provider_delta: source
|
|
60
|
+
},
|
|
61
|
+
finish_reason
|
|
62
|
+
})];
|
|
63
|
+
}
|
|
64
|
+
async fromHoloManyImpl(source) {
|
|
65
|
+
const d = source.delta;
|
|
66
|
+
if (!d || d.type !== 'message_delta')
|
|
67
|
+
return [];
|
|
68
|
+
// Fast pass-through for Ollama→Ollama streaming
|
|
69
|
+
if (d.provider === 'ollama' && d.provider_delta) {
|
|
70
|
+
return [d.provider_delta];
|
|
71
|
+
}
|
|
72
|
+
const results = [];
|
|
73
|
+
// 1) Map tool_calls → ChatResponse-shaped partial
|
|
74
|
+
const toolCalls = d.delta?.tool_calls;
|
|
75
|
+
if (Array.isArray(toolCalls) && toolCalls.length > 0) {
|
|
76
|
+
results.push({
|
|
77
|
+
// Chat format: tool_calls live under message
|
|
78
|
+
message: {
|
|
79
|
+
role: 'assistant',
|
|
80
|
+
content: '', // Ollama allows empty content with tool_calls
|
|
81
|
+
tool_calls: toolCalls
|
|
82
|
+
},
|
|
83
|
+
done: false
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
// 2) Map usage if present
|
|
87
|
+
if (d.usage) {
|
|
88
|
+
results.push(pickDefined({
|
|
89
|
+
done: false,
|
|
90
|
+
prompt_eval_count: d.usage.input_tokens,
|
|
91
|
+
eval_count: d.usage.output_tokens
|
|
92
|
+
}));
|
|
93
|
+
}
|
|
94
|
+
return results;
|
|
95
|
+
}
|
|
96
|
+
mapOllamaFinishReason(reason) {
|
|
97
|
+
if (!reason)
|
|
98
|
+
return undefined;
|
|
99
|
+
switch (reason) {
|
|
100
|
+
case 'stop':
|
|
101
|
+
return 'stop';
|
|
102
|
+
case 'length':
|
|
103
|
+
return 'length';
|
|
104
|
+
case 'load':
|
|
105
|
+
return undefined; // Model loading, not a real finish reason
|
|
106
|
+
default:
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
OllamaMessageDeltaTranslator = __decorate([
|
|
112
|
+
injectable(),
|
|
113
|
+
__metadata("design:paramtypes", [])
|
|
114
|
+
], OllamaMessageDeltaTranslator);
|
|
115
|
+
export { OllamaMessageDeltaTranslator };
|
|
116
|
+
//# sourceMappingURL=ollama.message.delta.translator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ollama.message.delta.translator.js","sourceRoot":"","sources":["../../../src/translators/streaming/ollama.message.delta.translator.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AAEpC,OAAO,EAAoC,WAAW,EAAC,MAAM,cAAc,CAAC;AAC5E,OAAO,EAAC,gBAAgB,EAAC,MAAM,uBAAuB,CAAC;AAKhD,IAAM,4BAA4B,GAAlC,MAAM,4BAA6B,SAAQ,gBAAuD;IAC3F,YAAY,GAA6B,EAAE,CAAC;IAC5C,gBAAgB,GAAkC,EAAE,CAAC;IAE/D;QACI,KAAK,EAAE,CAAC;IACZ,CAAC;IAES,KAAK,CAAC,cAAc,CAAC,MAA4B;QACvD,iDAAiD;QACjD,MAAM,MAAM,GAAG,SAAS,IAAI,MAAM,CAAC;QACnC,MAAM,SAAS,GAAG,MAAM,CAAC,CAAC,CAAE,MAAc,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC;QAC3E,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;QAEtE,0DAA0D;QAC1D,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;YACf,IAAI,CAAC,YAAY;gBAAE,OAAO,EAAE,CAAC;YAE7B,OAAO,CAAC,W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I,OAAO,SAAS,CAAC;QACzB,CAAC;IACL,CAAC;CACJ,CAAA;AA5GY,4BAA4B;IADxC,UAAU,EAAE;;GACA,4BAA4B,CA4GxC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { OllamaChatResponse, OllamaGenerateResponse } from '../../types';
|
|
3
|
+
import { HoloStreamChunk } from "@holokai/sdk";
|
|
4
|
+
import { StreamTranslator } from "@holokai/sdk/provider";
|
|
5
|
+
type OllamaStreamResponse = Partial<OllamaChatResponse> | Partial<OllamaGenerateResponse>;
|
|
6
|
+
export declare class OllamaMessageStopTranslator extends StreamTranslator<HoloStreamChunk, OllamaStreamResponse> {
|
|
7
|
+
protected holoDefaults: Partial<HoloStreamChunk>;
|
|
8
|
+
protected providerDefaults: Partial<OllamaStreamResponse>;
|
|
9
|
+
constructor();
|
|
10
|
+
protected toHoloManyImpl(source: OllamaStreamResponse): Promise<Partial<HoloStreamChunk>[]>;
|
|
11
|
+
protected fromHoloManyImpl(source: HoloStreamChunk): Promise<Partial<OllamaStreamResponse>[]>;
|
|
12
|
+
private mapOllamaFinishReason;
|
|
13
|
+
private mapHoloFinishReasonToOllama;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=ollama.message.stop.translator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ollama.message.stop.translator.d.ts","sourceRoot":"","sources":["../../../src/translators/streaming/ollama.message.stop.translator.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B,OAAO,EAAC,kBAAkB,EAAE,sBAAsB,EAAC,MAAM,aAAa,CAAC;AACvE,OAAO,EAAmB,eAAe,EAAc,MAAM,cAAc,CAAC;AAC5E,OAAO,EAAC,gBAAgB,EAAC,MAAM,uBAAuB,CAAC;AAEvD,KAAK,oBAAoB,GAAG,OAAO,CAAC,kBAAkB,CAAC,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAE1F,qBACa,2BAA4B,SAAQ,gBAAgB,CAAC,eAAe,EAAE,oBAAoB,CAAC;IACpG,SAAS,CAAC,YAAY,EAAE,OAAO,CAAC,eAAe,CAAC,CAAM;IACtD,SAAS,CAAC,gBAAgB,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAM;;cAM/C,cAAc,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,CAAC;cAgBjF,gBAAgB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,oBAAoB,CAAC,EAAE,CAAC;IAgBnG,OAAO,CAAC,qBAAqB;IAe7B,OAAO,CAAC,2BAA2B;CAiBtC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import 'reflect-metadata';
|
|
11
|
+
import { injectable } from 'tsyringe';
|
|
12
|
+
import { pickDefined } from "@holokai/sdk";
|
|
13
|
+
import { StreamTranslator } from "@holokai/sdk/provider";
|
|
14
|
+
let OllamaMessageStopTranslator = class OllamaMessageStopTranslator extends StreamTranslator {
|
|
15
|
+
holoDefaults = {};
|
|
16
|
+
providerDefaults = {};
|
|
17
|
+
constructor() {
|
|
18
|
+
super();
|
|
19
|
+
}
|
|
20
|
+
async toHoloManyImpl(source) {
|
|
21
|
+
// Only emit stop for done chunks
|
|
22
|
+
if (!source.done)
|
|
23
|
+
return [];
|
|
24
|
+
return [pickDefined({
|
|
25
|
+
delta: {
|
|
26
|
+
provider: 'ollama',
|
|
27
|
+
type: 'message_stop',
|
|
28
|
+
delta: {},
|
|
29
|
+
provider_delta: source
|
|
30
|
+
},
|
|
31
|
+
done: true,
|
|
32
|
+
finish_reason: source.done_reason ? this.mapOllamaFinishReason(source.done_reason) : undefined
|
|
33
|
+
})];
|
|
34
|
+
}
|
|
35
|
+
async fromHoloManyImpl(source) {
|
|
36
|
+
const d = source.delta;
|
|
37
|
+
if (!d || d.type !== 'message_stop')
|
|
38
|
+
return [];
|
|
39
|
+
// Emit final chunk with done=true
|
|
40
|
+
// Note: Usage is handled by message.delta translator, not here
|
|
41
|
+
return [pickDefined({
|
|
42
|
+
message: {
|
|
43
|
+
role: 'assistant',
|
|
44
|
+
content: ""
|
|
45
|
+
},
|
|
46
|
+
done: true,
|
|
47
|
+
done_reason: source.finish_reason ? this.mapHoloFinishReasonToOllama(source.finish_reason) : undefined
|
|
48
|
+
})];
|
|
49
|
+
}
|
|
50
|
+
mapOllamaFinishReason(reason) {
|
|
51
|
+
if (!reason)
|
|
52
|
+
return undefined;
|
|
53
|
+
switch (reason) {
|
|
54
|
+
case 'stop':
|
|
55
|
+
return 'stop';
|
|
56
|
+
case 'length':
|
|
57
|
+
return 'length';
|
|
58
|
+
case 'load':
|
|
59
|
+
return undefined; // Model loading, not a real finish reason
|
|
60
|
+
default:
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
mapHoloFinishReasonToOllama(reason) {
|
|
65
|
+
if (!reason)
|
|
66
|
+
return undefined;
|
|
67
|
+
switch (reason) {
|
|
68
|
+
case 'stop':
|
|
69
|
+
return 'stop';
|
|
70
|
+
case 'length':
|
|
71
|
+
return 'length';
|
|
72
|
+
case 'tool_calls':
|
|
73
|
+
case 'function_call':
|
|
74
|
+
case 'content_filter':
|
|
75
|
+
// Ollama doesn't have explicit support for these - map to 'stop'
|
|
76
|
+
return 'stop';
|
|
77
|
+
default:
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
OllamaMessageStopTranslator = __decorate([
|
|
83
|
+
injectable(),
|
|
84
|
+
__metadata("design:paramtypes", [])
|
|
85
|
+
], OllamaMessageStopTranslator);
|
|
86
|
+
export { OllamaMessageStopTranslator };
|
|
87
|
+
//# sourceMappingURL=ollama.message.stop.translator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ollama.message.stop.translator.js","sourceRoot":"","sources":["../../../src/translators/streaming/ollama.message.stop.translator.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AAEpC,OAAO,EAAoC,WAAW,EAAC,MAAM,cAAc,CAAC;AAC5E,OAAO,EAAC,gBAAgB,EAAC,MAAM,uBAAuB,CAAC;AAKhD,IAAM,2BAA2B,GAAjC,MAAM,2BAA4B,SAAQ,gBAAuD;IAC1F,YAAY,GAA6B,EAAE,CAAC;IAC5C,gBAAgB,GAAkC,EAAE,CAAC;IAE/D;QACI,KAAK,EAAE,CAAC;IACZ,CAAC;IAES,KAAK,CAAC,cAAc,CAAC,MAA4B;QACvD,iCAAiC;QACjC,IAAI,CAAC,MAAM,CAAC,IAAI;YAAE,OAAO,EAAE,CAAC;QAE5B,OAAO,CAAC,WAAW,CAAC;gBAChB,KAAK,EAAE;oBACH,QAAQ,EAAE,QAAQ;oBAClB,IAAI,EAAE,cAAuB;oBAC7B,KAAK,EAAE,EAAE;oBACT,cAAc,EAAE,MAAM;iBACzB;gBACD,IAAI,EAAE,IAAI;gBACV,aAAa,EAAE,MAAM,CAAC,WAAW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AAC;YAClB;gBACI,OAAO,SAAS,CAAC;QACzB,CAAC;IACL,CAAC;CACJ,CAAA;AAxEY,2BAA2B;IADvC,UAAU,EAAE;;GACA,2BAA2B,CAwEvC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { OllamaChatResponse, OllamaGenerateResponse } from '../../types';
|
|
3
|
+
import { OllamaContentDeltaTranslator } from './ollama.content.delta.translator';
|
|
4
|
+
import { OllamaMessageDeltaTranslator } from './ollama.message.delta.translator';
|
|
5
|
+
import { OllamaMessageStopTranslator } from './ollama.message.stop.translator';
|
|
6
|
+
import { StreamTranslator } from "@holokai/sdk/provider";
|
|
7
|
+
import { HoloStreamChunk } from "@holokai/sdk";
|
|
8
|
+
type OllamaStreamResponse = Partial<OllamaChatResponse> | Partial<OllamaGenerateResponse>;
|
|
9
|
+
export declare class OllamaStreamTranslator extends StreamTranslator<HoloStreamChunk, OllamaStreamResponse> {
|
|
10
|
+
private readonly contentDeltaTranslator;
|
|
11
|
+
private readonly messageDeltaTranslator;
|
|
12
|
+
private readonly messageStopTranslator;
|
|
13
|
+
protected holoDefaults: Partial<HoloStreamChunk>;
|
|
14
|
+
protected providerDefaults: Partial<OllamaStreamResponse>;
|
|
15
|
+
constructor(contentDeltaTranslator: OllamaContentDeltaTranslator, messageDeltaTranslator: OllamaMessageDeltaTranslator, messageStopTranslator: OllamaMessageStopTranslator);
|
|
16
|
+
protected toHoloManyImpl(source: OllamaStreamResponse): Promise<Partial<HoloStreamChunk>[]>;
|
|
17
|
+
protected fromHoloManyImpl(source: HoloStreamChunk): Promise<Partial<OllamaStreamResponse>[]>;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=ollama.stream.translator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ollama.stream.translator.d.ts","sourceRoot":"","sources":["../../../src/translators/streaming/ollama.stream.translator.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B,OAAO,EAAC,kBAAkB,EAAE,sBAAsB,EAAC,MAAM,aAAa,CAAC;AACvE,OAAO,EAAC,4BAA4B,EAAC,MAAM,mCAAmC,CAAC;AAC/E,OAAO,EAAC,4BAA4B,EAAC,MAAM,mCAAmC,CAAC;AAC/E,OAAO,EAAC,2BAA2B,EAAC,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EAAC,gBAAgB,EAAC,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAC,eAAe,EAAC,MAAM,cAAc,CAAC;AAG7C,KAAK,oBAAoB,GAAG,OAAO,CAAC,kBAAkB,CAAC,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAE1F,qBACa,sBAAuB,SAAQ,gBAAgB,CAAC,eAAe,EAAE,oBAAoB,CAAC;IAK3F,OAAO,CAAC,QAAQ,CAAC,sBAAsB;IACvC,OAAO,CAAC,QAAQ,CAAC,sBAAsB;IACvC,OAAO,CAAC,QAAQ,CAAC,qBAAqB;IAN1C,SAAS,CAAC,YAAY,EAAE,OAAO,CAAC,eAAe,CAAC,CAAM;IACtD,SAAS,CAAC,gBAAgB,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAM;gBAG1C,sBAAsB,EAAE,4BAA4B,EACpD,sBAAsB,EAAE,4BAA4B,EACpD,qBAAqB,EAAE,2BAA2B;cAKvD,cAAc,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,CAAC;cA4BjF,gBAAgB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,oBAAoB,CAAC,EAAE,CAAC;CA4BtG"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import 'reflect-metadata';
|
|
11
|
+
import { injectable } from 'tsyringe';
|
|
12
|
+
import { OllamaContentDeltaTranslator } from './ollama.content.delta.translator';
|
|
13
|
+
import { OllamaMessageDeltaTranslator } from './ollama.message.delta.translator';
|
|
14
|
+
import { OllamaMessageStopTranslator } from './ollama.message.stop.translator';
|
|
15
|
+
import { StreamTranslator } from "@holokai/sdk/provider";
|
|
16
|
+
let OllamaStreamTranslator = class OllamaStreamTranslator extends StreamTranslator {
|
|
17
|
+
contentDeltaTranslator;
|
|
18
|
+
messageDeltaTranslator;
|
|
19
|
+
messageStopTranslator;
|
|
20
|
+
holoDefaults = {};
|
|
21
|
+
providerDefaults = {};
|
|
22
|
+
constructor(contentDeltaTranslator, messageDeltaTranslator, messageStopTranslator) {
|
|
23
|
+
super();
|
|
24
|
+
this.contentDeltaTranslator = contentDeltaTranslator;
|
|
25
|
+
this.messageDeltaTranslator = messageDeltaTranslator;
|
|
26
|
+
this.messageStopTranslator = messageStopTranslator;
|
|
27
|
+
}
|
|
28
|
+
async toHoloManyImpl(source) {
|
|
29
|
+
const results = [];
|
|
30
|
+
// Non-final chunks
|
|
31
|
+
if (!source.done) {
|
|
32
|
+
// 1) Content deltas first
|
|
33
|
+
results.push(...await this.contentDeltaTranslator.toHoloMany(source));
|
|
34
|
+
// 2) Tool calls if present (chat-only)
|
|
35
|
+
const isChat = 'message' in source;
|
|
36
|
+
const toolCalls = isChat ? source.message?.tool_calls : undefined;
|
|
37
|
+
if (Array.isArray(toolCalls) && toolCalls.length > 0) {
|
|
38
|
+
// Message delta translator will handle tool calls
|
|
39
|
+
results.push(...await this.messageDeltaTranslator.toHoloMany(source));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
// Final chunk: emit usage/metrics and stop
|
|
43
|
+
if (source.done) {
|
|
44
|
+
// Message delta for usage and any final tool calls
|
|
45
|
+
results.push(...await this.messageDeltaTranslator.toHoloMany(source));
|
|
46
|
+
// Message stop for completion
|
|
47
|
+
results.push(...await this.messageStopTranslator.toHoloMany(source));
|
|
48
|
+
}
|
|
49
|
+
return results;
|
|
50
|
+
}
|
|
51
|
+
async fromHoloManyImpl(source) {
|
|
52
|
+
const d = source.delta;
|
|
53
|
+
if (!d)
|
|
54
|
+
return [];
|
|
55
|
+
// Fast pass-through for Ollama→Ollama streaming
|
|
56
|
+
if (d.provider === 'ollama' && d.provider_delta) {
|
|
57
|
+
return [d.provider_delta];
|
|
58
|
+
}
|
|
59
|
+
// Route based on delta type
|
|
60
|
+
switch (d.type) {
|
|
61
|
+
case 'message_start':
|
|
62
|
+
// No-op: Ollama has no equivalent to message_start
|
|
63
|
+
return [];
|
|
64
|
+
case 'content_delta':
|
|
65
|
+
return this.contentDeltaTranslator.fromHoloMany(source);
|
|
66
|
+
case 'message_delta':
|
|
67
|
+
return this.messageDeltaTranslator.fromHoloMany(source);
|
|
68
|
+
case 'message_stop':
|
|
69
|
+
return this.messageStopTranslator.fromHoloMany(source);
|
|
70
|
+
default:
|
|
71
|
+
return [];
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
OllamaStreamTranslator = __decorate([
|
|
76
|
+
injectable(),
|
|
77
|
+
__metadata("design:paramtypes", [OllamaContentDeltaTranslator,
|
|
78
|
+
OllamaMessageDeltaTranslator,
|
|
79
|
+
OllamaMessageStopTranslator])
|
|
80
|
+
], OllamaStreamTranslator);
|
|
81
|
+
export { OllamaStreamTranslator };
|
|
82
|
+
//# sourceMappingURL=ollama.stream.translator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ollama.stream.translator.js","sourceRoot":"","sources":["../../../src/translators/streaming/ollama.stream.translator.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AAEpC,OAAO,EAAC,4BAA4B,EAAC,MAAM,mCAAmC,CAAC;AAC/E,OAAO,EAAC,4BAA4B,EAAC,MAAM,mCAAmC,CAAC;AAC/E,OAAO,EAAC,2BAA2B,EAAC,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EAAC,gBAAgB,EAAC,MAAM,uBAAuB,CAAC;AAOhD,IAAM,sBAAsB,GAA5B,MAAM,sBAAuB,SAAQ,gBAAuD;IAK1E;IACA;IACA;IANX,YAAY,GAA6B,EAAE,CAAC;IAC5C,gBAAgB,GAAkC,EAAE,CAAC;IAE/D,YACqB,sBAAoD,EACpD,sBAAoD,EACpD,qBAAkD;QAEnE,KAAK,EAAE,CAAC;QAJS,2BAAsB,GAAtB,sBAAsB,CAA8B;QACpD,2BAAsB,GAAtB,sBAAsB,CAA8B;QACpD,0BAAqB,GAArB,qBAAqB,CAA6B;IAGvE,CAAC;IAES,KAAK,CAAC,cAAc,CAAC,MAA4B;QACvD,MAAM,OAAO,GAA+B,EAAE,CAAC;QAE/C,mBAAmB;QACnB,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;YACf,0BAA0B;YAC1B,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,IAAI,CAAC,sBAAsB,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;YAEtE,uCAAuC;YACvC,MAAM,MAAM,GAAG,SAAS,IAAI,MAAM,CAAC;YACnC,MAAM,SAAS,GAAG,MAAM,CAAC,CAAC,CAAE,MAAc,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,C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AAqB,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;YAE3D;gBACI,OAAO,EAAE,CAAC;QAClB,CAAC;IACL,CAAC;CACJ,CAAA;AApEY,sBAAsB;IADlC,UAAU,EAAE;qCAMoC,4BAA4B;QAC5B,4BAA4B;QAC7B,2BAA2B;GAP9D,sBAAsB,CAoElC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { OllamaChatRequest, OllamaGenerateRequest } from "./request.types";
|
|
2
|
+
export * from './request.types';
|
|
3
|
+
export * from './response.types';
|
|
4
|
+
export declare const OllamaGenerateRequestDefaults: Partial<OllamaGenerateRequest>;
|
|
5
|
+
export declare const OllamaChatRequestDefaults: Partial<OllamaChatRequest>;
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAE,qBAAqB,EAAC,MAAM,iBAAiB,CAAC;AAEzE,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,eAAO,MAAM,6BAA6B,EAAE,OAAO,CAAC,qBAAqB,CAExE,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,OAAO,CAAC,iBAAiB,CAGhE,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './request.types';
|
|
2
|
+
export * from './response.types';
|
|
3
|
+
export const OllamaGenerateRequestDefaults = {
|
|
4
|
+
stream: false
|
|
5
|
+
};
|
|
6
|
+
export const OllamaChatRequestDefaults = {
|
|
7
|
+
stream: true,
|
|
8
|
+
messages: []
|
|
9
|
+
};
|
|
10
|
+
// Ollama streams reuse ChatResponse and GenerateResponse types
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAEA,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,MAAM,CAAC,MAAM,6BAA6B,GAAmC;IACzE,MAAM,EAAE,KAAK;CAChB,CAAC;AAEF,MAAM,CAAC,MAAM,yBAAyB,GAA+B;IACjE,MAAM,EAAE,IAAI;IACZ,QAAQ,EAAE,EAAE;CACf,CAAC;AACF,+DAA+D"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ChatRequest, GenerateRequest, Message, Options, Tool, ToolCall } from "ollama";
|
|
2
|
+
export type OllamaToolCall = ToolCall;
|
|
3
|
+
export type OllamaMessage = Message;
|
|
4
|
+
export type OllamaTool = Tool;
|
|
5
|
+
export type OllamaOptions = Options;
|
|
6
|
+
export type OllamaGenerateRequest = GenerateRequest;
|
|
7
|
+
export type OllamaChatRequest = ChatRequest;
|
|
8
|
+
export type OllamaOnlyChatRequestFields = readonly ['keep_alive', 'options'];
|
|
9
|
+
export type OllamaOnlyChatRequest = Pick<OllamaChatRequest, OllamaOnlyChatRequestFields[number]>;
|
|
10
|
+
export type OllamaSharedChatRequest = Omit<OllamaChatRequest, OllamaOnlyChatRequestFields[number]>;
|
|
11
|
+
export declare function isGenerateRequest(req: OllamaChatRequest | OllamaGenerateRequest): req is OllamaGenerateRequest;
|
|
12
|
+
export declare function isChatRequest(req: OllamaChatRequest | OllamaGenerateRequest): req is OllamaChatRequest;
|
|
13
|
+
//# sourceMappingURL=request.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.types.d.ts","sourceRoot":"","sources":["../../src/types/request.types.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,WAAW,EAAE,eAAe,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAC,MAAM,QAAQ,CAAC;AAEtF,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC;AACtC,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC;AACpC,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC;AAC9B,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC;AACpC,MAAM,MAAM,qBAAqB,GAAG,eAAe,CAAC;AACpD,MAAM,MAAM,iBAAiB,GAAG,WAAW,CAAC;AAC5C,MAAM,MAAM,2BAA2B,GAAG,SAAQ,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;AAC5E,MAAM,MAAM,qBAAqB,GAAG,IAAI,CAAC,iBAAiB,EAAE,2BAA2B,CAAC,MAAM,CAAC,CAAC,CAAC;AACjG,MAAM,MAAM,uBAAuB,GAAG,IAAI,CAAC,iBAAiB,EAAE,2BAA2B,CAAC,MAAM,CAAC,CAAC,CAAC;AAInG,wBAAgB,iBAAiB,CAC7B,GAAG,EAAE,iBAAiB,GAAG,qBAAqB,GAC/C,GAAG,IAAI,qBAAqB,CAE9B;AAED,wBAAgB,aAAa,CACzB,GAAG,EAAE,iBAAiB,GAAG,qBAAqB,GAC/C,GAAG,IAAI,iBAAiB,CAE1B"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// ---- type guards ---------------------------------------------------------
|
|
2
|
+
export function isGenerateRequest(req) {
|
|
3
|
+
return 'prompt' in req && !('messages' in req);
|
|
4
|
+
}
|
|
5
|
+
export function isChatRequest(req) {
|
|
6
|
+
return 'messages' in req;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=request.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.types.js","sourceRoot":"","sources":["../../src/types/request.types.ts"],"names":[],"mappings":"AAaA,6EAA6E;AAE7E,MAAM,UAAU,iBAAiB,CAC7B,GAA8C;IAE9C,OAAO,QAAQ,IAAI,GAAG,IAAI,CAAC,CAAC,UAAU,IAAI,GAAG,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,UAAU,aAAa,CACzB,GAA8C;IAE9C,OAAO,UAAU,IAAI,GAAG,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ChatResponse, EmbeddingsResponse, EmbedResponse, ErrorResponse, GenerateResponse, ListResponse, ModelDetails, ModelResponse, ProgressResponse, ShowResponse, StatusResponse } from "ollama";
|
|
2
|
+
export type OllamaGenerateResponse = GenerateResponse;
|
|
3
|
+
export type OllamaChatResponse = ChatResponse;
|
|
4
|
+
export type OllamaEmbedResponse = EmbedResponse;
|
|
5
|
+
export type OllamaEmbeddingsResponse = EmbeddingsResponse;
|
|
6
|
+
export type OllamaProgressResponse = ProgressResponse;
|
|
7
|
+
export type OllamaModelDetails = ModelDetails;
|
|
8
|
+
export type OllamaModelResponse = ModelResponse;
|
|
9
|
+
export type OllamaShowResponse = ShowResponse;
|
|
10
|
+
export type OllamaListResponse = ListResponse;
|
|
11
|
+
export type OllamaErrorResponse = ErrorResponse;
|
|
12
|
+
export type OllamaStatusResponse = StatusResponse;
|
|
13
|
+
export type OllamaResponse = GenerateResponse | ChatResponse | EmbedResponse | EmbeddingsResponse | ProgressResponse | ModelResponse | ShowResponse | ListResponse | ErrorResponse | StatusResponse;
|
|
14
|
+
export type OllamaOnlyResponseFields = readonly [
|
|
15
|
+
'done',
|
|
16
|
+
'done_reason',
|
|
17
|
+
'response',
|
|
18
|
+
'context',
|
|
19
|
+
'total_duration',
|
|
20
|
+
'load_duration',
|
|
21
|
+
'prompt_eval_count',
|
|
22
|
+
'prompt_eval_duration',
|
|
23
|
+
'eval_count',
|
|
24
|
+
'eval_duration'
|
|
25
|
+
];
|
|
26
|
+
export type OllamaOnlyResponse = {
|
|
27
|
+
done?: boolean;
|
|
28
|
+
done_reason?: string;
|
|
29
|
+
response?: string;
|
|
30
|
+
context?: number[];
|
|
31
|
+
total_duration?: number;
|
|
32
|
+
load_duration?: number;
|
|
33
|
+
prompt_eval_count?: number;
|
|
34
|
+
prompt_eval_duration?: number;
|
|
35
|
+
eval_count?: number;
|
|
36
|
+
eval_duration?: number;
|
|
37
|
+
};
|
|
38
|
+
export declare function isGenerateResponse(res: OllamaResponse): res is OllamaGenerateResponse;
|
|
39
|
+
export declare function isChatResponse(res: OllamaResponse): res is OllamaChatResponse;
|
|
40
|
+
//# sourceMappingURL=response.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response.types.d.ts","sourceRoot":"","sources":["../../src/types/response.types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACR,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACjB,MAAM,QAAQ,CAAC;AAGhB,MAAM,MAAM,sBAAsB,GAAG,gBAAgB,CAAC;AACtD,MAAM,MAAM,kBAAkB,GAAG,YAAY,CAAC;AAC9C,MAAM,MAAM,mBAAmB,GAAG,aAAa,CAAC;AAChD,MAAM,MAAM,wBAAwB,GAAG,kBAAkB,CAAC;AAC1D,MAAM,MAAM,sBAAsB,GAAG,gBAAgB,CAAC;AACtD,MAAM,MAAM,kBAAkB,GAAG,YAAY,CAAC;AAC9C,MAAM,MAAM,mBAAmB,GAAG,aAAa,CAAC;AAChD,MAAM,MAAM,kBAAkB,GAAG,YAAY,CAAC;AAC9C,MAAM,MAAM,kBAAkB,GAAG,YAAY,CAAC;AAC9C,MAAM,MAAM,mBAAmB,GAAG,aAAa,CAAC;AAChD,MAAM,MAAM,oBAAoB,GAAG,cAAc,CAAC;AAClD,MAAM,MAAM,cAAc,GACtB,gBAAgB,GACd,YAAY,GACZ,aAAa,GACb,kBAAkB,GAClB,gBAAgB,GAChB,aAAa,GACb,YAAY,GACZ,YAAY,GACZ,aAAa,GACb,cAAc,CAAC;AAErB,MAAM,MAAM,wBAAwB,GAAG,SAAQ;IAC3C,MAAM;IACN,aAAa;IACb,UAAU;IACV,SAAS;IACT,gBAAgB;IAChB,eAAe;IACf,mBAAmB;IACnB,sBAAsB;IACtB,YAAY;IACZ,eAAe;CAClB,CAAC;AACF,MAAM,MAAM,kBAAkB,GAAG;IAC7B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,wBAAgB,kBAAkB,CAC9B,GAAG,EAAE,cAAc,GACpB,GAAG,IAAI,sBAAsB,CAG/B;AAED,wBAAgB,cAAc,CAC1B,GAAG,EAAE,cAAc,GACpB,GAAG,IAAI,kBAAkB,CAG3B"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function isGenerateResponse(res) {
|
|
2
|
+
// Generate mode has top-level "response" string
|
|
3
|
+
return 'response' in res && typeof res.response === 'string';
|
|
4
|
+
}
|
|
5
|
+
export function isChatResponse(res) {
|
|
6
|
+
// Chat mode has "message" with role/content
|
|
7
|
+
return 'message' in res;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=response.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response.types.js","sourceRoot":"","sources":["../../src/types/response.types.ts"],"names":[],"mappings":"AAgEA,MAAM,UAAU,kBAAkB,CAC9B,GAAmB;IAEnB,gDAAgD;IAChD,OAAO,UAAU,IAAI,GAAG,IAAI,OAAQ,GAAW,CAAC,QAAQ,KAAK,QAAQ,CAAC;AAC1E,CAAC;AAED,MAAM,UAAU,cAAc,CAC1B,GAAmB;IAEnB,4CAA4C;IAC5C,OAAO,SAAS,IAAI,GAAG,CAAC;AAC5B,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@holokai/holo-provider-ollama",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Ollama provider plugin for Holo LLM Gateway",
|
|
6
|
+
"author": "Holokai",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"engines": {
|
|
11
|
+
"node": ">=18.0.0"
|
|
12
|
+
},
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/holokai/holo-provider-ollama.git"
|
|
19
|
+
},
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/holokai/holo-provider-ollama/issues"
|
|
22
|
+
},
|
|
23
|
+
"homepage": "https://github.com/holokai/holo-provider-ollama#readme",
|
|
24
|
+
"keywords": [
|
|
25
|
+
"holokai",
|
|
26
|
+
"holo",
|
|
27
|
+
"plugin",
|
|
28
|
+
"provider",
|
|
29
|
+
"ollama",
|
|
30
|
+
"ai",
|
|
31
|
+
"llm"
|
|
32
|
+
],
|
|
33
|
+
"exports": {
|
|
34
|
+
".": {
|
|
35
|
+
"types": "./dist/index.d.ts",
|
|
36
|
+
"import": "./dist/index.js",
|
|
37
|
+
"require": "./dist/index.js"
|
|
38
|
+
},
|
|
39
|
+
"./package.json": "./package.json"
|
|
40
|
+
},
|
|
41
|
+
"files": [
|
|
42
|
+
"dist",
|
|
43
|
+
"!dist/**/*.test.*",
|
|
44
|
+
"!dist/**/*.spec.*",
|
|
45
|
+
"README.md",
|
|
46
|
+
"LICENSE"
|
|
47
|
+
],
|
|
48
|
+
"sideEffects": false,
|
|
49
|
+
"scripts": {
|
|
50
|
+
"build": "tsc --build",
|
|
51
|
+
"build:watch": "tsc --build --watch",
|
|
52
|
+
"clean": "rm -rf dist tsconfig.tsbuildinfo",
|
|
53
|
+
"type-check": "tsc --noEmit",
|
|
54
|
+
"lint": "eslint src",
|
|
55
|
+
"test": "jest",
|
|
56
|
+
"test:watch": "jest --watch",
|
|
57
|
+
"test:integration": "jest tests/integration",
|
|
58
|
+
"prepublishOnly": "npm run clean && npm run build"
|
|
59
|
+
},
|
|
60
|
+
"peerDependencies": {
|
|
61
|
+
"@holokai/sdk": "^0.1.0"
|
|
62
|
+
},
|
|
63
|
+
"dependencies": {
|
|
64
|
+
"ollama": "^0.6.3"
|
|
65
|
+
},
|
|
66
|
+
"devDependencies": {
|
|
67
|
+
"@types/node": "^24.0.11",
|
|
68
|
+
"typescript": "^5.8.3"
|
|
69
|
+
}
|
|
70
|
+
}
|