Skip to content

Commit 217dc3b

Browse files
committed
Ultra permissive config schema - 0.9.2
1 parent fc26b87 commit 217dc3b

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "promptl-ai",
3-
"version": "0.9.1",
3+
"version": "0.9.2",
44
"author": "Latitude Data",
55
"license": "MIT",
66
"description": "Compiler for PromptL, the prompt language",

src/compiler/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ import {
55
} from '$promptl/providers'
66
import { ProviderConversation } from '$promptl/providers/adapter'
77
import { ConversationMetadata, Message } from '$promptl/types'
8-
import { z } from 'zod'
98

109
import { Chain } from './chain'
11-
import { Scan } from './scan'
10+
import { Scan, ScanSchema } from './scan'
1211
import type { CompileOptions, Document, ReferencePromptFn } from './types'
1312
import { Fragment } from '$promptl/parser/interfaces'
1413

@@ -52,7 +51,7 @@ export function scan({
5251
fullPath?: string
5352
referenceFn?: ReferencePromptFn
5453
withParameters?: string[]
55-
configSchema?: z.ZodTypeAny
54+
configSchema?: ScanSchema
5655
requireConfig?: boolean
5756
}): Promise<ConversationMetadata> {
5857
return new Scan({

src/compiler/scan.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { z } from 'zod'
12
import sha256 from 'fast-sha256'
23

34
import {
@@ -26,7 +27,6 @@ import {
2627
} from '$promptl/types'
2728
import { Node as LogicalExpression } from 'estree'
2829
import yaml, { Node as YAMLItem } from 'yaml'
29-
import { z } from 'zod'
3030

3131
import { updateScopeContextForNode } from './logic'
3232
import { ScopeContext } from './scope'
@@ -49,6 +49,8 @@ function copyScopeContext(scopeContext: ScopeContext): ScopeContext {
4949
}
5050
}
5151

52+
export type ScanSchema = unknown
53+
5254
export class Scan {
5355
includedPromptPaths: Set<string>
5456

@@ -57,7 +59,7 @@ export class Scan {
5759
private fullPath: string
5860
private withParameters?: string[]
5961
private requireConfig: boolean
60-
private configSchema?: z.ZodTypeAny
62+
private configSchema?: ScanSchema
6163
private builtins: Record<string, () => any>
6264

6365
private config?: Config
@@ -86,7 +88,7 @@ export class Scan {
8688
document: Document
8789
referenceFn?: ReferencePromptFn
8890
withParameters?: string[]
89-
configSchema?: z.ZodType
91+
configSchema?: ScanSchema
9092
requireConfig?: boolean
9193
serialized?: Fragment
9294
}) {
@@ -315,8 +317,9 @@ export class Scan {
315317
let parsedObj = {}
316318

317319
try {
320+
const configSchema = this.configSchema as z.ZodType
318321
parsedObj = parsedYaml.toJS() ?? {}
319-
this.configSchema?.parse(parsedObj)
322+
configSchema?.parse(parsedObj)
320323
} catch (err) {
321324
if (isZodError(err)) {
322325
err.errors.forEach((error) => {

0 commit comments

Comments
 (0)