@holokai/holo-provider-ollama 1.3.0 → 1.4.1

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.
Files changed (72) hide show
  1. package/README.md +10 -10
  2. package/dist/manifest.d.ts +1 -1
  3. package/dist/manifest.d.ts.map +1 -1
  4. package/dist/manifest.js +1 -1
  5. package/dist/manifest.js.map +1 -1
  6. package/dist/ollama.auditor.d.ts +12 -28
  7. package/dist/ollama.auditor.d.ts.map +1 -1
  8. package/dist/ollama.auditor.js +81 -78
  9. package/dist/ollama.auditor.js.map +1 -1
  10. package/dist/ollama.provider.d.ts +9 -7
  11. package/dist/ollama.provider.d.ts.map +1 -1
  12. package/dist/ollama.provider.js +58 -36
  13. package/dist/ollama.provider.js.map +1 -1
  14. package/dist/ollama.response.factory.d.ts +1 -1
  15. package/dist/ollama.response.factory.d.ts.map +1 -1
  16. package/dist/ollama.translator.d.ts +9 -2
  17. package/dist/ollama.translator.d.ts.map +1 -1
  18. package/dist/ollama.translator.js +17 -0
  19. package/dist/ollama.translator.js.map +1 -1
  20. package/dist/ollama.wire.adapter.d.ts +1 -1
  21. package/dist/ollama.wire.adapter.d.ts.map +1 -1
  22. package/dist/ollama.wire.adapter.js +1 -1
  23. package/dist/ollama.wire.adapter.js.map +1 -1
  24. package/dist/plugin.d.ts +9 -7
  25. package/dist/plugin.d.ts.map +1 -1
  26. package/dist/plugin.js +13 -5
  27. package/dist/plugin.js.map +1 -1
  28. package/dist/translators/ollama.chat.request.translator.d.ts +2 -2
  29. package/dist/translators/ollama.chat.request.translator.d.ts.map +1 -1
  30. package/dist/translators/ollama.chat.request.translator.js +2 -2
  31. package/dist/translators/ollama.chat.request.translator.js.map +1 -1
  32. package/dist/translators/ollama.chat.response.translator.d.ts +2 -2
  33. package/dist/translators/ollama.chat.response.translator.d.ts.map +1 -1
  34. package/dist/translators/ollama.chat.response.translator.js +2 -2
  35. package/dist/translators/ollama.chat.response.translator.js.map +1 -1
  36. package/dist/translators/ollama.generate.request.translator.d.ts +2 -2
  37. package/dist/translators/ollama.generate.request.translator.d.ts.map +1 -1
  38. package/dist/translators/ollama.generate.request.translator.js +2 -2
  39. package/dist/translators/ollama.generate.request.translator.js.map +1 -1
  40. package/dist/translators/ollama.generate.response.translator.d.ts +2 -2
  41. package/dist/translators/ollama.generate.response.translator.d.ts.map +1 -1
  42. package/dist/translators/ollama.generate.response.translator.js +2 -2
  43. package/dist/translators/ollama.generate.response.translator.js.map +1 -1
  44. package/dist/translators/ollama.message.translators.d.ts +2 -2
  45. package/dist/translators/ollama.message.translators.d.ts.map +1 -1
  46. package/dist/translators/ollama.message.translators.js +2 -2
  47. package/dist/translators/ollama.message.translators.js.map +1 -1
  48. package/dist/translators/ollama.options.translators.d.ts +2 -2
  49. package/dist/translators/ollama.options.translators.d.ts.map +1 -1
  50. package/dist/translators/ollama.options.translators.js +2 -2
  51. package/dist/translators/ollama.options.translators.js.map +1 -1
  52. package/dist/translators/ollama.tool.translators.d.ts +2 -2
  53. package/dist/translators/ollama.tool.translators.d.ts.map +1 -1
  54. package/dist/translators/ollama.tool.translators.js +2 -2
  55. package/dist/translators/ollama.tool.translators.js.map +1 -1
  56. package/dist/translators/streaming/ollama.content.delta.translator.d.ts +2 -2
  57. package/dist/translators/streaming/ollama.content.delta.translator.d.ts.map +1 -1
  58. package/dist/translators/streaming/ollama.content.delta.translator.js +2 -2
  59. package/dist/translators/streaming/ollama.content.delta.translator.js.map +1 -1
  60. package/dist/translators/streaming/ollama.message.delta.translator.d.ts +2 -2
  61. package/dist/translators/streaming/ollama.message.delta.translator.d.ts.map +1 -1
  62. package/dist/translators/streaming/ollama.message.delta.translator.js +2 -2
  63. package/dist/translators/streaming/ollama.message.delta.translator.js.map +1 -1
  64. package/dist/translators/streaming/ollama.message.stop.translator.d.ts +2 -2
  65. package/dist/translators/streaming/ollama.message.stop.translator.d.ts.map +1 -1
  66. package/dist/translators/streaming/ollama.message.stop.translator.js +2 -2
  67. package/dist/translators/streaming/ollama.message.stop.translator.js.map +1 -1
  68. package/dist/translators/streaming/ollama.stream.translator.d.ts +2 -2
  69. package/dist/translators/streaming/ollama.stream.translator.d.ts.map +1 -1
  70. package/dist/translators/streaming/ollama.stream.translator.js +1 -1
  71. package/dist/translators/streaming/ollama.stream.translator.js.map +1 -1
  72. package/package.json +6 -6
