Use Case Guide

Build a stock analyzer agent using LLMs with access to a web browser

OpenAI
Agent
In this guide, we will build a stock analyzer agent app that will use LLM function calling with access to tools like a stock history database, web browser and a code interpreter

In this tutorial, we will guide you through the process of creating a highly functional stock analyzer agent. This agent leverages Large Language Models (LLMs) enhanced with web browsing capabilities, code interpretation, and access to external databases. It's designed to provide users with the ability to analyze historical stock data, generate informative plots, and gather real-time stock market insights. However, it's crucial to note that the responses generated by this agent should not be taken as financial advice. This tool is intended for informational purposes only, and users should conduct their own research or consult with a financial advisor before making investment decisions.

Function calling allows LLMs to use tools by generating inputs for the tools based on the task being performed. When working with LLMs in the context of function calling, the usual workflow is to pass the function schemas to the LLM along with their description followed by the user message. Depending on the task, model may generate arguments for the function to call. We will need to parse the arguments, invoke the said function, capture the output and pass the output back to the model for it to generate the next set of messages. We will need to run this loop till the model ends with a final output. Promptly's flexible platform makes it easy to build agents with LLM function calling without writing any code

1. Prepare Your Data Source

- Acquire Historical Stock Data: Download the dataset from Kaggle, which includes stock market data over the past five years.
- Set Up a Database: Create a database on SingleStore Portal with a schema that matches the dataset columns.
- Upload Your Data: Import the dataset into your SingleStore database.
- Configure Data Source on Promptly: On the datasources page of Promptly, add a new datasource. Choose Singlestore as the type, entering the necessary details (hostname, username, password, etc.), and submit to complete the setup.

SingleStore as an external datasource

2. Create Your Agent App

- Initiate App Creation: On the apps page of Promptly, start a new app from the Blank templates. Name it appropriately, such as "Stock Analyzer Agent".

Blank agent app template


2. Add Processors:
  - DataSource Search Processor: Configure this to query the SingleStore datasource for historical stock data.
  - Code Interpreter: Add a processor for executing code, enabling data analysis and visualization.
  - Web Browser Processor: This processor allows the agent to fetch real-time information from the internet.

Tools for stock analyzer agent app

3. Configure System Message

Update the system message to guide the agent, including details about the stock database schema and how to generate plots. This ensures the agent accurately understands and processes user requests.

Stock analyser agent system message

4. Interact with Your Agent

- Ask for Data Analysis: For instance, "Find the monthly average price of NVIDIA for 2023 and plot the results". The agent will:
  - Generate and execute a SQL query to retrieve data.
  - Create and run Python code for plotting.
  - Present the data analysis and plot.
- Request Real-Time Information: For real-time queries, the agent uses the web browser processor to navigate and interact with the web, providing up-to-date information.

Realtime price using LLM with web browser

5. Refine and Test Your App

- Test Various Queries: Ensure the agent can handle a broad range of stock analysis requests efficiently.
- Adjust Based on Performance: Modify processor configurations as necessary to enhance response accuracy and quality.

Conclusion

This tutorial demonstrates how to create a versatile stock analyzer agent with LLMs, capable of offering historical and real-time market insights. Remember, the information provided by this agent is for informational purposes only and should not be construed as financial advice. Always perform due diligence or consult a professional advisor when making investment decisions. Through this project, you'll appreciate the power of integrating LLMs with external data sources and web capabilities to create innovative and interactive applications.

Try Promptly today

Boost your productivity by automating your workflows with Generative AI