Skip to content

Commit 23654e4

Browse files
committed
change agents to usecase
1 parent a2516f7 commit 23654e4

10 files changed

+94
-82
lines changed

create-app.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export async function createApp({
3939
tools,
4040
useLlamaParse,
4141
observability,
42-
agents,
42+
useCase,
4343
}: InstallAppArgs): Promise<void> {
4444
const root = path.resolve(appPath);
4545

@@ -84,7 +84,7 @@ export async function createApp({
8484
tools,
8585
useLlamaParse,
8686
observability,
87-
agents,
87+
useCase,
8888
};
8989

9090
// Install backend

e2e/shared/multiagent_template.spec.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ const templateUI: TemplateUI = "shadcn";
1818
const templatePostInstallAction: TemplatePostInstallAction = "runApp";
1919
const appType: AppType = templateFramework === "fastapi" ? "--frontend" : "";
2020
const userMessage = "Write a blog post about physical standards for letters";
21-
const templateAgents = ["financial_report", "blog", "form_filling"];
21+
const templateUseCases = ["financial_report", "blog", "form_filling"];
2222

23-
for (const agents of templateAgents) {
24-
test.describe(`Test multiagent template ${agents} ${templateFramework} ${dataSource} ${templateUI} ${appType} ${templatePostInstallAction}`, async () => {
23+
for (const useCase of templateUseCases) {
24+
test.describe(`Test multiagent template ${useCase} ${templateFramework} ${dataSource} ${templateUI} ${appType} ${templatePostInstallAction}`, async () => {
2525
test.skip(
2626
process.platform !== "linux" || process.env.DATASOURCE === "--no-files",
2727
"The multiagent template currently only works with files. We also only run on Linux to speed up tests.",
@@ -46,7 +46,7 @@ for (const agents of templateAgents) {
4646
postInstallAction: templatePostInstallAction,
4747
templateUI,
4848
appType,
49-
agents,
49+
useCase,
5050
});
5151
name = result.projectName;
5252
appProcess = result.appProcess;
@@ -71,8 +71,8 @@ for (const agents of templateAgents) {
7171
}) => {
7272
test.skip(
7373
templatePostInstallAction !== "runApp" ||
74-
agents === "financial_report" ||
75-
agents === "form_filling" ||
74+
useCase === "financial_report" ||
75+
useCase === "form_filling" ||
7676
templateFramework === "express",
7777
"Skip chat tests for financial report and form filling.",
7878
);

e2e/shared/reflex_template.spec.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { expect, test } from "@playwright/test";
33
import { ChildProcess } from "child_process";
44
import fs from "fs";
55
import path from "path";
6-
import { TemplateAgents, TemplateFramework } from "../../helpers";
6+
import { TemplateFramework, TemplateUseCase } from "../../helpers";
77
import { createTestDir, runCreateLlama } from "../utils";
88

99
const templateFramework: TemplateFramework = process.env.FRAMEWORK
@@ -12,16 +12,16 @@ const templateFramework: TemplateFramework = process.env.FRAMEWORK
1212
const dataSource: string = process.env.DATASOURCE
1313
? process.env.DATASOURCE
1414
: "--example-file";
15-
const templateAgents: TemplateAgents[] = ["extractor", "contract_review"];
15+
const templateUseCases: TemplateUseCase[] = ["extractor", "contract_review"];
1616

1717
// The reflex template currently only works with FastAPI and files (and not on Windows)
1818
if (
1919
process.platform !== "win32" &&
2020
templateFramework === "fastapi" &&
2121
dataSource === "--example-file"
2222
) {
23-
for (const agents of templateAgents) {
24-
test.describe(`Test reflex template ${agents} ${templateFramework} ${dataSource}`, async () => {
23+
for (const useCase of templateUseCases) {
24+
test.describe(`Test reflex template ${useCase} ${templateFramework} ${dataSource}`, async () => {
2525
let appPort: number;
2626
let name: string;
2727
let appProcess: ChildProcess;
@@ -39,7 +39,7 @@ if (
3939
vectorDb: "none",
4040
port: appPort,
4141
postInstallAction: "runApp",
42-
agents,
42+
useCase,
4343
});
4444
name = result.projectName;
4545
appProcess = result.appProcess;

e2e/utils.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export type RunCreateLlamaOptions = {
3333
tools?: string;
3434
useLlamaParse?: boolean;
3535
observability?: string;
36-
agents?: string;
36+
useCase?: string;
3737
};
3838

3939
export async function runCreateLlama({
@@ -51,7 +51,7 @@ export async function runCreateLlama({
5151
tools,
5252
useLlamaParse,
5353
observability,
54-
agents,
54+
useCase,
5555
}: RunCreateLlamaOptions): Promise<CreateLlamaResult> {
5656
if (!process.env.OPENAI_API_KEY || !process.env.LLAMA_CLOUD_API_KEY) {
5757
throw new Error(
@@ -113,8 +113,8 @@ export async function runCreateLlama({
113113
if (observability) {
114114
commandArgs.push("--observability", observability);
115115
}
116-
if ((templateType === "multiagent" || templateType === "reflex") && agents) {
117-
commandArgs.push("--agents", agents);
116+
if ((templateType === "multiagent" || templateType === "reflex") && useCase) {
117+
commandArgs.push("--use-case", useCase);
118118
}
119119

120120
const command = commandArgs.join(" ");

helpers/python.ts

+15-20
Original file line numberDiff line numberDiff line change
@@ -380,28 +380,32 @@ export const installPythonDependencies = (
380380
};
381381

382382
export const installPythonTemplate = async ({
383+
appName,
383384
root,
384385
template,
385386
framework,
386387
vectorDb,
388+
postInstallAction,
389+
modelConfig,
387390
dataSources,
388391
tools,
389-
postInstallAction,
392+
useLlamaParse,
393+
useCase,
390394
observability,
391-
modelConfig,
392-
agents,
393395
}: Pick<
394396
InstallTemplateArgs,
397+
| "appName"
395398
| "root"
396-
| "framework"
397399
| "template"
400+
| "framework"
398401
| "vectorDb"
402+
| "postInstallAction"
403+
| "modelConfig"
399404
| "dataSources"
400405
| "tools"
401-
| "postInstallAction"
406+
| "useLlamaParse"
407+
| "useCase"
402408
| "observability"
403-
| "modelConfig"
404-
| "agents"
405409
>) => {
406410
console.log("\nInitializing Python project with template:", template, "\n");
407411
let templatePath;
@@ -476,21 +480,12 @@ export const installPythonTemplate = async ({
476480
await copyRouterCode(root, tools ?? []);
477481
}
478482

479-
if (template === "multiagent") {
480-
// Copy multi-agent code
481-
await copy("**", path.join(root), {
482-
parents: true,
483-
cwd: path.join(compPath, "multiagent", "python"),
484-
rename: assetRelocator,
485-
});
486-
}
487-
488483
if (template === "multiagent" || template === "reflex") {
489-
if (agents) {
484+
if (useCase) {
490485
const sourcePath =
491486
template === "multiagent"
492-
? path.join(compPath, "agents", "python", agents)
493-
: path.join(compPath, "reflex", agents);
487+
? path.join(compPath, "agents", "python", useCase)
488+
: path.join(compPath, "reflex", useCase);
494489

495490
await copy("**", path.join(root), {
496491
parents: true,
@@ -500,7 +495,7 @@ export const installPythonTemplate = async ({
500495
} else {
501496
console.log(
502497
red(
503-
`There is no agent selected for ${template} template. Please pick an agent to use via --agents flag.`,
498+
`There is no use case selected for ${template} template. Please pick a use case to use via --use-case flag.`,
504499
),
505500
);
506501
process.exit(1);

helpers/types.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export type TemplateDataSource = {
4949
};
5050
export type TemplateDataSourceType = "file" | "web" | "db";
5151
export type TemplateObservability = "none" | "traceloop" | "llamatrace";
52-
export type TemplateAgents =
52+
export type TemplateUseCase =
5353
| "financial_report"
5454
| "blog"
5555
| "form_filling"
@@ -106,5 +106,5 @@ export interface InstallTemplateArgs {
106106
postInstallAction?: TemplatePostInstallAction;
107107
tools?: Tool[];
108108
observability?: TemplateObservability;
109-
agents?: TemplateAgents;
109+
useCase?: TemplateUseCase;
110110
}

helpers/typescript.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const installTSTemplate = async ({
2626
tools,
2727
dataSources,
2828
useLlamaParse,
29-
agents,
29+
useCase,
3030
}: InstallTemplateArgs & { backend: boolean }) => {
3131
console.log(bold(`Using ${packageManager}.`));
3232

@@ -131,16 +131,16 @@ export const installTSTemplate = async ({
131131
cwd: path.join(multiagentPath, "workflow"),
132132
});
133133

134-
// Copy agents use case code for multiagent template
135-
if (agents) {
136-
console.log("\nCopying agent:", agents, "\n");
137-
const useCasePath = path.join(compPath, "agents", "typescript", agents);
138-
const agentsCodePath = path.join(useCasePath, "workflow");
134+
// Copy use case code for multiagent template
135+
if (useCase) {
136+
console.log("\nCopying use case:", useCase, "\n");
137+
const useCasePath = path.join(compPath, "agents", "typescript", useCase);
138+
const useCaseCodePath = path.join(useCasePath, "workflow");
139139

140-
// Copy agent codes
140+
// Copy use case codes
141141
await copy("**", path.join(root, relativeEngineDestPath, "workflow"), {
142142
parents: true,
143-
cwd: agentsCodePath,
143+
cwd: useCaseCodePath,
144144
rename: assetRelocator,
145145
});
146146

@@ -153,7 +153,7 @@ export const installTSTemplate = async ({
153153
} else {
154154
console.log(
155155
red(
156-
`There is no agent selected for ${template} template. Please pick an agent to use via --agents flag.`,
156+
`There is no use case selected for ${template} template. Please pick a use case to use via --use-case flag.`,
157157
),
158158
);
159159
process.exit(1);

index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,10 @@ const program = new Command(packageJson.name)
202202
false,
203203
)
204204
.option(
205-
"--agents <agents>",
205+
"--use-case <useCase>",
206206
`
207207
208-
Select which agents to use for the multi-agent template (e.g: financial_report, blog).
208+
Select which use case to use for the multi-agent template (e.g: financial_report, blog).
209209
`,
210210
)
211211
.allowUnknownOption()

questions/questions.ts

+44-27
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { blue } from "picocolors";
22
import prompts from "prompts";
33
import { isCI } from ".";
44
import { COMMUNITY_OWNER, COMMUNITY_REPO } from "../helpers/constant";
5-
import { EXAMPLE_FILE } from "../helpers/datasources";
5+
import { EXAMPLE_FILE, EXAMPLE_GDPR } from "../helpers/datasources";
66
import { getAvailableLlamapackOptions } from "../helpers/llama-pack";
77
import { askModelConfig } from "../helpers/providers";
88
import { getProjectOptions } from "../helpers/repo";
@@ -101,11 +101,10 @@ export const askProQuestions = async (program: QuestionArgs) => {
101101
program.dataSources = [EXAMPLE_FILE];
102102
program.framework = "fastapi";
103103
// Ask for which Reflex use case to use
104-
// TODO: rename to use case instead of agents
105-
const { agents } = await prompts(
104+
const { useCase } = await prompts(
106105
{
107106
type: "select",
108-
name: "agents",
107+
name: "useCase",
109108
message: "Which use case would you like to build?",
110109
choices: [
111110
{ title: "Structured Extractor", value: "extractor" },
@@ -118,7 +117,7 @@ export const askProQuestions = async (program: QuestionArgs) => {
118117
},
119118
questionHandlers,
120119
);
121-
program.agents = agents;
120+
program.useCase = useCase;
122121
}
123122

124123
if (!program.framework) {
@@ -190,32 +189,50 @@ export const askProQuestions = async (program: QuestionArgs) => {
190189
program.observability = observability;
191190
}
192191

193-
// Ask agents
194-
if (program.template === "multiagent" && !program.agents) {
195-
const { agents } = await prompts(
192+
if (
193+
(program.template === "reflex" || program.template === "multiagent") &&
194+
!program.useCase
195+
) {
196+
const choices =
197+
program.template === "reflex"
198+
? [
199+
{ title: "Structured Extractor", value: "extractor" },
200+
{
201+
title: "Contract review (using Workflow)",
202+
value: "contract_review",
203+
},
204+
]
205+
: [
206+
{
207+
title: "Financial report (generate a financial report)",
208+
value: "financial_report",
209+
},
210+
{
211+
title: "Form filling (fill missing value in a CSV file)",
212+
value: "form_filling",
213+
},
214+
{ title: "Blog writer (Write a blog post)", value: "blog_writer" },
215+
];
216+
217+
const { useCase } = await prompts(
196218
{
197219
type: "select",
198-
name: "agents",
199-
message: "Which agents would you like to use?",
200-
choices: [
201-
{
202-
title: "Financial report (generate a financial report)",
203-
value: "financial_report",
204-
},
205-
{
206-
title: "Form filling (fill missing value in a CSV file)",
207-
value: "form_filling",
208-
},
209-
{
210-
title: "Blog writer (Write a blog post)",
211-
value: "blog_writer",
212-
},
213-
],
220+
name: "useCase",
221+
message: "Which use case would you like to use?",
222+
choices,
214223
initial: 0,
215224
},
216225
questionHandlers,
217226
);
218-
program.agents = agents;
227+
program.useCase = useCase;
228+
}
229+
230+
// Configure framework and data sources for Reflex template
231+
if (program.template === "reflex") {
232+
program.framework = "fastapi";
233+
234+
program.dataSources =
235+
program.useCase === "extractor" ? [EXAMPLE_FILE] : [EXAMPLE_GDPR];
219236
}
220237

221238
if (!program.modelConfig) {
@@ -241,8 +258,8 @@ export const askProQuestions = async (program: QuestionArgs) => {
241258
program.vectorDb = vectorDb;
242259
}
243260

244-
if (program.vectorDb === "llamacloud") {
245-
// When using a LlamaCloud index, don't ask for data sources just copy an example file
261+
if (program.vectorDb === "llamacloud" && program.dataSources.length === 0) {
262+
// When using a LlamaCloud index and no data sources are provided, just copy an example file
246263
program.dataSources = [EXAMPLE_FILE];
247264
}
248265

0 commit comments

Comments
 (0)