package/README.md CHANGED
@@ -15,7 +15,7 @@ providing complete bidirectional translation between Ollama's native API and the
15
15
 
16
16
  ### Key Features
17
17
 
18
- - ✅ **Full Holo SDK Integration** - Uses `@holokai/sdk` types for strict type safety
18
+ - ✅ **Full Holo SDK Integration** - Uses `@holokai/holo-sdk` types for strict type safety
19
19
  - ✅ **Bidirectional Translation** - Ollama ↔ Holo format with lossless core fields
20
20
  - ✅ **Dual Mode Support** - Both Chat and Generate endpoints
21
21
  - ✅ **Streaming Support** - Frame-based streaming with proper orchestration
@@ -36,7 +36,7 @@ npm install @holokai/holo-provider-ollama
36
36
 
37
37
  This plugin requires:
38
38
 
39
- - `@holokai/sdk` ^0.1.0 - Holo universal format types and plugin contracts
39
+ - `@holokai/holo-sdk` ^0.1.0 - Holo universal format types and plugin contracts
40
40
  - `ollama` ^0.6.3 - Official Ollama JavaScript SDK
41
41
 
42
42
  ### Prerequisites
@@ -74,7 +74,7 @@ Add a provider configuration to your Holo deployment:
74
74
  ### Usage in Code
75
75
 
76
76
  ```typescript
77
- import {HoloRequest, HoloResponse} from '@holokai/sdk';
77
+ import {HoloRequest, HoloResponse} from '@holokai/holo-sdk';
78
78
 
79
79
  const request: HoloRequest = {
80
80
  model: 'llama2',
@@ -132,7 +132,7 @@ src/providers/ollama/
132
132
 
133
133
  ### Breaking Changes
134
134
 
135
- - **Import paths changed**: Use `@holokai/sdk` for types instead of `../../types`
135
+ - **Import paths changed**: Use `@holokai/holo-sdk` for types instead of `../../types`
136
136
  - **Configuration schema**: Now validated via plugin manifest
137
137
  - **Dependency injection**: Uses plugin container instead of core DI
138
138
 
@@ -518,7 +518,7 @@ The plugin translates Ollama frames to Holo streaming events:
518
518
  ### Streaming Example
519
519
 
520
520
  ```typescript
521
- import { HoloStreamChunk } from '@holokai/sdk';
521
+ import { HoloStreamChunk } from '@holokai/holo-sdk';
522
522
 
523
523
  const stream = await ollamaProvider.streamChat(request);
524
524
 
@@ -623,7 +623,7 @@ import type {
623
623
  HoloMessage,
624
624
  HoloTool,
625
625
  HoloJsonSchema
626
- } from '@holokai/sdk';
626
+ } from '@holokai/holo-sdk';
627
627
 
628
628
  // ❌ NO: Record<string, unknown>
629
629
  // ✅ YES: Proper SDK types
