How to Automate Supply Chain Risk Reports: A Guide for Developers
Do you use Python? If so, this guide will help you automate supply chain risk reports using AI Chat GPT and our News API.
The sheer volume of web data available today is both a blessing and a curse. This data presents businesses with endless opportunities for deriving valuable insights, but the challenge lies in efficiently processing and analyzing this information. Many companies have turned to large language models (LLMs) like ChatGPT to analyze and summarize massive volumes of web data.
ChatGPT recently introduced a new “web browsing” plug-in feature, currently in alpha. This feature connects to the internet, converting the user prompt into a search query that returns summaries based on Bing API’s search results. While this is a promising new ChatGPT capability, it has its limitations. For example, the browsing plug-in is limited to the web content indexed by Bing. On the other hand, Webz.io provides data from sources across the open, deep, and dark web. You can unlock a wealth of knowledge by combining the raw data from Webz.io with the natural language processing (NLP) capabilities of ChatGPT.
This article will discuss how you can use this powerful duo for data analysis and insight generation. We’ll use a financial report as an example and explore other use cases. Before we begin, here is a quick explainer of what Webz.io is, what ChatGPT is, and why you would automate financial analysis.
Webz.io is the link to accessing rich and diverse web data at scale. Webz.io’s APIs provide access to a vast array of web data from multiple sources, including news articles, blogs, forums, and reviews. You can create customized Boolean queries to filter the information, ensuring you gather only the most relevant and valuable data for your needs. The ability to extract specific information from a wide range of sources makes Webz.io an ideal starting point for any data analysis project.
ChatGPT is a tool that can transform raw data into meaningful insights. It is a powerful large language model developed by OpenAI that can process and analyze large volumes of textual data. Utilizing its NLP capabilities, you can transform raw data into actionable insights, summaries, and predictions. You can also use ChatGPT to identify key trends, patterns, and relationships within the data, making it an invaluable tool for data-driven decision-making.
By combining the power of ChatGPT with Webz.io data, you can efficiently analyze large volumes of financial news data and obtain actionable insights on investment opportunities. We’ve created a Python script that generates a financial report that provides information on:
While the script focuses on financial investment opportunities, you could use this script to generate reports for other industries. I’ve outlined additional use cases later in the article. Creating the automated report takes three steps. Using Python or your preferred language, you create a script that executes the following steps:
The following section includes a financial report example and the Python script that created it.
The financial analysis report and script demonstrate the synergy between Webz.io and ChatGPT. They show how you can streamline the process of creating a comprehensive financial report through automation. And you can create financial reports based on a wide range of data sources. As mentioned above, it takes three steps to generate a financial report, which the script executes through these functions:
This function retrieves the news articles from the Webz.io API based on the given query.
The Webz.io API provides a comprehensive source of news articles based on specific Boolean queries. For our financial report, we used the following query:
(site_category:financial_news OR site_category:financial_planning) domain_rank:<1000 site_type:news language:english social.facebook.likes:>0 invest
This query allows us to filter news articles from top-ranked financial news websites, written in English, and with positive social media engagement. It also focuses on articles discussing investments.
This function takes the article text as input and generates a summary using ChatGPT API. The script asks ChatGPT to provide essential information such as company names, market trends, industry, asset class, region, and investment opportunities.
This function fetches the selected articles, trimming their length if needed. It then summarizes the articles. The final step of the script generates a prompt for ChatGPT to act as a financial analyst. The prompt asks ChatGPT to write an investment opportunity report based on the news article summaries. The prompt also asks that the report include trends and themes, identify recurring themes, and note any patterns that might reveal potential investment opportunities.
By using a specific Boolean query, Webz.io can provide relevant financial news articles. ChatGPT can then analyze and summarize the articles, creating the investment opportunity report.
Here is the full Python script if you want to play around with it. Click on the code snippet to view the entire script. Option to copy the script to the clipboard.
import os
import requests
import openai
Webz.io_API_KEY = “XXX-XXXX-XXXX-XXXXX”
openai.api_key = os.getenv(“OPENAI_API_KEY”)
def trim_string(string, max_length):
if len(string) > max_length:
return string[:max_length]
else:
return string
# Function to get news articles from Webz.io API
def fetch_posts():
endpoint = f“https://api.webz.io/filterWebContent?token=XXXX-XXXX-XXXXX&format=json&sort=crawled&q=(site_category%3Afinancial_news%20OR%20site_category%3Afinancial_planning%20OR%20site_category%3Afinancial_planning)%20domain_rank%3A%3C1000%20site_type%3Anews%20language%3Aenglish%20social.facebook.likes%3A%3E0%20invest&size=50”
response = requests.get(endpoint)
data = response.json()
return data[“posts”]
# Function to interact with ChatGPT API
def chat_gpt_request(prompt, model):
response = openai.Completion.create(
model=model,
prompt=prompt,
temperature=0,
max_tokens=1000,
top_p=1,
frequency_penalty=0,
presence_penalty=0
)
return response.choices[0][“text”].strip()
# Function to summarize article text using ChatGPT API
def summarize_article(text):
prompt = f“Summarize the following article. Provide key information such as company names, market trends, industry, asset class, region, investment opportunities.:\n\n{text}\n\nSummary:”
summary = chat_gpt_request(prompt, “text-davinci-003”)
print(summary)
return summary
# Main function to fetch and summarize articles
def main():
articles = fetch_posts()
summaries = []
for article in articles:
text = trim_string(article[“title”] + “\n\n” + article[“text”], 14000)
summary = summarize_article(text)
summaries.append(summary)
summaries = “\n\n***\n\n”.join(summaries)
summaries = trim_string(summaries, 14000)
prompt = f“Act as a financial analyst. Write an investment opportunity report based on the following news article summaries separated by ‘***’ separator. Each summary contains key information such as company names, market trends, industry, asset class, region, investment opportunities. The report will include trends and themes, identify recurring themes, such as growing industries, emerging markets, or disruptive technologies. Note any patterns that might reveal potential investment opportunities. Identify key companies. As you analyze the summaries, take note of companies frequently mentioned or highlighted for their strong performance, innovative products, or competitive advantages. For each company of interest, take into account their fundamentals, management team, competitive position, and performance. Look for companies with strong growth potential or undervalued assets. \n\nSummaries:\n\n” + summaries + “\n\nReport:”
print(“\n\n—— Prompt ————-\n\n”)
print(prompt)
if __name__ == “__main__”:
main()
|
Below is an investment opportunity report generated by our Python script. Click on the bar below to see the full report.
Below is the full ChatGPT prompt that created the report. Click on the bar to see the whole prompt.
The combination of Webz.io and ChatGPT is not limited to financial analysis — the possibilities are endless. Some other use cases include:
It should be noted that large language models like ChatGPT can make mistakes. So when generating analyses with Webz.io and ChatGPT, you should cross-check the results with other sources. An automated report is another source of information meant to help the user gather quick insights at scale.
Combining Webz.io’s rich data sources and ChatGPT’s NLP capabilities gives you a powerful data analysis and insight generation solution. The financial report example highlights the potential of this duo, and the applications are vast and varied. Businesses and individuals can harness the power of Webz.io and ChatGPT to make data-driven decisions, unlock new opportunities, and stay ahead in today’s competitive landscape.
Ready to get started? If you don’t have access to Webz.io’s APIs yet, speak to one of our data experts now.
Do you use Python? If so, this guide will help you automate supply chain risk reports using AI Chat GPT and our News API.
Use this guide to learn how to easily automate supply chain risk reports with Chat GPT and news data.
A quick guide for developers to automate mergers and acquisitions reports with Python and AI. Learn to fetch data, analyze content, and generate reports automatically.