Automated Report Generation
LLMs are incredibly good at natural language based tasks like report writing.
Here we describe a simple example of generating a report based on daily stock data using an AgentHub pipeline.
Link to the pipeline to follow along: ๐ Report Generation

#
ObjectiveThe goal of this pipeline will be to go from a list of stock tickers (AAPL, AMZN, etc.) to 1-page PDF reports represting a financial analysis given the historical trend.
#
InputsWe will start by taking user input by text. I could've made this a CSV or similar, but for simplicity, the pipeline will expect a comma-separated list of tickers.
For this we will use the "Input" node:

#
Data ManipulationThen, we need to pull the stock data from an online source. I have chosen AlphaVantage, a common website for pulling stock data.
On AlphaVantage, you can get the stock data through navigating to a URL that includes the ticker. As an example, for APPL, we would have the following URL:
https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=AAPL&apikey=NHB74XJPBMN8A5Y5
After we have the URL, we can use the "Website Scraper" node to get all the information from the website as text.
Now we need to figure out how to do this process for every single ticker in the input list. Since the output of the Input node is a string (ex. "AAPL,AMZN"), we need to turn this into a string[] (ex. ["AAPL", "AMZN"]) to perform operations on each element of the list.
This can be done using the "Cast Type" node as follows:

We can format each ticker into our URL using the "CombineStrings" node, and then feed that into a "Website Scraper" node to pull the information. These will both be in "Batch Mode", as they will be used to process every element of the list.

#
Data GenerationNow comes the meat of the pipeline, actually generating the report itself. We will be using an "Ask ChatGPT" node to generate the report, but we will first formulate some context so that it has some factual information to use to generate the report.
"Context" is extra information that ChatGPT can reference when answering a user's query. This will be helpful as our query will be asking ChatGPT to generate the report text.
We can again use a "CombineStrings" node to generate this context, combining the ticker from the original input and our scraped stock data.

Notice in the above pipeline that we are using the output from the "Cast Type" node, i.e. the ticker names (["AAPL", "AMZN"]) as inputs for multiple nodes. Outputs are often used in multiple places where it makes sense.
Here the context in our "CombineStrings" node would look something like this for AAPL:
This is the recent stock data for APPL:
"Time Series (Daily)": { "2023-08-21": { "1. open": "175.0700", "2. high": "176.1300", "3. low": "173.7350", "4. close": "175.8400", "5. volume": "44990232" }, "2023-08-18": { "1. open": "172.3000", "2. high": "175.1000", "3. low": "171.9600", "4. close": "174.4900", "5. volume": "61172150" }, "2023-08-17": { "1. open": "177.1400", "2. high": "177.5054", "3. low": "173.4800", "4. close": "174.0000", "5. volume": "66062882" }, ... ... ...}
For our Ask ChatGPT prompt, we will tell it to use the context to generate a 1 page PDF financial analysis report:
Given the stock price information in the context, please generate the content for a 1 page PDF financial analysis report. The headline should be the price for the latest date, and the content should be an expert analysis based on the historical trend.
Don't include placeholders, just use the actual values. Don't use Markdown formatting as this will be a PDF report, so the markdown will not render.
Please ensure the length is kept to 1 page or less, as this is a brief analysis.
Finally, we can use a "Generate File" node to create a PDF file based off of this report content. For the name of this report, we can again re-use the output of our "Cast Type" node, that is the ticker name.

#
OutputHere is what it looks like to run our pipeline:

Clicking on the download links to our files, and opening up the AAPL.pdf we get the 1 page PDF report as promised:

And that's all there is to it! This is a simple example, and of course this report could be enhanced by adding news reports, expert analyses, adding graphs to the output, and more.