From 69114467d7ffdaa71d7a43e1ba3fd04eed3bbfec Mon Sep 17 00:00:00 2001 From: pelikhan Date: Fri, 29 Nov 2024 18:02:03 -0800 Subject: [PATCH 1/2] note about min version of lmstudio --- .../content/docs/getting-started/configuration.mdx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/src/content/docs/getting-started/configuration.mdx b/docs/src/content/docs/getting-started/configuration.mdx index 4b8199cda..14d5754a5 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 From 11e3007c54a42fc000378124e379c7b55720a95b Mon Sep 17 00:00:00 2001 From: pelikhan Date: Fri, 29 Nov 2024 18:10:09 -0800 Subject: [PATCH 2/2] expose scope in math eval --- packages/core/src/math.ts | 6 +++--- packages/core/src/parsers.ts | 4 ++-- packages/core/src/types/prompt_template.d.ts | 6 +++++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/core/src/math.ts b/packages/core/src/math.ts index 49c0332fa..30523f178 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 1fb4467ef..52b43b9cb 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 281669729..8b4b59000 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