nuxt-ollama 1.0.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 +137 -0
- package/dist/module.cjs +5 -0
- package/dist/module.d.mts +8 -0
- package/dist/module.d.ts +8 -0
- package/dist/module.json +12 -0
- package/dist/module.mjs +33 -0
- package/dist/runtime/composables/useOllama.d.ts +1 -0
- package/dist/runtime/composables/useOllama.js +1 -0
- package/dist/runtime/server/tsconfig.json +3 -0
- package/dist/runtime/server/utils/useOllama.d.ts +1 -0
- package/dist/runtime/server/utils/useOllama.js +1 -0
- package/dist/runtime/useOllama.d.ts +2 -0
- package/dist/runtime/useOllama.js +9 -0
- package/dist/types.d.mts +1 -0
- package/dist/types.d.ts +1 -0
- package/package.json +54 -0
package/README.md
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# Nuxt Ollama
|
|
2
|
+
|
|
3
|
+
[![npm version][npm-version-src]][npm-version-href]
|
|
4
|
+
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
|
5
|
+
[![License][license-src]][license-href]
|
|
6
|
+
[![Nuxt][nuxt-src]][nuxt-href]
|
|
7
|
+
|
|
8
|
+
Simple integration of the official Ollama JavaScript Library for your Nuxt application.
|
|
9
|
+
|
|
10
|
+
- [✨ Release Notes](/CHANGELOG.md)
|
|
11
|
+
|
|
12
|
+
<!-- - [🏀 Online playground](https://stackblitz.com/github/jericho/nuxt-ollama?file=playground%2Fapp.vue) -->
|
|
13
|
+
<!-- - [📖 Documentation](https://example.com) -->
|
|
14
|
+
|
|
15
|
+
## Features
|
|
16
|
+
|
|
17
|
+
- Vue 3 composable
|
|
18
|
+
- Server utils
|
|
19
|
+
|
|
20
|
+
usage on pages or server side:
|
|
21
|
+
```ts
|
|
22
|
+
const ollama = useOllama()
|
|
23
|
+
|
|
24
|
+
const response = await ollama.chat({
|
|
25
|
+
model: 'llama3.1',
|
|
26
|
+
messages: [{ role: 'user', content: 'Why is the sky blue?' }],
|
|
27
|
+
})
|
|
28
|
+
console.log(response.message.content)
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
See official [Ollama JavaScript Library documentation](https://github.com/ollama/ollama-js) for more information or examples.
|
|
32
|
+
|
|
33
|
+
## Settings
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
// nuxt.config.ts
|
|
37
|
+
export default defineNuxtConfig({
|
|
38
|
+
ollama: {
|
|
39
|
+
protocol: 'http', // or 'https'
|
|
40
|
+
host: 'localhost', //domain or ip address
|
|
41
|
+
port: 11434, // port
|
|
42
|
+
proxy: false, // use proxy
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Quick Setup
|
|
48
|
+
|
|
49
|
+
Install the module to your Nuxt application with one command: *(Pending module approval on Nuxt Module)*
|
|
50
|
+
```bash
|
|
51
|
+
npx nuxi module add nuxt-ollama
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
<details>
|
|
55
|
+
<summary>Or install it with your favorite package manager:</summary>
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# NPM:
|
|
59
|
+
npm install nuxt-ollama
|
|
60
|
+
|
|
61
|
+
# PNPM:
|
|
62
|
+
pnpm add nuxt-ollama
|
|
63
|
+
|
|
64
|
+
# Yarn:
|
|
65
|
+
yarn add nuxt-ollama
|
|
66
|
+
|
|
67
|
+
# Bun
|
|
68
|
+
bun add nuxt-ollama
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Add `nuxt-ollama` to the `modules` section of `nuxt.config.js`:
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
// nuxt.config.ts
|
|
75
|
+
export default {
|
|
76
|
+
modules: [
|
|
77
|
+
'nuxt-ollama',
|
|
78
|
+
],
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
</details>
|
|
82
|
+
|
|
83
|
+
That's it! You can now use Nuxt Ollama in your Nuxt app ✨
|
|
84
|
+
|
|
85
|
+
## Contribution
|
|
86
|
+
|
|
87
|
+
Contributions are welcome, feel free to open an issue or submit a pull request!
|
|
88
|
+
|
|
89
|
+
*guidelines coming soon*
|
|
90
|
+
|
|
91
|
+
<details>
|
|
92
|
+
<summary>Local development</summary>
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
# Install dependencies
|
|
96
|
+
bun install
|
|
97
|
+
|
|
98
|
+
# Generate type stubs
|
|
99
|
+
bun dev:prepare
|
|
100
|
+
|
|
101
|
+
# Develop with the playground
|
|
102
|
+
bun dev
|
|
103
|
+
|
|
104
|
+
# Build the playground
|
|
105
|
+
bun dev:build
|
|
106
|
+
|
|
107
|
+
# Run ESLint
|
|
108
|
+
bun lint
|
|
109
|
+
|
|
110
|
+
# Run Vitest
|
|
111
|
+
bun test
|
|
112
|
+
bun test:watch
|
|
113
|
+
|
|
114
|
+
# Release new version
|
|
115
|
+
bun release
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
</details>
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
<!-- Badges -->
|
|
122
|
+
|
|
123
|
+
[npm-version-src]: https://img.shields.io/npm/v/nuxt-ollama/latest.svg?style=flat&colorA=020420&colorB=00DC82
|
|
124
|
+
|
|
125
|
+
[npm-version-href]: https://npmjs.com/package/nuxt-ollama
|
|
126
|
+
|
|
127
|
+
[npm-downloads-src]: https://img.shields.io/npm/dm/nuxt-ollama.svg?style=flat&colorA=020420&colorB=00DC82
|
|
128
|
+
|
|
129
|
+
[npm-downloads-href]: https://npmjs.com/package/nuxt-ollama
|
|
130
|
+
|
|
131
|
+
[license-src]: https://img.shields.io/npm/l/nuxt-ollama.svg?style=flat&colorA=020420&colorB=00DC82
|
|
132
|
+
|
|
133
|
+
[license-href]: https://npmjs.com/package/nuxt-ollama
|
|
134
|
+
|
|
135
|
+
[nuxt-src]: https://img.shields.io/badge/Nuxt-020420?logo=nuxt.js
|
|
136
|
+
|
|
137
|
+
[nuxt-href]: https://nuxt.com
|
package/dist/module.cjs
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
import { OllamaOptions } from '~/src/types';
|
|
3
|
+
|
|
4
|
+
interface ModuleOptions extends OllamaOptions {
|
|
5
|
+
}
|
|
6
|
+
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
|
|
7
|
+
|
|
8
|
+
export { type ModuleOptions, _default as default };
|
package/dist/module.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
import { OllamaOptions } from '~/src/types';
|
|
3
|
+
|
|
4
|
+
interface ModuleOptions extends OllamaOptions {
|
|
5
|
+
}
|
|
6
|
+
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
|
|
7
|
+
|
|
8
|
+
export { type ModuleOptions, _default as default };
|
package/dist/module.json
ADDED
package/dist/module.mjs
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { defineNuxtModule, createResolver, addImports, addServerImportsDir } from '@nuxt/kit';
|
|
2
|
+
import { defu } from 'defu';
|
|
3
|
+
|
|
4
|
+
const module = defineNuxtModule({
|
|
5
|
+
meta: {
|
|
6
|
+
name: "nuxt-ollama",
|
|
7
|
+
configKey: "ollama",
|
|
8
|
+
compatibility: {
|
|
9
|
+
nuxt: ">=3.12"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
// Default configuration options of the Nuxt module
|
|
13
|
+
defaults: {
|
|
14
|
+
protocol: "http",
|
|
15
|
+
host: "localhost",
|
|
16
|
+
port: 11434,
|
|
17
|
+
proxy: false
|
|
18
|
+
},
|
|
19
|
+
setup(_options, _nuxt) {
|
|
20
|
+
const resolver = createResolver(import.meta.url);
|
|
21
|
+
const runtimeConfig = _nuxt.options.runtimeConfig;
|
|
22
|
+
const currentConfig = runtimeConfig.public.ollama ?? {};
|
|
23
|
+
runtimeConfig.public.ollama = defu(currentConfig, _options);
|
|
24
|
+
addImports({
|
|
25
|
+
name: "useOllama",
|
|
26
|
+
as: "useOllama",
|
|
27
|
+
from: resolver.resolve("./runtime/composables/useOllama")
|
|
28
|
+
});
|
|
29
|
+
addServerImportsDir(resolver.resolve("./runtime/server/utils"));
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
export { module as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useOllama } from '../useOllama.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useOllama } from "../useOllama.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useOllama } from '../../useOllama.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useOllama } from "../../useOllama.js";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Ollama } from "ollama";
|
|
2
|
+
import { useRuntimeConfig } from "#imports";
|
|
3
|
+
export function useOllama() {
|
|
4
|
+
const options = useRuntimeConfig().public.ollama;
|
|
5
|
+
return new Ollama({
|
|
6
|
+
host: `${options.protocol}://${options.host}:${options.port}`,
|
|
7
|
+
proxy: options.proxy
|
|
8
|
+
});
|
|
9
|
+
}
|
package/dist/types.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { type ModuleOptions, default } from './module.js'
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { type ModuleOptions, default } from './module'
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "nuxt-ollama",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Easy ollama integration for Nuxt",
|
|
5
|
+
"repository": "jericho1060/nuxt-ollama",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"author": {
|
|
9
|
+
"name": "Jericho",
|
|
10
|
+
"url": "https://jericho.dev"
|
|
11
|
+
},
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/types.d.ts",
|
|
15
|
+
"import": "./dist/module.mjs",
|
|
16
|
+
"require": "./dist/module.cjs"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"main": "./dist/module.cjs",
|
|
20
|
+
"types": "./dist/types.d.ts",
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"prepack": "nuxt-module-build build",
|
|
26
|
+
"dev": "nuxi dev playground",
|
|
27
|
+
"dev:build": "nuxi build playground",
|
|
28
|
+
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
|
|
29
|
+
"release": "npm run lint && npm run test && npm run prepack && changelogen --release && npm publish && git push --follow-tags",
|
|
30
|
+
"lint": "eslint .",
|
|
31
|
+
"test": "vitest run",
|
|
32
|
+
"test:watch": "vitest watch",
|
|
33
|
+
"test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@nuxt/kit": "^3.12.4",
|
|
37
|
+
"defu": "^6.1.4",
|
|
38
|
+
"ollama": "^0.5.6"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@nuxt/devtools": "^1.3.9",
|
|
42
|
+
"@nuxt/eslint-config": "^0.3.13",
|
|
43
|
+
"@nuxt/module-builder": "^0.8.1",
|
|
44
|
+
"@nuxt/schema": "^3.12.4",
|
|
45
|
+
"@nuxt/test-utils": "^3.13.1",
|
|
46
|
+
"@types/node": "^20.14.11",
|
|
47
|
+
"changelogen": "^0.5.5",
|
|
48
|
+
"eslint": "^9.7.0",
|
|
49
|
+
"nuxt": "^3.12.4",
|
|
50
|
+
"typescript": "latest",
|
|
51
|
+
"vitest": "^2.0.3",
|
|
52
|
+
"vue-tsc": "^2.0.26"
|
|
53
|
+
}
|
|
54
|
+
}
|