From ba1462ad9d542aaed2c9af628efbcdfa04e24de7 Mon Sep 17 00:00:00 2001 From: leehuwuj Date: Wed, 13 Nov 2024 10:40:12 +0700 Subject: [PATCH] update readme --- helpers/typescript.ts | 8 ++-- .../financial_report/README-template.md | 46 +++++++++++++++++++ .../form_filling/README-template.md | 36 +++++++++++++++ .../{attachments => }/sec_10k_template.csv | 0 .../multiagent/typescript/nextjs/route.ts | 3 +- 5 files changed, 87 insertions(+), 6 deletions(-) create mode 100644 templates/components/agents/typescript/financial_report/README-template.md create mode 100644 templates/components/agents/typescript/form_filling/README-template.md rename templates/components/agents/typescript/form_filling/{attachments => }/sec_10k_template.csv (100%) diff --git a/helpers/typescript.ts b/helpers/typescript.ts index 179ee9d38..b443286f2 100644 --- a/helpers/typescript.ts +++ b/helpers/typescript.ts @@ -146,11 +146,11 @@ export const installTSTemplate = async ({ rename: assetRelocator, }); - // Copy attachments for form filling agent - const attachmentPath = path.join(useCasePath, "attachments"); - await copy("**", path.join(root), { + // Copy use case files to project root + await copy("*.*", path.join(root), { parents: true, - cwd: attachmentPath, + cwd: useCasePath, + rename: assetRelocator, }); } else { console.log( diff --git a/templates/components/agents/typescript/financial_report/README-template.md b/templates/components/agents/typescript/financial_report/README-template.md new file mode 100644 index 000000000..c14c16174 --- /dev/null +++ b/templates/components/agents/typescript/financial_report/README-template.md @@ -0,0 +1,46 @@ +This is a [LlamaIndex](https://www.llamaindex.ai/) project using [Next.js](https://nextjs.org/) bootstrapped with [`create-llama`](https://github.com/run-llama/LlamaIndexTS/tree/main/packages/create-llama). + +## Getting Started + +First, install the dependencies: + +``` +npm install +``` + +Then check the parameters that have been pre-configured in the `.env` file in this directory. +Make sure you have the `OPENAI_API_KEY` set. + +Second, generate the embeddings of the documents in the `./data` directory: + +``` +npm run generate +``` + +Third, run the development server: + +``` +npm run dev +``` + +Open [http://localhost:3000](http://localhost:3000) with your browser to see the chat UI. + +## Use Case: Filling Financial CSV Template + +You can start by sending an request on the chat UI to create a report comparing the finances of Apple and Tesla. +Or you can test the `/api/chat` endpoint with the following curl request: + +``` +curl --location 'localhost:3000/api/chat' \ +--header 'Content-Type: application/json' \ +--data '{ "messages": [{ "role": "user", "content": "Create a report comparing the finances of Apple and Tesla" }] }' +``` + +## Learn More + +To learn more about LlamaIndex, take a look at the following resources: + +- [LlamaIndex Documentation](https://docs.llamaindex.ai) - learn about LlamaIndex. +- [Workflows Introduction](https://docs.llamaindex.ai/en/stable/understanding/workflows/) - learn about LlamaIndex workflows. + +You can check out [the LlamaIndex GitHub repository](https://github.com/run-llama/llama_index) - your feedback and contributions are welcome! diff --git a/templates/components/agents/typescript/form_filling/README-template.md b/templates/components/agents/typescript/form_filling/README-template.md new file mode 100644 index 000000000..796b641dd --- /dev/null +++ b/templates/components/agents/typescript/form_filling/README-template.md @@ -0,0 +1,36 @@ +This is a [LlamaIndex](https://www.llamaindex.ai/) project using [Next.js](https://nextjs.org/) bootstrapped with [`create-llama`](https://github.com/run-llama/LlamaIndexTS/tree/main/packages/create-llama). + +## Getting Started + +First, install the dependencies: + +``` +npm install +``` + +Then check the parameters that have been pre-configured in the `.env` file in this directory. +Make sure you have the `OPENAI_API_KEY` set. + +Second, run the development server: + +``` +npm run dev +``` + +Open [http://localhost:3000](http://localhost:3000) with your browser to see the chat UI. + +## Use Case: Filling Financial CSV Template + +1. Upload the Apple and Tesla financial reports from the [data](./data) directory. Just send an empty message. +2. Upload the CSV file [sec_10k_template.csv](./sec_10k_template.csv) and send the message "Fill the missing cells in the CSV file". + +The agent will fill the missing cells by retrieving the information from the uploaded financial reports and return a new CSV file with the filled cells. + +## Learn More + +To learn more about LlamaIndex, take a look at the following resources: + +- [LlamaIndex Documentation](https://docs.llamaindex.ai) - learn about LlamaIndex. +- [Workflows Introduction](https://docs.llamaindex.ai/en/stable/understanding/workflows/) - learn about LlamaIndex workflows. + +You can check out [the LlamaIndex GitHub repository](https://github.com/run-llama/llama_index) - your feedback and contributions are welcome! diff --git a/templates/components/agents/typescript/form_filling/attachments/sec_10k_template.csv b/templates/components/agents/typescript/form_filling/sec_10k_template.csv similarity index 100% rename from templates/components/agents/typescript/form_filling/attachments/sec_10k_template.csv rename to templates/components/agents/typescript/form_filling/sec_10k_template.csv diff --git a/templates/components/multiagent/typescript/nextjs/route.ts b/templates/components/multiagent/typescript/nextjs/route.ts index a4a1f835a..cdd5561fc 100644 --- a/templates/components/multiagent/typescript/nextjs/route.ts +++ b/templates/components/multiagent/typescript/nextjs/route.ts @@ -42,8 +42,7 @@ export async function POST(request: NextRequest) { const { stream, dataStream } = await createStreamFromWorkflowContext(context); - // Return using the new Response API - // TODO: StreamingTextResponse has been deprecated + // Return the two streams in one response return new StreamingTextResponse(stream, {}, dataStream); } catch (error) { console.error("[LlamaIndex]", error);