44import { CSVTryParse } from "./csv.js" ;
55import { filenameOrFileToContent , filenameOrFileToFilename , unfence } from "./unwrappers.js" ;
66import { JSON5TryParse , JSONLLMTryParse } from "./json5.js" ;
7- import { estimateTokens } from "./tokens.js" ;
87import { TOMLTryParse } from "./toml.js" ;
9- import { TraceOptions } from "./trace.js" ;
108import { YAMLTryParse } from "./yaml.js" ;
119import { DOCXTryParse } from "./docx.js" ;
1210import { frontmatterTryParse } from "./frontmatter.js" ;
@@ -24,15 +22,13 @@ import { host } from "./host.js";
2422import { unzip } from "./zip.js" ;
2523import { JSONLTryParse } from "./jsonl.js" ;
2624import { resolveFileContent } from "./file.js" ;
27- import { resolveTokenEncoder } from "./encoders.js" ;
2825import { mustacheRender } from "./mustache.js" ;
2926import { jinjaRender } from "./jinja.js" ;
3027import { llmifyDiff } from "./llmdiff.js" ;
3128import { tidyData } from "./tidy.js" ;
3229import { hash } from "./crypto.js" ;
3330import { GROQEvaluate } from "./groq.js" ;
3431import { unthink } from "./think.js" ;
35- import { CancellationOptions } from "./cancellation.js" ;
3632import { dedent } from "./indent.js" ;
3733import { vttSrtParse } from "./transcription.js" ;
3834import { encodeIDs } from "./cleaners.js" ;
@@ -84,14 +80,7 @@ import type { Parsers, WorkspaceFile } from "./types.js";
8480 * - dedent: Dedents indented text content.
8581 * - encodeIDs: Encodes identifiers for use in various operations.
8682 */
87- export async function createParsers (
88- options : {
89- model : string ;
90- } & TraceOptions &
91- CancellationOptions ,
92- ) : Promise < Parsers > {
93- const { trace, model, cancellationToken } = options ;
94- const { encode : encoder } = await resolveTokenEncoder ( model ) ;
83+ export function createParsers ( ) : Parsers {
9584 return Object . freeze < Parsers > ( {
9685 JSON5 : ( text , options ) =>
9786 tryValidateJSONWithSchema (
@@ -131,31 +120,15 @@ export async function createParsers(
131120 ) ,
132121 transcription : ( text ) => vttSrtParse ( filenameOrFileToContent ( text ) ) ,
133122 unzip : async ( file , options ) => await unzip ( await host . readFile ( file . filename ) , options ) ,
134- tokens : ( text ) => estimateTokens ( filenameOrFileToContent ( text ) , encoder ) ,
135123 fences : ( text ) => extractFenced ( filenameOrFileToContent ( text ) ) ,
136124 annotations : ( text ) => parseAnnotations ( filenameOrFileToContent ( text ) ) ,
137- HTMLToText : ( text , options ) =>
138- HTMLToText ( filenameOrFileToContent ( text ) , {
139- ...( options || { } ) ,
140- trace,
141- cancellationToken,
142- } ) ,
143- HTMLToMarkdown : ( text , options ) =>
144- HTMLToMarkdown ( filenameOrFileToContent ( text ) , {
145- ...( options || { } ) ,
146- trace,
147- cancellationToken,
148- } ) ,
125+ HTMLToText : ( text , options ) => HTMLToText ( filenameOrFileToContent ( text ) , options ) ,
126+ HTMLToMarkdown : ( text , options ) => HTMLToMarkdown ( filenameOrFileToContent ( text ) , options ) ,
149127 DOCX : async ( file , options ) => await DOCXTryParse ( file , options ) ,
150128 PDF : async ( file , options ) => {
151129 if ( ! file ) return { file : undefined , pages : [ ] , data : [ ] } ;
152- const opts = {
153- ...( options || { } ) ,
154- trace,
155- cancellationToken,
156- } ;
157130 const filename = typeof file === "string" ? file : file . filename ;
158- const { pages, content } = ( await parsePdf ( filename , opts ) ) || { } ;
131+ const { pages, content } = ( await parsePdf ( filename , options ) ) || { } ;
159132 return {
160133 file : < WorkspaceFile > {
161134 filename,
@@ -171,8 +144,8 @@ export async function createParsers(
171144 const res = await mermaidParse ( f ) ;
172145 return res ;
173146 } ,
174- math : async ( expression , scope ) => await MathTryEvaluate ( expression , { scope, trace } ) ,
175- validateJSON : ( schema , content ) => validateJSONWithSchema ( content , schema , { trace } ) ,
147+ math : async ( expression , scope ) => await MathTryEvaluate ( expression , { scope } ) ,
148+ validateJSON : ( schema , content ) => validateJSONWithSchema ( content , schema ) ,
176149 mustache : ( file , args ) => {
177150 const f = filenameOrFileToContent ( file ) ;
178151 return mustacheRender ( f , args ) ;
@@ -190,7 +163,7 @@ export async function createParsers(
190163 dedent : dedent ,
191164 encodeIDs : encodeIDs ,
192165 prompty : async ( file ) => {
193- await resolveFileContent ( file , { trace } ) ;
166+ await resolveFileContent ( file ) ;
194167 return promptyParse ( file . filename , file . content ) ;
195168 } ,
196169 } ) ;
0 commit comments