diff --git a/docs/src/content/docs/getting-started/configuration.mdx b/docs/src/content/docs/getting-started/configuration.mdx index 4b8199cda6..14d5754a5e 100644 --- a/docs/src/content/docs/getting-started/configuration.mdx +++ b/docs/src/content/docs/getting-started/configuration.mdx @@ -1101,7 +1101,13 @@ docker stop ollama && docker rm ollama ## LMStudio The `lmstudio` provider connects to the [LMStudio](https://lmstudio.ai/) headless server. -and allows to run local LLMs. +and allows to run local LLMs. + +:::note + +LMStudio 0.3.5 beta 4 or later is required. + +::: @@ -1155,6 +1161,10 @@ script({ }) ``` +### LMStudio and Hugging Face Models + +Follow [this guide](https://huggingface.co/blog/yagilb/lms-hf) to load Hugging Face models into LMStudio. + ## LocalAI [LocalAI](https://localai.io/) act as a drop-in replacement REST API that’s compatible diff --git a/packages/core/src/math.ts b/packages/core/src/math.ts index 49c0332fa8..30523f178b 100644 --- a/packages/core/src/math.ts +++ b/packages/core/src/math.ts @@ -16,10 +16,10 @@ import { TraceOptions } from "./trace" */ export async function MathTryEvaluate( expr: string, - options?: { defaultValue?: number } & TraceOptions + options?: { scope?: object; defaultValue?: number } & TraceOptions ): Promise { // Destructuring options with defaults - const { trace, defaultValue } = options || {} + const { trace, defaultValue, scope } = options || {} try { // Return defaultValue if expression is empty @@ -29,7 +29,7 @@ export async function MathTryEvaluate( const { evaluate } = await import("mathjs") // Evaluate the expression and return the result - const res = evaluate(expr) + const res = evaluate(expr, scope) return res } catch (e) { // Log an error if tracing is enabled diff --git a/packages/core/src/parsers.ts b/packages/core/src/parsers.ts index 1fb4467efe..52b43b9cbf 100644 --- a/packages/core/src/parsers.ts +++ b/packages/core/src/parsers.ts @@ -105,8 +105,8 @@ export async function createParsers(options: { await resolveFileContent(file, { trace }) return await treeSitterQuery(file, query, { trace }) }, - math: async (expression) => - await MathTryEvaluate(expression, { trace }), + math: async (expression, scope) => + await MathTryEvaluate(expression, { scope, trace }), validateJSON: (schema, content) => validateJSONWithSchema(content, schema, { trace }), mustache: (file, args) => { diff --git a/packages/core/src/types/prompt_template.d.ts b/packages/core/src/types/prompt_template.d.ts index 2cb840bea3..ad13173b72 100644 --- a/packages/core/src/types/prompt_template.d.ts +++ b/packages/core/src/types/prompt_template.d.ts @@ -1477,8 +1477,12 @@ interface Parsers { /** * Parses and evaluates a math expression * @param expression math expression compatible with mathjs + * @param scope object to read/write variables */ - math(expression: string): Promise + math( + expression: string, + scope?: object + ): Promise /** * Using the JSON schema, validates the content