Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add form filling use case for TS #417

Merged
merged 49 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
3c847f2
add csv extractor tool
leehuwuj Nov 6, 2024
85905ad
add formFilling agent and update event type
leehuwuj Nov 6, 2024
2e9d3d7
add tools and update template
leehuwuj Nov 7, 2024
ae8126f
update annotation
leehuwuj Nov 7, 2024
17b1dfe
update type
leehuwuj Nov 7, 2024
1bc9e32
allow multiple tool calls
leehuwuj Nov 7, 2024
5927861
enable e2e test for NextJS
leehuwuj Nov 7, 2024
1f9d412
revert wrong change on tools file
leehuwuj Nov 7, 2024
c632345
refactor copy code
leehuwuj Nov 8, 2024
9a022e8
refactor copy code
leehuwuj Nov 8, 2024
dc39b3e
fix typing
leehuwuj Nov 8, 2024
dc2b39e
Update for financial report
leehuwuj Nov 8, 2024
3cae9d7
add changesets
leehuwuj Nov 8, 2024
7848b83
improve code
leehuwuj Nov 8, 2024
a05d444
update with new workflow code
leehuwuj Nov 8, 2024
ef86d64
update with new workflow code
leehuwuj Nov 8, 2024
bd8812b
update workflow code
leehuwuj Nov 11, 2024
edf310a
refactor code
leehuwuj Nov 11, 2024
8b00369
improve form filling tool
leehuwuj Nov 11, 2024
24d1ef1
add generator typing
leehuwuj Nov 11, 2024
31a04b2
add back llamacloud retriever tools
leehuwuj Nov 11, 2024
0e78d38
remove code and add typing
leehuwuj Nov 11, 2024
c6c20fb
add agent message annotation
leehuwuj Nov 11, 2024
51672a8
add typing packages
leehuwuj Nov 11, 2024
291e1d6
improve stream
leehuwuj Nov 11, 2024
b517264
enable expressjs
leehuwuj Nov 11, 2024
b377aee
remove dead code
leehuwuj Nov 11, 2024
c8d204b
add missing code
leehuwuj Nov 11, 2024
15257a6
improve code
leehuwuj Nov 11, 2024
324184b
fix linting
leehuwuj Nov 11, 2024
7b27096
better error handling
leehuwuj Nov 11, 2024
88bc826
improve error handling for csv parsing
leehuwuj Nov 11, 2024
f50cff8
add missing code
leehuwuj Nov 11, 2024
70a01b5
change templates: use attachments folder
leehuwuj Nov 11, 2024
938534f
update for blog use case
leehuwuj Nov 12, 2024
ec8a3cd
refactor code
leehuwuj Nov 12, 2024
37f0e61
update typing
leehuwuj Nov 12, 2024
9258fbc
update stream
leehuwuj Nov 12, 2024
81b09ad
fix e2e and remove code
leehuwuj Nov 12, 2024
8dd5dfd
fix expressjs
leehuwuj Nov 12, 2024
ab6e5dc
improve code
leehuwuj Nov 12, 2024
613af08
remove @core package and refactor tools code
leehuwuj Nov 12, 2024
e16426b
update single agent
leehuwuj Nov 12, 2024
f07e58e
remove bind
leehuwuj Nov 12, 2024
0d9e49f
fix wrong import
leehuwuj Nov 12, 2024
2e6ad55
add missing tool call message in fin report
leehuwuj Nov 13, 2024
ba1462a
update readme
leehuwuj Nov 13, 2024
68b53cc
set type as required in AgentRunEvent
leehuwuj Nov 13, 2024
f7c0c9e
fix wrong readme
leehuwuj Nov 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/metal-cherries-sin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-llama": patch
---

Optimize Typescript multi-agent code
5 changes: 5 additions & 0 deletions .changeset/serious-suits-turn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-llama": patch
---

Add form filling use case (Typescript)
4 changes: 0 additions & 4 deletions e2e/shared/multiagent_template.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ for (const agents of templateAgents) {
process.platform !== "linux" || process.env.DATASOURCE === "--no-files",
"The multiagent template currently only works with files. We also only run on Linux to speed up tests.",
);
test.skip(
agents === "form_filling" && templateFramework !== "fastapi",
"Form filling is currently only supported with FastAPI.",
);
let port: number;
let externalPort: number;
let cwd: string;
Expand Down
17 changes: 10 additions & 7 deletions helpers/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,19 +136,22 @@ export const installTSTemplate = async ({
// Copy agents use case code for multiagent template
if (agents) {
console.log("\nCopying agent:", agents, "\n");
const useCasePath = path.join(compPath, "agents", "typescript", agents);
const agentsCodePath = path.join(useCasePath, "workflow");

const agentsCodePath = path.join(
compPath,
"agents",
"typescript",
agents,
);

// Copy agent codes
await copy("**", path.join(root, relativeEngineDestPath, "workflow"), {
parents: true,
cwd: agentsCodePath,
rename: assetRelocator,
});

// Copy attachments for form filling agent
const attachmentPath = path.join(useCasePath, "attachments");
await copy("**", path.join(root), {
parents: true,
cwd: attachmentPath,
});
} else {
console.log(
red(
Expand Down
29 changes: 13 additions & 16 deletions questions/simple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,19 @@ export const askSimpleQuestions = async (
let useLlamaCloud = false;

if (appType !== "extractor") {
// TODO: Add TS support for form filling use case
if (appType !== "form_filling") {
const { language: newLanguage } = await prompts(
{
type: "select",
name: "language",
message: "What language do you want to use?",
choices: [
{ title: "Python (FastAPI)", value: "fastapi" },
{ title: "Typescript (NextJS)", value: "nextjs" },
],
},
questionHandlers,
);
language = newLanguage;
}
const { language: newLanguage } = await prompts(
{
type: "select",
name: "language",
message: "What language do you want to use?",
choices: [
{ title: "Python (FastAPI)", value: "fastapi" },
{ title: "Typescript (NextJS)", value: "nextjs" },
],
},
questionHandlers,
);
language = newLanguage;

const { useLlamaCloud: newUseLlamaCloud } = await prompts(
{
Expand Down
230 changes: 0 additions & 230 deletions templates/components/agents/typescript/blog/factory.ts

This file was deleted.

54 changes: 0 additions & 54 deletions templates/components/agents/typescript/blog/tools.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
import { ChatMessage } from "llamaindex";
import { FunctionCallingAgent } from "./single-agent";
import { getQueryEngineTool, lookupTools } from "./tools";
import { getQueryEngineTools, lookupTools } from "./tools";

export const createResearcher = async (
chatHistory: ChatMessage[],
params?: any,
) => {
const queryEngineTool = await getQueryEngineTool(params);
export const createResearcher = async (chatHistory: ChatMessage[]) => {
const queryEngineTools = await getQueryEngineTools();
const tools = (
await lookupTools([
"wikipedia_tool",
"duckduckgo_search",
"image_generator",
])
).concat(queryEngineTool ? [queryEngineTool] : []);
).concat(queryEngineTools ? queryEngineTools : []);

return new FunctionCallingAgent({
name: "researcher",
Expand Down
Loading
Loading