Comparing version 0.1.0 to 0.1.1
@@ -61,16 +61,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
const chunk = _c; | ||
const res = JSON.parse(chunk.toString()); | ||
if (res.done) { | ||
return yield __await({ | ||
model: res.model, | ||
createdAt: new Date(res.created_at), | ||
context: res.context, | ||
totalDuration: res.total_duration, | ||
loadDuration: res.load_duration, | ||
promptEvalCount: res.prompt_eval_count, | ||
evalCount: res.eval_count, | ||
evalDuration: res.eval_duration | ||
}); | ||
const messages = chunk.toString().split("\n").filter(s => s.length !== 0); | ||
for (const message of messages) { | ||
const res = JSON.parse(message); | ||
if (res.done) { | ||
return yield __await({ | ||
model: res.model, | ||
createdAt: new Date(res.created_at), | ||
context: res.context, | ||
totalDuration: res.total_duration, | ||
loadDuration: res.load_duration, | ||
promptEvalCount: res.prompt_eval_count, | ||
evalCount: res.eval_count, | ||
evalDuration: res.eval_duration | ||
}); | ||
} | ||
yield yield __await(res.response); | ||
} | ||
yield yield __await(res.response); | ||
} | ||
@@ -77,0 +80,0 @@ finally { |
{ | ||
"type": "module", | ||
"name": "ollama", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Interface with an ollama instance over HTTP.", | ||
@@ -6,0 +6,0 @@ "main": "dist/index.js", |
@@ -1,2 +0,2 @@ | ||
# node-ollama | ||
# ollama | ||
Interface with an ollama instance over HTTP. | ||
@@ -3,0 +3,0 @@ |
@@ -45,18 +45,22 @@ import * as utils from "./utils.js"; | ||
for await (const chunk of response.body) { | ||
const res: GenerateResponse | GenerateResponseEnd = JSON.parse(chunk.toString()); | ||
const messages = chunk.toString().split("\n").filter(s => s.length !== 0); | ||
if (res.done) { | ||
return { | ||
model: res.model, | ||
createdAt: new Date(res.created_at), | ||
context: res.context, | ||
totalDuration: res.total_duration, | ||
loadDuration: res.load_duration, | ||
promptEvalCount: res.prompt_eval_count, | ||
evalCount: res.eval_count, | ||
evalDuration: res.eval_duration | ||
}; | ||
for (const message of messages) { | ||
const res: GenerateResponse | GenerateResponseEnd = JSON.parse(message); | ||
if (res.done) { | ||
return { | ||
model: res.model, | ||
createdAt: new Date(res.created_at), | ||
context: res.context, | ||
totalDuration: res.total_duration, | ||
loadDuration: res.load_duration, | ||
promptEvalCount: res.prompt_eval_count, | ||
evalCount: res.eval_count, | ||
evalDuration: res.eval_duration | ||
}; | ||
} | ||
yield res.response; | ||
} | ||
yield res.response; | ||
} | ||
@@ -63,0 +67,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
63122
554