Skip to content

Commit

Permalink
use eval for .js files
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Jun 30, 2024
1 parent 4698ce7 commit 353df6f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/core/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const XLSX_REGEX = /\.xlsx$/i
export const DOCX_REGEX = /\.docx$/i
export const PDF_REGEX = /\.pdf$/i
export const MDX_REGEX = /\.mdx$/i
export const MJS_REGEX = /\.mjs$/i
export const TOOL_NAME = "GenAIScript"
export const SERVER_PORT = 8003
export const CLIENT_RECONNECT_DELAY = 2000
Expand Down
10 changes: 8 additions & 2 deletions packages/core/src/expander.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import { Project, PromptScript } from "./ast"
import { assert, normalizeFloat, normalizeInt, unique } from "./util"
import { MarkdownTrace } from "./trace"
import { errorMessage, isCancelError } from "./error"
import { MAX_TOOL_CALLS, MODEL_PROVIDER_AICI, SYSTEM_FENCE } from "./constants"
import {
MAX_TOOL_CALLS,
MJS_REGEX,
MODEL_PROVIDER_AICI,
SYSTEM_FENCE,
} from "./constants"
import { PromptImage, renderPromptNode } from "./promptdom"
import { GenerationOptions, createPromptContext } from "./promptcontext"
import { evalPrompt } from "./evalprompt"
Expand Down Expand Up @@ -106,7 +111,8 @@ async function callExpander(
}

try {
if (r.filename) await importPrompt(ctx, r, { logCb, trace })
if (MJS_REGEX.test(r.filename))
await importPrompt(ctx, r, { logCb, trace })
else {
await evalPrompt(ctx, r, {
sourceMaps: true,
Expand Down

0 comments on commit 353df6f

Please sign in to comment.