@@ -644,7 +644,7 @@ interface HoloTool {
644
644
  **After** (Plugin SDK):
645
645
 
646
646
  ```typescript
647
- import type {HoloTool, HoloJsonSchema} from '@holokai/sdk';
647
+ import type {HoloTool, HoloJsonSchema} from '@holokai/holo-sdk';
648
648
 
649
649
  interface HoloTool {
650
650
  parameters?: HoloJsonSchema; // ✅ Strict JSON Schema Draft 7
@@ -653,7 +653,7 @@ interface HoloTool {
653
653
 
654
654
  ### Type Safety
655
655
 
656
- All interfaces use strict TypeScript types from `@holokai/sdk` for compile-time validation.
656
+ All interfaces use strict TypeScript types from `@holokai/holo-sdk` for compile-time validation.
657
657
 
658
658
  ---
659
659
 
@@ -762,7 +762,7 @@ chunks in a session.
762
762
 
763
763
  ### SDK Documentation
764
764
 
765
- - [SDK README](../sdk/README.md) - Plugin development guide and templates
765
+ - [SDK README](../holo-sdk/README.md) - Plugin development guide and templates
766
766
 
767
767
  ### Ollama Documentation
768
768
 
@@ -782,7 +782,7 @@ chunks in a session.
782
782
 
783
783
  ### Adding Features
784
784
 
785
- 1. Update types in `@holokai/sdk` first (if needed)
785
+ 1. Update types in `@holokai/holo-sdk` first (if needed)
786
786
  2. Implement translator logic
787
787
  3. Write tests (unit + integration)
788
788
  4. Update this README
@@ -1,3 +1,3 @@
1
- import { PluginManifest } from "@holokai/types/plugin";
1
+ import { PluginManifest } from "@holokai/holo-types/plugin";
2
2
  export declare const manifest: PluginManifest;
3
3
  //# sourceMappingURL=manifest.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAa,MAAM,uBAAuB,CAAC;AAMjE,eAAO,MAAM,QAAQ,EAAE,cAOtB,CAAC"}
1
+ {"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAa,MAAM,4BAA4B,CAAC;AAMtE,eAAO,MAAM,QAAQ,EAAE,cAOtB,CAAC"}
package/dist/manifest.js CHANGED
@@ -1,4 +1,4 @@
1
- import { PluginType } from "@holokai/types/plugin";
1
+ import { PluginType } from "@holokai/holo-types/plugin";
2
2
  import { createRequire } from 'module';
3
3
  const require = createRequire(import.meta.url);
4
4
  const { version } = require('../package.json');
@@ -1 +1 @@
1
- {"version":3,"file":"manifest.js","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,UAAU,EAAC,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAC,aAAa,EAAC,MAAM,QAAQ,CAAC;AAErC,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAAM,EAAC,OAAO,EAAC,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAE7C,MAAM,CAAC,MAAM,QAAQ,GAAmB;IACpC,IAAI,EAAE,0BAA0B;IAChC,OAAO;IACP,UAAU,EAAE,UAAU,CAAC,QAAQ;IAC/B,MAAM,EAAE,QAAQ;IAChB,WAAW,EAAE,iBAAiB;IAC9B,WAAW,EAAE,kCAAkC;CAClD,CAAC"}
1
+ {"version":3,"file":"manifest.js","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,UAAU,EAAC,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAC,aAAa,EAAC,MAAM,QAAQ,CAAC;AAErC,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAAM,EAAC,OAAO,EAAC,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAE7C,MAAM,CAAC,MAAM,QAAQ,GAAmB;IACpC,IAAI,EAAE,0BAA0B;IAChC,OAAO;IACP,UAAU,EAAE,UAAU,CAAC,QAAQ;IAC/B,MAAM,EAAE,QAAQ;IAChB,WAAW,EAAE,iBAAiB;IAC9B,WAAW,EAAE,kCAAkC;CAClD,CAAC"}
@@ -1,32 +1,16 @@
1
- import { BaseAuditor } from "@holokai/sdk/provider";
2
- import type { HoloWorkerRequest, WorkerResponseEnvelope } from "@holokai/types/worker";
3
- import type { ProviderEnvelope, ProviderEvent } from "@holokai/types/provider";
4
- import type { ProviderRequest } from "@holokai/types/entities";
5
- import { ChatRequest, GenerateRequest } from "ollama";
1
+ import { BaseAuditor } from "@holokai/holo-sdk/provider";
2
+ import type { HoloWorkerRequest, WorkerResponseEnvelope } from "@holokai/holo-types/worker";
3
+ import type { ProviderDoneEvent, ProviderEvent } from "@holokai/holo-types/provider";
4
+ import type { ProviderEnvelope, ProviderResponseMetrics } from "@holokai/holo-types/entities";
5
+ import { FinishReason } from "@holokai/holo-types/entities";
6
+ import type { HoloFinishReason, HoloUsage } from "@holokai/holo-types/holo";
6
7
  export declare class OllamaAuditor extends BaseAuditor {
7
8
  readonly provider = "ollama";
8
- protected toHoloRequest(workerRequest: HoloWorkerRequest, llmRequest: Omit<ProviderRequest, 'id'>): void;
9
- protected mapProviderPayload(workerRequest: HoloWorkerRequest, llmRequest: Omit<ProviderRequest, 'id'>): void;
10
- protected mapResponseMetrics(providerEvent: Extract<ProviderEvent, {
11
- type: 'done' | 'error';
12
- }>, envelope: WorkerResponseEnvelope): Promise<Partial<{
13
- usage_raw: any;
14
- input_tokens: any;
15
- output_tokens: any;
16
- time_to_first_token: any;
17
- total_processing_time: any;
18
- }>>;
19
- protected createProviderEnvelope(payload: GenerateRequest | ChatRequest): Promise<ProviderEnvelope>;
20
- protected extractExtraTokens(_metrics: Record<string, any>, base: Record<string, number>): Record<string, number>;
21
- private extractUserPromptFromMessages;
22
- private extractSystemPromptFromMessages;
23
- /**
24
- * Calculate time to first token using Ollama's timing data
25
- * Time to first token = load_duration + prompt_eval_duration
26
- * This represents the time spent loading the model and evaluating the prompt before generating the first token
27
- * @param payload - Ollama response payload with timing information
28
- * @returns Time to first token in milliseconds, or undefined if timing data is unavailable
29
- */
30
- private calculateTimeToFirstToken;
9
+ protected extractRequestOptions(workerRequest: HoloWorkerRequest): Promise<Record<string, any>>;
10
+ mapFinishReason(nativeResponse: any, _protocolName?: string): HoloFinishReason;
11
+ mapUsage(nativeResponse: any, _protocolName?: string): HoloUsage;
12
+ protected mapProviderResponseMetrics(providerEvent: ProviderDoneEvent): Promise<Partial<ProviderResponseMetrics>>;
13
+ protected extractFinishReason(providerEvent: ProviderEvent, _envelope: WorkerResponseEnvelope): Promise<FinishReason | undefined>;
14
+ protected createProviderEnvelope(workerRequest: HoloWorkerRequest): Promise<ProviderEnvelope>;
31
15
  }
32
16
  //# sourceMappingURL=ollama.auditor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ollama.auditor.d.ts","sourceRoot":"","sources":["../src/ollama.auditor.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,WAAW,EAAC,MAAM,uBAAuB,CAAC;AAElD,OAAO,KAAK,EAAC,iBAAiB,EAAE,sBAAsB,EAAC,MAAM,uBAAuB,CAAC;AACrF,OAAO,KAAK,EAAC,gBAAgB,EAAE,aAAa,EAAC,MAAM,yBAAyB,CAAC;AAC7E,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAC,WAAW,EAAgB,eAAe,EAAmB,MAAM,QAAQ,CAAC;AAGpF,qBACa,aAAc,SAAQ,WAAW;IAC1C,QAA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EAAC,MAAM,0BAA0B,CAAC;AAI1E,qBACa,aAAc,SAAQ,WAAW;IAC1C,QAAQ,CAAC,QAAQ,YAAY;cAEb,qBAAqB,CAAC,aAAa,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAM5F,eAAe,CAAC,cAAc,EAAE,GAAG,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,gBAAgB;IAe9E,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS;cAkBzD,0BAA0B,CAAC,aAAa,EAAE,iBAAiB;cAwB3D,mBAAmB,CAAC,aAAa,EAAE,aAAa,EAAE,SAAS,EAAE,sBAAsB,GAAG,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC;cAMvH,sBAAsB,CAAC,aAAa,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAgCtG"}
@@ -5,98 +5,101 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
7
  import { injectable } from 'tsyringe';
8
- import { BaseAuditor } from "@holokai/sdk/provider";
9
- import { pickDefined } from "@holokai/sdk";
8
+ import { BaseAuditor, extractPromptByRole, extractTextContent, normalizeText } from "@holokai/holo-sdk/provider";
9
+ import { nsToMs, pickDefined } from "@holokai/holo-sdk";
10
+ import { FinishReason } from "@holokai/holo-types/entities";
10
11
  import { OllamaProtocols } from "./plugin";
11
12
  let OllamaAuditor = class OllamaAuditor extends BaseAuditor {
12
13
  provider = 'ollama';
13
- toHoloRequest(workerRequest, llmRequest) {
14
- const payload = workerRequest.payload;
15
- llmRequest.access_model = payload.model;
16
- if (workerRequest.protocol.name === OllamaProtocols.CHAT) {
17
- const chatPayload = payload;
18
- const userPrompt = this.extractUserPromptFromMessages(chatPayload.messages);
19
- const systemPrompt = this.extractSystemPromptFromMessages(chatPayload.messages);
20
- if (userPrompt !== undefined) {
21
- llmRequest.metadata.user_prompt = userPrompt;
22
- }
23
- if (systemPrompt !== undefined) {
24
- llmRequest.metadata.system_prompt = systemPrompt;
25
- }
26
- }
27
- else if (workerRequest.protocol.name === OllamaProtocols.GENERATE) {
28
- const generatePayload = payload;
29
- if (generatePayload.prompt !== undefined) {
30
- llmRequest.metadata.user_prompt = generatePayload.prompt;
31
- }
32
- if (generatePayload.system !== undefined) {
33
- llmRequest.metadata.system_prompt = generatePayload.system;
34
- }
35
- }
14
+ async extractRequestOptions(workerRequest) {
15
+ return {
16
+ ...workerRequest.payload.options
17
+ };
36
18
  }
37
- mapProviderPayload(workerRequest, llmRequest) {
38
- const payload = workerRequest.payload;
39
- if (payload.options !== undefined) {
40
- llmRequest.metadata.options = payload.options;
19
+ mapFinishReason(nativeResponse, _protocolName) {
20
+ if (!nativeResponse)
21
+ return 'stop';
22
+ const doneReason = nativeResponse.done_reason;
23
+ switch (doneReason) {
24
+ case 'stop':
25
+ return 'stop';
26
+ case 'load':
27
+ return 'error';
28
+ case 'length':
29
+ return 'length';
30
+ default:
31
+ return 'stop';
41
32
  }
42
33
  }
43
- async mapResponseMetrics(providerEvent, envelope) {
44
- const metrics = await super.mapResponseMetrics(providerEvent, envelope);
45
- if (providerEvent.type === 'error') {
46
- return metrics;
47
- }
48
- const payload = providerEvent.message;
49
- const usage = {
50
- input_tokens: payload.prompt_eval_count || metrics.input_tokens,
51
- output_tokens: payload.eval_count || metrics.output_tokens,
52
- time_to_first_token: this.calculateTimeToFirstToken(payload) || metrics.time_to_first_token,
53
- total_processing_time: payload.total_duration ? Math.round(payload.total_duration / 1000000) : metrics.total_processing_time
54
- };
55
- return pickDefined({
56
- usage_raw: usage,
57
- ...usage
34
+ mapUsage(nativeResponse, _protocolName) {
35
+ if (!nativeResponse)
36
+ return {};
37
+ const { prompt_eval_count, eval_count, load_duration, prompt_eval_duration, total_duration } = nativeResponse;
38
+ const usage = pickDefined({
39
+ input_tokens: prompt_eval_count,
40
+ output_tokens: eval_count,
41
+ total_tokens: (eval_count ?? 0) + (prompt_eval_count ?? 0) || undefined,
58
42
  });
43
+ if (load_duration != null || total_duration != null) {
44
+ const timings = {};
45
+ if (total_duration != null)
46
+ timings.total = Math.round(nsToMs(total_duration));
47
+ if (load_duration != null)
48
+ timings.load = Math.round(nsToMs(load_duration));
49
+ if (prompt_eval_duration != null)
50
+ timings.prompt_eval = Math.round(nsToMs(prompt_eval_duration));
51
+ usage.timings = timings;
52
+ }
53
+ return usage;
59
54
  }
60
- async createProviderEnvelope(payload) {
55
+ async mapProviderResponseMetrics(providerEvent) {
56
+ const payload = providerEvent.message;
57
+ const { load_duration, eval_count, prompt_eval_count, prompt_eval_duration, total_duration } = payload;
61
58
  return pickDefined({
62
- access_model: payload.model
59
+ input_tokens: prompt_eval_count,
60
+ output_tokens: eval_count,
61
+ total_tokens: (eval_count ?? 0) + (prompt_eval_count ?? 0) || undefined,
62
+ time_to_first_token: load_duration != null && prompt_eval_duration != null ? Math.round(nsToMs(load_duration + prompt_eval_duration)) : undefined,
63
+ total_processing_time: total_duration != null ? Math.round(nsToMs(total_duration)) : undefined,
64
+ usage_raw: {
65
+ load_duration,
66
+ prompt_eval_duration,
67
+ total_duration,
68
+ eval_count,
69
+ prompt_eval_count
70
+ },
71
+ metadata: {
72
+ load_duration,
73
+ prompt_eval_duration
74
+ }
63
75
  });
64
76
  }
65
- extractExtraTokens(_metrics, base) {
66
- return base;
67
- }
68
- extractUserPromptFromMessages(messages) {
69
- if (!messages || !Array.isArray(messages))
70
- return undefined;
71
- const userMessages = messages.filter(msg => msg.role === 'user');
72
- if (userMessages.length === 0)
73
- return undefined;
74
- // Return the last user message content
75
- const lastUserMessage = userMessages[userMessages.length - 1];
76
- return typeof lastUserMessage.content === 'string' ? lastUserMessage.content : undefined;
77
- }
78
- extractSystemPromptFromMessages(messages) {
79
- if (!messages || !Array.isArray(messages))
77
+ async extractFinishReason(providerEvent, _envelope) {
78
+ if (providerEvent.type === 'error')
79
+ return FinishReason.ERROR;
80
+ if (providerEvent.type !== 'done')
80
81
  return undefined;
81
- const systemMessage = messages.find(msg => msg.role === 'system');
82
- return systemMessage && typeof systemMessage.content === 'string' ? systemMessage.content : undefined;
82
+ return this.mapFinishReason(providerEvent.message);
83
83
  }
84
- /**
85
- * Calculate time to first token using Ollama's timing data
86
- * Time to first token = load_duration + prompt_eval_duration
87
- * This represents the time spent loading the model and evaluating the prompt before generating the first token
88
- * @param payload - Ollama response payload with timing information
89
- * @returns Time to first token in milliseconds, or undefined if timing data is unavailable
90
- */
91
- calculateTimeToFirstToken(payload) {
92
- const loadDuration = payload.load_duration;
93
- const promptEvalDuration = payload.prompt_eval_duration;
94
- if (loadDuration !== undefined && promptEvalDuration !== undefined) {
95
- // Convert nanoseconds to milliseconds and sum the durations
96
- const timeToFirstTokenNs = loadDuration + promptEvalDuration;
97
- return Math.round(timeToFirstTokenNs / 1000000);
84
+ async createProviderEnvelope(workerRequest) {
85
+ const payload = workerRequest.payload;
86
+ let last_user_prompt;
87
+ let system_prompt;
88
+ if (workerRequest.protocol.name === OllamaProtocols.GENERATE) {
89
+ const generatePayload = payload;
90
+ last_user_prompt = normalizeText(generatePayload.prompt);
91
+ system_prompt = generatePayload.system ? normalizeText(generatePayload.system) : generatePayload.system;
98
92
  }
99
- return undefined;
93
+ else {
94
+ const chatPayload = payload;
95
+ last_user_prompt = extractPromptByRole(chatPayload.messages, "user", "last", (msg) => extractTextContent(msg.content));
96
+ system_prompt = extractPromptByRole(chatPayload.messages, "system", "first", (msg) => extractTextContent(msg.content));
97
+ }
98
+ return pickDefined({
99
+ access_model: payload.model,
100
+ last_user_prompt,
101
+ system_prompt
102
+ });
100
103
  }
101
104
  };
102
105
  OllamaAuditor = __decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"ollama.auditor.js","sourceRoot":"","sources":["../src/ollama.auditor.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;A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AAM,CAAC;YACJ,MAAM,WAAW,GAAI,OAAuB,CAAC;YAC7C,gBAAgB,GAAG,mBAAmB,CAClC,WAAW,CAAC,QAAQ,EACpB,MAAM,EACN,MAAM,EACN,CAAC,GAAG,EAAE,EAAE,CAAC,kBAAkB,CAAC,GAAG,CAAC,OAAO,CAAC,CAC3C,CAAA;YAED,aAAa,GAAG,mBAAmB,CAC/B,WAAW,CAAC,QAAQ,EACpB,QAAQ,EACR,OAAO,EACP,CAAC,GAAG,EAAE,EAAE,CAAC,kBAAkB,CAAC,GAAG,CAAC,OAAO,CAAC,CAC3C,CAAC;QACN,CAAC;QAED,OAAO,WAAW,CAAC;YACf,YAAY,EAAE,OAAO,CAAC,KAAK;YAC3B,gBAAgB;YAChB,aAAa;SAChB,CAAqB,CAAC;IAC3B,CAAC;CACJ,CAAA;AAxGY,aAAa;IADzB,UAAU,EAAE;GACA,aAAa,CAwGzB"}
@@ -1,19 +1,21 @@
1
1
  import { ChatRequest, EmbedRequest, ErrorResponse, GenerateRequest, ListResponse, Ollama } from 'ollama';
2
- import { BaseProvider } from '@holokai/sdk/provider';
3
- import type { IAuditor, IProviderTranslator, IResponseFactory, ProviderContext, RunHandle } from '@holokai/types/provider';
4
- export declare class OllamaProvider extends BaseProvider<Ollama, GenerateRequest | ChatRequest> {
5
- getModelNameFromRequest(payload: GenerateRequest | ChatRequest): Promise<string>;
2
+ import { BaseProvider } from '@holokai/holo-sdk/provider';
3
+ import type { DiscoveredModel, IAuditor, IProviderTranslator, IResponseFactory, ProviderContext, RunHandle } from '@holokai/holo-types/provider';
4
+ export declare class OllamaProvider extends BaseProvider<Ollama, EmbedRequest | GenerateRequest | ChatRequest> {
5
+ getModelNameFromRequest(payload: EmbedRequest | GenerateRequest | ChatRequest): Promise<string>;
6
+ discoverModels(): Promise<DiscoveredModel[]>;
6
7
  getModels(allowedModels: string[] | true): Promise<ListResponse>;
7
- ollamaEmbed(payload: EmbedRequest, _ctx: ProviderContext): Promise<{
8
- final: () => Promise<import("ollama").EmbedResponse>;
8
+ ollamaEmbed(payload: EmbedRequest): Promise<{
9
+ start: () => Promise<import("ollama").EmbedResponse>;
9
10
  }>;
10
11
  protected createAuditor(): IAuditor;
11
12
  protected createClient(): Ollama;
12
13
  protected createTranslator(): IProviderTranslator;
13
14
  protected createResponseFactory(): IResponseFactory;
14
15
  protected handleError(error: Error): Promise<ErrorResponse>;
15
- protected handleRequest(payload: GenerateRequest | ChatRequest | EmbedRequest, ctx: ProviderContext): Promise<RunHandle<any>>;
16
+ protected createRequestRunner(payload: GenerateRequest | ChatRequest | EmbedRequest, ctx: ProviderContext): Promise<RunHandle<any>>;
16
17
  private ollamaGenerate;
18
+ private emitOllamaToolCalls;
17
19
  private ollamaChat;
18
20
  }
19
21
  //# sourceMappingURL=ollama.provider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ollama.provider.d.ts","sourceRoot":"","sources":["../src/ollama.provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,EAAC,MAAM,QAAQ,CAAC;AACvG,OAAO,EAAC,YAAY,EAAC,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EACR,QAAQ,EACR,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EACf,SAAS,EACZ,MAAM,yBAAyB,CAAC;AAMjC,qBAAa,cAAe,SAAQ,YAAY,CAAC,MAAM,EAAE,eAAe,GAAG,WAAW,CAAC;IAE7E,uBAAuB,CAAC,OAAO,EAAE,eAAe,GAAG,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC;IAIhF,SAAS,CAAC,aAAa,EAAE,MAAM,EAAE,GAAG,IAAI,GAAG,OAAO,CAAC,YAAY,CAAC;IAchE,WAAW,CAAC,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,eAAe;;;IAa9D,SAAS,CAAC,aAAa,IAAI,QAAQ;IAInC,SAAS,CAAC,YAAY,IA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AAK,GAAG,OAAO,CAAC,aAAa,CAAC;cAIjD,mBAAmB,CAAC,OAAO,EAAE,eAAe,GAAG,WAAW,GAAG,YAAY,EAAE,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;YAY3H,cAAc;IA4B5B,OAAO,CAAC,mBAAmB;YAUb,UAAU;CA0C3B"}
@@ -1,5 +1,5 @@
1
1
  import { Ollama } from 'ollama';
2
- import { BaseProvider } from '@holokai/sdk/provider';
2
+ import { BaseProvider } from '@holokai/holo-sdk/provider';
3
3
  import { OllamaAuditor } from './ollama.auditor';
4
4
  import { OllamaTranslator } from './ollama.translator';
5
5
  import { OllamaResponseFactory } from './ollama.response.factory';
@@ -8,6 +8,25 @@ export class OllamaProvider extends BaseProvider {
8
8
  async getModelNameFromRequest(payload) {
9
9
  return payload.model;
10
10
  }
11
+ async discoverModels() {
12
+ const response = await this.client.list();
13
+ return response.models.map(m => {
14
+ const name = m.name;
15
+ const modelName = name.split(':')[0];
16
+ return {
17
+ name,
18
+ accessModel: name,
19
+ description: `${modelName} (Model ID: ${name})`,
20
+ version: name.match(/-(\d+\.\d+(?:\.\d+)?)/)?.[1] ?? '1.0',
21
+ metadata: {
22
+ name: m.name,
23
+ size: m.size,
24
+ digest: m.digest,
25
+ details: m.details,
26
+ },
27
+ };
28
+ });
29
+ }
11
30
  async getModels(allowedModels) {
12
31
  const response = await this.client.list();
13
32
  if (allowedModels === true) {
@@ -19,16 +38,10 @@ export class OllamaProvider extends BaseProvider {
19
38
  models
20
39
  };
21
40
  }
22
- async ollamaEmbed(payload, _ctx) {
41
+ async ollamaEmbed(payload) {
23
42
  return {
24
- final: async () => {
25
- try {
26
- return await this.client.embed(payload);
27
- }
28
- catch (error) {
29
- this.log.error(`Ollama embed error: ${error instanceof Error ? error.message : String(error)}`);
30
- throw error;
31
- }
43
+ start: async () => {
44
+ return await this.client.embed(payload);
32
45
  }
33
46
  };
34
47
  }
@@ -47,36 +60,29 @@ export class OllamaProvider extends BaseProvider {
47
60
  async handleError(error) {
48
61
  return { error: error.message };
49
62
  }
50
- async handleRequest(payload, ctx) {
63
+ async createRequestRunner(payload, ctx) {
51
64
  switch (ctx.protocol.name) {
52
65
  case OllamaProtocols.GENERATE:
53
66
  return this.ollamaGenerate(payload, ctx);
54
67
  case OllamaProtocols.CHAT:
55
68
  return this.ollamaChat(payload, ctx);
56
69
  case OllamaProtocols.EMBED:
57
- return this.ollamaEmbed(payload, ctx);
70
+ return this.ollamaEmbed(payload);
58
71
  }
59
72
  throw new Error(`Unsupported requestType: ${JSON.stringify(ctx)}`);
60
73
  }
61
74
  async ollamaGenerate(request, ctx) {
62
75
  if (!request.stream) {
63
76
  return {
64
- final: async () => {
65
- try {
66
- return await this.client.generate({ ...request, stream: false /* ensure */ });
67
- }
68
- catch (error) {
69
- this.log.error(`Ollama generate error: ${error instanceof Error ? error.message : String(error)}`, {
70
- config: JSON.stringify(this._config),
71
- request: JSON.stringify(request)
72
- });
73
- throw error;
74
- }
77
+ start: async () => {
78
+ const result = await this.client.generate({ ...request, stream: false /* ensure */ });
79
+ ctx.emitTextDelta(result.response);
80
+ return result;
75
81
  },
76
82
  };
77
83
  }
78
84
  return {
79
- final: async () => {
85
+ start: async () => {
80
86
  const streamResp = await this.client.generate({ ...request, stream: true });
81
87
  for await (const chunk of streamResp) {
82
88
  if (chunk.done)
@@ -90,30 +96,46 @@ export class OllamaProvider extends BaseProvider {
90
96
  }
91
97
  };
92
98
  }
99
+ emitOllamaToolCalls(toolCalls, ctx) {
100
+ for (let i = 0; i < toolCalls.length; i++) {
101
+ const fn = toolCalls[i].function;
102
+ if (!fn)
103
+ continue;
104
+ const argsStr = typeof fn.arguments === 'string' ? fn.arguments : JSON.stringify(fn.arguments);
105
+ ctx.emitToolCallDelta(i, { name: fn.name });
106
+ ctx.emitToolCallDelta(i, { arguments_delta: argsStr });
107
+ }
108
+ }
93
109
  async ollamaChat(request, ctx) {
94
110
  if (!request.stream) {
95
111
  return {
96
- final: async () => {
97
- try {
98
- return await this.client.chat({ ...request, stream: false });
99
- }
100
- catch (error) {
101
- this.log.error(`Ollama chat error: ${error instanceof Error ? error.message : String(error)}`, {
102
- config: JSON.stringify(this._config),
103
- request: JSON.stringify(request)
104
- });
105
- throw error;
112
+ start: async () => {
113
+ const result = await this.client.chat({ ...request, stream: false });
114
+ ctx.emitTextDelta(result.message.content);
115
+ if (result.message.tool_calls?.length) {
116
+ this.emitOllamaToolCalls(result.message.tool_calls, ctx);
106
117
  }
118
+ return result;
107
119
  },
108
120
  };
109
121
  }
110
122
  return {
111
- final: async () => {
123
+ start: async () => {
112
124
  const streamResp = await this.client.chat({ ...request, stream: true });
113
125
  for await (const chunk of streamResp) {
114
- if (chunk.done)
126
+ if (chunk.done) {
127
+ const finalToken = chunk.message?.content ?? '';
128
+ if (finalToken)
129
+ ctx.emitTextDelta(finalToken);
130
+ if (chunk.message?.tool_calls?.length) {
131
+ this.emitOllamaToolCalls(chunk.message.tool_calls, ctx);
132
+ }
115
133
  return chunk;
134
+ }
116
135
  ctx.emitStreamEvent(chunk);
136
+ if (chunk.message?.tool_calls?.length) {
137
+ this.emitOllamaToolCalls(chunk.message.tool_calls, ctx);
138
+ }
117
139
  const token = chunk.message.content ?? '';
118
140
  if (token)
119
141
  ctx.emitTextDelta(token);
@@ -1 +1 @@
1
- {"version":3,"file":"ollama.provider.js","sourceRoot":"","sources":["../src/ollama.provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0E,MAAM,EAAC,MAAM,QAAQ,CAAC;AACvG,OAAO,EAAC,YAAY,EAAC,MAAM,uBAAuB,CAAC;AAQnD,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAC,gBAAgB,EAAC,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAC,qBAAqB,EAAC,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAC,eAAe,EAAC,MAAM,UAAU,CAAC;AAEzC,MAAM,OAA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,EAAE,CAAC;4BACpC,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;wBAC5D,CAAC;wBACD,OAAO,KAAK,CAAC;oBACjB,CAAC;oBACD,GAAG,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;oBAE3B,IAAI,KAAK,CAAC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC;wBACpC,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;oBAC5D,CAAC;oBAED,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;oBAC1C,IAAI,KAAK;wBAAE,GAAG,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;gBACxC,CAAC;gBAED,OAAO,EAAC,IAAI,EAAE,IAAI,EAAC,CAAC;YACxB,CAAC;SACJ,CAAC;IACN,CAAC;CAEJ"}
@@ -1,4 +1,4 @@
1
- import type { IResponseFactory } from "@holokai/types/provider";
1
+ import type { IResponseFactory } from "@holokai/holo-types/provider";
2
2
  import { ErrorResponse } from "ollama";
3
3
  export declare class OllamaResponseFactory implements IResponseFactory {
4
4
  static instance(): OllamaResponseFactory;
@@ -1 +1 @@
1
- {"version":3,"file":"ollama.response.factory.d.ts","sourceRoot":"","sources":["../src/ollama.response.factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAC,aAAa,EAAC,MAAM,QAAQ,CAAC;AAErC,qBAAa,qBAAsB,YAAW,gBAAgB;IAC1D,MAAM,CAAC,QAAQ,IAAI,qBAAqB;IAIxC,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa;CAG9C"}
1
+ {"version":3,"file":"ollama.response.factory.d.ts","sourceRoot":"","sources":["../src/ollama.response.factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAC,aAAa,EAAC,MAAM,QAAQ,CAAC;AAErC,qBAAa,qBAAsB,YAAW,gBAAgB;IAC1D,MAAM,CAAC,QAAQ,IAAI,qBAAqB;IAIxC,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa;CAG9C"}