Skip to content

Commit

Permalink
fix: use config/tools.json for TS
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusschiesser committed Mar 28, 2024
1 parent ce2f24d commit 9ca343c
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
6 changes: 4 additions & 2 deletions create-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,13 @@ export async function createApp({
}

if (toolsRequireConfig(tools)) {
const configFile =
framework === "fastapi" ? "config/tools.yaml" : "config/tools.json";
console.log(
yellow(
`You have selected tools that require configuration. Please configure them in the ${terminalLink(
"config/tools.yaml",
`file://${root}/config/tools.yaml`,
configFile,
`file://${root}/${configFile}`,
)} file.`,
),
);
Expand Down
8 changes: 5 additions & 3 deletions helpers/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { copy } from "../helpers/copy";
import { callPackageManager } from "../helpers/install";
import { templatesDir } from "./dir";
import { PackageManager } from "./get-pkg-manager";
import { makeDir } from "./make-dir";
import { InstallTemplateArgs } from "./types";

const rename = (name: string) => {
Expand Down Expand Up @@ -179,14 +180,15 @@ export const installTSTemplate = async ({
cwd: path.join(compPath, "engines", "typescript", "agent"),
});

// Write tools_config.json
// Write config/tools.json
const configContent: Record<string, any> = {};
tools.forEach((tool) => {
configContent[tool.name] = tool.config ?? {};
});
const configFilePath = path.join(enginePath, "tools_config.json");
const configPath = path.join(root, "config");
await makeDir(configPath);
await fs.writeFile(
configFilePath,
path.join(configPath, "tools.json"),
JSON.stringify(configContent, null, 2),
);
} else {
Expand Down
10 changes: 5 additions & 5 deletions questions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -626,19 +626,19 @@ export const askQuestions = async (
program.dataSources = [];
// continue asking user for data sources if none are initially provided
while (true) {
const firstQuestion = program.dataSources.length === 0;
const { selectedSource } = await prompts(
{
type: "select",
name: "selectedSource",
message:
program.dataSources.length === 0
? "Which data source would you like to use?"
: "Would you like to add another data source?",
message: firstQuestion
? "Which data source would you like to use?"
: "Would you like to add another data source?",
choices: getDataSourceChoices(
program.framework,
program.dataSources,
),
initial: 0,
initial: firstQuestion ? 1 : 0,
},
handlers,
);
Expand Down
2 changes: 1 addition & 1 deletion templates/components/engines/typescript/agent/chat.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import config from "@/config/tools.json";
import { OpenAI, OpenAIAgent, QueryEngineTool, ToolFactory } from "llamaindex";
import { STORAGE_CACHE_DIR } from "./constants.mjs";
import { getDataSource } from "./index";
import config from "./tools_config.json";

export async function createChatEngine(llm: OpenAI) {
const index = await getDataSource(llm);
Expand Down
5 changes: 4 additions & 1 deletion templates/types/streaming/express/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"moduleResolution": "node"
"moduleResolution": "node",
"paths": {
"@/*": ["./*"]
}
}
}

0 comments on commit 9ca343c

Please sign in to comment.