@aeye/ollama 0.0.0-stage → 0.8.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.
- package/README.md +53 -2
- package/aeye-ollama.md +93 -0
- package/dist/api.d.ts +107 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +126 -0
- package/dist/api.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/ollama.d.ts +103 -0
- package/dist/ollama.d.ts.map +1 -0
- package/dist/ollama.js +172 -0
- package/dist/ollama.js.map +1 -0
- package/package.json +70 -4
package/README.md
CHANGED
|
@@ -1,3 +1,54 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @aeye/ollama
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Ollama provider for the @aeye (AI TypeScript) framework: local (or cloud) Ollama models for chat, embeddings, and System One decisions.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Chat and embeddings** through Ollama's OpenAI-compatible `/v1`, with system messages sent as `system` (Ollama's templates drop OpenAI's `developer` role)
|
|
8
|
+
- **Decisions** through `/v1/systemone` (Ollama v0.35+): predicates, choices, and scores, with images and `keep_alive`
|
|
9
|
+
- **Honest model list** from `/api/tags` and `/api/show`: what each model does (`completion`, `tools`, `thinking`, `vision`, `embedding`, `decision`) and the context window it is really served with
|
|
10
|
+
- **Decision limits**: decision models carry `maxQuestions` (64) and `maxRequestBytes` (64 KiB); larger calls are refused, never split
|
|
11
|
+
- **Extends OpenAI**: built on `@aeye/openai`'s `OpenAIProvider`
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @aeye/ollama @aeye/openai @aeye/ai @aeye/core openai
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Requires Node >= 22 and the `openai` SDK v7.
|
|
20
|
+
|
|
21
|
+
## Quick Start
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import { AI } from '@aeye/ai';
|
|
25
|
+
import { OllamaProvider } from '@aeye/ollama';
|
|
26
|
+
|
|
27
|
+
const ollama = new OllamaProvider({ keepAlive: '10m' });
|
|
28
|
+
const ai = AI.with().providers({ ollama }).create();
|
|
29
|
+
|
|
30
|
+
const response = await ai.chat.get([{ role: 'user', content: 'Hello!' }], { metadata: { model: 'qwen2.5:3b' } });
|
|
31
|
+
|
|
32
|
+
const { answers } = await ai.decide.get({
|
|
33
|
+
input: 'The printer is on fire.',
|
|
34
|
+
questions: { urgent: { type: 'predicate', instructions: 'Is this urgent?' } },
|
|
35
|
+
}, { metadata: { model: 'nimble' } });
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Configuration
|
|
39
|
+
|
|
40
|
+
| Option | Meaning |
|
|
41
|
+
|--------|---------|
|
|
42
|
+
| `baseURL` | Ollama's root, not `/v1` (default `http://127.0.0.1:11434`) |
|
|
43
|
+
| `apiKey` | A key, for Ollama's cloud |
|
|
44
|
+
| `contextWindow` | The window the server serves models with no `num_ctx` at (as `OLLAMA_CONTEXT_LENGTH` sets) |
|
|
45
|
+
| `maxContextWindow` | The most window assumed when `contextWindow` is unset |
|
|
46
|
+
| `keepAlive` | How long a decision model stays loaded (`'5m'`, seconds, `0` unloads, below 0 keeps) |
|
|
47
|
+
| `decisionModels` | Decision models, for servers whose `/api/show` lists no capabilities |
|
|
48
|
+
| `fetch` | The `fetch` every call goes through |
|
|
49
|
+
|
|
50
|
+
See the [Ollama provider docs](https://github.com/ClickerMonkey/aeye/tree/main/packages/docs/providers/ollama.md) and the [decisions guide](https://github.com/ClickerMonkey/aeye/tree/main/packages/docs/guides/decisions.md).
|
|
51
|
+
|
|
52
|
+
## License
|
|
53
|
+
|
|
54
|
+
GPL-3.0
|
package/aeye-ollama.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# @aeye/ollama
|
|
2
|
+
|
|
3
|
+
One-line purpose: Ollama provider for `@aeye/ai` — local (or cloud) Ollama models for chat, embeddings and System One decisions, with the model list, capabilities and the context window each model is really served with read from Ollama's native API. Built as a subclass of `@aeye/openai`'s `OpenAIProvider`.
|
|
4
|
+
|
|
5
|
+
## When to use
|
|
6
|
+
|
|
7
|
+
- You run models on a local Ollama (or Ollama's cloud) and want them in the same `AI` instance as other providers.
|
|
8
|
+
- You want fast typed decisions (`ai.decide`) from an Ollama System One model (`/v1/systemone`, Ollama v0.35+), optionally over images.
|
|
9
|
+
- You need honest context windows: Ollama silently cuts the front of a prompt longer than the window it serves (`num_ctx`), whatever the model was trained to.
|
|
10
|
+
|
|
11
|
+
## Install / import
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @aeye/ollama
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
`@aeye/openai`, `@aeye/ai`, `@aeye/core`, and `openai` (v7) ship as dependencies. Requires Node >= 22.
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import {
|
|
21
|
+
OllamaProvider,
|
|
22
|
+
type OllamaConfig,
|
|
23
|
+
type OllamaOptions,
|
|
24
|
+
OLLAMA_SYSTEM_ONE_LIMITS,
|
|
25
|
+
capabilitiesOf,
|
|
26
|
+
// native API and served-window helpers
|
|
27
|
+
OllamaApi,
|
|
28
|
+
type OllamaShow,
|
|
29
|
+
type OllamaTags,
|
|
30
|
+
OLLAMA_BASE_URL,
|
|
31
|
+
numCtxOf,
|
|
32
|
+
trainedLengthOf,
|
|
33
|
+
servedDefault,
|
|
34
|
+
unsetWindow,
|
|
35
|
+
servedWindow,
|
|
36
|
+
takesTools,
|
|
37
|
+
reasons,
|
|
38
|
+
} from '@aeye/ollama';
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
The provider's registry name is `ollama`.
|
|
42
|
+
|
|
43
|
+
## Register with an `@aeye/ai` instance
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
import { AI } from '@aeye/ai';
|
|
47
|
+
import { OllamaProvider } from '@aeye/ollama';
|
|
48
|
+
|
|
49
|
+
const ollama = new OllamaProvider({ keepAlive: '10m' });
|
|
50
|
+
const ai = AI.with().providers({ ollama }).create();
|
|
51
|
+
await ai.models.refresh(); // lists the server's models
|
|
52
|
+
|
|
53
|
+
await ai.chat.get([{ role: 'user', content: 'Hi' }], { metadata: { model: 'qwen2.5:3b' } });
|
|
54
|
+
|
|
55
|
+
const { answers } = await ai.decide.get({
|
|
56
|
+
input: 'The printer is on fire.',
|
|
57
|
+
images: [photo], // optional, needs a `vision` decision model
|
|
58
|
+
questions: { urgent: { type: 'predicate', instructions: 'Is this urgent?' } },
|
|
59
|
+
}, { metadata: { model: 'nimble' } });
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Configuration (`OllamaConfig`)
|
|
63
|
+
|
|
64
|
+
`OllamaConfig extends OpenAIConfig`; `apiKey` is optional (a local server takes none; a key is sent as a bearer token, for Ollama's cloud).
|
|
65
|
+
|
|
66
|
+
| Option | Meaning |
|
|
67
|
+
|--------|---------|
|
|
68
|
+
| `baseURL` | Ollama's root, not `/v1` (default `http://127.0.0.1:11434`) |
|
|
69
|
+
| `contextWindow` | The window the server serves models whose Modelfile sets no `num_ctx` (as `OLLAMA_CONTEXT_LENGTH` does) |
|
|
70
|
+
| `maxContextWindow` | The most window assumed when `contextWindow` is unset |
|
|
71
|
+
| `keepAlive` | Sent as `keep_alive` on decisions: a duration (`'5m'`) or seconds (`0` unloads, below 0 keeps loaded) |
|
|
72
|
+
| `decisionModels` | Decision models, for servers whose `/api/show` lists no capabilities |
|
|
73
|
+
| `fetch` | The `fetch` every call goes through (native API and `/v1`) |
|
|
74
|
+
|
|
75
|
+
## Models and capabilities
|
|
76
|
+
|
|
77
|
+
`listModels()` reads `/api/tags`, then `/api/show` per model and `/api/version`:
|
|
78
|
+
|
|
79
|
+
- Capabilities come from `/api/show`'s `capabilities` when listed: `completion` → `chat`, `streaming`, `json`; plus `embedding` (text only: Ollama's embed endpoints take no images, so no model gets `imageEmbedding` and an image input throws `ImageEmbeddingError`), `decision`, `vision`; `tools` and `reasoning` for chat models. A server that lists none: a model named in `decisionModels` (with or without `:latest`) is a decision model, every other one a chat model (tools from the template, reasoning from the template or name).
|
|
80
|
+
- `contextWindow` is the served window: the Modelfile's `num_ctx`, else `contextWindow`, else Ollama's default for the server's version (2048 before 0.6, 4096 after) held to `maxContextWindow`, never above the trained length.
|
|
81
|
+
- Pricing is zero; tier is `efficient`.
|
|
82
|
+
- Decision models carry `OLLAMA_SYSTEM_ONE_LIMITS`: `maxQuestions: 64` and `maxRequestBytes: 65536`.
|
|
83
|
+
|
|
84
|
+
## Decisions (`/v1/systemone`)
|
|
85
|
+
|
|
86
|
+
`decide()` sends System One's shape (shared with OpenRouter, from `@aeye/openai`'s `toSystemOneParams`): `state` (text, or the conversation as chat messages with `system` roles), `questions` (`noul` / `choice` / `score`), `images` as plain base64, and `keep_alive` from `keepAlive`. The request's `extra` overrides any of them. Answers are parsed with `fromSystemOneAnswers`: score probabilities come back keyed by level index and are put in level order.
|
|
87
|
+
|
|
88
|
+
## Gotchas
|
|
89
|
+
|
|
90
|
+
- **No splitting.** A decision call over `maxQuestions` (64) or `maxRequestBytes` (64 KiB of state and questions; images don't count) is refused with `DecisionLimitError` before anything is sent. The caller splits its questions by `model.maxQuestions`.
|
|
91
|
+
- System messages go to Ollama as `system`, not OpenAI's `developer` role, which Ollama's chat templates drop without a word.
|
|
92
|
+
- Ollama's OpenAI-compatible endpoint takes no `num_ctx`: set it in the Modelfile or with `OLLAMA_CONTEXT_LENGTH` on the server, and tell the provider with `contextWindow`.
|
|
93
|
+
- No model is assumed: there are no default models; pass `metadata.model` or let selection pick from the listed ones.
|
package/dist/api.d.ts
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ollama's native API (`/api/tags`, `/api/show`, `/api/version`): which
|
|
3
|
+
* models a server has, what each can do, and the context window it serves
|
|
4
|
+
* each with.
|
|
5
|
+
*
|
|
6
|
+
* The served window is the one that matters: Ollama runs a model with its
|
|
7
|
+
* Modelfile's `num_ctx` (or its own default) and silently cuts the front of
|
|
8
|
+
* a longer prompt, whatever length the model was trained to, and its
|
|
9
|
+
* OpenAI-compatible endpoint takes no `num_ctx`.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Where a local Ollama listens by default.
|
|
13
|
+
*/
|
|
14
|
+
export declare const OLLAMA_BASE_URL = "http://127.0.0.1:11434";
|
|
15
|
+
/**
|
|
16
|
+
* The window Ollama served before 0.6 when a Modelfile set no `num_ctx`.
|
|
17
|
+
*/
|
|
18
|
+
export declare const OLLAMA_LEGACY_CTX = 2048;
|
|
19
|
+
/**
|
|
20
|
+
* The window Ollama serves from 0.6 when a Modelfile sets no `num_ctx`.
|
|
21
|
+
*/
|
|
22
|
+
export declare const OLLAMA_CTX = 4096;
|
|
23
|
+
/**
|
|
24
|
+
* What `/api/show` says about a model.
|
|
25
|
+
*/
|
|
26
|
+
export interface OllamaShow {
|
|
27
|
+
parameters?: string;
|
|
28
|
+
template?: string;
|
|
29
|
+
model_info?: Record<string, unknown>;
|
|
30
|
+
capabilities?: string[];
|
|
31
|
+
details?: {
|
|
32
|
+
family?: string;
|
|
33
|
+
parameter_size?: string;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* What `/api/tags` lists.
|
|
38
|
+
*/
|
|
39
|
+
export interface OllamaTags {
|
|
40
|
+
models: Array<{
|
|
41
|
+
name: string;
|
|
42
|
+
model: string;
|
|
43
|
+
}>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Ollama's native API, over an injectable `fetch`.
|
|
47
|
+
*/
|
|
48
|
+
export declare class OllamaApi {
|
|
49
|
+
readonly baseURL: string;
|
|
50
|
+
private readonly fetcher;
|
|
51
|
+
private readonly headers;
|
|
52
|
+
/**
|
|
53
|
+
* @param baseURL Where Ollama listens (its root, not `/v1`)
|
|
54
|
+
* @param fetcher The `fetch` to call it with
|
|
55
|
+
* @param apiKey A key, for Ollama's cloud
|
|
56
|
+
*/
|
|
57
|
+
constructor(baseURL?: string, fetcher?: typeof fetch, apiKey?: string);
|
|
58
|
+
/**
|
|
59
|
+
* The models the server has.
|
|
60
|
+
*/
|
|
61
|
+
tags(): Promise<OllamaTags>;
|
|
62
|
+
/**
|
|
63
|
+
* What one model is and can do.
|
|
64
|
+
*/
|
|
65
|
+
show(model: string): Promise<OllamaShow>;
|
|
66
|
+
/**
|
|
67
|
+
* The server's version (`0.6.2`).
|
|
68
|
+
*/
|
|
69
|
+
version(): Promise<string>;
|
|
70
|
+
private json;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The `num_ctx` a Modelfile sets, if any.
|
|
74
|
+
*/
|
|
75
|
+
export declare function numCtxOf(show: OllamaShow): number | undefined;
|
|
76
|
+
/**
|
|
77
|
+
* The length the model was trained to (`<architecture>.context_length`).
|
|
78
|
+
*/
|
|
79
|
+
export declare function trainedLengthOf(show: OllamaShow): number | undefined;
|
|
80
|
+
/**
|
|
81
|
+
* The window Ollama serves when nothing sets `num_ctx`, by its version
|
|
82
|
+
* (`0.5.7` → 2048).
|
|
83
|
+
*/
|
|
84
|
+
export declare function servedDefault(version: string): number;
|
|
85
|
+
/**
|
|
86
|
+
* The window a server serves a model with when its Modelfile sets no
|
|
87
|
+
* `num_ctx`: the configured one (the server may set
|
|
88
|
+
* `OLLAMA_CONTEXT_LENGTH`), else Ollama's default for its version, held to
|
|
89
|
+
* `max`.
|
|
90
|
+
*/
|
|
91
|
+
export declare function unsetWindow(version: string, configured: number | undefined, max?: number): number;
|
|
92
|
+
/**
|
|
93
|
+
* The window a model is served with: its Modelfile's `num_ctx`, else
|
|
94
|
+
* `unset` (see `unsetWindow`), never more than it was trained to.
|
|
95
|
+
*/
|
|
96
|
+
export declare function servedWindow(show: OllamaShow, unset: number): number;
|
|
97
|
+
/**
|
|
98
|
+
* Whether a model takes native tools: listed as an ability, or its template
|
|
99
|
+
* renders `.Tools`.
|
|
100
|
+
*/
|
|
101
|
+
export declare function takesTools(show: OllamaShow): boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Whether a model thinks before it answers (its thinking counts against its
|
|
104
|
+
* output).
|
|
105
|
+
*/
|
|
106
|
+
export declare function reasons(model: string, show: OllamaShow): boolean;
|
|
107
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;GAEG;AACH,eAAO,MAAM,eAAe,2BAA2B,CAAC;AAExD;;GAEG;AACH,eAAO,MAAM,iBAAiB,OAAQ,CAAC;AAEvC;;GAEG;AACH,eAAO,MAAM,UAAU,OAAQ,CAAC;AAEhC;;GAEG;AACH,MAAM,WAAW,UAAU;IAEzB,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAGrC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,cAAc,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACxD;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAChD;AAED;;GAEG;AACH,qBAAa,SAAS;IACpB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAe;IACvC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAyB;IAEjD;;;;OAIG;gBACS,OAAO,GAAE,MAAwB,EAAE,OAAO,GAAE,OAAO,KAAa,EAAE,MAAM,CAAC,EAAE,MAAM;IAM7F;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,UAAU,CAAC;IAIjC;;OAEG;IACG,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAI9C;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;YAIlB,IAAI;CAUnB;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,CAI7D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,CAOpE;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAGrD;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,SAAS,EAAE,GAAG,GAAE,MAAiC,GAAG,MAAM,CAE3H;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAEpE;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAEpD;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAEhE"}
|
package/dist/api.js
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ollama's native API (`/api/tags`, `/api/show`, `/api/version`): which
|
|
3
|
+
* models a server has, what each can do, and the context window it serves
|
|
4
|
+
* each with.
|
|
5
|
+
*
|
|
6
|
+
* The served window is the one that matters: Ollama runs a model with its
|
|
7
|
+
* Modelfile's `num_ctx` (or its own default) and silently cuts the front of
|
|
8
|
+
* a longer prompt, whatever length the model was trained to, and its
|
|
9
|
+
* OpenAI-compatible endpoint takes no `num_ctx`.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Where a local Ollama listens by default.
|
|
13
|
+
*/
|
|
14
|
+
export const OLLAMA_BASE_URL = 'http://127.0.0.1:11434';
|
|
15
|
+
/**
|
|
16
|
+
* The window Ollama served before 0.6 when a Modelfile set no `num_ctx`.
|
|
17
|
+
*/
|
|
18
|
+
export const OLLAMA_LEGACY_CTX = 2_048;
|
|
19
|
+
/**
|
|
20
|
+
* The window Ollama serves from 0.6 when a Modelfile sets no `num_ctx`.
|
|
21
|
+
*/
|
|
22
|
+
export const OLLAMA_CTX = 4_096;
|
|
23
|
+
/**
|
|
24
|
+
* Ollama's native API, over an injectable `fetch`.
|
|
25
|
+
*/
|
|
26
|
+
export class OllamaApi {
|
|
27
|
+
baseURL;
|
|
28
|
+
fetcher;
|
|
29
|
+
headers;
|
|
30
|
+
/**
|
|
31
|
+
* @param baseURL Where Ollama listens (its root, not `/v1`)
|
|
32
|
+
* @param fetcher The `fetch` to call it with
|
|
33
|
+
* @param apiKey A key, for Ollama's cloud
|
|
34
|
+
*/
|
|
35
|
+
constructor(baseURL = OLLAMA_BASE_URL, fetcher = fetch, apiKey) {
|
|
36
|
+
this.baseURL = baseURL.replace(/\/+$/, '');
|
|
37
|
+
this.fetcher = fetcher;
|
|
38
|
+
this.headers = apiKey ? { authorization: `Bearer ${apiKey}` } : {};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The models the server has.
|
|
42
|
+
*/
|
|
43
|
+
async tags() {
|
|
44
|
+
return this.json('/api/tags');
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* What one model is and can do.
|
|
48
|
+
*/
|
|
49
|
+
async show(model) {
|
|
50
|
+
return this.json('/api/show', { model });
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The server's version (`0.6.2`).
|
|
54
|
+
*/
|
|
55
|
+
async version() {
|
|
56
|
+
return (await this.json('/api/version')).version;
|
|
57
|
+
}
|
|
58
|
+
async json(path, body) {
|
|
59
|
+
const init = body === undefined
|
|
60
|
+
? { headers: this.headers }
|
|
61
|
+
: { method: 'POST', headers: { ...this.headers, 'content-type': 'application/json' }, body: JSON.stringify(body) };
|
|
62
|
+
const response = await this.fetcher(`${this.baseURL}${path}`, init);
|
|
63
|
+
if (!response.ok) {
|
|
64
|
+
throw new Error(`Ollama ${path} answered ${response.status}`);
|
|
65
|
+
}
|
|
66
|
+
return response.json();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The `num_ctx` a Modelfile sets, if any.
|
|
71
|
+
*/
|
|
72
|
+
export function numCtxOf(show) {
|
|
73
|
+
const line = show.parameters?.split('\n').map((l) => l.trim().split(/\s+/)).find(([name]) => name === 'num_ctx');
|
|
74
|
+
const value = Number(line?.[1]);
|
|
75
|
+
return Number.isInteger(value) && value > 0 ? value : undefined;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* The length the model was trained to (`<architecture>.context_length`).
|
|
79
|
+
*/
|
|
80
|
+
export function trainedLengthOf(show) {
|
|
81
|
+
for (const [key, value] of Object.entries(show.model_info ?? {})) {
|
|
82
|
+
if (key.endsWith('.context_length') && typeof value === 'number') {
|
|
83
|
+
return value;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* The window Ollama serves when nothing sets `num_ctx`, by its version
|
|
90
|
+
* (`0.5.7` → 2048).
|
|
91
|
+
*/
|
|
92
|
+
export function servedDefault(version) {
|
|
93
|
+
const [major = 0, minor = 0] = version.split('.').map(Number);
|
|
94
|
+
return major === 0 && minor < 6 ? OLLAMA_LEGACY_CTX : OLLAMA_CTX;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* The window a server serves a model with when its Modelfile sets no
|
|
98
|
+
* `num_ctx`: the configured one (the server may set
|
|
99
|
+
* `OLLAMA_CONTEXT_LENGTH`), else Ollama's default for its version, held to
|
|
100
|
+
* `max`.
|
|
101
|
+
*/
|
|
102
|
+
export function unsetWindow(version, configured, max = Number.POSITIVE_INFINITY) {
|
|
103
|
+
return configured ?? Math.min(max, servedDefault(version));
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* The window a model is served with: its Modelfile's `num_ctx`, else
|
|
107
|
+
* `unset` (see `unsetWindow`), never more than it was trained to.
|
|
108
|
+
*/
|
|
109
|
+
export function servedWindow(show, unset) {
|
|
110
|
+
return Math.min(numCtxOf(show) ?? unset, trainedLengthOf(show) ?? Number.POSITIVE_INFINITY);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Whether a model takes native tools: listed as an ability, or its template
|
|
114
|
+
* renders `.Tools`.
|
|
115
|
+
*/
|
|
116
|
+
export function takesTools(show) {
|
|
117
|
+
return show.capabilities?.includes('tools') ?? show.template?.includes('.Tools') ?? false;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Whether a model thinks before it answers (its thinking counts against its
|
|
121
|
+
* output).
|
|
122
|
+
*/
|
|
123
|
+
export function reasons(model, show) {
|
|
124
|
+
return show.capabilities?.includes('thinking') ?? (/(^|[^a-z])(r1|qwq|think)/i.test(model) || (show.template?.includes('<think>') ?? false));
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=api.js.map
|
package/dist/api.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,wBAAwB,CAAC;AAExD;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,CAAC;AAEvC;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,CAAC;AAyBhC;;GAEG;AACH,MAAM,OAAO,SA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cAAc,UAAU,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC"}
|
package/dist/ollama.d.ts
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ollama Provider
|
|
3
|
+
*
|
|
4
|
+
* Local (or cloud) Ollama models: chat and embeddings through Ollama's
|
|
5
|
+
* OpenAI-compatible `/v1` (Chat Completions), System One decisions through
|
|
6
|
+
* `/v1/systemone`, and the model list from Ollama's native API, with what
|
|
7
|
+
* each model can do and the context window it is really served with.
|
|
8
|
+
*/
|
|
9
|
+
import type { ModelCapability, ModelInfo, Provider } from '@aeye/ai';
|
|
10
|
+
import type { Request } from '@aeye/core';
|
|
11
|
+
import { type DefaultModels, type OpenAIConfig, OpenAIProvider } from '@aeye/openai';
|
|
12
|
+
import OpenAI from 'openai';
|
|
13
|
+
import { OllamaApi, type OllamaShow } from './api';
|
|
14
|
+
/**
|
|
15
|
+
* The limits of Ollama's `/v1/systemone`: questions per call, and bytes of
|
|
16
|
+
* state and questions per call (images aside).
|
|
17
|
+
*/
|
|
18
|
+
export declare const OLLAMA_SYSTEM_ONE_LIMITS: {
|
|
19
|
+
readonly maxQuestions: 64;
|
|
20
|
+
readonly maxRequestBytes: number;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Configuration of an Ollama provider.
|
|
24
|
+
*/
|
|
25
|
+
export interface OllamaConfig extends OpenAIConfig {
|
|
26
|
+
baseURL?: string;
|
|
27
|
+
contextWindow?: number;
|
|
28
|
+
maxContextWindow?: number;
|
|
29
|
+
keepAlive?: string | number;
|
|
30
|
+
decisionModels?: string[];
|
|
31
|
+
fetch?: typeof fetch;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* What an Ollama provider is made from: its config, with the key optional
|
|
35
|
+
* (a local server takes none).
|
|
36
|
+
*/
|
|
37
|
+
export type OllamaOptions = Omit<OllamaConfig, 'apiKey'> & {
|
|
38
|
+
apiKey?: string;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* What a model can do: from the capabilities `/api/show` lists, else (older
|
|
42
|
+
* servers) from its template and name, with decisions from `decisionModels`.
|
|
43
|
+
*
|
|
44
|
+
* @param model The model's name
|
|
45
|
+
* @param show What `/api/show` says about it
|
|
46
|
+
* @param decisionModels Models that answer decisions, when `/api/show` lists no capabilities
|
|
47
|
+
*/
|
|
48
|
+
export declare function capabilitiesOf(model: string, show: OllamaShow, decisionModels?: readonly string[]): Set<ModelCapability>;
|
|
49
|
+
/**
|
|
50
|
+
* Ollama through its OpenAI-compatible API. `@aeye/openai` sends system
|
|
51
|
+
* messages with OpenAI's `developer` role, which Ollama's chat templates
|
|
52
|
+
* drop without a word, so they go to Ollama as `system`.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* const ollama = new OllamaProvider({ keepAlive: '10m' });
|
|
57
|
+
* const ai = AI.with().providers({ ollama }).create();
|
|
58
|
+
* const { answers } = await ai.decide.get({
|
|
59
|
+
* input: 'The printer is on fire.',
|
|
60
|
+
* questions: { urgent: { type: 'predicate', instructions: 'Is this urgent?' } },
|
|
61
|
+
* }, { metadata: { model: 'nimble' } });
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export declare class OllamaProvider extends OpenAIProvider<OllamaConfig> implements Provider<OllamaConfig> {
|
|
65
|
+
readonly name: string;
|
|
66
|
+
protected readonly defaults: DefaultModels;
|
|
67
|
+
constructor(options?: OllamaOptions);
|
|
68
|
+
/**
|
|
69
|
+
* Ollama's native API, for a config.
|
|
70
|
+
*/
|
|
71
|
+
api(config?: Partial<OllamaConfig>): OllamaApi;
|
|
72
|
+
protected createClient(config: OllamaConfig): OpenAI;
|
|
73
|
+
/**
|
|
74
|
+
* The Chat Completions messages, each system one with the `system` role
|
|
75
|
+
* Ollama reads.
|
|
76
|
+
*/
|
|
77
|
+
protected convertMessages(request: Request, config: OllamaConfig): Promise<OpenAI.Chat.ChatCompletionMessageParam[]>;
|
|
78
|
+
/**
|
|
79
|
+
* The window the server serves a model with when its Modelfile sets no
|
|
80
|
+
* `num_ctx`.
|
|
81
|
+
*/
|
|
82
|
+
unsetWindow(config?: Partial<OllamaConfig>): Promise<number>;
|
|
83
|
+
/**
|
|
84
|
+
* The server's models, each with what it can do and the window it is
|
|
85
|
+
* served with. Decision models carry System One's limits.
|
|
86
|
+
*/
|
|
87
|
+
listModels(config?: Partial<OllamaConfig>): Promise<ModelInfo[]>;
|
|
88
|
+
/**
|
|
89
|
+
* Typed answers from a System One model at `/v1/systemone`. A
|
|
90
|
+
* conversation goes in as chat messages, images as base64, and the
|
|
91
|
+
* config's `keepAlive` as `keep_alive` (the request's `extra` overrides
|
|
92
|
+
* it). A call over the model's limits (`maxQuestions`, `maxRequestBytes`,
|
|
93
|
+
* else Ollama's) is refused before it is sent, never split.
|
|
94
|
+
*
|
|
95
|
+
* @param request Decision request parameters
|
|
96
|
+
* @param ctx Context object
|
|
97
|
+
* @param config Optional configuration override
|
|
98
|
+
* @returns Answers by question name
|
|
99
|
+
* @throws {DecisionLimitError} When the call is over a limit
|
|
100
|
+
*/
|
|
101
|
+
decide: Provider['decide'];
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=ollama.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ollama.d.ts","sourceRoot":"","sources":["../src/ollama.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAkC,eAAe,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAErG,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,KAAK,aAAa,EAAwB,KAAK,YAAY,EAAE,cAAc,EAAg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AC,MAAM,CAAC,IAAI,CAAC,0BAA0B,EAAE,CAAC;IAKnI;;;OAGG;IACG,WAAW,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAKlE;;;OAGG;IACY,UAAU,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAyB/E;;;;;;;;;;;;OAYG;IACM,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAgBlC;CACF"}
|
package/dist/ollama.js
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ollama Provider
|
|
3
|
+
*
|
|
4
|
+
* Local (or cloud) Ollama models: chat and embeddings through Ollama's
|
|
5
|
+
* OpenAI-compatible `/v1` (Chat Completions), System One decisions through
|
|
6
|
+
* `/v1/systemone`, and the model list from Ollama's native API, with what
|
|
7
|
+
* each model can do and the context window it is really served with.
|
|
8
|
+
*/
|
|
9
|
+
import { checkDecisionLimits } from '@aeye/ai';
|
|
10
|
+
import { fromSystemOneAnswers, OpenAIProvider, ProviderError, systemOneTextBytes, toSystemOneParams } from '@aeye/openai';
|
|
11
|
+
import OpenAI from 'openai';
|
|
12
|
+
import { OLLAMA_BASE_URL, OllamaApi, reasons, servedWindow, takesTools, unsetWindow } from './api';
|
|
13
|
+
/**
|
|
14
|
+
* The limits of Ollama's `/v1/systemone`: questions per call, and bytes of
|
|
15
|
+
* state and questions per call (images aside).
|
|
16
|
+
*/
|
|
17
|
+
export const OLLAMA_SYSTEM_ONE_LIMITS = { maxQuestions: 64, maxRequestBytes: 64 * 1024 };
|
|
18
|
+
/**
|
|
19
|
+
* What a model can do: from the capabilities `/api/show` lists, else (older
|
|
20
|
+
* servers) from its template and name, with decisions from `decisionModels`.
|
|
21
|
+
*
|
|
22
|
+
* @param model The model's name
|
|
23
|
+
* @param show What `/api/show` says about it
|
|
24
|
+
* @param decisionModels Models that answer decisions, when `/api/show` lists no capabilities
|
|
25
|
+
*/
|
|
26
|
+
export function capabilitiesOf(model, show, decisionModels = []) {
|
|
27
|
+
const listed = show.capabilities;
|
|
28
|
+
const capabilities = new Set();
|
|
29
|
+
if (listed) {
|
|
30
|
+
if (listed.includes('completion')) {
|
|
31
|
+
capabilities.add('chat').add('streaming').add('json');
|
|
32
|
+
}
|
|
33
|
+
// Ollama's embedding endpoints take text only, so no model gets
|
|
34
|
+
// `imageEmbedding`, even one that lists `vision`
|
|
35
|
+
if (listed.includes('embedding')) {
|
|
36
|
+
capabilities.add('embedding');
|
|
37
|
+
}
|
|
38
|
+
if (listed.includes('decision')) {
|
|
39
|
+
capabilities.add('decision');
|
|
40
|
+
}
|
|
41
|
+
if (listed.includes('vision')) {
|
|
42
|
+
capabilities.add('vision');
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
else if (decisionModels.includes(model) || decisionModels.includes(model.replace(/:latest$/, ''))) {
|
|
46
|
+
capabilities.add('decision');
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
capabilities.add('chat').add('streaming').add('json');
|
|
50
|
+
}
|
|
51
|
+
if (capabilities.has('chat')) {
|
|
52
|
+
if (takesTools(show)) {
|
|
53
|
+
capabilities.add('tools');
|
|
54
|
+
}
|
|
55
|
+
if (reasons(model, show)) {
|
|
56
|
+
capabilities.add('reasoning');
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return capabilities;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Ollama through its OpenAI-compatible API. `@aeye/openai` sends system
|
|
63
|
+
* messages with OpenAI's `developer` role, which Ollama's chat templates
|
|
64
|
+
* drop without a word, so they go to Ollama as `system`.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```typescript
|
|
68
|
+
* const ollama = new OllamaProvider({ keepAlive: '10m' });
|
|
69
|
+
* const ai = AI.with().providers({ ollama }).create();
|
|
70
|
+
* const { answers } = await ai.decide.get({
|
|
71
|
+
* input: 'The printer is on fire.',
|
|
72
|
+
* questions: { urgent: { type: 'predicate', instructions: 'Is this urgent?' } },
|
|
73
|
+
* }, { metadata: { model: 'nimble' } });
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export class OllamaProvider extends OpenAIProvider {
|
|
77
|
+
name = 'ollama';
|
|
78
|
+
// Ollama serves whatever models it has pulled: no model is assumed
|
|
79
|
+
defaults = {};
|
|
80
|
+
constructor(options = {}) {
|
|
81
|
+
super({ api: 'chat', ...options, apiKey: options.apiKey ?? 'ollama', baseURL: (options.baseURL ?? OLLAMA_BASE_URL).replace(/\/+$/, '') });
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Ollama's native API, for a config.
|
|
85
|
+
*/
|
|
86
|
+
api(config) {
|
|
87
|
+
const effective = { ...this.config, ...config };
|
|
88
|
+
return new OllamaApi(effective.baseURL, effective.fetch, effective.apiKey === 'ollama' ? undefined : effective.apiKey);
|
|
89
|
+
}
|
|
90
|
+
createClient(config) {
|
|
91
|
+
return new OpenAI({
|
|
92
|
+
apiKey: config.apiKey,
|
|
93
|
+
baseURL: `${(config.baseURL ?? OLLAMA_BASE_URL).replace(/\/+$/, '')}/v1`,
|
|
94
|
+
...(config.fetch ? { fetch: config.fetch } : {}),
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* The Chat Completions messages, each system one with the `system` role
|
|
99
|
+
* Ollama reads.
|
|
100
|
+
*/
|
|
101
|
+
async convertMessages(request, config) {
|
|
102
|
+
const messages = await super.convertMessages(request, config);
|
|
103
|
+
return messages.map((message) => (message.role === 'developer' ? { ...message, role: 'system' } : message));
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* The window the server serves a model with when its Modelfile sets no
|
|
107
|
+
* `num_ctx`.
|
|
108
|
+
*/
|
|
109
|
+
async unsetWindow(config) {
|
|
110
|
+
const effective = { ...this.config, ...config };
|
|
111
|
+
return unsetWindow(await this.api(effective).version(), effective.contextWindow, effective.maxContextWindow);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* The server's models, each with what it can do and the window it is
|
|
115
|
+
* served with. Decision models carry System One's limits.
|
|
116
|
+
*/
|
|
117
|
+
async listModels(config) {
|
|
118
|
+
const effective = { ...this.config, ...config };
|
|
119
|
+
const api = this.api(effective);
|
|
120
|
+
try {
|
|
121
|
+
const [tags, unset] = await Promise.all([api.tags(), this.unsetWindow(effective)]);
|
|
122
|
+
return await Promise.all(tags.models.map(async ({ name }) => {
|
|
123
|
+
const show = await api.show(name);
|
|
124
|
+
const capabilities = capabilitiesOf(name, show, effective.decisionModels);
|
|
125
|
+
return {
|
|
126
|
+
provider: this.name,
|
|
127
|
+
id: name,
|
|
128
|
+
name,
|
|
129
|
+
capabilities,
|
|
130
|
+
tier: 'efficient',
|
|
131
|
+
pricing: { text: { input: 0, output: 0 } },
|
|
132
|
+
contextWindow: servedWindow(show, unset),
|
|
133
|
+
...(capabilities.has('decision') ? OLLAMA_SYSTEM_ONE_LIMITS : {}),
|
|
134
|
+
metadata: { family: show.details?.family, size: show.details?.parameter_size },
|
|
135
|
+
};
|
|
136
|
+
}));
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
throw new ProviderError(this.name, 'Failed to list models', error instanceof Error ? error : undefined);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Typed answers from a System One model at `/v1/systemone`. A
|
|
144
|
+
* conversation goes in as chat messages, images as base64, and the
|
|
145
|
+
* config's `keepAlive` as `keep_alive` (the request's `extra` overrides
|
|
146
|
+
* it). A call over the model's limits (`maxQuestions`, `maxRequestBytes`,
|
|
147
|
+
* else Ollama's) is refused before it is sent, never split.
|
|
148
|
+
*
|
|
149
|
+
* @param request Decision request parameters
|
|
150
|
+
* @param ctx Context object
|
|
151
|
+
* @param config Optional configuration override
|
|
152
|
+
* @returns Answers by question name
|
|
153
|
+
* @throws {DecisionLimitError} When the call is over a limit
|
|
154
|
+
*/
|
|
155
|
+
decide = async (request, ctx, config) => {
|
|
156
|
+
const run = this.prepare('decide', request, ctx, undefined, config, undefined, 'decision');
|
|
157
|
+
const state = typeof request.input === 'string' ? request.input : await this.convertMessages({ messages: request.input }, run.config);
|
|
158
|
+
const params = await toSystemOneParams(run.model.id, state, request, run.config.keepAlive === undefined ? {} : { keep_alive: run.config.keepAlive });
|
|
159
|
+
checkDecisionLimits({
|
|
160
|
+
id: run.model.id,
|
|
161
|
+
maxQuestions: run.modelInfo?.maxQuestions ?? OLLAMA_SYSTEM_ONE_LIMITS.maxQuestions,
|
|
162
|
+
maxRequestBytes: run.modelInfo?.maxRequestBytes ?? OLLAMA_SYSTEM_ONE_LIMITS.maxRequestBytes,
|
|
163
|
+
}, Object.keys(params.questions).length, systemOneTextBytes(params));
|
|
164
|
+
const result = await this.send('decide', run, request, params, (signal) => run.client.post('/systemone', { body: params, signal }));
|
|
165
|
+
return this.finish('decide', run, request, params, {
|
|
166
|
+
answers: fromSystemOneAnswers(result.answers),
|
|
167
|
+
model: run.model,
|
|
168
|
+
usage: { text: { input: result.usage.input_tokens, output: result.usage.output_tokens || undefined } },
|
|
169
|
+
});
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=ollama.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ollama.js","sourceRoot":"","sources":["../src/ollama.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE/C,OAAO,EAAsB,oBAAoB,EAAqB,cAAc,EAAE,aAAa,EAA0B,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACzL,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,SAAS,EAAmB,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,M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AAC,QAAQ,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE;YACjD,OAAO,EAAE,oBAAoB,CAAC,MAAM,CAAC,OAAO,CAAC;YAC7C,KAAK,EAAE,GAAG,CAAC,KAAK;YAChB,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,aAAa,IAAI,SAAS,EAAE,EAAE;SACvG,CAAC,CAAC;IACL,CAAC,CAAA;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,72 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aeye/ollama",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.8.1",
|
|
4
|
+
"description": "@aeye Ollama - local and cloud Ollama models for @aeye: chat, embeddings, and System One decisions",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"require": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"default": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"default": "./dist/index.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsc",
|
|
23
|
+
"test": "jest",
|
|
24
|
+
"test:unit": "jest --testPathIgnorePatterns=__integration__",
|
|
25
|
+
"test:integration": "jest --testPathPattern=__integration__",
|
|
26
|
+
"test:coverage": "jest --coverage --testPathIgnorePatterns=__integration__",
|
|
27
|
+
"test:watch": "jest --watch",
|
|
28
|
+
"clean": "rimraf dist tsconfig.tsbuildinfo",
|
|
29
|
+
"typecheck": "tsc --noEmit"
|
|
30
|
+
},
|
|
31
|
+
"keywords": [
|
|
32
|
+
"ai",
|
|
33
|
+
"ollama",
|
|
34
|
+
"typescript",
|
|
35
|
+
"local-llm"
|
|
36
|
+
],
|
|
37
|
+
"author": "ClickerMonkey",
|
|
38
|
+
"license": "GPL-3.0",
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "https://github.com/ClickerMonkey/aeye.git",
|
|
42
|
+
"directory": "packages/ollama"
|
|
43
|
+
},
|
|
44
|
+
"files": [
|
|
45
|
+
"dist",
|
|
46
|
+
"README.md",
|
|
47
|
+
"LICENSE",
|
|
48
|
+
"aeye-*.md"
|
|
49
|
+
],
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"@aeye/ai": "^0.8.1",
|
|
52
|
+
"@aeye/core": "^0.8.1",
|
|
53
|
+
"@aeye/openai": "^0.8.1",
|
|
54
|
+
"openai": "^7.45.1"
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"@types/jest": "^30.0.0",
|
|
58
|
+
"jest": "^30.2.0",
|
|
59
|
+
"ts-jest": "^29.4.5",
|
|
60
|
+
"typescript": "^5.9.3"
|
|
61
|
+
},
|
|
62
|
+
"publishConfig": {
|
|
63
|
+
"access": "public"
|
|
64
|
+
},
|
|
65
|
+
"engines": {
|
|
66
|
+
"node": ">=22.0.0"
|
|
67
|
+
},
|
|
68
|
+
"homepage": "https://github.com/ClickerMonkey/aeye#readme",
|
|
69
|
+
"bugs": {
|
|
70
|
+
"url": "https://github.com/ClickerMonkey/aeye/issues"
|
|
71
|
+
}
|
|
72
|
+
}
|