fix: JSON utils unit tests

Travis Fischer 2023-06-14 22:59:58 -07:00
rodzic 4a2560432f
commit cb63718743
3 zmienionych plików z 8 dodań i 4 usunięć

Wyświetl plik

@ -1,3 +1,4 @@
import * as types from '@/types'
import { Agentic } from '@/agentic'
import { BaseTask } from '@/task'
@ -257,7 +258,11 @@ export abstract class HumanFeedbackMechanism<
}
}
export function withHumanFeedback<TInput, TOutput, V extends HumanFeedbackType>(
export function withHumanFeedback<
TInput extends void | types.JsonObject,
TOutput extends types.JsonObject,
V extends HumanFeedbackType
>(
task: BaseTask<TInput, TOutput>,
options: HumanFeedbackOptions<V, TOutput> = {}
) {

Wyświetl plik

@ -4,7 +4,6 @@ import { ZodType } from 'zod'
import * as errors from './errors'
import * as types from './types'
import type { Agentic } from './agentic'
import { defaultLogger } from './logger'
import { defaultIDGeneratorFn, isValidTaskIdentifier } from './utils'
/**

Wyświetl plik

@ -9,7 +9,7 @@ import * as types from './types'
* @returns extracted JSON object string, or `undefined` if no JSON object is found
*/
export function extractJSONObjectFromString(text: string): string | undefined {
return text.match(/\{(.|\n)*\}/gm)?.[0]
return text.match(/\{([^}]|\n)*\}/gm)?.[0]
}
/**
@ -19,7 +19,7 @@ export function extractJSONObjectFromString(text: string): string | undefined {
* @returns extracted JSON array string, or `undefined` if no JSON array is found
*/
export function extractJSONArrayFromString(text: string): string | undefined {
return text.match(/\[(.|\n)*\]/gm)?.[0]
return text.match(/\[([^\]]|\n)*\]/gm)?.[0]
}
/**