@@ -14,7 +14,9 @@ import {
1414} from "@azure/ai-agents" ;
1515import registerDebug from "debug" ;
1616import { ChatModelWithStreaming , CompletionSettings , openai } from "aiclient" ;
17- import { readFileSync } from "fs" ;
17+ import { readFileSync } from "node:fs" ;
18+ import path from "node:path" ;
19+ import { fileURLToPath } from "node:url" ;
1820import { Result } from "typechat" ;
1921import * as wikipediaSchemas from "./wikipediaSchemas.js" ;
2022import * as wikipedia from "./wikipedia.js" ;
@@ -469,6 +471,11 @@ export async function resolveURLWithWikipedia(
469471 */
470472export let keyWordsToSites : Record < string , string [ ] | undefined > | undefined ;
471473
474+ // Build will copy the file from ../../examples/websiteAliases/cache/phrases.json
475+ const phrasesFile = path . join (
476+ path . dirname ( fileURLToPath ( import . meta. url ) ) ,
477+ "phrases.json" ,
478+ ) ;
472479/**
473480 * Resolves a URL by keyword using the URL resolver agent.
474481 * @param keyword The keyword to resolve.
@@ -478,12 +485,7 @@ export function resolveURLByKeyword(
478485 keyword : string ,
479486) : string [ ] | undefined | null {
480487 if ( ! keyWordsToSites ) {
481- const phrasesToSites = JSON . parse (
482- readFileSync (
483- "../../examples/websiteAliases/cache/phrases.json" ,
484- "utf-8" ,
485- ) ,
486- ) ;
488+ const phrasesToSites = JSON . parse ( readFileSync ( phrasesFile , "utf-8" ) ) ;
487489 keyWordsToSites = phrasesToSites ;
488490 }
489491
0 commit comments