LLMs X OpenBB Platform
Project description
OpenBB LLM Agents
Work-in-progress.
This is a project that leverages LLMs and OpenBB Platform to create financial analyst agents that can autonomously perform financial research, and answer questions using up-to-date data. This is possible as a result of agents utilizing function calling to interact with the OpenBB Platform.
Installation
Currently, we support Python 3.10+. We will be adding support for more version of Python relatively soon.
openbb-agents
is available as a PyPI package:
pip install openbb-agents --upgrade
Setup
OpenAI API keys
To use OpenBB LLM Agents, you need an OpenAI API key. Follow these steps:
- Get API Key: Sign up on OpenAI and get your API key.
- Set Environment Variable: Add this to your shell profile (
.bashrc
,.zshrc
, etc.):export OPENAI_API_KEY="your_openai_api_key"
OpenBB Platform data provider credentials
To use the OpenBB Platform functions, you need to configure the necessary data provider API credentials. This can be done in one of two ways:
- Local Configuration: Specify your credentials in a
~/.openbb_platform/user_settings.json
file. Follow the local environment setup guide for detailed instructions. - OpenBB Hub: Create a personal access token (PAT) via your OpenBB Hub account. This PAT can then be passed to the agent as an argument.
Getting started
It is highly recommended to take a look at the Getting Started Notebook, which runs you through the features of openbb-agents
at a high level.
Usage
>>> from openbb_agents.agent import openbb_agent
>>> result = openbb_agent("What is the current market cap of TSLA?") # Will print some logs to show you progress
>>> print(result)
- The current market cap of TSLA (Tesla, Inc.) is approximately $695,833,798,800.00.
- This figure is based on the most recent data available, which is from January 15, 2024.
- The market cap is calculated by multiplying the current stock price ($218.89) by the number of outstanding shares (3,178,920,000).
To use your data provider credentials stored in OpenBB Hub, you can pass in your OpenBB Hub PAT directly to the agent:
>>> openbb_agent("What is the stock price of AAPL?", openbb_pat="<openbb-hub-pat>")
Note: The agent dynamically configures itself based on the available data provider credentials. Consequently, certain data sources and functions may be inaccessible without the appropriate API key. By default, yfinance
is included as a data provider and does not require an API key. For a comprehensive list of functions and their supported data providers, refer to the OpenBB Platform documentation.
Queries can be relatively complex:
>>> openbb_agent("Perform a fundamentals financial analysis of AMZN using the most recently available data. What do you find that's interesting?")
Queries can also have temporal dependencies (i.e the answers of previous subquestions are required to answer a later subquestion):
>>> openbb_agent("Who are TSLA's peers? What is their respective market cap? Return the results in _descending_ order of market cap.")
An async
variant of the agent is also available:
>>> from openbb_agents.agent import aopenbb_agent
>>> await aopenbb_agent("What is the current market cap of TSLA?")
Development
- Create a new virtual environment, with
poetry
poetry install
Linting and Formatting
We're currently experimenting with ruff
as a drop-in replacement for black
, isort
and pylint
.
You can run linting checks as follows:
ruff check
Or fix linting errors:
ruff check --fix
Or format the code:
ruff format
We've also included these in the pre-commit
, if you'd prefer to have these checks run automatically before commiting code.
You can install the pre-commit
hooks as follows:
pre-commit install
Testing
We use pytest
as our test runner:
pytest -n 8 tests/
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file openbb_agents-0.0.4.tar.gz
.
File metadata
- Download URL: openbb_agents-0.0.4.tar.gz
- Upload date:
- Size: 13.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a917916b06076f3f03a398e74df5db27faed96e07aab44c523dce7ccce9d439 |
|
MD5 | 461d27a058d27a54c40f7a4a16e410b1 |
|
BLAKE2b-256 | 45ff4df3078196602874f24d4a85104c087736f6e990516dbcc9b9464ae85595 |
File details
Details for the file openbb_agents-0.0.4-py3-none-any.whl
.
File metadata
- Download URL: openbb_agents-0.0.4-py3-none-any.whl
- Upload date:
- Size: 14.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 29335ce1b6db86d4c3a21330676368fbae14f77a5b0013eb9a0c721f588e5ee5 |
|
MD5 | 630f4f753a12cf60bbe867096ed8be47 |
|
BLAKE2b-256 | abdcd82e0c69b7e33df4f86123bef747c7c3ca4d658b603c496336e0952591fe |