Skip to content

Commit d643a67

Browse files
authored
Fix alias file path (#1829)
1 parent e3f74cd commit d643a67

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

ts/packages/azure-ai-foundry/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
],
2323
"scripts": {
2424
"build": "npm run tsc",
25+
"postbuild": "copyfiles -f ../../examples/websiteAliases/cache/phrases.json dist",
2526
"clean": "rimraf --glob dist *.tsbuildinfo *.done.build.log",
2627
"prettier": "prettier --check . --ignore-path ../../.prettierignore",
2728
"prettier:fix": "prettier --write . --ignore-path ../../prettierignore",
@@ -46,6 +47,7 @@
4647
"@types/async": "^3.2.24",
4748
"@types/debug": "^4.1.12",
4849
"@types/jest": "^29.5.7",
50+
"copyfiles": "^2.4.1",
4951
"dotenv": "^16.3.1",
5052
"jest": "^29.7.0",
5153
"rimraf": "^6.0.1",

ts/packages/azure-ai-foundry/src/urlResolver.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ import {
1414
} from "@azure/ai-agents";
1515
import registerDebug from "debug";
1616
import { 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";
1820
import { Result } from "typechat";
1921
import * as wikipediaSchemas from "./wikipediaSchemas.js";
2022
import * as wikipedia from "./wikipedia.js";
@@ -469,6 +471,11 @@ export async function resolveURLWithWikipedia(
469471
*/
470472
export 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

ts/pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)