@workplane/adapter-ollama 0.3.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/dist/index.d.ts +10 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -0
- package/package.json +35 -0
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { writeFile } from "fs/promises";
|
|
3
|
+
import { join } from "path";
|
|
4
|
+
var ollamaAdapter = {
|
|
5
|
+
name: "ollama",
|
|
6
|
+
kind: "inference.batch",
|
|
7
|
+
async run(context, payload) {
|
|
8
|
+
const args = ["run", payload.model, payload.prompt];
|
|
9
|
+
const result = await context.exec("ollama", args, { cwd: context.workspacePath });
|
|
10
|
+
if (result.exitCode !== 0) {
|
|
11
|
+
throw new Error(`ollama failed with exit code ${result.exitCode}`);
|
|
12
|
+
}
|
|
13
|
+
const artifactsPath = await context.ensureWorkspace("artifacts");
|
|
14
|
+
const outputPath = join(artifactsPath, "inference-output.txt");
|
|
15
|
+
const output = `${result.stdout}${result.stderr}`.trim();
|
|
16
|
+
await writeFile(outputPath, output, "utf8");
|
|
17
|
+
await context.emitArtifact({
|
|
18
|
+
type: "inference.output",
|
|
19
|
+
name: "inference-output.txt",
|
|
20
|
+
path: outputPath,
|
|
21
|
+
metadata: { model: payload.model, adapter: "ollama" }
|
|
22
|
+
});
|
|
23
|
+
if (payload.inputFile) {
|
|
24
|
+
await context.log("system", `inputFile ${payload.inputFile} noted (batch file expansion not implemented)`, "inference");
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
export {
|
|
29
|
+
ollamaAdapter
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { writeFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport type { WorkAdapter } from \"@workplane/adapter-sdk\";\n\nexport interface OllamaPayload {\n model: string;\n prompt: string;\n inputFile?: string;\n}\n\nexport const ollamaAdapter: WorkAdapter<OllamaPayload> = {\n name: \"ollama\",\n kind: \"inference.batch\",\n async run(context, payload) {\n const args = [\"run\", payload.model, payload.prompt];\n const result = await context.exec(\"ollama\", args, { cwd: context.workspacePath });\n if (result.exitCode !== 0) {\n throw new Error(`ollama failed with exit code ${result.exitCode}`);\n }\n\n const artifactsPath = await context.ensureWorkspace(\"artifacts\");\n const outputPath = join(artifactsPath, \"inference-output.txt\");\n const output = `${result.stdout}${result.stderr}`.trim();\n await writeFile(outputPath, output, \"utf8\");\n await context.emitArtifact({\n type: \"inference.output\",\n name: \"inference-output.txt\",\n path: outputPath,\n metadata: { model: payload.model, adapter: \"ollama\" },\n });\n\n if (payload.inputFile) {\n await context.log(\"system\", `inputFile ${payload.inputFile} noted (batch file expansion not implemented)`, \"inference\");\n }\n },\n};\n"],"mappings":";AAAA,SAAS,iBAAiB;AAC1B,SAAS,YAAY;AASd,IAAM,gBAA4C;AAAA,EACvD,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM,IAAI,SAAS,SAAS;AAC1B,UAAM,OAAO,CAAC,OAAO,QAAQ,OAAO,QAAQ,MAAM;AAClD,UAAM,SAAS,MAAM,QAAQ,KAAK,UAAU,MAAM,EAAE,KAAK,QAAQ,cAAc,CAAC;AAChF,QAAI,OAAO,aAAa,GAAG;AACzB,YAAM,IAAI,MAAM,gCAAgC,OAAO,QAAQ,EAAE;AAAA,IACnE;AAEA,UAAM,gBAAgB,MAAM,QAAQ,gBAAgB,WAAW;AAC/D,UAAM,aAAa,KAAK,eAAe,sBAAsB;AAC7D,UAAM,SAAS,GAAG,OAAO,MAAM,GAAG,OAAO,MAAM,GAAG,KAAK;AACvD,UAAM,UAAU,YAAY,QAAQ,MAAM;AAC1C,UAAM,QAAQ,aAAa;AAAA,MACzB,MAAM;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,MACN,UAAU,EAAE,OAAO,QAAQ,OAAO,SAAS,SAAS;AAAA,IACtD,CAAC;AAED,QAAI,QAAQ,WAAW;AACrB,YAAM,QAAQ,IAAI,UAAU,aAAa,QAAQ,SAAS,iDAAiD,WAAW;AAAA,IACxH;AAAA,EACF;AACF;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@workplane/adapter-ollama",
|
|
3
|
+
"version": "0.3.1",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/MindStaq/workplane.git"
|
|
10
|
+
},
|
|
11
|
+
"main": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"import": "./dist/index.js",
|
|
16
|
+
"types": "./dist/index.d.ts"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"README.md"
|
|
22
|
+
],
|
|
23
|
+
"sideEffects": false,
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public",
|
|
26
|
+
"registry": "https://registry.npmjs.org/"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"ollama": "^0.5.16",
|
|
30
|
+
"@workplane/adapter-sdk": "0.3.1"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "tsup"
|
|
34
|
+
}
|
|
35
|
+
}
|