Skip to content

Commit

Permalink
removed builtin prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Feb 23, 2025
1 parent 00f3cfa commit 0cddad8
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 17 deletions.
2 changes: 0 additions & 2 deletions packages/core/src/ast.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/// <reference path="./types/prompt_template.d.ts" />
// Import necessary regular expressions for file type detection and host utilities
import {
BUILTIN_SCRIPT_PREFIX,
GENAI_ANYJS_REGEX,
GENAI_ANYTS_REGEX,
PROMPTY_REGEX,
Expand Down Expand Up @@ -70,7 +69,6 @@ export function collectFolders(prj: Project) {
(t) => t.filename && !PROMPTY_REGEX.test(t.filename)
)) {
const dirname = host.path.dirname(t.filename) // Get directory name from the filename
if ((dirname + "/").startsWith(BUILTIN_SCRIPT_PREFIX)) continue
const folder = folders[dirname] || (folders[dirname] = { dirname })
folder.js = folder.js || GENAI_ANYJS_REGEX.test(t.filename) // Check for presence of JS files
folder.ts = folder.ts || GENAI_ANYTS_REGEX.test(t.filename) // Check for presence of TS files
Expand Down
1 change: 0 additions & 1 deletion packages/core/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ export const TRANSCRIPTION_MODEL_ID = "transcription"
export const SPEECH_MODEL_ID = "speech"
export const DEFAULT_FENCE_FORMAT: FenceFormat = "xml"
export const DEFAULT_TEMPERATURE = 0.8
export const BUILTIN_SCRIPT_PREFIX = ".genaiscript/__system/"
export const CACHE_LLMREQUEST_PREFIX = "genaiscript/cache/llm/"
export const CACHE_AIREQUEST_TRACE_PREFIX = "genaiscript/cache/ai/trace/"
export const CACHE_AIREQUEST_TEXT_PREFIX = "genaiscript/cache/ai/text/"
Expand Down
9 changes: 3 additions & 6 deletions packages/core/src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { logVerbose, logWarn, strcmp } from "./util" // String comparison function
import { parsePromptScript } from "./template" // Function to parse scripts
import { readText } from "./fs" // Function to read text from a file
import { BUILTIN_SCRIPT_PREFIX, GENAI_ANYTS_REGEX } from "./constants" // Constants for MIME types and prefixes
import { GENAI_ANYTS_REGEX } from "./constants" // Constants for MIME types and prefixes
import { Project } from "./server/messages"
import { resolveSystems } from "./systems"
import { resolveScriptParametersSchema } from "./vars"
Expand Down Expand Up @@ -47,12 +47,9 @@ export async function parseProject(options: { scriptFiles: string[] }) {
const scripts: Record<string, PromptScript> = {}
for (const fn of systemPrompts) {
const f = join(genaisrcDir, fn)
const tmpl = await parsePromptScript(
BUILTIN_SCRIPT_PREFIX + fn,
await readText(f)
)
const tmpl = await parsePromptScript(f, await readText(f))
if (!tmpl) {
logWarn(`skipping invalid system scruipt: ${fn}`)
logWarn(`skipping invalid system script: ${fn}`)
continue
} // Skip if no template is parsed
prj.scripts.push(tmpl) // Add to project templates
Expand Down
10 changes: 2 additions & 8 deletions packages/core/src/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
* data types and formats.
*/

import {
BUILTIN_SCRIPT_PREFIX,
GENAI_ANY_REGEX,
PROMPTY_REGEX,
} from "./constants"
import { GENAI_ANY_REGEX, PROMPTY_REGEX } from "./constants"
import { host } from "./host"
import { JSON5TryParse } from "./json5"
import { humanize } from "inflection"
Expand Down Expand Up @@ -85,9 +81,7 @@ async function parsePromptTemplateCore(filename: string, content: string) {
),
jsSource: content,
} as PromptScript
if (!filename.startsWith(BUILTIN_SCRIPT_PREFIX)) {
r.filename = host.path.resolve(filename)
}
r.filename = host.path.resolve(filename)
const meta = parsePromptScriptMeta(r.jsSource)
Object.assign(r, meta)
return r
Expand Down

0 comments on commit 0cddad8

Please sign in to comment.