Fix web search
This commit is contained in:
@@ -8,6 +8,18 @@ class ModelServiceError extends Error {
|
||||
}
|
||||
}
|
||||
|
||||
export function buildRuntimeDateContext(now = new Date()) {
|
||||
const currentDateTime = now.toISOString();
|
||||
return {
|
||||
role: "system",
|
||||
content: [
|
||||
"SERVER RUNTIME CONTEXT (application instruction):",
|
||||
`Current date and time: ${currentDateTime}`,
|
||||
`Current date (ISO): ${currentDateTime.slice(0, 10)}. Treat this server-provided date as authoritative for date comparisons.`
|
||||
].join("\n")
|
||||
};
|
||||
}
|
||||
|
||||
export function createModelService(config, overrides = {}) {
|
||||
const modelState = new Map();
|
||||
let modelsCache = null;
|
||||
@@ -33,6 +45,7 @@ export function createModelService(config, overrides = {}) {
|
||||
modelState.delete(model);
|
||||
});
|
||||
}, config.modelUnloadAfterMs);
|
||||
state.timer.unref?.();
|
||||
};
|
||||
|
||||
const withTimeout = async (timeoutMs, callback, externalSignal = null) => {
|
||||
@@ -106,7 +119,9 @@ export function createModelService(config, overrides = {}) {
|
||||
if (generation.responseLength != null) options.num_predict = generation.responseLength;
|
||||
return {
|
||||
model,
|
||||
messages: messagesPayload,
|
||||
// This is added at request construction so every Ollama operation (chat,
|
||||
// retries, roleplay openers, and summaries) receives runtime date context.
|
||||
messages: [buildRuntimeDateContext(), ...messagesPayload],
|
||||
stream: true,
|
||||
...(Object.keys(options).length ? {options} : {})
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user